PCI: dwc: uniphier: use fwnode API for legacy-interrupt-controller
Subsystems (4)
PATCH v2 1/1 PCI: dwc: uniphier: use fwnode API for legacy-interrupt-controller
Convert uniphier_pcie_config_intx_irq() from the OF-specific to the generic firmware-node API: of_get_child_by_name() to device_get_named_child_node(), irq_of_parse_and_map() to fwnode_irq_get(), of_fwnode_handle() on the child node to passing the fwnode directly, and of_node_put() to fwnode_handle_put().
Unlike irq_of_parse_and_map(), fwnode_irq_get() returns a positive IRQ or a negative errno and never 0 (it rewrites 0 to -EINVAL), so check pp->irq < 0 and propagate the error. pp->irq is an int, so the negative value is preserved. Drop the now-unused np / dev_fwnode() locals, since device_get_named_child_node() operates on the device directly.
Built for arm64 (defconfig + CONFIG_PCIE_UNIPHIER) with LLVM=1; drivers/pci/controller/dwc/pcie-uniphier.o compiles cleanly.
---
v2: fix fwnode_irq_get() error propagation.
drivers/pci/controller/dwc/pcie-uniphier.c | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/pci/controller/dwc/pcie-uniphier.c +12 -13
@@ -14,7 +14,6 @@#include <linux/iopoll.h> #include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h> -#include <linux/of_irq.h> #include <linux/pci.h> #include <linux/phy/phy.h> #include <linux/platform_device.h>
@@ -262,27 +261,27 @@ static int uniphier_pcie_config_intx_irq(struct dw_pcie_rp *pp) {struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct uniphier_pcie *pcie =to_uniphier_pcie (pci); -struct device_node *np = pci->dev->of_node; -struct device_node *np_intc; +struct device *dev = pci->dev; +struct fwnode_handle *fw_intc;int ret =0 ; - np_intc =of_get_child_by_name (np,"legacy-interrupt-controller" ); -if (!np_intc) { -dev_err (pci->dev,"Failed to get legacy-interrupt-controller node\n" ); + fw_intc =device_get_named_child_node (dev,"legacy-interrupt-controller" ); +if (!fw_intc) { +dev_err (dev,"Failed to get legacy-interrupt-controller node\n" );return -EINVAL ; } - pp->irq =irq_of_parse_and_map (np_intc,0 ); -if (!pp->irq) { -dev_err (pci->dev,"Failed to get an IRQ entry in legacy-interrupt-controller\n" ); - ret = -EINVAL ; + pp->irq =fwnode_irq_get (fw_intc,0 ); +if (pp->irq <0 ) { +dev_err (dev,"Failed to get an IRQ entry in legacy-interrupt-controller\n" ); + ret = pp->irq; goto out_put_node; } - pcie->intx_irq_domain =irq_domain_create_linear (of_fwnode_handle (np_intc),PCI_NUM_INTX , + pcie->intx_irq_domain =irq_domain_create_linear (fw_intc,PCI_NUM_INTX , &uniphier_intx_domain_ops, pp);if (!pcie->intx_irq_domain) { -dev_err (pci->dev,"Failed to get INTx domain\n" ); +dev_err (dev,"Failed to get INTx domain\n" ); ret = -ENODEV ; goto out_put_node; }
@@ -291,7 +290,7 @@ static int uniphier_pcie_config_intx_irq(struct dw_pcie_rp *pp) pp); out_put_node: -of_node_put (np_intc); +fwnode_handle_put (fw_intc);return ret; }
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 12 lines
Convert
uniphier_pcie_config_intx_irq()from the OF-specific to the generic firmware-node API:of_get_child_by_name()todevice_get_named_child_node(),irq_of_parse_and_map()tofwnode_irq_get(),of_fwnode_handle()on the child node to passing the fwnode directly, andof_node_put()tofwnode_handle_put().Unlike
irq_of_parse_and_map(),fwnode_irq_get()returns a positive IRQ or a negative errno and never 0 (it rewrites 0 to-EINVAL), so checkpp->irq< 0 and propagate the error.pp->irqis an int, so the negative value is preserved. Drop the now-unused np /dev_fwnode()locals, sincedevice_get_named_child_node()operates on the device directly.
Quoted 5 lines
Built for arm64 (defconfig +
CONFIG_PCIE_UNIPHIER) with LLVM=1;drivers/pci/controller/dwc/pcie-uniphier.ocompiles cleanly.Assisted-by opencode:hy3-freeSigned-off-by Rosen Penev <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Manivannan Sadhasivam
maintainerQuoted 12 lines · Rosen Penev
Convert
uniphier_pcie_config_intx_irq()from the OF-specific to the generic firmware-node API:of_get_child_by_name()todevice_get_named_child_node(),irq_of_parse_and_map()tofwnode_irq_get(),of_fwnode_handle()on the child node to passing the fwnode directly, andof_node_put()tofwnode_handle_put().Unlike
irq_of_parse_and_map(),fwnode_irq_get()returns a positive IRQ or a negative errno and never 0 (it rewrites 0 to-EINVAL), so checkpp->irq< 0 and propagate the error.pp->irqis an int, so the negative value is preserved. Drop the now-unused np /dev_fwnode()locals, sincedevice_get_named_child_node()operates on the device directly.
Quoted 5 lines
Built for arm64 (defconfig +
CONFIG_PCIE_UNIPHIER) with LLVM=1;drivers/pci/controller/dwc/pcie-uniphier.ocompiles cleanly.Assisted-by opencode:hy3-freeSigned-off-by Rosen Penev <[email protected]>
What is the point of doing all these conversions of an OF only driver to fwnode? It just adds noise and provide no value.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்