summaryrefslogtreecommitdiff
path: root/drivers/of/of_pci_irq.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@linaro.org>2013-09-19 16:44:55 -0500
committerGrant Likely <grant.likely@linaro.org>2013-10-24 11:50:36 +0100
commit16b84e5a505c790538e534ad8dfda9c288691e40 (patch)
tree887e4da0c9cdf408350230165cf72730cec599e6 /drivers/of/of_pci_irq.c
parentf7578496a671a96e501f16a5104893275e32c33a (diff)
downloadlwn-16b84e5a505c790538e534ad8dfda9c288691e40.tar.gz
lwn-16b84e5a505c790538e534ad8dfda9c288691e40.zip
of/irq: Create of_irq_parse_and_map_pci() to consolidate arch code.
Several architectures open code effectively the same code block for finding and mapping PCI irqs. This patch consolidates it down to a single function. Signed-off-by: Grant Likely <grant.likely@linaro.org> Acked-by: Michal Simek <monstr@monstr.eu> Cc: Russell King <linux@arm.linux.org.uk> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/of/of_pci_irq.c')
-rw-r--r--drivers/of/of_pci_irq.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c
index 303afebc247a..8e92acd8253f 100644
--- a/drivers/of/of_pci_irq.c
+++ b/drivers/of/of_pci_irq.c
@@ -94,3 +94,28 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
return of_irq_parse_raw(laddr, out_irq);
}
EXPORT_SYMBOL_GPL(of_irq_parse_pci);
+
+/**
+ * of_irq_parse_and_map_pci() - Decode a PCI irq from the device tree and map to a virq
+ * @dev: The pci device needing an irq
+ * @slot: PCI slot number; passed when used as map_irq callback. Unused
+ * @pin: PCI irq pin number; passed when used as map_irq callback. Unused
+ *
+ * @slot and @pin are unused, but included in the function so that this
+ * function can be used directly as the map_irq callback to pci_fixup_irqs().
+ */
+int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
+{
+ struct of_phandle_args oirq;
+ int ret;
+
+ ret = of_irq_parse_pci(dev, &oirq);
+ if (ret) {
+ dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret);
+ return 0; /* Proper return code 0 == NO_IRQ */
+ }
+
+ return irq_create_of_mapping(&oirq);
+}
+EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci);
+