diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-02-11 07:51:36 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-11 12:06:48 -0500 |
commit | 495b335885f822444b66be3b81edcd4835f379c5 (patch) | |
tree | 8a980f8ddfc02f838c1d049645e8966ec2cf95a1 | |
parent | b52a37f517d62c92d7d5bffb0fab0b025a51b9eb (diff) |
spi: orion: Convert to let spi core validate xfer->bits_per_word
Set bits_per_word_mask so spi core will reject transfers that attempt to use
an unsupported bits_per_word value.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/spi/spi-orion.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index 20f174ee06ec..caaa53fc68cc 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c | |||
@@ -73,23 +73,6 @@ orion_spi_clrbits(struct orion_spi *orion_spi, u32 reg, u32 mask) | |||
73 | writel(val, reg_addr); | 73 | writel(val, reg_addr); |
74 | } | 74 | } |
75 | 75 | ||
76 | static int orion_spi_set_transfer_size(struct orion_spi *orion_spi, int size) | ||
77 | { | ||
78 | if (size == 16) { | ||
79 | orion_spi_setbits(orion_spi, ORION_SPI_IF_CONFIG_REG, | ||
80 | ORION_SPI_IF_8_16_BIT_MODE); | ||
81 | } else if (size == 8) { | ||
82 | orion_spi_clrbits(orion_spi, ORION_SPI_IF_CONFIG_REG, | ||
83 | ORION_SPI_IF_8_16_BIT_MODE); | ||
84 | } else { | ||
85 | pr_debug("Bad bits per word value %d (only 8 or 16 are allowed).\n", | ||
86 | size); | ||
87 | return -EINVAL; | ||
88 | } | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed) | 76 | static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed) |
94 | { | 77 | { |
95 | u32 tclk_hz; | 78 | u32 tclk_hz; |
@@ -168,7 +151,14 @@ orion_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
168 | if (rc) | 151 | if (rc) |
169 | return rc; | 152 | return rc; |
170 | 153 | ||
171 | return orion_spi_set_transfer_size(orion_spi, bits_per_word); | 154 | if (bits_per_word == 16) |
155 | orion_spi_setbits(orion_spi, ORION_SPI_IF_CONFIG_REG, | ||
156 | ORION_SPI_IF_8_16_BIT_MODE); | ||
157 | else | ||
158 | orion_spi_clrbits(orion_spi, ORION_SPI_IF_CONFIG_REG, | ||
159 | ORION_SPI_IF_8_16_BIT_MODE); | ||
160 | |||
161 | return 0; | ||
172 | } | 162 | } |
173 | 163 | ||
174 | static void orion_spi_set_cs(struct orion_spi *orion_spi, int enable) | 164 | static void orion_spi_set_cs(struct orion_spi *orion_spi, int enable) |
@@ -391,6 +381,7 @@ static int orion_spi_probe(struct platform_device *pdev) | |||
391 | 381 | ||
392 | master->transfer_one_message = orion_spi_transfer_one_message; | 382 | master->transfer_one_message = orion_spi_transfer_one_message; |
393 | master->num_chipselect = ORION_NUM_CHIPSELECTS; | 383 | master->num_chipselect = ORION_NUM_CHIPSELECTS; |
384 | master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); | ||
394 | 385 | ||
395 | platform_set_drvdata(pdev, master); | 386 | platform_set_drvdata(pdev, master); |
396 | 387 | ||