Skip to content

Commit 24777ba

Browse files
Mani-Sadhasivamtorvalds
authored andcommitted
PCI: Check for the existence of 'dev.of_node' before calling of_platform_populate()
Commit 50b040e ("PCI/pwrctl: only call of_platform_populate() if CONFIG_OF is enabled") added the CONFIG_OF guard for the of_platform_populate() API. But it missed the fact that the CONFIG_OF platforms can also run on ACPI without devicetree (so dev.of_node will be NULL). In those cases, of_platform_populate() will fail with below error messages as seen on the Ampere Altra box: pci 000c:00:01.0: failed to populate child OF nodes (-22) pci 000c:00:02.0: failed to populate child OF nodes (-22) Fix this by checking for the existence of 'dev.of_node' before calling the of_platform_populate() API. This also warrants the removal of CONFIG_OF check, since dev_of_node() helper will return NULL if CONFIG_OF is not enabled. While at it, let's also use dev_of_node() to pass device OF node pointer to of_platform_populate(). Fixes: 50b040e ("PCI/pwrctl: only call of_platform_populate() if CONFIG_OF is enabled") Reported-by: Linus Torvalds <[email protected]> Closes: https://lore.kernel.org/linux-arm-msm/CAHk-=wjcO_9dkNf-bNda6bzykb5ZXWtAYA97p7oDsXPHmMRi6g@mail.gmail.com Reviewed-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f2f6a8e commit 24777ba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/pci/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ void pci_bus_add_device(struct pci_dev *dev)
356356

357357
pci_dev_assign_added(dev, true);
358358

359-
if (IS_ENABLED(CONFIG_OF) && pci_is_bridge(dev)) {
360-
retval = of_platform_populate(dev->dev.of_node, NULL, NULL,
359+
if (dev_of_node(&dev->dev) && pci_is_bridge(dev)) {
360+
retval = of_platform_populate(dev_of_node(&dev->dev), NULL, NULL,
361361
&dev->dev);
362362
if (retval)
363363
pci_err(dev, "failed to populate child OF nodes (%d)\n",

0 commit comments

Comments
 (0)