mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 14:56:54 -04:00
PCI: of: Use device_{add,remove}_of_node() to attach of_node to existing device
The commit 407d1a5192 ("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/20250224141356.36325-3-herve.codina@bootlin.com
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
This commit is contained in:
committed by
Bjorn Helgaas
parent
3b62449da4
commit
e2267841fe
@@ -653,8 +653,8 @@ void of_pci_remove_node(struct pci_dev *pdev)
|
||||
np = pci_device_to_OF_node(pdev);
|
||||
if (!np || !of_node_check_flag(np, OF_DYNAMIC))
|
||||
return;
|
||||
pdev->dev.of_node = NULL;
|
||||
|
||||
device_remove_of_node(&pdev->dev);
|
||||
of_changeset_revert(np->data);
|
||||
of_changeset_destroy(np->data);
|
||||
of_node_put(np);
|
||||
@@ -711,11 +711,18 @@ void of_pci_make_dev_node(struct pci_dev *pdev)
|
||||
goto out_free_node;
|
||||
|
||||
np->data = cset;
|
||||
pdev->dev.of_node = np;
|
||||
|
||||
ret = device_add_of_node(&pdev->dev, np);
|
||||
if (ret)
|
||||
goto out_revert_cset;
|
||||
|
||||
kfree(name);
|
||||
|
||||
return;
|
||||
|
||||
out_revert_cset:
|
||||
np->data = NULL;
|
||||
of_changeset_revert(cset);
|
||||
out_free_node:
|
||||
of_node_put(np);
|
||||
out_destroy_cset:
|
||||
|
||||
Reference in New Issue
Block a user