]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - arch/sparc/kernel/of_device.c
[SPARC/64] Rename some functions like PowerPC
[karo-tx-linux.git] / arch / sparc / kernel / of_device.c
index 48c24f7518c24e3ccd8c3b6ae127111c5c194518..cb21983cff9fb7aa8b24fe1094e3af2c6190366d 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/of.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
@@ -8,38 +9,6 @@
 #include <asm/errno.h>
 #include <asm/of_device.h>
 
-/**
- * of_match_device - Tell if an of_device structure has a matching
- * of_match structure
- * @ids: array of of device match structures to search in
- * @dev: the of device structure to match against
- *
- * Used by a driver to check whether an of_device present in the
- * system is in its list of supported devices.
- */
-const struct of_device_id *of_match_device(const struct of_device_id *matches,
-                                       const struct of_device *dev)
-{
-       if (!dev->node)
-               return NULL;
-       while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
-               int match = 1;
-               if (matches->name[0])
-                       match &= dev->node->name
-                               && !strcmp(matches->name, dev->node->name);
-               if (matches->type[0])
-                       match &= dev->node->type
-                               && !strcmp(matches->type, dev->node->type);
-               if (matches->compatible[0])
-                       match &= of_device_is_compatible(dev->node,
-                                                        matches->compatible);
-               if (match)
-                       return matches;
-               matches++;
-       }
-       return NULL;
-}
-
 static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
 {
        struct of_device * of_dev = to_of_device(dev);
@@ -52,27 +21,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
        return of_match_device(matches, of_dev) != NULL;
 }
 
-struct of_device *of_dev_get(struct of_device *dev)
-{
-       struct device *tmp;
-
-       if (!dev)
-               return NULL;
-       tmp = get_device(&dev->dev);
-       if (tmp)
-               return to_of_device(tmp);
-       else
-               return NULL;
-}
-
-void of_dev_put(struct of_device *dev)
-{
-       if (dev)
-               put_device(&dev->dev);
-}
-
-
-static int of_device_probe(struct device *dev)
+static int of_platform_device_probe(struct device *dev)
 {
        int error = -ENODEV;
        struct of_platform_driver *drv;
@@ -96,7 +45,7 @@ static int of_device_probe(struct device *dev)
        return error;
 }
 
-static int of_device_remove(struct device *dev)
+static int of_platform_device_remove(struct device *dev)
 {
        struct of_device * of_dev = to_of_device(dev);
        struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
@@ -106,7 +55,7 @@ static int of_device_remove(struct device *dev)
        return 0;
 }
 
-static int of_device_suspend(struct device *dev, pm_message_t state)
+static int of_platform_device_suspend(struct device *dev, pm_message_t state)
 {
        struct of_device * of_dev = to_of_device(dev);
        struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
@@ -117,7 +66,7 @@ static int of_device_suspend(struct device *dev, pm_message_t state)
        return error;
 }
 
-static int of_device_resume(struct device * dev)
+static int of_platform_device_resume(struct device * dev)
 {
        struct of_device * of_dev = to_of_device(dev);
        struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
@@ -138,7 +87,7 @@ static int node_match(struct device *dev, void *data)
 
 struct of_device *of_find_device_by_node(struct device_node *dp)
 {
-       struct device *dev = bus_find_device(&of_bus_type, NULL,
+       struct device *dev = bus_find_device(&of_platform_bus_type, NULL,
                                             dp, node_match);
 
        if (dev)
@@ -152,10 +101,10 @@ EXPORT_SYMBOL(of_find_device_by_node);
 struct bus_type ebus_bus_type = {
        .name   = "ebus",
        .match  = of_platform_bus_match,
-       .probe  = of_device_probe,
-       .remove = of_device_remove,
-       .suspend        = of_device_suspend,
-       .resume = of_device_resume,
+       .probe  = of_platform_device_probe,
+       .remove = of_platform_device_remove,
+       .suspend        = of_platform_device_suspend,
+       .resume = of_platform_device_resume,
 };
 EXPORT_SYMBOL(ebus_bus_type);
 #endif
@@ -164,23 +113,23 @@ EXPORT_SYMBOL(ebus_bus_type);
 struct bus_type sbus_bus_type = {
        .name   = "sbus",
        .match  = of_platform_bus_match,
-       .probe  = of_device_probe,
-       .remove = of_device_remove,
-       .suspend        = of_device_suspend,
-       .resume = of_device_resume,
+       .probe  = of_platform_device_probe,
+       .remove = of_platform_device_remove,
+       .suspend        = of_platform_device_suspend,
+       .resume = of_platform_device_resume,
 };
 EXPORT_SYMBOL(sbus_bus_type);
 #endif
 
-struct bus_type of_bus_type = {
+struct bus_type of_platform_bus_type = {
        .name   = "of",
        .match  = of_platform_bus_match,
-       .probe  = of_device_probe,
-       .remove = of_device_remove,
-       .suspend        = of_device_suspend,
-       .resume = of_device_resume,
+       .probe  = of_platform_device_probe,
+       .remove = of_platform_device_remove,
+       .suspend        = of_platform_device_suspend,
+       .resume = of_platform_device_resume,
 };
-EXPORT_SYMBOL(of_bus_type);
+EXPORT_SYMBOL(of_platform_bus_type);
 
 static inline u64 of_read_addr(const u32 *cell, int size)
 {
@@ -210,7 +159,7 @@ struct of_bus {
                                       int *addrc, int *sizec);
        int             (*map)(u32 *addr, const u32 *range,
                               int na, int ns, int pna);
-       unsigned int    (*get_flags)(u32 *addr);
+       unsigned int    (*get_flags)(const u32 *addr);
 };
 
 /*
@@ -270,7 +219,7 @@ static int of_bus_default_map(u32 *addr, const u32 *range,
        return 0;
 }
 
-static unsigned int of_bus_default_get_flags(u32 *addr)
+static unsigned int of_bus_default_get_flags(const u32 *addr)
 {
        return IORESOURCE_MEM;
 }
@@ -334,7 +283,7 @@ static int of_bus_pci_map(u32 *addr, const u32 *range,
        return 0;
 }
 
-static unsigned int of_bus_pci_get_flags(u32 *addr)
+static unsigned int of_bus_pci_get_flags(const u32 *addr)
 {
        unsigned int flags = 0;
        u32 w = addr[0];
@@ -375,7 +324,7 @@ static int of_bus_sbus_map(u32 *addr, const u32 *range, int na, int ns, int pna)
        return of_bus_default_map(addr, range, na, ns, pna);
 }
 
-static unsigned int of_bus_sbus_get_flags(u32 *addr)
+static unsigned int of_bus_sbus_get_flags(const u32 *addr)
 {
        return IORESOURCE_MEM;
 }
@@ -432,7 +381,7 @@ static int __init build_one_resource(struct device_node *parent,
                                     u32 *addr,
                                     int na, int ns, int pna)
 {
-       u32 *ranges;
+       const u32 *ranges;
        unsigned int rlen;
        int rone;
 
@@ -470,7 +419,7 @@ static void __init build_device_resources(struct of_device *op,
        struct of_bus *bus;
        int na, ns;
        int index, num_reg;
-       void *preg;
+       const void *preg;
 
        if (!parent)
                return;
@@ -492,7 +441,7 @@ static void __init build_device_resources(struct of_device *op,
        for (index = 0; index < num_reg; index++) {
                struct resource *r = &op->resource[index];
                u32 addr[OF_MAX_ADDR_CELLS];
-               u32 *reg = (preg + (index * ((na + ns) * 4)));
+               const u32 *reg = (preg + (index * ((na + ns) * 4)));
                struct device_node *dp = op->node;
                struct device_node *pp = p_op->node;
                struct of_bus *pbus, *dbus;
@@ -559,7 +508,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
                                                 struct device *parent)
 {
        struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL);
-       struct linux_prom_irqs *intr;
+       const struct linux_prom_irqs *intr;
        int len, i;
 
        if (!op)
@@ -579,7 +528,8 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
                for (i = 0; i < op->num_irqs; i++)
                        op->irqs[i] = intr[i].pri;
        } else {
-               unsigned int *irq = of_get_property(dp, "interrupts", &len);
+               const unsigned int *irq =
+                       of_get_property(dp, "interrupts", &len);
 
                if (irq) {
                        op->num_irqs = len / sizeof(unsigned int);
@@ -594,7 +544,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
                        0, 0, 1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 0,
                };
                struct device_node *io_unit, *sbi = dp->parent;
-               struct linux_prom_registers *regs;
+               const struct linux_prom_registers *regs;
                int board, slot;
 
                while (sbi) {
@@ -645,7 +595,7 @@ build_resources:
        build_device_resources(op, parent);
 
        op->dev.parent = parent;
-       op->dev.bus = &of_bus_type;
+       op->dev.bus = &of_platform_bus_type;
        if (!parent)
                strcpy(op->dev.bus_id, "root");
        else
@@ -689,7 +639,7 @@ static int __init of_bus_driver_init(void)
 {
        int err;
 
-       err = bus_register(&of_bus_type);
+       err = bus_register(&of_platform_bus_type);
 #ifdef CONFIG_PCI
        if (!err)
                err = bus_register(&ebus_bus_type);
@@ -734,56 +684,6 @@ void of_unregister_driver(struct of_platform_driver *drv)
        driver_unregister(&drv->driver);
 }
 
-
-static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct of_device *ofdev;
-
-       ofdev = to_of_device(dev);
-       return sprintf(buf, "%s", ofdev->node->full_name);
-}
-
-static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL);
-
-/**
- * of_release_dev - free an of device structure when all users of it are finished.
- * @dev: device that's been disconnected
- *
- * Will be called only by the device core when all users of this of device are
- * done.
- */
-void of_release_dev(struct device *dev)
-{
-       struct of_device *ofdev;
-
-        ofdev = to_of_device(dev);
-
-       kfree(ofdev);
-}
-
-int of_device_register(struct of_device *ofdev)
-{
-       int rc;
-
-       BUG_ON(ofdev->node == NULL);
-
-       rc = device_register(&ofdev->dev);
-       if (rc)
-               return rc;
-
-       rc = device_create_file(&ofdev->dev, &dev_attr_devspec);
-       if (rc)
-               device_unregister(&ofdev->dev);
-
-       return rc;
-}
-
-void of_device_unregister(struct of_device *ofdev)
-{
-       device_remove_file(&ofdev->dev, &dev_attr_devspec);
-       device_unregister(&ofdev->dev);
-}
-
 struct of_device* of_platform_device_create(struct device_node *np,
                                            const char *bus_id,
                                            struct device *parent,
@@ -809,12 +709,6 @@ struct of_device* of_platform_device_create(struct device_node *np,
        return dev;
 }
 
-EXPORT_SYMBOL(of_match_device);
 EXPORT_SYMBOL(of_register_driver);
 EXPORT_SYMBOL(of_unregister_driver);
-EXPORT_SYMBOL(of_device_register);
-EXPORT_SYMBOL(of_device_unregister);
-EXPORT_SYMBOL(of_dev_get);
-EXPORT_SYMBOL(of_dev_put);
 EXPORT_SYMBOL(of_platform_device_create);
-EXPORT_SYMBOL(of_release_dev);