lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1451881723-2478-17-git-send-email-milo.kim@ti.com>
Date:	Mon, 4 Jan 2016 13:28:40 +0900
From:	Milo Kim <milo.kim@...com>
To:	<tglx@...utronix.de>
CC:	<jason@...edaemon.net>, <marc.zyngier@....com>,
	<alexandre.belloni@...e-electrons.com>,
	<boris.brezillon@...e-electrons.com>,
	<ludovic.desroches@...el.com>, <nicolas.ferre@...el.com>,
	<linux-kernel@...r.kernel.org>, Milo Kim <milo.kim@...com>
Subject: [PATCH 16/19] irqchip: atmel-aic: get total number of IRQs from device node

aic_common_of_init() needs an argument for number of interrupts.
Argument, 'nirqs' can be ignored if device compatible string is used.
This patch provides unified way to get total number of interrupts.
Chip specific register data is assigned as well.

Use single constant total AIC IRQ number, 'NR_AT91RM9200_IRQS'.

Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Jason Cooper <jason@...edaemon.net>
Cc: Marc Zyngier <marc.zyngier@....com>
Cc: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
Cc: Boris BREZILLON <boris.brezillon@...e-electrons.com>
Cc: Ludovic Desroches <ludovic.desroches@...el.com>
Cc: Nicolas Ferre <nicolas.ferre@...el.com>
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Milo Kim <milo.kim@...com>
---
 drivers/irqchip/irq-atmel-aic-common.c | 38 ++++++++++++++++++++++++++++++----
 drivers/irqchip/irq-atmel-aic-common.h |  4 +---
 drivers/irqchip/irq-atmel-aic.c        |  2 +-
 drivers/irqchip/irq-atmel-aic5.c       | 37 +++++----------------------------
 4 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
index 3d8cc8d..deec551 100644
--- a/drivers/irqchip/irq-atmel-aic-common.c
+++ b/drivers/irqchip/irq-atmel-aic-common.c
@@ -28,7 +28,11 @@
 
 #include "irq-atmel-aic-common.h"
 
-#define NR_AIC_IRQS			32
+#define AIC_IRQS_PER_CHIP		32
+#define NR_AT91RM9200_IRQS		32
+#define NR_SAMA5D2_IRQS			77
+#define NR_SAMA5D3_IRQS			48
+#define NR_SAMA5D4_IRQS			68
 
 #define AT91_AIC_SMR_BASE		0
 #define AT91_AIC_SVR_BASE		0x80
@@ -425,6 +429,30 @@ static void aic_pm_shutdown(struct irq_data *d)
 #define aic_pm_shutdown	NULL
 #endif /* CONFIG_PM */
 
+static int __init aic_get_num_chips(struct device_node *node)
+{
+	int nirqs;
+
+	/* Get total number of IRQs and configure register data */
+	if (of_device_is_compatible(node, "atmel,at91rm9200-aic")) {
+		nirqs = NR_AT91RM9200_IRQS;
+		aic_reg_data = &aic_regs;
+	} else if (of_device_is_compatible(node, "atmel,sama5d2-aic")) {
+		nirqs = NR_SAMA5D2_IRQS;
+		aic_reg_data = &aic5_regs;
+	} else if (of_device_is_compatible(node, "atmel,sama5d3-aic")) {
+		nirqs = NR_SAMA5D3_IRQS;
+		aic_reg_data = &aic5_regs;
+	} else if (of_device_is_compatible(node, "atmel,sama5d4-aic")) {
+		nirqs = NR_SAMA5D4_IRQS;
+		aic_reg_data = &aic5_regs;
+	} else {
+		return -EINVAL;
+	}
+
+	return DIV_ROUND_UP(nirqs, AIC_IRQS_PER_CHIP);
+}
+
 static void __init aic_common_ext_irq_of_init(struct irq_domain *domain)
 {
 	struct device_node *node = irq_domain_get_of_node(domain);
@@ -486,13 +514,13 @@ static void __init aic_hw_init(struct irq_domain *domain)
 		irq_reg_writel(gc, 0xffffffff, aic_reg_data->idcr);
 		irq_reg_writel(gc, 0xffffffff, aic_reg_data->iccr);
 
-		for (i = 0; i < NR_AIC_IRQS; i++)
+		for (i = 0; i < NR_AT91RM9200_IRQS; i++)
 			irq_reg_writel(gc, i, aic_reg_data->svr + (i * 4));
 	}
 }
 
 struct irq_domain *__init aic_common_of_init(struct device_node *node,
-					     const char *name, int nirqs)
+					     const char *name)
 {
 	struct irq_chip_generic *gc;
 	struct irq_domain *domain;
@@ -505,7 +533,9 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
 	if (aic_domain)
 		return ERR_PTR(-EEXIST);
 
-	nchips = DIV_ROUND_UP(nirqs, AIC_IRQS_PER_CHIP);
+	nchips = aic_get_num_chips(node);
+	if (nchips < 0)
+		return ERR_PTR(-EINVAL);
 
 	reg_base = of_iomap(node, 0);
 	if (!reg_base)
diff --git a/drivers/irqchip/irq-atmel-aic-common.h b/drivers/irqchip/irq-atmel-aic-common.h
index bf721b8..4170133 100644
--- a/drivers/irqchip/irq-atmel-aic-common.h
+++ b/drivers/irqchip/irq-atmel-aic-common.h
@@ -16,9 +16,7 @@
 #ifndef __IRQ_ATMEL_AIC_COMMON_H
 #define __IRQ_ATMEL_AIC_COMMON_H
 
-#define AIC_IRQS_PER_CHIP	32
-
 struct irq_domain *__init aic_common_of_init(struct device_node *node,
-					     const char *name, int nirqs);
+					     const char *name);
 
 #endif /* __IRQ_ATMEL_AIC_COMMON_H */
diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
index 44cedce..980197f 100644
--- a/drivers/irqchip/irq-atmel-aic.c
+++ b/drivers/irqchip/irq-atmel-aic.c
@@ -60,7 +60,7 @@ static int __init aic_of_init(struct device_node *node,
 {
 	struct irq_domain *domain;
 
-	domain = aic_common_of_init(node, "atmel-aic", NR_AIC_IRQS);
+	domain = aic_common_of_init(node, "atmel-aic");
 	if (IS_ERR(domain))
 		return PTR_ERR(domain);
 
diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
index d09cefe..dcf4711 100644
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -66,44 +66,17 @@
 #define AT91_AIC5_FFSR			0x58
 
 static int __init aic5_of_init(struct device_node *node,
-			       struct device_node *parent,
-			       int nirqs)
+			       struct device_node *parent)
 {
 	struct irq_domain *domain;
 
-	if (nirqs > NR_AIC5_IRQS)
-		return -EINVAL;
-
-	domain = aic_common_of_init(node, "atmel-aic5", nirqs);
+	domain = aic_common_of_init(node, "atmel-aic5");
 	if (IS_ERR(domain))
 		return PTR_ERR(domain);
 
 	return 0;
 }
 
-#define NR_SAMA5D2_IRQS		77
-
-static int __init sama5d2_aic5_of_init(struct device_node *node,
-				       struct device_node *parent)
-{
-	return aic5_of_init(node, parent, NR_SAMA5D2_IRQS);
-}
-IRQCHIP_DECLARE(sama5d2_aic5, "atmel,sama5d2-aic", sama5d2_aic5_of_init);
-
-#define NR_SAMA5D3_IRQS		48
-
-static int __init sama5d3_aic5_of_init(struct device_node *node,
-				       struct device_node *parent)
-{
-	return aic5_of_init(node, parent, NR_SAMA5D3_IRQS);
-}
-IRQCHIP_DECLARE(sama5d3_aic5, "atmel,sama5d3-aic", sama5d3_aic5_of_init);
-
-#define NR_SAMA5D4_IRQS		68
-
-static int __init sama5d4_aic5_of_init(struct device_node *node,
-				       struct device_node *parent)
-{
-	return aic5_of_init(node, parent, NR_SAMA5D4_IRQS);
-}
-IRQCHIP_DECLARE(sama5d4_aic5, "atmel,sama5d4-aic", sama5d4_aic5_of_init);
+IRQCHIP_DECLARE(sama5d2_aic5, "atmel,sama5d2-aic", aic5_of_init);
+IRQCHIP_DECLARE(sama5d3_aic5, "atmel,sama5d3-aic", aic5_of_init);
+IRQCHIP_DECLARE(sama5d4_aic5, "atmel,sama5d4-aic", aic5_of_init);
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ