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

PCI: Check for platform_get_irq() failure consistently

The platform_get_irq*() interfaces return either a negative error number or
a valid IRQ. 0 is not a valid return value, so check for "< 0" to detect
failure as recommended by the function documentation.

On failure, return the error number from platform_get_irq*() instead of
making up a new one.

Link: https://lore.kernel.org/r/cover.1583952275.git.amanharitsh123@gmail.com
[bhelgaas: commit log, squash into one patch]
Signed-off-by: Aman Sharma <amanharitsh123@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Karthikeyan Mitran <m.karthikeyan@mobiveil.co.in>
Cc: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Ryder Lee <ryder.lee@mediatek.com>
Cc: Marc Gonzalez <marc.w.gonzalez@free.fr>

authored by

Aman Sharma and committed by
Bjorn Helgaas
0584bff0 a85a6c86

+16 -10
+2 -2
drivers/pci/controller/dwc/pci-imx6.c
··· 868 868 869 869 if (IS_ENABLED(CONFIG_PCI_MSI)) { 870 870 pp->msi_irq = platform_get_irq_byname(pdev, "msi"); 871 - if (pp->msi_irq <= 0) { 871 + if (pp->msi_irq < 0) { 872 872 dev_err(dev, "failed to get MSI irq\n"); 873 - return -ENODEV; 873 + return pp->msi_irq; 874 874 } 875 875 } 876 876
+2 -2
drivers/pci/controller/dwc/pcie-tegra194.c
··· 2190 2190 } 2191 2191 2192 2192 pp->irq = platform_get_irq_byname(pdev, "intr"); 2193 - if (!pp->irq) { 2193 + if (pp->irq < 0) { 2194 2194 dev_err(dev, "Failed to get \"intr\" interrupt\n"); 2195 - return -ENODEV; 2195 + return pp->irq; 2196 2196 } 2197 2197 2198 2198 pcie->bpmp = tegra_bpmp_get(dev);
+2 -2
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c
··· 522 522 mobiveil_pcie_enable_msi(pcie); 523 523 524 524 rp->irq = platform_get_irq(pdev, 0); 525 - if (rp->irq <= 0) { 525 + if (rp->irq < 0) { 526 526 dev_err(dev, "failed to map IRQ: %d\n", rp->irq); 527 - return -ENODEV; 527 + return rp->irq; 528 528 } 529 529 530 530 /* initialize the IRQ domains */
+3
drivers/pci/controller/pci-aardvark.c
··· 973 973 return PTR_ERR(pcie->base); 974 974 975 975 irq = platform_get_irq(pdev, 0); 976 + if (irq < 0) 977 + return irq; 978 + 976 979 ret = devm_request_irq(dev, irq, advk_pcie_irq_handler, 977 980 IRQF_SHARED | IRQF_NO_THREAD, "advk-pcie", 978 981 pcie);
+2 -2
drivers/pci/controller/pci-v3-semi.c
··· 777 777 778 778 /* Get and request error IRQ resource */ 779 779 irq = platform_get_irq(pdev, 0); 780 - if (irq <= 0) { 780 + if (irq < 0) { 781 781 dev_err(dev, "unable to obtain PCIv3 error IRQ\n"); 782 - return -ENODEV; 782 + return irq; 783 783 } 784 784 ret = devm_request_irq(dev, irq, v3_irq, 0, 785 785 "PCIv3 error", v3);
+3
drivers/pci/controller/pcie-mediatek.c
··· 651 651 } 652 652 653 653 port->irq = platform_get_irq(pdev, port->slot); 654 + if (port->irq < 0) 655 + return port->irq; 656 + 654 657 irq_set_chained_handler_and_data(port->irq, 655 658 mtk_pcie_intr_handler, port); 656 659
+2 -2
drivers/pci/controller/pcie-tango.c
··· 273 273 writel_relaxed(0, pcie->base + SMP8759_ENABLE + offset); 274 274 275 275 virq = platform_get_irq(pdev, 1); 276 - if (virq <= 0) { 276 + if (virq < 0) { 277 277 dev_err(dev, "Failed to map IRQ\n"); 278 - return -ENXIO; 278 + return virq; 279 279 } 280 280 281 281 irq_dom = irq_domain_create_linear(fwnode, MSI_MAX, &dom_ops, pcie);