aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@linux-m68k.org>2014-02-25 05:21:12 -0500
committerMark Brown <broonie@linaro.org>2014-02-27 05:44:03 -0500
commit2416289c714343ea855e725d59d42668a9ab3cf6 (patch)
tree9bc4cead95a07fdc2008d7e6d3b434adb3a46f61
parentc833ff7304511805ce5a3378d1637e39e00e00ea (diff)
spi: sh-msiof: Convert to let spi core validate xfer->bits_per_word
Set bits_per_word_mask so the spi core will reject transfers that attempt to use an unsupported bits_per_word value. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/spi/spi-sh-msiof.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index efeda03bbace..a0380b7c977f 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -439,22 +439,6 @@ static u32 sh_msiof_spi_hz(struct spi_device *spi, struct spi_transfer *t)
439 return hz; 439 return hz;
440} 440}
441 441
442static int sh_msiof_spi_setup_transfer(struct spi_device *spi,
443 struct spi_transfer *t)
444{
445 int bits;
446
447 /* noting to check hz values against since parent clock is disabled */
448
449 bits = sh_msiof_spi_bits(spi, t);
450 if (bits < 8)
451 return -EINVAL;
452 if (bits > 32)
453 return -EINVAL;
454
455 return spi_bitbang_setup_transfer(spi, t);
456}
457
458static int sh_msiof_spi_setup(struct spi_device *spi) 442static int sh_msiof_spi_setup(struct spi_device *spi)
459{ 443{
460 struct device_node *np = spi->master->dev.of_node; 444 struct device_node *np = spi->master->dev.of_node;
@@ -826,10 +810,11 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
826 master->cleanup = spi_bitbang_cleanup; 810 master->cleanup = spi_bitbang_cleanup;
827 master->prepare_message = sh_msiof_prepare_message; 811 master->prepare_message = sh_msiof_prepare_message;
828 master->unprepare_message = sh_msiof_unprepare_message; 812 master->unprepare_message = sh_msiof_unprepare_message;
813 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
829 814
830 p->bitbang.master = master; 815 p->bitbang.master = master;
831 p->bitbang.chipselect = sh_msiof_spi_chipselect; 816 p->bitbang.chipselect = sh_msiof_spi_chipselect;
832 p->bitbang.setup_transfer = sh_msiof_spi_setup_transfer; 817 p->bitbang.setup_transfer = spi_bitbang_setup_transfer;
833 p->bitbang.txrx_bufs = sh_msiof_spi_txrx; 818 p->bitbang.txrx_bufs = sh_msiof_spi_txrx;
834 p->bitbang.txrx_word[SPI_MODE_0] = sh_msiof_spi_txrx_word; 819 p->bitbang.txrx_word[SPI_MODE_0] = sh_msiof_spi_txrx_word;
835 p->bitbang.txrx_word[SPI_MODE_1] = sh_msiof_spi_txrx_word; 820 p->bitbang.txrx_word[SPI_MODE_1] = sh_msiof_spi_txrx_word;