mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
gpio: mcp23s08: Bug fix of SPI device tree registration.
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. Cc: [email protected] Signed-off-by: Michael Welling <[email protected]> Acked-by: Peter Korsgaard <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
This commit is contained in:
parent
a7008ee1a4
commit
99e4b98dbe
1 changed files with 7 additions and 5 deletions
|
|
@ -894,9 +894,11 @@ static int mcp23s08_probe(struct spi_device *spi)
|
|||
dev_err(&spi->dev, "invalid spi-present-mask\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++)
|
||||
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
|
||||
if ((spi_present_mask & (1 << addr)))
|
||||
chips++;
|
||||
pullups[addr] = 0;
|
||||
}
|
||||
} else {
|
||||
type = spi_get_device_id(spi)->driver_data;
|
||||
pdata = dev_get_platdata(&spi->dev);
|
||||
|
|
@ -919,12 +921,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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue