diff options
author | Grant Likely <grant.likely@linaro.org> | 2013-09-19 17:44:55 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2013-10-24 06:50:36 -0400 |
commit | 16b84e5a505c790538e534ad8dfda9c288691e40 (patch) | |
tree | 887e4da0c9cdf408350230165cf72730cec599e6 | |
parent | f7578496a671a96e501f16a5104893275e32c33a (diff) |
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>
-rw-r--r-- | arch/arm/mach-integrator/pci_v3.c | 17 | ||||
-rw-r--r-- | arch/mips/pci/fixup-lantiq.c | 12 | ||||
-rw-r--r-- | arch/mips/pci/pci-rt3883.c | 22 | ||||
-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 |
7 files changed, 31 insertions, 67 deletions
diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c index bb3aeb31a54e..a87e510fe0c4 100644 --- a/arch/arm/mach-integrator/pci_v3.c +++ b/arch/arm/mach-integrator/pci_v3.c | |||
@@ -835,21 +835,6 @@ static struct hw_pci pci_v3 __initdata = { | |||
835 | 835 | ||
836 | #ifdef CONFIG_OF | 836 | #ifdef CONFIG_OF |
837 | 837 | ||
838 | static int __init pci_v3_map_irq_dt(const struct pci_dev *dev, u8 slot, u8 pin) | ||
839 | { | ||
840 | struct of_phandle_args oirq; | ||
841 | int ret; | ||
842 | |||
843 | ret = of_irq_parse_pci(dev, &oirq); | ||
844 | if (ret) { | ||
845 | dev_err(&dev->dev, "of_irq_parse_pci() %d\n", ret); | ||
846 | /* Proper return code 0 == NO_IRQ */ | ||
847 | return 0; | ||
848 | } | ||
849 | |||
850 | return irq_create_of_mapping(&oirq); | ||
851 | } | ||
852 | |||
853 | static int __init pci_v3_dtprobe(struct platform_device *pdev, | 838 | static int __init pci_v3_dtprobe(struct platform_device *pdev, |
854 | struct device_node *np) | 839 | struct device_node *np) |
855 | { | 840 | { |
@@ -918,7 +903,7 @@ static int __init pci_v3_dtprobe(struct platform_device *pdev, | |||
918 | return -EINVAL; | 903 | return -EINVAL; |
919 | } | 904 | } |
920 | 905 | ||
921 | pci_v3.map_irq = pci_v3_map_irq_dt; | 906 | pci_v3.map_irq = of_irq_parse_and_map_pci; |
922 | pci_common_init_dev(&pdev->dev, &pci_v3); | 907 | pci_common_init_dev(&pdev->dev, &pci_v3); |
923 | 908 | ||
924 | return 0; | 909 | return 0; |
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/mips/pci/pci-rt3883.c b/arch/mips/pci/pci-rt3883.c index eadc4310cd36..adeff2bfe4cd 100644 --- a/arch/mips/pci/pci-rt3883.c +++ b/arch/mips/pci/pci-rt3883.c | |||
@@ -583,27 +583,7 @@ err_put_intc_node: | |||
583 | 583 | ||
584 | int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 584 | int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
585 | { | 585 | { |
586 | struct of_phandle_args dev_irq; | 586 | return of_irq_parse_and_map_pci(dev, slot, pin); |
587 | int err; | ||
588 | int irq; | ||
589 | |||
590 | err = of_irq_parse_pci(dev, &dev_irq); | ||
591 | if (err) { | ||
592 | pr_err("pci %s: unable to get irq map, err=%d\n", | ||
593 | pci_name((struct pci_dev *) dev), err); | ||
594 | return 0; | ||
595 | } | ||
596 | |||
597 | irq = irq_create_of_mapping(&dev_irq); | ||
598 | |||
599 | if (irq == 0) | ||
600 | pr_crit("pci %s: no irq found for pin %u\n", | ||
601 | pci_name((struct pci_dev *) dev), pin); | ||
602 | else | ||
603 | pr_info("pci %s: using irq %d for pin %u\n", | ||
604 | pci_name((struct pci_dev *) dev), irq, pin); | ||
605 | |||
606 | return irq; | ||
607 | } | 587 | } |
608 | 588 | ||
609 | int pcibios_plat_dev_init(struct pci_dev *dev) | 589 | int pcibios_plat_dev_init(struct pci_dev *dev) |
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index d39948f654a0..69c826a3d07e 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c | |||
@@ -105,7 +105,6 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) | |||
105 | 105 | ||
106 | static int x86_of_pci_irq_enable(struct pci_dev *dev) | 106 | static int x86_of_pci_irq_enable(struct pci_dev *dev) |
107 | { | 107 | { |
108 | struct of_phandle_args oirq; | ||
109 | u32 virq; | 108 | u32 virq; |
110 | int ret; | 109 | int ret; |
111 | u8 pin; | 110 | u8 pin; |
@@ -116,11 +115,7 @@ static int x86_of_pci_irq_enable(struct pci_dev *dev) | |||
116 | if (!pin) | 115 | if (!pin) |
117 | return 0; | 116 | return 0; |
118 | 117 | ||
119 | ret = of_irq_parse_pci(dev, &oirq); | 118 | virq = of_irq_parse_and_map_pci(dev, 0, 0); |
120 | if (ret) | ||
121 | return ret; | ||
122 | |||
123 | virq = irq_create_of_mapping(&oirq); | ||
124 | if (virq == 0) | 119 | if (virq == 0) |
125 | return -EINVAL; | 120 | return -EINVAL; |
126 | dev->irq = virq; | 121 | 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 3a8d01ec50f7..07ddb3a13c6e 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c | |||
@@ -645,18 +645,6 @@ static int __init mvebu_pcie_setup(int nr, struct pci_sys_data *sys) | |||
645 | return 1; | 645 | return 1; |
646 | } | 646 | } |
647 | 647 | ||
648 | static int __init mvebu_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | ||
649 | { | ||
650 | struct of_phandle_args oirq; | ||
651 | int ret; | ||
652 | |||
653 | ret = of_irq_parse_pci(dev, &oirq); | ||
654 | if (ret) | ||
655 | return ret; | ||
656 | |||
657 | return irq_create_of_mapping(&oirq); | ||
658 | } | ||
659 | |||
660 | static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) | 648 | static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) |
661 | { | 649 | { |
662 | struct mvebu_pcie *pcie = sys_to_pcie(sys); | 650 | struct mvebu_pcie *pcie = sys_to_pcie(sys); |
@@ -705,7 +693,7 @@ static void __init mvebu_pcie_enable(struct mvebu_pcie *pcie) | |||
705 | hw.private_data = (void **)&pcie; | 693 | hw.private_data = (void **)&pcie; |
706 | hw.setup = mvebu_pcie_setup; | 694 | hw.setup = mvebu_pcie_setup; |
707 | hw.scan = mvebu_pcie_scan_bus; | 695 | hw.scan = mvebu_pcie_scan_bus; |
708 | hw.map_irq = mvebu_pcie_map_irq; | 696 | hw.map_irq = of_irq_parse_and_map_pci; |
709 | hw.ops = &mvebu_pcie_ops; | 697 | hw.ops = &mvebu_pcie_ops; |
710 | hw.align_resource = mvebu_pcie_align_resource; | 698 | hw.align_resource = mvebu_pcie_align_resource; |
711 | 699 | ||
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, |