Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: controller: Use dev_fwnode() instead of of_fwnode_handle()

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.

In the case of altera, this also removes an unused 'node' variable that is
only used when CONFIG_OF is enabled:

drivers/pci/controller/pcie-altera.c: In function 'altera_pcie_init_irq_domain':
drivers/pci/controller/pcie-altera.c:855:29: error: unused variable 'node' [-Werror=unused-variable]
855 | struct device_node *node = dev->of_node;

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de> # altera
[bhelgaas: squash together, rebase to precede msi-parent]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250521163329.2137973-1-arnd@kernel.org
Link: https://patch.msgid.link/20250611104348.192092-16-jirislaby@kernel.org
Link: https://patch.msgid.link/20250723065907.1841758-1-jirislaby@kernel.org

authored by

Jiri Slaby (SUSE) and committed by
Bjorn Helgaas
a103d2de 19272b37

+11 -14
+1 -1
drivers/pci/controller/dwc/pcie-designware-host.c
··· 227 227 int dw_pcie_allocate_domains(struct dw_pcie_rp *pp) 228 228 { 229 229 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 230 - struct fwnode_handle *fwnode = of_fwnode_handle(pci->dev->of_node); 230 + struct fwnode_handle *fwnode = dev_fwnode(pci->dev); 231 231 232 232 pp->irq_domain = irq_domain_create_linear(fwnode, pp->num_vectors, 233 233 &dw_pcie_msi_domain_ops, pp);
+3 -4
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c
··· 435 435 static int mobiveil_allocate_msi_domains(struct mobiveil_pcie *pcie) 436 436 { 437 437 struct device *dev = &pcie->pdev->dev; 438 - struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node); 438 + struct fwnode_handle *fwnode = dev_fwnode(dev); 439 439 struct mobiveil_msi *msi = &pcie->rp.msi; 440 440 441 441 mutex_init(&msi->lock); ··· 464 464 struct mobiveil_root_port *rp = &pcie->rp; 465 465 466 466 /* setup INTx */ 467 - rp->intx_domain = irq_domain_create_linear(of_fwnode_handle(dev->of_node), PCI_NUM_INTX, 468 - &intx_domain_ops, pcie); 469 - 467 + rp->intx_domain = irq_domain_create_linear(dev_fwnode(dev), PCI_NUM_INTX, &intx_domain_ops, 468 + pcie); 470 469 if (!rp->intx_domain) { 471 470 dev_err(dev, "Failed to get a INTx IRQ domain\n"); 472 471 return -ENOMEM;
+1 -1
drivers/pci/controller/pcie-altera-msi.c
··· 164 164 165 165 static int altera_allocate_domains(struct altera_msi *msi) 166 166 { 167 - struct fwnode_handle *fwnode = of_fwnode_handle(msi->pdev->dev.of_node); 167 + struct fwnode_handle *fwnode = dev_fwnode(&msi->pdev->dev); 168 168 169 169 msi->inner_domain = irq_domain_create_linear(NULL, msi->num_of_vectors, 170 170 &msi_domain_ops, msi);
+1 -2
drivers/pci/controller/pcie-altera.c
··· 852 852 static int altera_pcie_init_irq_domain(struct altera_pcie *pcie) 853 853 { 854 854 struct device *dev = &pcie->pdev->dev; 855 - struct device_node *node = dev->of_node; 856 855 857 856 /* Setup INTx */ 858 - pcie->irq_domain = irq_domain_create_linear(of_fwnode_handle(node), PCI_NUM_INTX, 857 + pcie->irq_domain = irq_domain_create_linear(dev_fwnode(dev), PCI_NUM_INTX, 859 858 &intx_domain_ops, pcie); 860 859 if (!pcie->irq_domain) { 861 860 dev_err(dev, "Failed to get a INTx IRQ domain\n");
+1 -2
drivers/pci/controller/pcie-mediatek-gen3.c
··· 756 756 /* Setup MSI */ 757 757 mutex_init(&pcie->lock); 758 758 759 - pcie->msi_bottom_domain = irq_domain_create_linear(of_fwnode_handle(node), 760 - PCIE_MSI_IRQS_NUM, 759 + pcie->msi_bottom_domain = irq_domain_create_linear(dev_fwnode(dev), PCIE_MSI_IRQS_NUM, 761 760 &mtk_msi_bottom_domain_ops, pcie); 762 761 if (!pcie->msi_bottom_domain) { 763 762 dev_err(dev, "failed to create MSI bottom domain\n");
+1 -1
drivers/pci/controller/pcie-mediatek.c
··· 485 485 486 486 static int mtk_pcie_allocate_msi_domains(struct mtk_pcie_port *port) 487 487 { 488 - struct fwnode_handle *fwnode = of_fwnode_handle(port->pcie->dev->of_node); 488 + struct fwnode_handle *fwnode = dev_fwnode(port->pcie->dev); 489 489 490 490 mutex_init(&port->lock); 491 491
+1 -1
drivers/pci/controller/pcie-xilinx-dma-pl.c
··· 470 470 struct device *dev = port->dev; 471 471 struct xilinx_msi *msi = &port->msi; 472 472 int size = BITS_TO_LONGS(XILINX_NUM_MSI_IRQS) * sizeof(long); 473 - struct fwnode_handle *fwnode = of_fwnode_handle(port->dev->of_node); 473 + struct fwnode_handle *fwnode = dev_fwnode(port->dev); 474 474 475 475 msi->dev_domain = irq_domain_create_linear(NULL, XILINX_NUM_MSI_IRQS, 476 476 &dev_msi_domain_ops, port);
+1 -1
drivers/pci/controller/pcie-xilinx-nwl.c
··· 495 495 { 496 496 #ifdef CONFIG_PCI_MSI 497 497 struct device *dev = pcie->dev; 498 - struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node); 498 + struct fwnode_handle *fwnode = dev_fwnode(dev); 499 499 struct nwl_msi *msi = &pcie->msi; 500 500 501 501 msi->dev_domain = irq_domain_create_linear(NULL, INT_PCI_MSI_NR, &dev_msi_domain_ops, pcie);
+1 -1
drivers/pci/controller/plda/pcie-plda-host.c
··· 150 150 static int plda_allocate_msi_domains(struct plda_pcie_rp *port) 151 151 { 152 152 struct device *dev = port->dev; 153 - struct fwnode_handle *fwnode = of_fwnode_handle(dev->of_node); 153 + struct fwnode_handle *fwnode = dev_fwnode(dev); 154 154 struct plda_msi *msi = &port->msi; 155 155 156 156 mutex_init(&port->msi.lock);