Commit 766ed70447e0a9cfb23d068a4a929e18e54b0022
Committed by
Grant Likely
1 parent
bb29785e0d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 11 changed files with 16 additions and 25 deletions Side-by-side Diff
drivers/spi/spi-altera.c
... | ... | @@ -134,7 +134,7 @@ |
134 | 134 | hw->tx = t->tx_buf; |
135 | 135 | hw->rx = t->rx_buf; |
136 | 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 | 138 | hw->len = t->len / hw->bytes_per_word; |
139 | 139 | |
140 | 140 | if (hw->irq >= 0) { |
drivers/spi/spi-bfin-sport.c
... | ... | @@ -416,8 +416,7 @@ |
416 | 416 | drv_data->cs_change = transfer->cs_change; |
417 | 417 | |
418 | 418 | /* Bits per word setup */ |
419 | - bits_per_word = transfer->bits_per_word ? : | |
420 | - message->spi->bits_per_word ? : 8; | |
419 | + bits_per_word = transfer->bits_per_word; | |
421 | 420 | if (bits_per_word % 16 == 0) |
422 | 421 | drv_data->ops = &bfin_sport_transfer_ops_u16; |
423 | 422 | else |
drivers/spi/spi-bfin5xx.c
... | ... | @@ -642,8 +642,7 @@ |
642 | 642 | drv_data->cs_change = transfer->cs_change; |
643 | 643 | |
644 | 644 | /* Bits per word setup */ |
645 | - bits_per_word = transfer->bits_per_word ? : | |
646 | - message->spi->bits_per_word ? : 8; | |
645 | + bits_per_word = transfer->bits_per_word; | |
647 | 646 | if (bits_per_word % 16 == 0) { |
648 | 647 | drv_data->n_bytes = bits_per_word/8; |
649 | 648 | drv_data->len = (transfer->len) >> 1; |
drivers/spi/spi-bitbang.c
... | ... | @@ -69,7 +69,7 @@ |
69 | 69 | unsigned ns, |
70 | 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 | 73 | unsigned count = t->len; |
74 | 74 | const u8 *tx = t->tx_buf; |
75 | 75 | u8 *rx = t->rx_buf; |
... | ... | @@ -95,7 +95,7 @@ |
95 | 95 | unsigned ns, |
96 | 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 | 99 | unsigned count = t->len; |
100 | 100 | const u16 *tx = t->tx_buf; |
101 | 101 | u16 *rx = t->rx_buf; |
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | unsigned ns, |
122 | 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 | 125 | unsigned count = t->len; |
126 | 126 | const u32 *tx = t->tx_buf; |
127 | 127 | u32 *rx = t->rx_buf; |
drivers/spi/spi-clps711x.c
... | ... | @@ -68,7 +68,7 @@ |
68 | 68 | struct spi_transfer *xfer) |
69 | 69 | { |
70 | 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 | 72 | struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); |
73 | 73 | |
74 | 74 | if (bpw != 8) { |
drivers/spi/spi-coldfire-qspi.c
... | ... | @@ -329,8 +329,7 @@ |
329 | 329 | mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high); |
330 | 330 | |
331 | 331 | mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE); |
332 | - if ((t->bits_per_word ? t->bits_per_word : | |
333 | - spi->bits_per_word) == 8) | |
332 | + if (t->bits_per_word == 8) | |
334 | 333 | mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf, |
335 | 334 | t->rx_buf); |
336 | 335 | else |
drivers/spi/spi-ep93xx.c
... | ... | @@ -446,7 +446,7 @@ |
446 | 446 | struct spi_message *msg = espi->current_msg; |
447 | 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 | 452 | static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t) |
drivers/spi/spi-s3c64xx.c
... | ... | @@ -697,7 +697,7 @@ |
697 | 697 | INIT_COMPLETION(sdd->xfer_completion); |
698 | 698 | |
699 | 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 | 701 | speed = xfer->speed_hz ? : spi->max_speed_hz; |
702 | 702 | |
703 | 703 | if (xfer->len % (bpw / 8)) { |
drivers/spi/spi-sirf.c
... | ... | @@ -382,8 +382,7 @@ |
382 | 382 | |
383 | 383 | sspi = spi_master_get_devdata(spi->master); |
384 | 384 | |
385 | - bits_per_word = t && t->bits_per_word ? t->bits_per_word : | |
386 | - spi->bits_per_word; | |
385 | + bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word; | |
387 | 386 | hz = t && t->speed_hz ? t->speed_hz : spi->max_speed_hz; |
388 | 387 | |
389 | 388 | /* Enable IO mode for RX, TX */ |
drivers/spi/spi-tegra20-slink.c
... | ... | @@ -284,8 +284,7 @@ |
284 | 284 | unsigned max_len; |
285 | 285 | unsigned total_fifo_words; |
286 | 286 | |
287 | - bits_per_word = t->bits_per_word ? t->bits_per_word : | |
288 | - spi->bits_per_word; | |
287 | + bits_per_word = t->bits_per_word; | |
289 | 288 | tspi->bytes_per_word = (bits_per_word - 1) / 8 + 1; |
290 | 289 | |
291 | 290 | if (bits_per_word == 8 || bits_per_word == 16) { |
... | ... | @@ -378,8 +377,7 @@ |
378 | 377 | } else { |
379 | 378 | unsigned int bits_per_word; |
380 | 379 | |
381 | - bits_per_word = t->bits_per_word ? t->bits_per_word : | |
382 | - tspi->cur_spi->bits_per_word; | |
380 | + bits_per_word = t->bits_per_word; | |
383 | 381 | for (count = 0; count < rx_full_count; count++) { |
384 | 382 | x = tegra_slink_readl(tspi, SLINK_RX_FIFO); |
385 | 383 | for (i = 0; (i < tspi->bytes_per_word); i++) |
... | ... | @@ -444,8 +442,7 @@ |
444 | 442 | unsigned int x; |
445 | 443 | unsigned int rx_mask, bits_per_word; |
446 | 444 | |
447 | - bits_per_word = t->bits_per_word ? t->bits_per_word : | |
448 | - tspi->cur_spi->bits_per_word; | |
445 | + bits_per_word = t->bits_per_word; | |
449 | 446 | rx_mask = (1 << bits_per_word) - 1; |
450 | 447 | for (count = 0; count < tspi->curr_dma_words; count++) { |
451 | 448 | x = tspi->rx_dma_buf[count]; |
drivers/spi/spi-txx9.c
... | ... | @@ -189,9 +189,8 @@ |
189 | 189 | unsigned int len = t->len; |
190 | 190 | unsigned int wsize; |
191 | 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 | 194 | wsize = bits_per_word >> 3; /* in bytes */ |
196 | 195 | |
197 | 196 | if (prev_speed_hz != speed_hz |
198 | 197 | |
... | ... | @@ -316,9 +315,8 @@ |
316 | 315 | /* check each transfer's parameters */ |
317 | 316 | list_for_each_entry (t, &m->transfers, transfer_list) { |
318 | 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 | 320 | if (!t->tx_buf && !t->rx_buf && t->len) |
323 | 321 | return -EINVAL; |
324 | 322 | if (bits_per_word != 8 && bits_per_word != 16) |