[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200219080024.4002-2-lkundrak@v3.sk>
Date:   Wed, 19 Feb 2020 09:00:23 +0100
From:   Lubomir Rintel <lkundrak@...sk>
To:     Marc Zyngier <maz@...nel.org>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Jason Cooper <jason@...edaemon.net>,
        linux-kernel@...r.kernel.org, Lubomir Rintel <lkundrak@...sk>
Subject: [PATCH 1/2] irqchip/mmp: Safeguard against multiple root intc initialization
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@...sk>
---
 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
Powered by blists - more mailing lists