diff mbox series

[v2,1/1] PCI: of: Propagate firmware node by calling device_set_node()

Message ID 20230421092945.66176-1-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v2,1/1] PCI: of: Propagate firmware node by calling device_set_node() | expand

Commit Message

Andy Shevchenko April 21, 2023, 9:29 a.m. UTC
Insulate pci_set_of_node() and pci_set_bus_of_node() from possible
changes to fwnode_handle implementation by using device_set_node()
instead of open-coding dev->dev.fwnode assignments.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: rewritten commit message as suggested (Bjorn), rebased on the latest code
 drivers/pci/of.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Andy Shevchenko April 21, 2023, 9:59 a.m. UTC | #1
On Fri, Apr 21, 2023 at 12:29:45PM +0300, Andy Shevchenko wrote:
> Insulate pci_set_of_node() and pci_set_bus_of_node() from possible
> changes to fwnode_handle implementation by using device_set_node()
> instead of open-coding dev->dev.fwnode assignments.

Sorry, this version needs to be discarded. It has a non-squashed change and
hence can't be compiled.
diff mbox series

Patch

diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index 4c2ef2e28fb5..2679d6e6da30 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -39,16 +39,14 @@  int pci_set_of_node(struct pci_dev *dev)
 		return -ENODEV;
 	}
 
-	dev->dev.of_node = node;
-	dev->dev.fwnode = &node->fwnode;
+	device_set_node(&dev->dev, node);
 	return 0;
 }
 
 void pci_release_of_node(struct pci_dev *dev)
 {
 	of_node_put(dev->dev.of_node);
-	dev->dev.of_node = NULL;
-	dev->dev.fwnode = NULL;
+	device_set_node(&dev->dev, NULL);
 }
 
 void pci_set_bus_of_node(struct pci_bus *bus)
@@ -63,17 +61,13 @@  void pci_set_bus_of_node(struct pci_bus *bus)
 			bus->self->external_facing = true;
 	}
 
-	bus->dev.of_node = node;
-
-	if (bus->dev.of_node)
-		bus->dev.fwnode = &bus->dev.of_node->fwnode;
+	device_set_node(&bus->dev, of_fwnode_handle(node));
 }
 
 void pci_release_bus_of_node(struct pci_bus *bus)
 {
 	of_node_put(bus->dev.of_node);
-	bus->dev.of_node = NULL;
-	bus->dev.fwnode = NULL;
+	device_set_node(&bus->dev, NULL);
 }
 
 struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus)