diff mbox

gpiolib:change to use irq_alloc_descs_from to alloc virqs

Message ID 35FD53F367049845BC99AC72306C23D103D6DB4D6F2A@CNBJMBX05.corpusers.net
State Not Applicable, archived
Headers show

Commit Message

Wang, Yalin Sept. 23, 2014, 1:37 p.m. UTC

In fact, i don't encounter any problem about gpio code,
i just find this issue when i see the source code,
i feel it is not safe, so i make a patch for it.

yes, you are right,
"irq_base" is used only twice in gpiolib code,
but it maybe used by some other drivers,
if remove it, some drivers will can't get virq base.
it should get it by find_irq_mapping(), but it is also ok.

in fact , we can allow the virq are allocated one by one,
but this need change gpiochip_irqchip_remove( ) function,
it should not assume the virq are contentious,
i think both method are ok ,
it is just decided by how you want design it :) 

To summarize, we should make gpiochip_irqchip_add() and 
gpiochip_irqchip_remove() both work correctly.
diff mbox


diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 15cc0bb..81762ed 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -524,7 +524,7 @@  static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
        /* Remove all IRQ mappings and delete the domain */
        if (gpiochip->irqdomain) {
                for (offset = 0; offset < gpiochip->ngpio; offset++)
-                       irq_dispose_mapping(gpiochip->irq_base + offset);
+                       irq_dispose_mapping(irq_find_mapping(gpiochip->irqdomain, offset));