Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1300546
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 04/19] irqchip: atmel-aic: replace magic numbers with named constant |
| Date | 2016-01-04 09:30 +0100 |
| Message-ID | <qN8GC-YX-13@gated-at.bofh.it> (permalink) |
| References | <qN4Wl-6EU-3@gated-at.bofh.it> <qN4Wm-6EU-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, 4 Jan 2016 13:28:28 +0900
Milo Kim <milo.kim@ti.com> wrote:
> One AIC IRQ chip can have 32 interrupt source.
> To enhance code readability, magic number is replaced with named constant,
> 'AIC_IRQS_PER_CHIP'.
>
> aic_hw_init() initializes vector registers up to total number of
> AIC interrupts. This magic number is replaced with NR_AIC_IRQS.
Actually this is a limitation of the generic chip infrastructure
(the irq_chip_generic uses u32 fields to store its internal status, and
each irq is attributed a bit position, which explains the 32 irqs per
chip limit), so I think this macro should be defined in
include/linux/irq.h:
#define MAX_IRQS_PER_GENERIC_CHIP 32
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Cc: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Milo Kim <milo.kim@ti.com>
> ---
> drivers/irqchip/irq-atmel-aic-common.c | 11 ++++++-----
> drivers/irqchip/irq-atmel-aic-common.h | 1 +
> drivers/irqchip/irq-atmel-aic.c | 2 +-
> drivers/irqchip/irq-atmel-aic5.c | 4 ++--
> 4 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
> index ef2c619..5effd52 100644
> --- a/drivers/irqchip/irq-atmel-aic-common.c
> +++ b/drivers/irqchip/irq-atmel-aic-common.c
> @@ -135,7 +135,7 @@ static void __init aic_common_ext_irq_of_init(struct irq_domain *domain)
> }
>
> aic = gc->private;
> - aic->ext_irqs |= (1 << (hwirq % 32));
> + aic->ext_irqs |= (1 << (hwirq % AIC_IRQS_PER_CHIP));
> }
> }
>
> @@ -151,7 +151,7 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
> int ret;
> int i;
>
> - nchips = DIV_ROUND_UP(nirqs, 32);
> + nchips = DIV_ROUND_UP(nirqs, AIC_IRQS_PER_CHIP);
>
> reg_base = of_iomap(node, 0);
> if (!reg_base)
> @@ -163,13 +163,14 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
> goto err_iounmap;
> }
>
> - domain = irq_domain_add_linear(node, nchips * 32, ops, aic);
> + domain = irq_domain_add_linear(node, nchips * AIC_IRQS_PER_CHIP, ops,
> + aic);
> if (!domain) {
> ret = -ENOMEM;
> goto err_free_aic;
> }
>
> - ret = irq_alloc_domain_generic_chips(domain, 32, 1, name,
> + ret = irq_alloc_domain_generic_chips(domain, AIC_IRQS_PER_CHIP, 1, name,
> handle_fasteoi_irq,
> IRQ_NOREQUEST | IRQ_NOPROBE |
> IRQ_NOAUTOEN, 0, 0);
> @@ -177,7 +178,7 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
> goto err_domain_remove;
>
> for (i = 0; i < nchips; i++) {
> - gc = irq_get_domain_generic_chip(domain, i * 32);
> + gc = irq_get_domain_generic_chip(domain, i * AIC_IRQS_PER_CHIP);
>
> gc->reg_base = reg_base;
>
> diff --git a/drivers/irqchip/irq-atmel-aic-common.h b/drivers/irqchip/irq-atmel-aic-common.h
> index c178557..4c0b471 100644
> --- a/drivers/irqchip/irq-atmel-aic-common.h
> +++ b/drivers/irqchip/irq-atmel-aic-common.h
> @@ -16,6 +16,7 @@
> #ifndef __IRQ_ATMEL_AIC_COMMON_H
> #define __IRQ_ATMEL_AIC_COMMON_H
>
> +#define AIC_IRQS_PER_CHIP 32
>
> int aic_common_set_type(struct irq_data *d, unsigned type, unsigned *val);
>
> diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
> index 6fcd680..c499949 100644
> --- a/drivers/irqchip/irq-atmel-aic.c
> +++ b/drivers/irqchip/irq-atmel-aic.c
> @@ -164,7 +164,7 @@ static void __init aic_hw_init(struct irq_domain *domain)
> irq_reg_writel(gc, 0xffffffff, AT91_AIC_IDCR);
> irq_reg_writel(gc, 0xffffffff, AT91_AIC_ICCR);
>
> - for (i = 0; i < 32; i++)
> + for (i = 0; i < NR_AIC_IRQS; i++)
> irq_reg_writel(gc, i, AT91_AIC_SVR(i));
> }
>
> diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
> index 8b8f5e2..f5848c8 100644
> --- a/drivers/irqchip/irq-atmel-aic5.c
> +++ b/drivers/irqchip/irq-atmel-aic5.c
> @@ -306,9 +306,9 @@ static int __init aic5_of_init(struct device_node *node,
> return PTR_ERR(domain);
>
> aic5_domain = domain;
> - nchips = aic5_domain->revmap_size / 32;
> + nchips = aic5_domain->revmap_size / AIC_IRQS_PER_CHIP;
> for (i = 0; i < nchips; i++) {
> - gc = irq_get_domain_generic_chip(domain, i * 32);
> + gc = irq_get_domain_generic_chip(domain, i * AIC_IRQS_PER_CHIP);
>
> gc->chip_types[0].regs.eoi = AT91_AIC5_EOICR;
> gc->chip_types[0].chip.irq_mask = aic5_mask;
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
[PATCH 07/19] irqchip: atmel-aic: make common IRQ domain translate function Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
[PATCH 09/19] irqchip: atmel-aic: add common retrigger function Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
[PATCH 13/19] irqchip: atmel-aic: clean up irq_chip_generic Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
[PATCH 01/19] irqchip: atmel-aic: fix wrong bit operation for IRQ priority Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
Re: [PATCH 01/19] irqchip: atmel-aic: fix wrong bit operation for IRQ priority Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-04 09:20 +0100
[PATCH 17/19] irqchip: atmel-aic: use unified IRQ chip initialization function Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
[PATCH 06/19] irqchip: atmel-aic: introduce register data structure Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
Re: [PATCH 06/19] irqchip: atmel-aic: introduce register data structure Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-04 10:00 +0100
Re: [PATCH 06/19] irqchip: atmel-aic: introduce register data structure Milo Kim <milo.kim@ti.com> - 2016-01-06 09:40 +0100
[PATCH 04/19] irqchip: atmel-aic: replace magic numbers with named constant Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
Re: [PATCH 04/19] irqchip: atmel-aic: replace magic numbers with named constant Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-04 09:30 +0100
[PATCH 19/19] irqchip: atmel-aic: rename AIC driver and fix Kconfig Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
[PATCH 11/19] irqchip: atmel-aic: add common PM IRQ chip operation Milo Kim <milo.kim@ti.com> - 2016-01-04 05:30 +0100
[PATCH 12/19] irqchip: atmel-aic: use EOI register data in aic_reg_data Milo Kim <milo.kim@ti.com> - 2016-01-04 05:40 +0100
[PATCH 14/19] irqchip: atmel-aic: add common HW init function Milo Kim <milo.kim@ti.com> - 2016-01-04 05:40 +0100
[PATCH 10/19] irqchip: atmel-aic: add common set_type function Milo Kim <milo.kim@ti.com> - 2016-01-04 05:40 +0100
[PATCH 08/19] irqchip: atmel-aic: add common mask and unmask functions Milo Kim <milo.kim@ti.com> - 2016-01-04 05:40 +0100
Re: [PATCH 08/19] irqchip: atmel-aic: add common mask and unmask functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-04 09:50 +0100
[PATCH 02/19] irqchip: atmel-aic: clean up RTC interrupt code Milo Kim <milo.kim@ti.com> - 2016-01-04 05:40 +0100
Re: [PATCH 02/19] irqchip: atmel-aic: clean up RTC interrupt code Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-04 09:20 +0100
[PATCH 05/19] irqchip: atmel-aic: use simple constant to get number of interrupts per chip Milo Kim <milo.kim@ti.com> - 2016-01-04 05:40 +0100
Re: [PATCH 05/19] irqchip: atmel-aic: use simple constant to get number of interrupts per chip Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-04 09:40 +0100
[PATCH 03/19] irqchip: atmel-aic: clean up RTT interrupt code Milo Kim <milo.kim@ti.com> - 2016-01-04 05:40 +0100
Re: [PATCH 03/19] irqchip: atmel-aic: clean up RTT interrupt code Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-04 09:20 +0100
[PATCH 15/19] irqchip: atmel-aic: add common interrupt handler Milo Kim <milo.kim@ti.com> - 2016-01-04 05:40 +0100
Re: [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-04 10:10 +0100
Re: [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Nicolas Ferre <nicolas.ferre@atmel.com> - 2016-01-04 10:40 +0100
Re: [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Milo Kim <milo.kim@ti.com> - 2016-01-06 09:00 +0100
Re: [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Milo Kim <milo.kim@ti.com> - 2016-01-06 08:50 +0100
Re: [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-01-06 10:10 +0100
Re: [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Jason Cooper <jason@lakedaemon.net> - 2016-01-06 15:50 +0100
Re: [PATCH 00/19] irqchip: atmel-aic: make unified AIC driver Milo Kim <milo.kim@ti.com> - 2016-01-07 08:50 +0100
csiph-web