driver-core: Add device node pointer to struct device
authorGrant Likely <grant.likely@secretlab.ca>
Tue, 13 Apr 2010 23:12:28 +0000 (16:12 -0700)
committerGrant Likely <grant.likely@secretlab.ca>
Thu, 29 Apr 2010 00:20:57 +0000 (18:20 -0600)
Currently, platforms using CONFIG_OF add a 'struct device_node *of_node'
to dev->archdata.  However, with CONFIG_OF becoming generic for all
architectures, it makes sense for commonality to move it out of archdata
and into struct device proper.

This patch adds a struct device_node *of_node member to struct device
and updates all locations which currently write the device_node pointer
into archdata to also update dev->of_node.  Subsequent patches will
modify callers to use the archdata location and ultimately remove
the archdata member entirely.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
CC: Michal Simek <monstr@monstr.eu>
CC: Greg Kroah-Hartman <gregkh@suse.de>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: "David S. Miller" <davem@davemloft.net>
CC: Stephen Rothwell <sfr@canb.auug.org.au>
CC: Jeremy Kerr <jeremy.kerr@canonical.com>
CC: microblaze-uclinux@itee.uq.edu.au
CC: linux-kernel@vger.kernel.org
CC: linuxppc-dev@ozlabs.org
CC: sparclinux@vger.kernel.org
arch/microblaze/kernel/of_device.c
arch/powerpc/kernel/of_device.c
arch/powerpc/kernel/pci-common.c
arch/powerpc/kernel/vio.c
arch/powerpc/platforms/ps3/system-bus.c
arch/sparc/kernel/of_device_32.c
arch/sparc/kernel/of_device_64.c
arch/sparc/kernel/pci.c
drivers/of/of_mdio.c
drivers/of/of_spi.c
include/linux/device.h

index 9a0f7632c47c92ed471250d4858731531e7bd381..f6c521898ebfab5720025268b49ae738d230fc28 100644 (file)
@@ -54,6 +54,7 @@ struct of_device *of_device_alloc(struct device_node *np,
        dev->dev.parent = parent;
        dev->dev.release = of_release_dev;
        dev->dev.archdata.of_node = np;
+       dev->dev.of_node = np;
 
        if (bus_id)
                dev_set_name(&dev->dev, bus_id);
index a359cb08e9006168a60ba87b9e34df0c02256d51..9577e6f4e3bf7deb9605e5447faa1336950dfea7 100644 (file)
@@ -74,6 +74,7 @@ struct of_device *of_device_alloc(struct device_node *np,
        dev->dev.parent = parent;
        dev->dev.release = of_release_dev;
        dev->dev.archdata.of_node = np;
+       dev->dev.of_node = np;
 
        if (bus_id)
                dev_set_name(&dev->dev, "%s", bus_id);
index 0c0567e58409ae006ae4f077d4a54e2a29fb81d4..88da282047c39c9ee73e0a66d6a667172e3e81aa 100644 (file)
@@ -1097,8 +1097,9 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
                if (dev->is_added)
                        continue;
 
-               /* Setup OF node pointer in archdata */
+               /* Setup OF node pointer in the device */
                sd->of_node = pci_device_to_OF_node(dev);
+               dev->dev.of_node = pci_device_to_OF_node(dev);
 
                /* Fixup NUMA node as it may not be setup yet by the generic
                 * code and is needed by the DMA init
index 82237176a2a3db8c2eadc29db867b5ed0415398f..d6708da114eef852c956e0c92eefc8f1addbbe75 100644 (file)
@@ -1230,7 +1230,8 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
                if (unit_address != NULL)
                        viodev->unit_address = *unit_address;
        }
-       viodev->dev.archdata.of_node = of_node_get(of_node);
+       viodev->dev.of_node = of_node_get(of_node);
+       viodev->dev.archdata.of_node = viodev->dev.of_node;
 
        if (firmware_has_feature(FW_FEATURE_CMO))
                vio_cmo_set_dma_ops(viodev);
index 6d09f5e3e7e49c77bd286dcc22366b4daf53c4b8..e546c86a539bc7fbcddcdbe9bf68d6feeceb1e64 100644 (file)
@@ -766,6 +766,7 @@ int ps3_system_bus_device_register(struct ps3_system_bus_device *dev)
                BUG();
        };
 
+       dev->core.of_node = NULL;
        dev->core.archdata.of_node = NULL;
        set_dev_node(&dev->core, 0);
 
index da527b33ebc708ad2693d9932bbae97f671e2d88..4926c1babd84b9991b0dd865f8f69823e7f388fd 100644 (file)
@@ -348,6 +348,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
        sd->prom_node = dp;
        sd->op = op;
 
+       op->dev.of_node = dp;
        op->node = dp;
 
        op->clock_freq = of_getintprop_default(dp, "clock-frequency",
index b3d4cb5d21b333c54fee00998491644397eb92d1..5bc74161667cef1523b6089abdcb85400711c0a8 100644 (file)
@@ -643,6 +643,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
        sd->prom_node = dp;
        sd->op = op;
 
+       op->dev.of_node = dp;
        op->node = dp;
 
        op->clock_freq = of_getintprop_default(dp, "clock-frequency",
index 5ac539a5930f5401239d81f2e1bfff217472a60e..0c920147b4efd94482efea7ce704f1117f543a16 100644 (file)
@@ -262,6 +262,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
        sd->stc = &pbm->stc;
        sd->host_controller = pbm;
        sd->prom_node = node;
+       dev->dev.of_node = node;
        sd->op = op = of_find_device_by_node(node);
        sd->numa_node = pbm->numa_node;
 
index 18ecae4a4375d461957b04ee8171f1e5e1434b8c..12090f57dc8771820f52762dd136ab2cbd8eb8a0 100644 (file)
@@ -80,6 +80,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
                 * can be looked up later */
                of_node_get(child);
                dev_archdata_set_node(&phy->dev.archdata, child);
+               phy->dev.of_node = child;
 
                /* All data is now stored in the phy struct; register it */
                rc = phy_device_register(phy);
index f65f48b9844885c9708596c73aa4f7eeefba1904..f3119a0836af940ea7ae72da3a74edecead1ca23 100644 (file)
@@ -79,6 +79,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np)
 
                /* Store a pointer to the node in the device structure */
                of_node_get(nc);
+               spi->dev.of_node = nc;
                spi->dev.archdata.of_node = nc;
 
                /* Register the new device */
index 182192892d45cf6db1e0c2cacb5a96835084a36d..7a968bdb02e21a9acf150113e3171e933c5b8896 100644 (file)
@@ -34,6 +34,7 @@ struct class;
 struct class_private;
 struct bus_type;
 struct bus_type_private;
+struct device_node;
 
 struct bus_attribute {
        struct attribute        attr;
@@ -433,6 +434,9 @@ struct device {
                                             override */
        /* arch specific additions */
        struct dev_archdata     archdata;
+#ifdef CONFIG_OF
+       struct device_node      *of_node;
+#endif
 
        dev_t                   devt;   /* dev_t, creates the sysfs "dev" */