gpio: gpio-max710x: Support device tree probing
authorRoland Stigge <stigge@antcom.de>
Thu, 15 Nov 2012 13:59:40 +0000 (14:59 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 17 Nov 2012 20:21:08 +0000 (21:21 +0100)
For probing via device tree, we need to support the case without platform_data.
In this case, chip.base is set to -1 for automatic numbering.

Signed-off-by: Roland Stigge <stigge@antcom.de>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-max730x.c

index 05e2dac60b3b83e2974b718c6a72db3aa90efc3b..c4bf86abd4d80738727c085d273f891f8c5c38e5 100644 (file)
@@ -167,10 +167,6 @@ int __devinit __max730x_probe(struct max7301 *ts)
        int i, ret;
 
        pdata = dev->platform_data;
-       if (!pdata || !pdata->base) {
-               dev_err(dev, "incorrect or missing platform data\n");
-               return -EINVAL;
-       }
 
        mutex_init(&ts->lock);
        dev_set_drvdata(dev, ts);
@@ -178,7 +174,12 @@ int __devinit __max730x_probe(struct max7301 *ts)
        /* Power up the chip and disable IRQ output */
        ts->write(dev, 0x04, 0x01);
 
-       ts->input_pullup_active = pdata->input_pullup_active;
+       if (pdata) {
+               ts->input_pullup_active = pdata->input_pullup_active;
+               ts->chip.base = pdata->base;
+       } else {
+               ts->chip.base = -1;
+       }
        ts->chip.label = dev->driver->name;
 
        ts->chip.direction_input = max7301_direction_input;
@@ -186,7 +187,6 @@ int __devinit __max730x_probe(struct max7301 *ts)
        ts->chip.direction_output = max7301_direction_output;
        ts->chip.set = max7301_set;
 
-       ts->chip.base = pdata->base;
        ts->chip.ngpio = PIN_NUMBER;
        ts->chip.can_sleep = 1;
        ts->chip.dev = dev;