diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-12-18 03:55:43 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2013-02-05 07:26:59 -0500 |
commit | 766ed70447e0a9cfb23d068a4a929e18e54b0022 (patch) | |
tree | 95e426348573fd136fa4c7aeeeffb84143661e7a /drivers | |
parent | bb29785e0d6d150181704be2efcc3141044625e2 (diff) |
spi: remove check for bits_per_word on transfer from low level driver
The spi core make sure that each transfer structure have the proper
setting for bits_per_word before calling low level transfer APIs.
Hence it is no more require to check again in low level driver for
this field whether this is set correct or not. Removing such code
from low level driver.
The txx9 change also removes a test for bits_per_word set to 0, and
forcing it to 8 in that case. This can also be removed now since
spi_setup() ensures spi->bits_per_word is not zero.
if (!spi->bits_per_word)
spi->bits_per_word = 8;
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/spi-altera.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi-bfin-sport.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-bfin5xx.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-bitbang.c | 6 | ||||
-rw-r--r-- | drivers/spi/spi-clps711x.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi-coldfire-qspi.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-ep93xx.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi-s3c64xx.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi-sirf.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-tegra20-slink.c | 9 | ||||
-rw-r--r-- | drivers/spi/spi-txx9.c | 6 |
11 files changed, 16 insertions, 25 deletions
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c index 5e7314ac51e9..a537f8dffc09 100644 --- a/drivers/spi/spi-altera.c +++ b/drivers/spi/spi-altera.c | |||
@@ -134,7 +134,7 @@ static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t) | |||
134 | hw->tx = t->tx_buf; | 134 | hw->tx = t->tx_buf; |
135 | hw->rx = t->rx_buf; | 135 | hw->rx = t->rx_buf; |
136 | hw->count = 0; | 136 | hw->count = 0; |
137 | hw->bytes_per_word = (t->bits_per_word ? : spi->bits_per_word) / 8; | 137 | hw->bytes_per_word = t->bits_per_word / 8; |
138 | hw->len = t->len / hw->bytes_per_word; | 138 | hw->len = t->len / hw->bytes_per_word; |
139 | 139 | ||
140 | if (hw->irq >= 0) { | 140 | if (hw->irq >= 0) { |
diff --git a/drivers/spi/spi-bfin-sport.c b/drivers/spi/spi-bfin-sport.c index ac7ffca7ba47..39b0d1711b4e 100644 --- a/drivers/spi/spi-bfin-sport.c +++ b/drivers/spi/spi-bfin-sport.c | |||
@@ -416,8 +416,7 @@ bfin_sport_spi_pump_transfers(unsigned long data) | |||
416 | drv_data->cs_change = transfer->cs_change; | 416 | drv_data->cs_change = transfer->cs_change; |
417 | 417 | ||
418 | /* Bits per word setup */ | 418 | /* Bits per word setup */ |
419 | bits_per_word = transfer->bits_per_word ? : | 419 | bits_per_word = transfer->bits_per_word; |
420 | message->spi->bits_per_word ? : 8; | ||
421 | if (bits_per_word % 16 == 0) | 420 | if (bits_per_word % 16 == 0) |
422 | drv_data->ops = &bfin_sport_transfer_ops_u16; | 421 | drv_data->ops = &bfin_sport_transfer_ops_u16; |
423 | else | 422 | else |
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c index 0429d833f75b..7d7c9918fffe 100644 --- a/drivers/spi/spi-bfin5xx.c +++ b/drivers/spi/spi-bfin5xx.c | |||
@@ -642,8 +642,7 @@ static void bfin_spi_pump_transfers(unsigned long data) | |||
642 | drv_data->cs_change = transfer->cs_change; | 642 | drv_data->cs_change = transfer->cs_change; |
643 | 643 | ||
644 | /* Bits per word setup */ | 644 | /* Bits per word setup */ |
645 | bits_per_word = transfer->bits_per_word ? : | 645 | bits_per_word = transfer->bits_per_word; |
646 | message->spi->bits_per_word ? : 8; | ||
647 | if (bits_per_word % 16 == 0) { | 646 | if (bits_per_word % 16 == 0) { |
648 | drv_data->n_bytes = bits_per_word/8; | 647 | drv_data->n_bytes = bits_per_word/8; |
649 | drv_data->len = (transfer->len) >> 1; | 648 | drv_data->len = (transfer->len) >> 1; |
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c index 8b3d8efafd3c..61beaec7cbed 100644 --- a/drivers/spi/spi-bitbang.c +++ b/drivers/spi/spi-bitbang.c | |||
@@ -69,7 +69,7 @@ static unsigned bitbang_txrx_8( | |||
69 | unsigned ns, | 69 | unsigned ns, |
70 | struct spi_transfer *t | 70 | struct spi_transfer *t |
71 | ) { | 71 | ) { |
72 | unsigned bits = t->bits_per_word ? : spi->bits_per_word; | 72 | unsigned bits = t->bits_per_word; |
73 | unsigned count = t->len; | 73 | unsigned count = t->len; |
74 | const u8 *tx = t->tx_buf; | 74 | const u8 *tx = t->tx_buf; |
75 | u8 *rx = t->rx_buf; | 75 | u8 *rx = t->rx_buf; |
@@ -95,7 +95,7 @@ static unsigned bitbang_txrx_16( | |||
95 | unsigned ns, | 95 | unsigned ns, |
96 | struct spi_transfer *t | 96 | struct spi_transfer *t |
97 | ) { | 97 | ) { |
98 | unsigned bits = t->bits_per_word ? : spi->bits_per_word; | 98 | unsigned bits = t->bits_per_word; |
99 | unsigned count = t->len; | 99 | unsigned count = t->len; |
100 | const u16 *tx = t->tx_buf; | 100 | const u16 *tx = t->tx_buf; |
101 | u16 *rx = t->rx_buf; | 101 | u16 *rx = t->rx_buf; |
@@ -121,7 +121,7 @@ static unsigned bitbang_txrx_32( | |||
121 | unsigned ns, | 121 | unsigned ns, |
122 | struct spi_transfer *t | 122 | struct spi_transfer *t |
123 | ) { | 123 | ) { |
124 | unsigned bits = t->bits_per_word ? : spi->bits_per_word; | 124 | unsigned bits = t->bits_per_word; |
125 | unsigned count = t->len; | 125 | unsigned count = t->len; |
126 | const u32 *tx = t->tx_buf; | 126 | const u32 *tx = t->tx_buf; |
127 | u32 *rx = t->rx_buf; | 127 | u32 *rx = t->rx_buf; |
diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c index 1366c4620d5d..a11cbf02691a 100644 --- a/drivers/spi/spi-clps711x.c +++ b/drivers/spi/spi-clps711x.c | |||
@@ -68,7 +68,7 @@ static int spi_clps711x_setup_xfer(struct spi_device *spi, | |||
68 | struct spi_transfer *xfer) | 68 | struct spi_transfer *xfer) |
69 | { | 69 | { |
70 | u32 speed = xfer->speed_hz ? : spi->max_speed_hz; | 70 | u32 speed = xfer->speed_hz ? : spi->max_speed_hz; |
71 | u8 bpw = xfer->bits_per_word ? : spi->bits_per_word; | 71 | u8 bpw = xfer->bits_per_word; |
72 | struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); | 72 | struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); |
73 | 73 | ||
74 | if (bpw != 8) { | 74 | if (bpw != 8) { |
diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c index 58466b810da4..7b5cc9e4e94d 100644 --- a/drivers/spi/spi-coldfire-qspi.c +++ b/drivers/spi/spi-coldfire-qspi.c | |||
@@ -329,8 +329,7 @@ static int mcfqspi_transfer_one_message(struct spi_master *master, | |||
329 | mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high); | 329 | mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high); |
330 | 330 | ||
331 | mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE); | 331 | mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE); |
332 | if ((t->bits_per_word ? t->bits_per_word : | 332 | if (t->bits_per_word == 8) |
333 | spi->bits_per_word) == 8) | ||
334 | mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf, | 333 | mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf, |
335 | t->rx_buf); | 334 | t->rx_buf); |
336 | else | 335 | else |
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index acb1e1935c5a..aecbff16ad60 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c | |||
@@ -446,7 +446,7 @@ static inline int bits_per_word(const struct ep93xx_spi *espi) | |||
446 | struct spi_message *msg = espi->current_msg; | 446 | struct spi_message *msg = espi->current_msg; |
447 | struct spi_transfer *t = msg->state; | 447 | struct spi_transfer *t = msg->state; |
448 | 448 | ||
449 | return t->bits_per_word ? t->bits_per_word : msg->spi->bits_per_word; | 449 | return t->bits_per_word; |
450 | } | 450 | } |
451 | 451 | ||
452 | static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t) | 452 | static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t) |
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index ad93231a8038..d77b6560b67f 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c | |||
@@ -697,7 +697,7 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master, | |||
697 | INIT_COMPLETION(sdd->xfer_completion); | 697 | INIT_COMPLETION(sdd->xfer_completion); |
698 | 698 | ||
699 | /* Only BPW and Speed may change across transfers */ | 699 | /* Only BPW and Speed may change across transfers */ |
700 | bpw = xfer->bits_per_word ? : spi->bits_per_word; | 700 | bpw = xfer->bits_per_word; |
701 | speed = xfer->speed_hz ? : spi->max_speed_hz; | 701 | speed = xfer->speed_hz ? : spi->max_speed_hz; |
702 | 702 | ||
703 | if (xfer->len % (bpw / 8)) { | 703 | if (xfer->len % (bpw / 8)) { |
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index e0f43a512e84..750666751efd 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c | |||
@@ -382,8 +382,7 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
382 | 382 | ||
383 | sspi = spi_master_get_devdata(spi->master); | 383 | sspi = spi_master_get_devdata(spi->master); |
384 | 384 | ||
385 | bits_per_word = t && t->bits_per_word ? t->bits_per_word : | 385 | bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word; |
386 | spi->bits_per_word; | ||
387 | hz = t && t->speed_hz ? t->speed_hz : spi->max_speed_hz; | 386 | hz = t && t->speed_hz ? t->speed_hz : spi->max_speed_hz; |
388 | 387 | ||
389 | /* Enable IO mode for RX, TX */ | 388 | /* Enable IO mode for RX, TX */ |
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c index 651167f2e0af..7a95bddfb604 100644 --- a/drivers/spi/spi-tegra20-slink.c +++ b/drivers/spi/spi-tegra20-slink.c | |||
@@ -284,8 +284,7 @@ static unsigned tegra_slink_calculate_curr_xfer_param( | |||
284 | unsigned max_len; | 284 | unsigned max_len; |
285 | unsigned total_fifo_words; | 285 | unsigned total_fifo_words; |
286 | 286 | ||
287 | bits_per_word = t->bits_per_word ? t->bits_per_word : | 287 | bits_per_word = t->bits_per_word; |
288 | spi->bits_per_word; | ||
289 | tspi->bytes_per_word = (bits_per_word - 1) / 8 + 1; | 288 | tspi->bytes_per_word = (bits_per_word - 1) / 8 + 1; |
290 | 289 | ||
291 | if (bits_per_word == 8 || bits_per_word == 16) { | 290 | if (bits_per_word == 8 || bits_per_word == 16) { |
@@ -378,8 +377,7 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf( | |||
378 | } else { | 377 | } else { |
379 | unsigned int bits_per_word; | 378 | unsigned int bits_per_word; |
380 | 379 | ||
381 | bits_per_word = t->bits_per_word ? t->bits_per_word : | 380 | bits_per_word = t->bits_per_word; |
382 | tspi->cur_spi->bits_per_word; | ||
383 | for (count = 0; count < rx_full_count; count++) { | 381 | for (count = 0; count < rx_full_count; count++) { |
384 | x = tegra_slink_readl(tspi, SLINK_RX_FIFO); | 382 | x = tegra_slink_readl(tspi, SLINK_RX_FIFO); |
385 | for (i = 0; (i < tspi->bytes_per_word); i++) | 383 | for (i = 0; (i < tspi->bytes_per_word); i++) |
@@ -444,8 +442,7 @@ static void tegra_slink_copy_spi_rxbuf_to_client_rxbuf( | |||
444 | unsigned int x; | 442 | unsigned int x; |
445 | unsigned int rx_mask, bits_per_word; | 443 | unsigned int rx_mask, bits_per_word; |
446 | 444 | ||
447 | bits_per_word = t->bits_per_word ? t->bits_per_word : | 445 | bits_per_word = t->bits_per_word; |
448 | tspi->cur_spi->bits_per_word; | ||
449 | rx_mask = (1 << bits_per_word) - 1; | 446 | rx_mask = (1 << bits_per_word) - 1; |
450 | for (count = 0; count < tspi->curr_dma_words; count++) { | 447 | for (count = 0; count < tspi->curr_dma_words; count++) { |
451 | x = tspi->rx_dma_buf[count]; | 448 | x = tspi->rx_dma_buf[count]; |
diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c index d5a3cbb646cb..550b5f48fd8f 100644 --- a/drivers/spi/spi-txx9.c +++ b/drivers/spi/spi-txx9.c | |||
@@ -189,9 +189,8 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m) | |||
189 | unsigned int len = t->len; | 189 | unsigned int len = t->len; |
190 | unsigned int wsize; | 190 | unsigned int wsize; |
191 | u32 speed_hz = t->speed_hz ? : spi->max_speed_hz; | 191 | u32 speed_hz = t->speed_hz ? : spi->max_speed_hz; |
192 | u8 bits_per_word = t->bits_per_word ? : spi->bits_per_word; | 192 | u8 bits_per_word = t->bits_per_word; |
193 | 193 | ||
194 | bits_per_word = bits_per_word ? : 8; | ||
195 | wsize = bits_per_word >> 3; /* in bytes */ | 194 | wsize = bits_per_word >> 3; /* in bytes */ |
196 | 195 | ||
197 | if (prev_speed_hz != speed_hz | 196 | if (prev_speed_hz != speed_hz |
@@ -316,9 +315,8 @@ static int txx9spi_transfer(struct spi_device *spi, struct spi_message *m) | |||
316 | /* check each transfer's parameters */ | 315 | /* check each transfer's parameters */ |
317 | list_for_each_entry (t, &m->transfers, transfer_list) { | 316 | list_for_each_entry (t, &m->transfers, transfer_list) { |
318 | u32 speed_hz = t->speed_hz ? : spi->max_speed_hz; | 317 | u32 speed_hz = t->speed_hz ? : spi->max_speed_hz; |
319 | u8 bits_per_word = t->bits_per_word ? : spi->bits_per_word; | 318 | u8 bits_per_word = t->bits_per_word; |
320 | 319 | ||
321 | bits_per_word = bits_per_word ? : 8; | ||
322 | if (!t->tx_buf && !t->rx_buf && t->len) | 320 | if (!t->tx_buf && !t->rx_buf && t->len) |
323 | return -EINVAL; | 321 | return -EINVAL; |
324 | if (bits_per_word != 8 && bits_per_word != 16) | 322 | if (bits_per_word != 8 && bits_per_word != 16) |