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/20241025-pci-pwrctl-rework-v2-1-568756156cbe@linaro.org Tested-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Tested-by: Krishna chaitanya chundru <quic_krichai@quicinc.com> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
committed by
Krzysztof Wilczyński
parent
9852d85ec9
commit
7582fe07f4
+7
-5
@@ -13,6 +13,7 @@
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
@@ -329,6 +330,7 @@ void __weak pcibios_bus_add_device(struct pci_dev *pdev) { }
|
||||
void pci_bus_add_device(struct pci_dev *dev)
|
||||
{
|
||||
struct device_node *dn = dev->dev.of_node;
|
||||
struct platform_device *pdev;
|
||||
int retval;
|
||||
|
||||
/*
|
||||
@@ -351,11 +353,11 @@ void pci_bus_add_device(struct pci_dev *dev)
|
||||
pci_dev_assign_added(dev, true);
|
||||
|
||||
if (dev_of_node(&dev->dev) && pci_is_bridge(dev)) {
|
||||
retval = of_platform_populate(dev_of_node(&dev->dev), NULL, NULL,
|
||||
&dev->dev);
|
||||
if (retval)
|
||||
pci_err(dev, "failed to populate child OF nodes (%d)\n",
|
||||
retval);
|
||||
for_each_available_child_of_node_scoped(dn, child) {
|
||||
pdev = of_platform_device_create(child, NULL, &dev->dev);
|
||||
if (!pdev)
|
||||
pci_err(dev, "failed to create OF node: %s\n", child->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pci_bus_add_device);
|
||||
|
||||
Reference in New Issue
Block a user