Skip to content

Commit

Permalink
gpio: mcp23s08: Bug fix of SPI device tree registration.
Browse files Browse the repository at this point in the history
commit 99e4b98 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: Michael Welling <mwelling@ieee.org>
Acked-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Michael Welling authored and Greg Kroah-Hartman committed Jun 11, 2014
1 parent 3af2e71 commit f10acdb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/gpio/gpio-mcp23s08.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,11 @@ static int mcp23s08_probe(struct spi_device *spi)
return -ENODEV;
}

for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++)
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
pullups[addr] = 0;
if (spi_present_mask & (1 << addr))
chips++;
}
} else {
type = spi_get_device_id(spi)->driver_data;
pdata = dev_get_platdata(&spi->dev);
Expand All @@ -919,12 +922,12 @@ static int mcp23s08_probe(struct spi_device *spi)
pullups[addr] = pdata->chip[addr].pullups;
}

if (!chips)
return -ENODEV;

base = pdata->base;
}

if (!chips)
return -ENODEV;

data = kzalloc(sizeof *data + chips * sizeof(struct mcp23s08),
GFP_KERNEL);
if (!data)
Expand Down

0 comments on commit f10acdb

Please sign in to comment.