Skip to contentSkip to conversation

PCI: controller: use dev_fwnode()

PATCH In review Jiri Slaby (SUSE) 2 participants 3 messages Jul 23, 2025 – Jul 25, 2025

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: controller: use dev_fwnode()

All irq_domain functions now accept fwnode instead of of_node. But many PCI controllers still extract dev to of_node and then of_node to fwnode.

Instead, clean this up and simply use the dev_fwnode() helper to extract fwnode directly from dev. Internally, it still does dev => of_node => fwnode steps, but it's now hidden from the users.

Cc Jingoo Han <[email protected]>
Cc Manivannan Sadhasivam <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc "Krzysztof Wilczyński" <[email protected]>
Cc Rob Herring <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Karthikeyan Mitran <[email protected]>
Cc Hou Zhiqiang <[email protected]>
Cc Joyce Ooi <[email protected]>
Cc Ryder Lee <[email protected]>
Cc Jianjun Wang <[email protected]>
Cc Michal Simek <[email protected]>
Cc Daire McNamara <[email protected]>

---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/pci/controller/dwc/pcie-designware-host.c    | 3 +--
 drivers/pci/controller/mobiveil/pcie-mobiveil-host.c | 3 +--
 drivers/pci/controller/pcie-altera-msi.c             | 3 +--
 drivers/pci/controller/pcie-mediatek.c               | 4 +---
 drivers/pci/controller/pcie-xilinx-dma-pl.c          | 3 +--
 drivers/pci/controller/pcie-xilinx-nwl.c             | 3 +--
 drivers/pci/controller/plda/pcie-plda-host.c         | 3 +--
 7 files changed, 7 insertions(+), 15 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +1 -2
index 4af7da14b350..952f8594b501 100644
@@ -214,9 +214,8 @@ static const struct irq_domain_ops dw_pcie_msi_domain_ops = {
 int dw_pcie_allocate_domains(struct dw_pcie_rp *pp)
 {
 	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
-	struct fwnode_handle *fwnode = of_fwnode_handle(pci->dev->of_node);
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(pci->dev),
 		.ops		= &dw_pcie_msi_domain_ops,
 		.size		= pp->num_vectors,
 		.host_data	= pp,
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +1 -2
index d17e887b6b61..dbc72c73fd0a 100644
@@ -439,13 +439,12 @@ static const struct irq_domain_ops msi_domain_ops = {
 static int mobiveil_allocate_msi_domains(struct mobiveil_pcie *pcie)
 {
 	struct device *dev = &pcie->pdev->dev;
-	struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node);
 	struct mobiveil_msi *msi = &pcie->rp.msi;
 
 	mutex_init(&msi->lock);
 
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(dev),
 		.ops		= &msi_domain_ops,
 		.host_data	= pcie,
 		.size		= msi->num_of_vectors,
drivers/pci/controller/pcie-altera-msi.c +1 -2
index 2e48acd632c5..ea2ca2e70f20 100644
@@ -166,9 +166,8 @@ static const struct irq_domain_ops msi_domain_ops = {
 
 static int altera_allocate_domains(struct altera_msi *msi)
 {
-	struct fwnode_handle *fwnode = of_fwnode_handle(msi->pdev->dev.of_node);
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(&msi->pdev->dev),
 		.ops		= &msi_domain_ops,
 		.host_data	= msi,
 		.size		= msi->num_of_vectors,
drivers/pci/controller/pcie-mediatek.c +1 -3
index 3ac5d14dd543..24cc30a2ab6c 100644
@@ -487,12 +487,10 @@ static const struct msi_parent_ops mtk_msi_parent_ops = {
 
 static int mtk_pcie_allocate_msi_domains(struct mtk_pcie_port *port)
 {
-	struct fwnode_handle *fwnode = of_fwnode_handle(port->pcie->dev->of_node);
-
 	mutex_init(&port->lock);
 
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(port->pcie->dev),
 		.ops		= &msi_domain_ops,
 		.host_data	= port,
 		.size		= MTK_MSI_IRQS_NUM,
drivers/pci/controller/pcie-xilinx-dma-pl.c +1 -2
index fbc379fd118b..b037c8f315e4 100644
@@ -465,9 +465,8 @@ static int xilinx_pl_dma_pcie_init_msi_irq_domain(struct pl_dma_pcie *port)
 	struct device *dev = port->dev;
 	struct xilinx_msi *msi = &port->msi;
 	int size = BITS_TO_LONGS(XILINX_NUM_MSI_IRQS) * sizeof(long);
-	struct fwnode_handle *fwnode = of_fwnode_handle(port->dev->of_node);
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(port->dev),
 		.ops		= &dev_msi_domain_ops,
 		.host_data	= port,
 		.size		= XILINX_NUM_MSI_IRQS,
drivers/pci/controller/pcie-xilinx-nwl.c +1 -2
index de76c836915f..05b8c205493c 100644
@@ -498,10 +498,9 @@ static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie)
 {
 #ifdef CONFIG_PCI_MSI
 	struct device *dev = pcie->dev;
-	struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node);
 	struct nwl_msi *msi = &pcie->msi;
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(dev),
 		.ops		= &dev_msi_domain_ops,
 		.host_data	= pcie,
 		.size		= INT_PCI_MSI_NR,
drivers/pci/controller/plda/pcie-plda-host.c +1 -2
index 92866840875e..8e2db2e5b64b 100644
@@ -153,13 +153,12 @@ static const struct msi_parent_ops plda_msi_parent_ops = {
 static int plda_allocate_msi_domains(struct plda_pcie_rp *port)
 {
 	struct device *dev = port->dev;
-	struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node);
 	struct plda_msi *msi = &port->msi;
 
 	mutex_init(&port->msi.lock);
 
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(dev),
 		.ops		= &msi_domain_ops,
 		.host_data	= port,
 		.size		= msi->num_vectors,
Signature · 1 line
2.50.1
#1 lore raw

[+cc Arnd, Nam]

Quoted 10 lines · Jiri Slaby (SUSE)

All irq_domain functions now accept fwnode instead of of_node. But many PCI controllers still extract dev to of_node and then of_node to fwnode.

Instead, clean this up and simply use the dev_fwnode() helper to extract fwnode directly from dev. Internally, it still does dev => of_node => fwnode steps, but it's now hidden from the users.

Thanks, Jiri, I applied this on pci/controller/msi-parent for v6.17; it's at
https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=controller/msi-parent

The dev_fwnode() conversions touched the same places as Nam's changes to use msi_create_parent_irq_domain(). The previous dev_fwnode() conversions were *before* Nam's changes and these are *after*, and it all ended up looking more complicated than I wanted, so I squashed all the dev_fwnode() conversions together in
https://git.kernel.org/cgit/linux/kernel/git/pci/pci.git/commit/?id=a103d2dede56
("PCI: controller: Use dev_fwnode() instead of of_fwnode_handle()") and then added Nam's msi_create_parent_irq_domain() patches on top.

So a103d2dede56 ("PCI: controller: Use dev_fwnode() instead of of_fwnode_handle()") ends up *looking* different from the patch below, but I think having them all together makes it more obvious that they're all making the same conversion, and I think the end result is identical.

Bjorn

Quoted 147 lines
Cc Jingoo Han <[email protected]>
Cc Manivannan Sadhasivam <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc "Krzysztof Wilczyński" <[email protected]>
Cc Rob Herring <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Karthikeyan Mitran <[email protected]>
Cc Hou Zhiqiang <[email protected]>
Cc Joyce Ooi <[email protected]>
Cc Ryder Lee <[email protected]>
Cc Jianjun Wang <[email protected]>
Cc Michal Simek <[email protected]>
Cc Daire McNamara <[email protected]>

---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/pci/controller/dwc/pcie-designware-host.c    | 3 +--
 drivers/pci/controller/mobiveil/pcie-mobiveil-host.c | 3 +--
 drivers/pci/controller/pcie-altera-msi.c             | 3 +--
 drivers/pci/controller/pcie-mediatek.c               | 4 +---
 drivers/pci/controller/pcie-xilinx-dma-pl.c          | 3 +--
 drivers/pci/controller/pcie-xilinx-nwl.c             | 3 +--
 drivers/pci/controller/plda/pcie-plda-host.c         | 3 +--
 7 files changed, 7 insertions(+), 15 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +1 -2
index 4af7da14b350..952f8594b501 100644
@@ -214,9 +214,8 @@ static const struct irq_domain_ops dw_pcie_msi_domain_ops = {
 int dw_pcie_allocate_domains(struct dw_pcie_rp *pp)
 {
 	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
-	struct fwnode_handle *fwnode = of_fwnode_handle(pci->dev->of_node);
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(pci->dev),
 		.ops		= &dw_pcie_msi_domain_ops,
 		.size		= pp->num_vectors,
 		.host_data	= pp,
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +1 -2
index d17e887b6b61..dbc72c73fd0a 100644
@@ -439,13 +439,12 @@ static const struct irq_domain_ops msi_domain_ops = {
 static int mobiveil_allocate_msi_domains(struct mobiveil_pcie *pcie)
 {
 	struct device *dev = &pcie->pdev->dev;
-	struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node);
 	struct mobiveil_msi *msi = &pcie->rp.msi;
 
 	mutex_init(&msi->lock);
 
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(dev),
 		.ops		= &msi_domain_ops,
 		.host_data	= pcie,
 		.size		= msi->num_of_vectors,
drivers/pci/controller/pcie-altera-msi.c +1 -2
index 2e48acd632c5..ea2ca2e70f20 100644
@@ -166,9 +166,8 @@ static const struct irq_domain_ops msi_domain_ops = {
 
 static int altera_allocate_domains(struct altera_msi *msi)
 {
-	struct fwnode_handle *fwnode = of_fwnode_handle(msi->pdev->dev.of_node);
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(&msi->pdev->dev),
 		.ops		= &msi_domain_ops,
 		.host_data	= msi,
 		.size		= msi->num_of_vectors,
drivers/pci/controller/pcie-mediatek.c +1 -3
index 3ac5d14dd543..24cc30a2ab6c 100644
@@ -487,12 +487,10 @@ static const struct msi_parent_ops mtk_msi_parent_ops = {
 
 static int mtk_pcie_allocate_msi_domains(struct mtk_pcie_port *port)
 {
-	struct fwnode_handle *fwnode = of_fwnode_handle(port->pcie->dev->of_node);
-
 	mutex_init(&port->lock);
 
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(port->pcie->dev),
 		.ops		= &msi_domain_ops,
 		.host_data	= port,
 		.size		= MTK_MSI_IRQS_NUM,
drivers/pci/controller/pcie-xilinx-dma-pl.c +1 -2
index fbc379fd118b..b037c8f315e4 100644
@@ -465,9 +465,8 @@ static int xilinx_pl_dma_pcie_init_msi_irq_domain(struct pl_dma_pcie *port)
 	struct device *dev = port->dev;
 	struct xilinx_msi *msi = &port->msi;
 	int size = BITS_TO_LONGS(XILINX_NUM_MSI_IRQS) * sizeof(long);
-	struct fwnode_handle *fwnode = of_fwnode_handle(port->dev->of_node);
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(port->dev),
 		.ops		= &dev_msi_domain_ops,
 		.host_data	= port,
 		.size		= XILINX_NUM_MSI_IRQS,
drivers/pci/controller/pcie-xilinx-nwl.c +1 -2
index de76c836915f..05b8c205493c 100644
@@ -498,10 +498,9 @@ static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie)
 {
 #ifdef CONFIG_PCI_MSI
 	struct device *dev = pcie->dev;
-	struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node);
 	struct nwl_msi *msi = &pcie->msi;
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(dev),
 		.ops		= &dev_msi_domain_ops,
 		.host_data	= pcie,
 		.size		= INT_PCI_MSI_NR,
drivers/pci/controller/plda/pcie-plda-host.c +1 -2
index 92866840875e..8e2db2e5b64b 100644
@@ -153,13 +153,12 @@ static const struct msi_parent_ops plda_msi_parent_ops = {
 static int plda_allocate_msi_domains(struct plda_pcie_rp *port)
 {
 	struct device *dev = port->dev;
-	struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node);
 	struct plda_msi *msi = &port->msi;
 
 	mutex_init(&port->msi.lock);
 
 	struct irq_domain_info info = {
-		.fwnode		= fwnode,
+		.fwnode		= dev_fwnode(dev),
 		.ops		= &msi_domain_ops,
 		.host_data	= port,
 		.size		= msi->num_vectors,
Signature · 1 line
2.50.1
author
#2 lore raw
Quoted 27 lines · Bjorn Helgaas

[+cc Arnd, Nam]

Quoted 10 lines · Jiri Slaby (SUSE)

All irq_domain functions now accept fwnode instead of of_node. But many PCI controllers still extract dev to of_node and then of_node to fwnode.

Instead, clean this up and simply use the dev_fwnode() helper to extract fwnode directly from dev. Internally, it still does dev => of_node => fwnode steps, but it's now hidden from the users.

Thanks, Jiri, I applied this on pci/controller/msi-parent for v6.17; it's at
https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=controller/msi-parent

The dev_fwnode() conversions touched the same places as Nam's changes to use msi_create_parent_irq_domain(). The previous dev_fwnode() conversions were *before* Nam's changes and these are *after*, and it all ended up looking more complicated than I wanted, so I squashed all the dev_fwnode() conversions together in
https://git.kernel.org/cgit/linux/kernel/git/pci/pci.git/commit/?id=a103d2dede56
("PCI: controller: Use dev_fwnode() instead of of_fwnode_handle()") and then added Nam's msi_create_parent_irq_domain() patches on top.

Quoted 5 lines

So a103d2dede56 ("PCI: controller: Use dev_fwnode() instead of of_fwnode_handle()") ends up *looking* different from the patch below, but I think having them all together makes it more obvious that they're all making the same conversion, and I think the end result is identical.

Makes sense to me.

Thanks!

Signature · 2 lines
js
suse labs