[PATCH 1/2] irqchip/mmp: Safeguard against multiple root intc initialization

From: Lubomir Rintel
Date: Wed Feb 19 2020 - 03:00:39 EST


We can only handle one root ICU. Let's warn if someone messes up and adds
multiple in the devicetree.

Signed-off-by: Lubomir Rintel <lkundrak@xxxxx>
---
drivers/irqchip/irq-mmp.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/drivers/irqchip/irq-mmp.c b/drivers/irqchip/irq-mmp.c
index 4a74ac7b7c42e..f597d96409a1f 100644
--- a/drivers/irqchip/irq-mmp.c
+++ b/drivers/irqchip/irq-mmp.c
@@ -250,6 +250,11 @@ void __init icu_init_irq(void)
int irq;

max_icu_nr = 1;
+ if (mmp_icu_base) {
+ pr_err("ICU already initialized\n");
+ return;
+ }
+
mmp_icu_base = ioremap(0xd4282000, 0x1000);
icu_data[0].conf_enable = mmp_conf.conf_enable;
icu_data[0].conf_disable = mmp_conf.conf_disable;
@@ -273,6 +278,11 @@ void __init mmp2_init_icu(void)
int irq, end;

max_icu_nr = 8;
+ if (mmp_icu_base) {
+ pr_err("ICU already initialized\n");
+ return;
+ }
+
mmp_icu_base = ioremap(0xd4282000, 0x1000);
icu_data[0].conf_enable = mmp2_conf.conf_enable;
icu_data[0].conf_disable = mmp2_conf.conf_disable;
@@ -380,6 +390,11 @@ static int __init mmp_init_bases(struct device_node *node)
return ret;
}

+ if (mmp_icu_base) {
+ pr_err("ICU already initialized\n");
+ return -EEXIST;
+ }
+
mmp_icu_base = of_iomap(node, 0);
if (!mmp_icu_base) {
pr_err("Failed to get interrupt controller register\n");
--
2.24.1