gpiolib: Make WM831x GPIO count dynamic
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 1 Oct 2009 14:41:05 +0000 (15:41 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 13 Dec 2009 18:20:43 +0000 (19:20 +0100)
This supports future devices with fewer GPIOs.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/gpio/wm831x-gpio.c
drivers/mfd/wm831x-core.c
include/linux/mfd/wm831x/core.h

index f9c09a54ec7fb66047bed59fcb4fc5548cee9b2c..f5e4934f1da1698b7aaaac7fb42ab69e25791cdc 100644 (file)
@@ -23,8 +23,6 @@
 #include <linux/mfd/wm831x/pdata.h>
 #include <linux/mfd/wm831x/gpio.h>
 
-#define WM831X_GPIO_MAX 16
-
 struct wm831x_gpio {
        struct wm831x *wm831x;
        struct gpio_chip gpio_chip;
@@ -192,7 +190,7 @@ static int __devinit wm831x_gpio_probe(struct platform_device *pdev)
 
        wm831x_gpio->wm831x = wm831x;
        wm831x_gpio->gpio_chip = template_chip;
-       wm831x_gpio->gpio_chip.ngpio = WM831X_GPIO_MAX;
+       wm831x_gpio->gpio_chip.ngpio = wm831x->num_gpio;
        wm831x_gpio->gpio_chip.dev = &pdev->dev;
        if (pdata && pdata->gpio_base)
                wm831x_gpio->gpio_chip.base = pdata->gpio_base;
index 8504c6ef4a168121be6ba0f823ba988beda33405..8d386c0c8027fa528b881be9cdc7e5351bee40d0 100644 (file)
@@ -1293,16 +1293,19 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
        switch (ret) {
        case WM8310:
                parent = WM8310;
+               wm831x->num_gpio = 16;
                dev_info(wm831x->dev, "WM8310 revision %c\n", 'A' + rev);
                break;
 
        case WM8311:
                parent = WM8311;
+               wm831x->num_gpio = 16;
                dev_info(wm831x->dev, "WM8311 revision %c\n", 'A' + rev);
                break;
 
        case WM8312:
                parent = WM8312;
+               wm831x->num_gpio = 16;
                dev_info(wm831x->dev, "WM8312 revision %c\n", 'A' + rev);
                break;
 
index 91eb493bf14cffc5a8095c729c9c274afb9fea3c..c1bc59f6cbf2505ed2b5843661b4eccbe1df51fa 100644 (file)
@@ -253,6 +253,8 @@ struct wm831x {
        unsigned int irq_base;
        int irq_masks[5];
 
+       int num_gpio;
+
        struct mutex auxadc_lock;
 
        /* The WM831x has a security key blocking access to certain