Commit af1cf971 authored by Michael Welling's avatar Michael Welling Committed by Jiri Slaby

gpio: mcp23s08: Bug fix of SPI device tree registration.

commit 99e4b98d upstream.

The chips variable needs to be incremented for each chip that is
found in the spi_present_mask when registering via device tree.
Without this and the checking a negative index is passed to the
data->chip array in a subsequent loop.
Signed-off-by: default avatarMichael Welling <mwelling@ieee.org>
Acked-by: default avatarPeter Korsgaard <peter@korsgaard.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent ca55f49d
...@@ -657,8 +657,11 @@ static int mcp23s08_probe(struct spi_device *spi) ...@@ -657,8 +657,11 @@ static int mcp23s08_probe(struct spi_device *spi)
return -ENODEV; return -ENODEV;
} }
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
pullups[addr] = 0; pullups[addr] = 0;
if (spi_present_mask & (1 << addr))
chips++;
}
} 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);
...@@ -681,12 +684,12 @@ static int mcp23s08_probe(struct spi_device *spi) ...@@ -681,12 +684,12 @@ static int mcp23s08_probe(struct spi_device *spi)
pullups[addr] = pdata->chip[addr].pullups; pullups[addr] = pdata->chip[addr].pullups;
} }
if (!chips)
return -ENODEV;
base = pdata->base; base = pdata->base;
} }
if (!chips)
return -ENODEV;
data = kzalloc(sizeof *data + chips * sizeof(struct mcp23s08), data = kzalloc(sizeof *data + chips * sizeof(struct mcp23s08),
GFP_KERNEL); GFP_KERNEL);
if (!data) if (!data)
......
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