diff options
author | Murali Karicheri <m-karicheri2@ti.com> | 2014-07-31 13:33:14 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-07-31 15:35:32 -0400 |
commit | 7480e755c6e6e890200e8998597e8d0baa51fa8e (patch) | |
tree | a8f0da48dffdc24fe0958843848621457d415bfe /drivers/spi/spi-davinci.c | |
parent | 7171511eaec5bf23fb06078f59784a3a0626b38f (diff) |
spi: davinci: fix to support more than 2 chip selects
Currently, the driver defines SPI_MAX_CHIPSELECT as 2 and
use per device array bytes_per_word based on this. This breaks
if num_chipselect per device is greater than 2. This patch
fix this and allocate memory for this array based on
num_chipselect.
It's preparation patch to enable GPIO CS feature for
Davinci SPI.
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-davinci.c')
-rw-r--r-- | drivers/spi/spi-davinci.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 50f750989258..2477af4bc1c7 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c | |||
@@ -38,8 +38,6 @@ | |||
38 | 38 | ||
39 | #define SPI_NO_RESOURCE ((resource_size_t)-1) | 39 | #define SPI_NO_RESOURCE ((resource_size_t)-1) |
40 | 40 | ||
41 | #define SPI_MAX_CHIPSELECT 2 | ||
42 | |||
43 | #define CS_DEFAULT 0xFF | 41 | #define CS_DEFAULT 0xFF |
44 | 42 | ||
45 | #define SPIFMT_PHASE_MASK BIT(16) | 43 | #define SPIFMT_PHASE_MASK BIT(16) |
@@ -142,7 +140,7 @@ struct davinci_spi { | |||
142 | void (*get_rx)(u32 rx_data, struct davinci_spi *); | 140 | void (*get_rx)(u32 rx_data, struct davinci_spi *); |
143 | u32 (*get_tx)(struct davinci_spi *); | 141 | u32 (*get_tx)(struct davinci_spi *); |
144 | 142 | ||
145 | u8 bytes_per_word[SPI_MAX_CHIPSELECT]; | 143 | u8 *bytes_per_word; |
146 | }; | 144 | }; |
147 | 145 | ||
148 | static struct davinci_spi_config davinci_spi_default_cfg; | 146 | static struct davinci_spi_config davinci_spi_default_cfg; |
@@ -876,6 +874,14 @@ static int davinci_spi_probe(struct platform_device *pdev) | |||
876 | /* pdata in dspi is now updated and point pdata to that */ | 874 | /* pdata in dspi is now updated and point pdata to that */ |
877 | pdata = &dspi->pdata; | 875 | pdata = &dspi->pdata; |
878 | 876 | ||
877 | dspi->bytes_per_word = devm_kzalloc(&pdev->dev, | ||
878 | sizeof(*dspi->bytes_per_word) * | ||
879 | pdata->num_chipselect, GFP_KERNEL); | ||
880 | if (dspi->bytes_per_word == NULL) { | ||
881 | ret = -ENOMEM; | ||
882 | goto free_master; | ||
883 | } | ||
884 | |||
879 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 885 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
880 | if (r == NULL) { | 886 | if (r == NULL) { |
881 | ret = -ENOENT; | 887 | ret = -ENOENT; |