aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-02-15 01:26:21 -0500
committerMark Brown <broonie@linaro.org>2014-03-02 22:58:29 -0500
commit790fc55a77bc041d613da087b3e03bdc59edcfa5 (patch)
tree718f90dc64fcd40f98694fab74cc8b2edde41606
parent354312f16e49add1da78f0cfb2bcb633709d0071 (diff)
spi: omap-uwire: Convert to use bits_per_word_mask
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-omap-uwire.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/drivers/spi/spi-omap-uwire.c b/drivers/spi/spi-omap-uwire.c
index 462ddd458217..95cc6948a2ba 100644
--- a/drivers/spi/spi-omap-uwire.c
+++ b/drivers/spi/spi-omap-uwire.c
@@ -99,7 +99,6 @@ struct uwire_spi {
99}; 99};
100 100
101struct uwire_state { 101struct uwire_state {
102 unsigned bits_per_word;
103 unsigned div1_idx; 102 unsigned div1_idx;
104}; 103};
105 104
@@ -210,9 +209,8 @@ static void uwire_chipselect(struct spi_device *spi, int value)
210 209
211static int uwire_txrx(struct spi_device *spi, struct spi_transfer *t) 210static int uwire_txrx(struct spi_device *spi, struct spi_transfer *t)
212{ 211{
213 struct uwire_state *ust = spi->controller_state;
214 unsigned len = t->len; 212 unsigned len = t->len;
215 unsigned bits = ust->bits_per_word; 213 unsigned bits = t->bits_per_word ? : spi->bits_per_word;
216 unsigned bytes; 214 unsigned bytes;
217 u16 val, w; 215 u16 val, w;
218 int status = 0; 216 int status = 0;
@@ -322,7 +320,6 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
322 struct uwire_state *ust = spi->controller_state; 320 struct uwire_state *ust = spi->controller_state;
323 struct uwire_spi *uwire; 321 struct uwire_spi *uwire;
324 unsigned flags = 0; 322 unsigned flags = 0;
325 unsigned bits;
326 unsigned hz; 323 unsigned hz;
327 unsigned long rate; 324 unsigned long rate;
328 int div1_idx; 325 int div1_idx;
@@ -332,17 +329,6 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
332 329
333 uwire = spi_master_get_devdata(spi->master); 330 uwire = spi_master_get_devdata(spi->master);
334 331
335 bits = spi->bits_per_word;
336 if (t != NULL && t->bits_per_word)
337 bits = t->bits_per_word;
338
339 if (bits > 16) {
340 pr_debug("%s: wordsize %d?\n", dev_name(&spi->dev), bits);
341 status = -ENODEV;
342 goto done;
343 }
344 ust->bits_per_word = bits;
345
346 /* mode 0..3, clock inverted separately; 332 /* mode 0..3, clock inverted separately;
347 * standard nCS signaling; 333 * standard nCS signaling;
348 * don't treat DI=high as "not ready" 334 * don't treat DI=high as "not ready"
@@ -509,7 +495,7 @@ static int uwire_probe(struct platform_device *pdev)
509 495
510 /* the spi->mode bits understood by this driver: */ 496 /* the spi->mode bits understood by this driver: */
511 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 497 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
512 498 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 16);
513 master->flags = SPI_MASTER_HALF_DUPLEX; 499 master->flags = SPI_MASTER_HALF_DUPLEX;
514 500
515 master->bus_num = 2; /* "official" */ 501 master->bus_num = 2; /* "official" */