Commit b184c388 authored by Sonic Zhang's avatar Sonic Zhang Committed by Linus Walleij

gpio: mcp23s08: handle default gpio base

Create default gpio base if neither device node nor
platform data is defined.

Cc: Stable <stable@vger.kernel.org>
Signed-off-by: default avatarSonic Zhang <sonic.zhang@analog.com>
Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Tested-by: default avatarAntonio Fiol <antonio@fiol.es>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 3d009c8c
...@@ -801,9 +801,11 @@ static int mcp230xx_probe(struct i2c_client *client, ...@@ -801,9 +801,11 @@ static int mcp230xx_probe(struct i2c_client *client,
client->irq = irq_of_parse_and_map(client->dev.of_node, 0); client->irq = irq_of_parse_and_map(client->dev.of_node, 0);
} else { } else {
pdata = dev_get_platdata(&client->dev); pdata = dev_get_platdata(&client->dev);
if (!pdata || !gpio_is_valid(pdata->base)) { if (!pdata) {
dev_dbg(&client->dev, "invalid platform data\n"); pdata = devm_kzalloc(&client->dev,
return -EINVAL; sizeof(struct mcp23s08_platform_data),
GFP_KERNEL);
pdata->base = -1;
} }
} }
...@@ -924,10 +926,11 @@ static int mcp23s08_probe(struct spi_device *spi) ...@@ -924,10 +926,11 @@ static int mcp23s08_probe(struct spi_device *spi)
} else { } else {
type = spi_get_device_id(spi)->driver_data; type = spi_get_device_id(spi)->driver_data;
pdata = dev_get_platdata(&spi->dev); pdata = dev_get_platdata(&spi->dev);
if (!pdata || !gpio_is_valid(pdata->base)) { if (!pdata) {
dev_dbg(&spi->dev, pdata = devm_kzalloc(&spi->dev,
"invalid or missing platform data\n"); sizeof(struct mcp23s08_platform_data),
return -EINVAL; GFP_KERNEL);
pdata->base = -1;
} }
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) { for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment