diff options
author | Grant Likely <grant.likely@linaro.org> | 2013-09-19 17:44:55 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@freescale.com> | 2014-05-16 04:19:12 -0400 |
commit | 0a60ddc194485aa16a810d80a38a2ca1c557f3b9 (patch) | |
tree | 8edda331f3ab17a09a9572c871774fdfcd31986e | |
parent | 41db6e32df83b780d148b25a97b5a3cf63e8f1c1 (diff) |
ENGR00313685-7 of/irq: Create of_irq_parse_and_map_pci() to consolidate arch code.
commit 16b84e5a505c790538e534ad8dfda9c288691e40 upstream.
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>
Signed-off-by: Shawn Guo <shawn.guo@freescale.com>
Conflicts:
arch/arm/mach-integrator/pci_v3.c
arch/mips/pci/pci-rt3883.c
-rw-r--r-- | arch/mips/pci/fixup-lantiq.c | 12 | ||||
-rw-r--r-- | arch/x86/kernel/devicetree.c | 7 | ||||
-rw-r--r-- | drivers/of/of_pci_irq.c | 25 | ||||
-rw-r--r-- | drivers/pci/host/pci-mvebu.c | 14 | ||||
-rw-r--r-- | include/linux/of_pci.h | 1 |
5 files changed, 29 insertions, 30 deletions
diff --git a/arch/mips/pci/fixup-lantiq.c b/arch/mips/pci/fixup-lantiq.c index aef60e75003e..c2ce41ea61d7 100644 --- a/arch/mips/pci/fixup-lantiq.c +++ b/arch/mips/pci/fixup-lantiq.c | |||
@@ -25,15 +25,5 @@ int pcibios_plat_dev_init(struct pci_dev *dev) | |||
25 | 25 | ||
26 | int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 26 | int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
27 | { | 27 | { |
28 | struct of_phandle_args dev_irq; | 28 | return of_irq_parse_and_map_pci(dev, slot, pin); |
29 | int irq; | ||
30 | |||
31 | if (of_irq_parse_pci(dev, &dev_irq)) { | ||
32 | dev_err(&dev->dev, "trying to map irq for unknown slot:%d pin:%d\n", | ||
33 | slot, pin); | ||
34 | return 0; | ||
35 | } | ||
36 | irq = irq_create_of_mapping(&dev_irq); | ||
37 | dev_info(&dev->dev, "SLOT:%d PIN:%d IRQ:%d\n", slot, pin, irq); | ||
38 | return irq; | ||
39 | } | 29 | } |
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 0171604becb5..02cb78203397 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c | |||
@@ -106,7 +106,6 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) | |||
106 | 106 | ||
107 | static int x86_of_pci_irq_enable(struct pci_dev *dev) | 107 | static int x86_of_pci_irq_enable(struct pci_dev *dev) |
108 | { | 108 | { |
109 | struct of_phandle_args oirq; | ||
110 | u32 virq; | 109 | u32 virq; |
111 | int ret; | 110 | int ret; |
112 | u8 pin; | 111 | u8 pin; |
@@ -117,11 +116,7 @@ static int x86_of_pci_irq_enable(struct pci_dev *dev) | |||
117 | if (!pin) | 116 | if (!pin) |
118 | return 0; | 117 | return 0; |
119 | 118 | ||
120 | ret = of_irq_parse_pci(dev, &oirq); | 119 | virq = of_irq_parse_and_map_pci(dev, 0, 0); |
121 | if (ret) | ||
122 | return ret; | ||
123 | |||
124 | virq = irq_create_of_mapping(&oirq); | ||
125 | if (virq == 0) | 120 | if (virq == 0) |
126 | return -EINVAL; | 121 | return -EINVAL; |
127 | dev->irq = virq; | 122 | dev->irq = virq; |
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 | |||
94 | return of_irq_parse_raw(laddr, out_irq); | 94 | return of_irq_parse_raw(laddr, out_irq); |
95 | } | 95 | } |
96 | EXPORT_SYMBOL_GPL(of_irq_parse_pci); | 96 | EXPORT_SYMBOL_GPL(of_irq_parse_pci); |
97 | |||
98 | /** | ||
99 | * of_irq_parse_and_map_pci() - Decode a PCI irq from the device tree and map to a virq | ||
100 | * @dev: The pci device needing an irq | ||
101 | * @slot: PCI slot number; passed when used as map_irq callback. Unused | ||
102 | * @pin: PCI irq pin number; passed when used as map_irq callback. Unused | ||
103 | * | ||
104 | * @slot and @pin are unused, but included in the function so that this | ||
105 | * function can be used directly as the map_irq callback to pci_fixup_irqs(). | ||
106 | */ | ||
107 | int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) | ||
108 | { | ||
109 | struct of_phandle_args oirq; | ||
110 | int ret; | ||
111 | |||
112 | ret = of_irq_parse_pci(dev, &oirq); | ||
113 | if (ret) { | ||
114 | dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret); | ||
115 | return 0; /* Proper return code 0 == NO_IRQ */ | ||
116 | } | ||
117 | |||
118 | return irq_create_of_mapping(&oirq); | ||
119 | } | ||
120 | EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci); | ||
121 | |||
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 3636bda8db14..8500817c0ac6 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c | |||
@@ -636,18 +636,6 @@ static int __init mvebu_pcie_setup(int nr, struct pci_sys_data *sys) | |||
636 | return 1; | 636 | return 1; |
637 | } | 637 | } |
638 | 638 | ||
639 | static int __init mvebu_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | ||
640 | { | ||
641 | struct of_phandle_args oirq; | ||
642 | int ret; | ||
643 | |||
644 | ret = of_irq_parse_pci(dev, &oirq); | ||
645 | if (ret) | ||
646 | return ret; | ||
647 | |||
648 | return irq_create_of_mapping(&oirq); | ||
649 | } | ||
650 | |||
651 | static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) | 639 | static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) |
652 | { | 640 | { |
653 | struct mvebu_pcie *pcie = sys_to_pcie(sys); | 641 | struct mvebu_pcie *pcie = sys_to_pcie(sys); |
@@ -696,7 +684,7 @@ static void __init mvebu_pcie_enable(struct mvebu_pcie *pcie) | |||
696 | hw.private_data = (void **)&pcie; | 684 | hw.private_data = (void **)&pcie; |
697 | hw.setup = mvebu_pcie_setup; | 685 | hw.setup = mvebu_pcie_setup; |
698 | hw.scan = mvebu_pcie_scan_bus; | 686 | hw.scan = mvebu_pcie_scan_bus; |
699 | hw.map_irq = mvebu_pcie_map_irq; | 687 | hw.map_irq = of_irq_parse_and_map_pci; |
700 | hw.ops = &mvebu_pcie_ops; | 688 | hw.ops = &mvebu_pcie_ops; |
701 | hw.align_resource = mvebu_pcie_align_resource; | 689 | hw.align_resource = mvebu_pcie_align_resource; |
702 | 690 | ||
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index f297237349e8..1a1f5ffd5288 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h | |||
@@ -7,6 +7,7 @@ | |||
7 | struct pci_dev; | 7 | struct pci_dev; |
8 | struct of_phandle_args; | 8 | struct of_phandle_args; |
9 | int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq); | 9 | int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq); |
10 | int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); | ||
10 | 11 | ||
11 | struct device_node; | 12 | struct device_node; |
12 | struct device_node *of_pci_find_child_device(struct device_node *parent, | 13 | struct device_node *of_pci_find_child_device(struct device_node *parent, |