Commit fe46e503 authored by John Crispin's avatar John Crispin Committed by Ralf Baechle

MIPS: Lantiq: Fix eiu interrupt loading code

Using of_irq_count to load the irq index from the devicetree is incorrect.
This will cause the kernel to map them regardless, even if they dont
actually get used. Change the code to use of_property_count_u32_elems()
instead which is the correct API to use in this case.
Signed-off-by: default avatarJohn Crispin <john@phrozen.org>
Cc: Linux-MIPS <linux-mips@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/13601/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 7840d618
...@@ -66,7 +66,7 @@ int gic_present; ...@@ -66,7 +66,7 @@ int gic_present;
#endif #endif
static int exin_avail; static int exin_avail;
static struct resource ltq_eiu_irq[MAX_EIU]; static u32 ltq_eiu_irq[MAX_EIU];
static void __iomem *ltq_icu_membase[MAX_IM]; static void __iomem *ltq_icu_membase[MAX_IM];
static void __iomem *ltq_eiu_membase; static void __iomem *ltq_eiu_membase;
static struct irq_domain *ltq_domain; static struct irq_domain *ltq_domain;
...@@ -75,7 +75,7 @@ static int ltq_perfcount_irq; ...@@ -75,7 +75,7 @@ static int ltq_perfcount_irq;
int ltq_eiu_get_irq(int exin) int ltq_eiu_get_irq(int exin)
{ {
if (exin < exin_avail) if (exin < exin_avail)
return ltq_eiu_irq[exin].start; return ltq_eiu_irq[exin];
return -1; return -1;
} }
...@@ -126,7 +126,7 @@ static int ltq_eiu_settype(struct irq_data *d, unsigned int type) ...@@ -126,7 +126,7 @@ static int ltq_eiu_settype(struct irq_data *d, unsigned int type)
int i; int i;
for (i = 0; i < MAX_EIU; i++) { for (i = 0; i < MAX_EIU; i++) {
if (d->hwirq == ltq_eiu_irq[i].start) { if (d->hwirq == ltq_eiu_irq[i]) {
int val = 0; int val = 0;
int edge = 0; int edge = 0;
...@@ -174,7 +174,7 @@ static unsigned int ltq_startup_eiu_irq(struct irq_data *d) ...@@ -174,7 +174,7 @@ static unsigned int ltq_startup_eiu_irq(struct irq_data *d)
ltq_enable_irq(d); ltq_enable_irq(d);
for (i = 0; i < MAX_EIU; i++) { for (i = 0; i < MAX_EIU; i++) {
if (d->hwirq == ltq_eiu_irq[i].start) { if (d->hwirq == ltq_eiu_irq[i]) {
/* by default we are low level triggered */ /* by default we are low level triggered */
ltq_eiu_settype(d, IRQF_TRIGGER_LOW); ltq_eiu_settype(d, IRQF_TRIGGER_LOW);
/* clear all pending */ /* clear all pending */
...@@ -196,7 +196,7 @@ static void ltq_shutdown_eiu_irq(struct irq_data *d) ...@@ -196,7 +196,7 @@ static void ltq_shutdown_eiu_irq(struct irq_data *d)
ltq_disable_irq(d); ltq_disable_irq(d);
for (i = 0; i < MAX_EIU; i++) { for (i = 0; i < MAX_EIU; i++) {
if (d->hwirq == ltq_eiu_irq[i].start) { if (d->hwirq == ltq_eiu_irq[i]) {
/* disable */ /* disable */
ltq_eiu_w32(ltq_eiu_r32(LTQ_EIU_EXIN_INEN) & ~BIT(i), ltq_eiu_w32(ltq_eiu_r32(LTQ_EIU_EXIN_INEN) & ~BIT(i),
LTQ_EIU_EXIN_INEN); LTQ_EIU_EXIN_INEN);
...@@ -341,7 +341,7 @@ static int icu_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) ...@@ -341,7 +341,7 @@ static int icu_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
return 0; return 0;
for (i = 0; i < exin_avail; i++) for (i = 0; i < exin_avail; i++)
if (hw == ltq_eiu_irq[i].start) if (hw == ltq_eiu_irq[i])
chip = &ltq_eiu_type; chip = &ltq_eiu_type;
irq_set_chip_and_handler(hw, chip, handle_level_irq); irq_set_chip_and_handler(hw, chip, handle_level_irq);
...@@ -439,14 +439,15 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent) ...@@ -439,14 +439,15 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
eiu_node = of_find_compatible_node(NULL, NULL, "lantiq,eiu-xway"); eiu_node = of_find_compatible_node(NULL, NULL, "lantiq,eiu-xway");
if (eiu_node && !of_address_to_resource(eiu_node, 0, &res)) { if (eiu_node && !of_address_to_resource(eiu_node, 0, &res)) {
/* find out how many external irq sources we have */ /* find out how many external irq sources we have */
exin_avail = of_irq_count(eiu_node); exin_avail = of_property_count_u32_elems(eiu_node,
"lantiq,eiu-irqs");
if (exin_avail > MAX_EIU) if (exin_avail > MAX_EIU)
exin_avail = MAX_EIU; exin_avail = MAX_EIU;
ret = of_irq_to_resource_table(eiu_node, ret = of_property_read_u32_array(eiu_node, "lantiq,eiu-irqs",
ltq_eiu_irq, exin_avail); ltq_eiu_irq, exin_avail);
if (ret != exin_avail) if (ret)
panic("failed to load external irq resources"); panic("failed to load external irq resources");
if (!request_mem_region(res.start, resource_size(&res), if (!request_mem_region(res.start, resource_size(&res),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment