Skip to content

Commit e226784

Browse files
hcodinabjorn-helgaas
authored andcommitted
PCI: of: Use device_{add,remove}_of_node() to attach of_node to existing device
The commit 407d1a5 ("PCI: Create device tree node for bridge") creates of_node for PCI devices. The newly created of_node is attached to an existing device. This is done setting directly pdev->dev.of_node in the code. Even if pdev->dev.of_node cannot be previously set, this doesn't handle the fwnode field of the struct device. Indeed, this field needs to be set if it hasn't already been set. device_{add,remove}_of_node() have been introduced to handle this case. Use them instead of the direct setting. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Herve Codina <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Rob Herring (Arm) <[email protected]>
1 parent 3b62449 commit e226784

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/pci/of.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ void of_pci_remove_node(struct pci_dev *pdev)
653653
np = pci_device_to_OF_node(pdev);
654654
if (!np || !of_node_check_flag(np, OF_DYNAMIC))
655655
return;
656-
pdev->dev.of_node = NULL;
657656

657+
device_remove_of_node(&pdev->dev);
658658
of_changeset_revert(np->data);
659659
of_changeset_destroy(np->data);
660660
of_node_put(np);
@@ -711,11 +711,18 @@ void of_pci_make_dev_node(struct pci_dev *pdev)
711711
goto out_free_node;
712712

713713
np->data = cset;
714-
pdev->dev.of_node = np;
714+
715+
ret = device_add_of_node(&pdev->dev, np);
716+
if (ret)
717+
goto out_revert_cset;
718+
715719
kfree(name);
716720

717721
return;
718722

723+
out_revert_cset:
724+
np->data = NULL;
725+
of_changeset_revert(cset);
719726
out_free_node:
720727
of_node_put(np);
721728
out_destroy_cset:

0 commit comments

Comments
 (0)