All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpiolib:change to use irq_alloc_descs_from to alloc virqs
@ 2014-09-09  7:12 Wang, Yalin
  2014-09-23 10:17 ` Linus Walleij
  2014-09-23 10:21 ` Linus Walleij
  0 siblings, 2 replies; 14+ messages in thread
From: Wang, Yalin @ 2014-09-09  7:12 UTC (permalink / raw)
  To: 'linus.walleij@linaro.org', 'gnurou@gmail.com',
	'linux-gpio@vger.kernel.org',
	'akpm@linux-foundation.org'

this patch change use from irq_create_mapping to irq_alloc_descs_from,
use irq_create_mapping to alloc virq one by one is not safe,
it can't promise the allcated virqs are continuous,
in stead, we use irq_alloc_descs_from() to alloc virqs in one time,
so that the allocated virqs are in continuous bitmaps.

Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
 drivers/gpio/gpiolib.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 15cc0bb..2b6c441 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -566,7 +566,6 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
 			 unsigned int type)
 {
 	struct device_node *of_node;
-	unsigned int offset;
 	unsigned irq_base = 0;
 
 	if (!gpiochip || !irqchip)
@@ -604,14 +603,13 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
 	 * any gpiochip calls. If the first_irq was zero, this is
 	 * necessary to allocate descriptors for all IRQs.
 	 */
-	for (offset = 0; offset < gpiochip->ngpio; offset++) {
-		irq_base = irq_create_mapping(gpiochip->irqdomain, offset);
-		if (offset == 0)
-			/*
-			 * Store the base into the gpiochip to be used when
-			 * unmapping the irqs.
-			 */
-			gpiochip->irq_base = irq_base;
+	if (first_irq > 0) {
+		gpiochip->irq_base = first_irq;
+	} else {
+		gpiochip->irq_base = irq_alloc_descs_from(1, gpiochip->ngpio,
+				of_node_to_nid(of_node));
+		irq_domain_associate_many(gpiochip->irqdomain,
+				gpiochip->irq_base, 0, gpiochip->ngpio);
 	}
 
 	acpi_gpiochip_request_interrupts(gpiochip);
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-09-25 13:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09  7:12 [PATCH] gpiolib:change to use irq_alloc_descs_from to alloc virqs Wang, Yalin
2014-09-23 10:17 ` Linus Walleij
2014-09-23 10:21 ` Linus Walleij
2014-09-23 12:03   ` Wang, Yalin
2014-09-23 12:59     ` Grygorii Strashko
2014-09-23 13:37       ` Wang, Yalin
2014-09-23 13:39         ` Wang, Yalin
2014-09-23 14:15           ` Wang, Yalin
2014-09-23 14:51             ` Wang, Yalin
2014-09-23 15:03             ` Grygorii Strashko
2014-09-24  1:59               ` Wang, Yalin
2014-09-25  7:39       ` Linus Walleij
2014-09-25  7:47         ` Wang, Yalin
2014-09-25 13:18           ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.