Skip to content

Commit d706c1b

Browse files
committed
driver-core: Add device node pointer to struct device
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 <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> CC: Michal Simek <[email protected]> CC: Greg Kroah-Hartman <[email protected]> CC: Benjamin Herrenschmidt <[email protected]> CC: "David S. Miller" <[email protected]> CC: Stephen Rothwell <[email protected]> CC: Jeremy Kerr <[email protected]> CC: [email protected] CC: [email protected] CC: [email protected] CC: [email protected]
1 parent efb2e01 commit d706c1b

File tree

11 files changed

+16
-2
lines changed

11 files changed

+16
-2
lines changed

arch/microblaze/kernel/of_device.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct of_device *of_device_alloc(struct device_node *np,
5454
dev->dev.parent = parent;
5555
dev->dev.release = of_release_dev;
5656
dev->dev.archdata.of_node = np;
57+
dev->dev.of_node = np;
5758

5859
if (bus_id)
5960
dev_set_name(&dev->dev, bus_id);

arch/powerpc/kernel/of_device.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct of_device *of_device_alloc(struct device_node *np,
7474
dev->dev.parent = parent;
7575
dev->dev.release = of_release_dev;
7676
dev->dev.archdata.of_node = np;
77+
dev->dev.of_node = np;
7778

7879
if (bus_id)
7980
dev_set_name(&dev->dev, "%s", bus_id);

arch/powerpc/kernel/pci-common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,9 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
10971097
if (dev->is_added)
10981098
continue;
10991099

1100-
/* Setup OF node pointer in archdata */
1100+
/* Setup OF node pointer in the device */
11011101
sd->of_node = pci_device_to_OF_node(dev);
1102+
dev->dev.of_node = pci_device_to_OF_node(dev);
11021103

11031104
/* Fixup NUMA node as it may not be setup yet by the generic
11041105
* code and is needed by the DMA init

arch/powerpc/kernel/vio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,8 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
12301230
if (unit_address != NULL)
12311231
viodev->unit_address = *unit_address;
12321232
}
1233-
viodev->dev.archdata.of_node = of_node_get(of_node);
1233+
viodev->dev.of_node = of_node_get(of_node);
1234+
viodev->dev.archdata.of_node = viodev->dev.of_node;
12341235

12351236
if (firmware_has_feature(FW_FEATURE_CMO))
12361237
vio_cmo_set_dma_ops(viodev);

arch/powerpc/platforms/ps3/system-bus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ int ps3_system_bus_device_register(struct ps3_system_bus_device *dev)
766766
BUG();
767767
};
768768

769+
dev->core.of_node = NULL;
769770
dev->core.archdata.of_node = NULL;
770771
set_dev_node(&dev->core, 0);
771772

arch/sparc/kernel/of_device_32.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
348348
sd->prom_node = dp;
349349
sd->op = op;
350350

351+
op->dev.of_node = dp;
351352
op->node = dp;
352353

353354
op->clock_freq = of_getintprop_default(dp, "clock-frequency",

arch/sparc/kernel/of_device_64.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
643643
sd->prom_node = dp;
644644
sd->op = op;
645645

646+
op->dev.of_node = dp;
646647
op->node = dp;
647648

648649
op->clock_freq = of_getintprop_default(dp, "clock-frequency",

arch/sparc/kernel/pci.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
262262
sd->stc = &pbm->stc;
263263
sd->host_controller = pbm;
264264
sd->prom_node = node;
265+
dev->dev.of_node = node;
265266
sd->op = op = of_find_device_by_node(node);
266267
sd->numa_node = pbm->numa_node;
267268

drivers/of/of_mdio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
8080
* can be looked up later */
8181
of_node_get(child);
8282
dev_archdata_set_node(&phy->dev.archdata, child);
83+
phy->dev.of_node = child;
8384

8485
/* All data is now stored in the phy struct; register it */
8586
rc = phy_device_register(phy);

drivers/of/of_spi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np)
7979

8080
/* Store a pointer to the node in the device structure */
8181
of_node_get(nc);
82+
spi->dev.of_node = nc;
8283
spi->dev.archdata.of_node = nc;
8384

8485
/* Register the new device */

include/linux/device.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct class;
3434
struct class_private;
3535
struct bus_type;
3636
struct bus_type_private;
37+
struct device_node;
3738

3839
struct bus_attribute {
3940
struct attribute attr;
@@ -433,6 +434,9 @@ struct device {
433434
override */
434435
/* arch specific additions */
435436
struct dev_archdata archdata;
437+
#ifdef CONFIG_OF
438+
struct device_node *of_node;
439+
#endif
436440

437441
dev_t devt; /* dev_t, creates the sysfs "dev" */
438442

0 commit comments

Comments
 (0)