]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
gpio/twl: Allocate irq_desc dynamically for SPARSE_IRQ support
authorBenoit Cousson <b-cousson@ti.com>
Wed, 29 Feb 2012 21:48:32 +0000 (22:48 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 22 Mar 2012 12:05:53 +0000 (13:05 +0100)
Do not use the board pdata for irq_base, but allocate them dynamically
to allow a proper support of SPARSE_IRQ.

Fix an unneeded line wrap.

Signed-off-by: Benoit Cousson <b-cousson@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/gpio/gpio-twl4030.c

index 697396c74627cac392f456902b734dae3c806bbc..49e5c6eb403ae59b2534c073be3b85c6fac67d7f 100644 (file)
@@ -395,23 +395,26 @@ static int gpio_twl4030_remove(struct platform_device *pdev);
 static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
 {
        struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data;
-       int ret;
+       int ret, irq_base;
 
        /* maybe setup IRQs */
-       if (pdata->irq_base) {
-               if (is_module()) {
-                       dev_err(&pdev->dev,
-                               "can't dispatch IRQs from modules\n");
-                       goto no_irqs;
-               }
-               ret = twl4030_sih_setup(&pdev->dev, TWL4030_MODULE_GPIO,
-                                       pdata->irq_base);
-               if (ret < 0)
-                       return ret;
-               WARN_ON(ret != pdata->irq_base);
-               twl4030_gpio_irq_base = ret;
+       if (is_module()) {
+               dev_err(&pdev->dev, "can't dispatch IRQs from modules\n");
+               goto no_irqs;
+       }
+
+       irq_base = irq_alloc_descs(-1, 0, TWL4030_GPIO_MAX, 0);
+       if (irq_base < 0) {
+               dev_err(&pdev->dev, "Failed to alloc irq_descs\n");
+               return irq_base;
        }
 
+       ret = twl4030_sih_setup(&pdev->dev, TWL4030_MODULE_GPIO, irq_base);
+       if (ret < 0)
+               return ret;
+
+       twl4030_gpio_irq_base = irq_base;
+
 no_irqs:
        /*
         * NOTE:  boards may waste power if they don't set pullups
@@ -443,9 +446,7 @@ no_irqs:
 
        ret = gpiochip_add(&twl_gpiochip);
        if (ret < 0) {
-               dev_err(&pdev->dev,
-                               "could not register gpiochip, %d\n",
-                               ret);
+               dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
                twl_gpiochip.ngpio = 0;
                gpio_twl4030_remove(pdev);
        } else if (pdata->setup) {