Skip to content

Commit 7582fe0

Browse files
Mani-Sadhasivamkwilczynski
authored andcommitted
PCI/pwrctl: Use of_platform_device_create() to create pwrctl devices
The of_platform_populate() API creates platform devices by descending through the children of the parent node. But it provides no control over the child nodes, which makes it difficult to add checks for the child nodes in the future. Use of_platform_device_create() and for_each_child_of_node_scoped() to make it possible to add checks for each node before creating the platform device. Link: https://lore.kernel.org/r/[email protected] Tested-by: Bartosz Golaszewski <[email protected]> Tested-by: Krishna chaitanya chundru <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]>
1 parent 9852d85 commit 7582fe0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/pci/bus.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/ioport.h>
1414
#include <linux/of.h>
1515
#include <linux/of_platform.h>
16+
#include <linux/platform_device.h>
1617
#include <linux/proc_fs.h>
1718
#include <linux/slab.h>
1819

@@ -329,6 +330,7 @@ void __weak pcibios_bus_add_device(struct pci_dev *pdev) { }
329330
void pci_bus_add_device(struct pci_dev *dev)
330331
{
331332
struct device_node *dn = dev->dev.of_node;
333+
struct platform_device *pdev;
332334
int retval;
333335

334336
/*
@@ -351,11 +353,11 @@ void pci_bus_add_device(struct pci_dev *dev)
351353
pci_dev_assign_added(dev, true);
352354

353355
if (dev_of_node(&dev->dev) && pci_is_bridge(dev)) {
354-
retval = of_platform_populate(dev_of_node(&dev->dev), NULL, NULL,
355-
&dev->dev);
356-
if (retval)
357-
pci_err(dev, "failed to populate child OF nodes (%d)\n",
358-
retval);
356+
for_each_available_child_of_node_scoped(dn, child) {
357+
pdev = of_platform_device_create(child, NULL, &dev->dev);
358+
if (!pdev)
359+
pci_err(dev, "failed to create OF node: %s\n", child->name);
360+
}
359361
}
360362
}
361363
EXPORT_SYMBOL_GPL(pci_bus_add_device);

0 commit comments

Comments
 (0)