[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1367843533-7117-1-git-send-email-sebastian.hesselbarth@gmail.com>
Date: Mon, 6 May 2013 14:32:12 +0200
From: Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Russell King - ARM Linux <linux@....linux.org.uk>,
Grant Likely <grant.likely@...aro.org>,
Rob Herring <rob.herring@...xeda.com>,
Rob Landley <rob@...dley.net>, Arnd Bergmann <arnd@...db.de>,
Jason Cooper <jason@...edaemon.net>,
Andrew Lunn <andrew@...n.ch>,
Jason Gunthorpe <jgunthorpe@...idianresearch.com>,
Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
Gregory Clement <gregory.clement@...e-electrons.com>,
Ezequiel Garcia <ezequiel.garcia@...e-electrons.com>,
Maxime Ripard <maxime.ripard@...e-electrons.com>,
Jean-Francois Moine <moinejf@...e.fr>,
Gerlando Falauto <gerlando.falauto@...mile.com>,
Uwe Kleine-Koenig <u.kleine-koenig@...gutronix.de>,
devicetree-discuss@...ts.ozlabs.org, linux-doc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [RFC patch 7/8] fixup 1/2: genirq: generic chip: Add linear irq domain support
irq_domain_chip_generic is allocating and indexing irq_chip_generic
itself. However, the size of irq_chip_generic varies with number of
irq_chip_types. This fixup moves irq_chip_generic helt by
irq_domain_chip_generic to array of ptr and fixes the pointer arith
used by irq_alloc_domain_generic_chip.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>
---
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Russell King - ARM Linux <linux@....linux.org.uk>
Cc: Grant Likely <grant.likely@...aro.org>
Cc: Rob Herring <rob.herring@...xeda.com>
Cc: Rob Landley <rob@...dley.net>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Jason Cooper <jason@...edaemon.net>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: Jason Gunthorpe <jgunthorpe@...idianresearch.com>
Cc: Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
Cc: Gregory Clement <gregory.clement@...e-electrons.com>
Cc: Ezequiel Garcia <ezequiel.garcia@...e-electrons.com>
Cc: Maxime Ripard <maxime.ripard@...e-electrons.com>
Cc: Jean-Francois Moine <moinejf@...e.fr>
Cc: Gerlando Falauto <gerlando.falauto@...mile.com>
Cc: Uwe Kleine-Koenig <u.kleine-koenig@...gutronix.de>
Cc: devicetree-discuss@...ts.ozlabs.org
Cc: linux-doc@...r.kernel.org
Cc: linux-arm-kernel@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org
---
include/linux/irq.h | 4 ++--
kernel/irq/generic-chip.c | 20 +++++++++++++-------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 7315155..fd2d7cb 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -730,7 +730,7 @@ enum irq_gc_flags {
* @irq_flags_to_set: IRQ* flags to set on irq setup
* @irq_flags_to_clear: IRQ* flags to clear on irq setup
* @gc_flags: Generic chip specific setup flags
- * @gc: Array of generic interrupt chips
+ * @gc: Array of pointer to generic interrupt chips
*/
struct irq_domain_chip_generic {
unsigned int irqs_per_chip;
@@ -738,7 +738,7 @@ struct irq_domain_chip_generic {
unsigned int irq_flags_to_clear;
unsigned int irq_flags_to_set;
enum irq_gc_flags gc_flags;
- struct irq_chip_generic gc[0];
+ struct irq_chip_generic *gc[0];
};
/* Generic chip callback functions */
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index e212b26..3dbfe2e 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -247,6 +247,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
struct irq_chip_generic *gc;
int numchips, sz, i;
unsigned long flags;
+ void *p;
if (d->gc)
return -EBUSY;
@@ -260,9 +261,9 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
sz = sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
sz *= numchips;
- sz += sizeof(*dgc);
+ sz += sizeof(*dgc) + numchips * sizeof(void *);
- dgc = kzalloc(sz, GFP_KERNEL);
+ p = dgc = kzalloc(sz, GFP_KERNEL);
if (!dgc)
return -ENOMEM;
dgc->irqs_per_chip = irqs_per_chip;
@@ -270,17 +271,22 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
dgc->irq_flags_to_set = set;
dgc->irq_flags_to_clear = clr;
dgc->gc_flags = gcflags;
- gc = dgc->gc;
+ d->gc = dgc;
- for (i = 0; i < numchips; i++, gc++) {
+ p += sizeof(*dgc) + numchips * sizeof(void *);
+ for (i = 0; i < numchips; i++) {
+ gc = (struct irq_chip_generic *)p;
+ dgc->gc[i] = gc;
irq_init_generic_chip(gc, name, num_ct, i * irqs_per_chip,
NULL, handler);
gc->domain = d;
+
raw_spin_lock_irqsave(&gc_lock, flags);
list_add_tail(&gc->list, &gc_list);
raw_spin_unlock_irqrestore(&gc_lock, flags);
+
+ p += sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
}
- d->gc = dgc;
return 0;
}
EXPORT_SYMBOL_GPL(irq_alloc_domain_generic_chips);
@@ -301,7 +307,7 @@ irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq)
idx = hw_irq / dgc->irqs_per_chip;
if (idx >= dgc->num_chips)
return NULL;
- return &dgc->gc[idx];
+ return dgc->gc[idx];
}
EXPORT_SYMBOL_GPL(irq_get_domain_generic_chip);
@@ -331,7 +337,7 @@ static int irq_map_generic_chip(struct irq_domain *d, unsigned int virq,
idx = hw_irq / dgc->irqs_per_chip;
if (idx >= dgc->num_chips)
return -EINVAL;
- gc = &dgc->gc[idx];
+ gc = dgc->gc[idx];
idx = hw_irq % dgc->irqs_per_chip;
--
1.7.2.5
--
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