Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: gpio-max710x: Support device tree probing

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>

authored by

Roland Stigge and committed by
Linus Walleij
8754fccb 9859eb99

+6 -6
+6 -6
drivers/gpio/gpio-max730x.c
··· 167 167 int i, ret; 168 168 169 169 pdata = dev->platform_data; 170 - if (!pdata || !pdata->base) { 171 - dev_err(dev, "incorrect or missing platform data\n"); 172 - return -EINVAL; 173 - } 174 170 175 171 mutex_init(&ts->lock); 176 172 dev_set_drvdata(dev, ts); ··· 174 178 /* Power up the chip and disable IRQ output */ 175 179 ts->write(dev, 0x04, 0x01); 176 180 177 - ts->input_pullup_active = pdata->input_pullup_active; 181 + if (pdata) { 182 + ts->input_pullup_active = pdata->input_pullup_active; 183 + ts->chip.base = pdata->base; 184 + } else { 185 + ts->chip.base = -1; 186 + } 178 187 ts->chip.label = dev->driver->name; 179 188 180 189 ts->chip.direction_input = max7301_direction_input; ··· 187 186 ts->chip.direction_output = max7301_direction_output; 188 187 ts->chip.set = max7301_set; 189 188 190 - ts->chip.base = pdata->base; 191 189 ts->chip.ngpio = PIN_NUMBER; 192 190 ts->chip.can_sleep = 1; 193 191 ts->chip.dev = dev;