diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-02-14 08:06:43 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-22 22:53:21 -0500 |
commit | 9bf46f6df5d1e9db8b4b786d22e88d8b6edd949e (patch) | |
tree | a8c87a069b1cd79c713eeb1e3637c6ab62456aed /drivers/spi | |
parent | 38dbfb59d1175ef458d006556061adeaa8751b72 (diff) |
spi: xilinx: Convert to let spi core validate bits_per_word
Set bits_per_word_mask so spi core will reject transfers that attempt to use
an unsupported bits_per_word value.
spi_bitbang requires custom setup_transfer() to be defined if there is a
custom txrx_bufs(). Thus keep the empty xilinx_spi_setup_transfer() function
in the code.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-xilinx.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 6d4ce4615163..4eb1ed9ab6da 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c | |||
@@ -209,26 +209,11 @@ static void xilinx_spi_chipselect(struct spi_device *spi, int is_on) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | /* spi_bitbang requires custom setup_transfer() to be defined if there is a | 211 | /* spi_bitbang requires custom setup_transfer() to be defined if there is a |
212 | * custom txrx_bufs(). We have nothing to setup here as the SPI IP block | 212 | * custom txrx_bufs(). |
213 | * supports 8 or 16 bits per word which cannot be changed in software. | ||
214 | * SPI clock can't be changed in software either. | ||
215 | * Check for correct bits per word. Chip select delay calculations could be | ||
216 | * added here as soon as bitbang_work() can be made aware of the delay value. | ||
217 | */ | 213 | */ |
218 | static int xilinx_spi_setup_transfer(struct spi_device *spi, | 214 | static int xilinx_spi_setup_transfer(struct spi_device *spi, |
219 | struct spi_transfer *t) | 215 | struct spi_transfer *t) |
220 | { | 216 | { |
221 | struct xilinx_spi *xspi = spi_master_get_devdata(spi->master); | ||
222 | u8 bits_per_word; | ||
223 | |||
224 | bits_per_word = (t && t->bits_per_word) | ||
225 | ? t->bits_per_word : spi->bits_per_word; | ||
226 | if (bits_per_word != xspi->bits_per_word) { | ||
227 | dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", | ||
228 | __func__, bits_per_word); | ||
229 | return -EINVAL; | ||
230 | } | ||
231 | |||
232 | return 0; | 217 | return 0; |
233 | } | 218 | } |
234 | 219 | ||
@@ -407,6 +392,7 @@ static int xilinx_spi_probe(struct platform_device *pdev) | |||
407 | xspi->write_fn = xspi_write32_be; | 392 | xspi->write_fn = xspi_write32_be; |
408 | } | 393 | } |
409 | 394 | ||
395 | master->bits_per_word_mask = SPI_BPW_MASK(bits_per_word); | ||
410 | xspi->bits_per_word = bits_per_word; | 396 | xspi->bits_per_word = bits_per_word; |
411 | if (xspi->bits_per_word == 8) { | 397 | if (xspi->bits_per_word == 8) { |
412 | xspi->tx_fn = xspi_tx8; | 398 | xspi->tx_fn = xspi_tx8; |