diff options
author | Roland Stigge <stigge@antcom.de> | 2012-09-03 04:14:29 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-05 19:44:10 -0400 |
commit | b4b8482690d97ea5421acf71e9e397fe0c5a25b8 (patch) | |
tree | 79ea09077400fbe684e9ca99f516837595af80f9 /drivers/spi | |
parent | 38e271cde5ae62b0b94ff8e8e7e1e1395da7dbf5 (diff) |
spi/pl022: Fix chipselects pointer computation
The new chip select handling via GPIO introduced a pointer computation bug:
(int *) pl022 + sizeof(struct pl022)
doesn't point to the data immediately after the actual struct pl022 (as was
intended) but to a multiple of bytes after it because of the (int *) type.
Replacing the kludgy pointer arithmetic with managed memory allocation for the
chip selects.
Reported-by: Shiraz Hashim <shiraz.linux.kernel@gmail.com>
Signed-off-by: Roland Stigge <stigge@antcom.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-pl022.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 959f2acff2d3..827ad5152d8b 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c | |||
@@ -2053,8 +2053,7 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2053 | } | 2053 | } |
2054 | 2054 | ||
2055 | /* Allocate master with space for data */ | 2055 | /* Allocate master with space for data */ |
2056 | master = spi_alloc_master(dev, sizeof(struct pl022) + sizeof(int) * | 2056 | master = spi_alloc_master(dev, sizeof(struct pl022)); |
2057 | num_cs); | ||
2058 | if (master == NULL) { | 2057 | if (master == NULL) { |
2059 | dev_err(&adev->dev, "probe - cannot alloc SPI master\n"); | 2058 | dev_err(&adev->dev, "probe - cannot alloc SPI master\n"); |
2060 | status = -ENOMEM; | 2059 | status = -ENOMEM; |
@@ -2066,8 +2065,8 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2066 | pl022->master_info = platform_info; | 2065 | pl022->master_info = platform_info; |
2067 | pl022->adev = adev; | 2066 | pl022->adev = adev; |
2068 | pl022->vendor = id->data; | 2067 | pl022->vendor = id->data; |
2069 | /* Point chipselects to allocated memory beyond the main struct */ | 2068 | pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int), |
2070 | pl022->chipselects = (int *) pl022 + sizeof(struct pl022); | 2069 | GFP_KERNEL); |
2071 | 2070 | ||
2072 | /* | 2071 | /* |
2073 | * Bus Number Which has been Assigned to this SSP controller | 2072 | * Bus Number Which has been Assigned to this SSP controller |