diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-01-15 04:07:43 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-03 07:25:12 -0500 |
commit | 8c328a262f513c042f97fcd2f2797a6d69fc0773 (patch) | |
tree | 6fd771c37a0eebda91e07c5df46b27b909bc1b95 | |
parent | 38dbfb59d1175ef458d006556061adeaa8751b72 (diff) |
spi: sirf: Avoid duplicate code in various bits_per_word cases
Trivial cleanup to avoid duplicate code in various bits_per_word cases.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/spi/spi-sirf.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index e430689c3837..632d2b5b821f 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c | |||
@@ -459,11 +459,6 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
459 | regval |= SIRFSOC_SPI_TRAN_DAT_FORMAT_8; | 459 | regval |= SIRFSOC_SPI_TRAN_DAT_FORMAT_8; |
460 | sspi->rx_word = spi_sirfsoc_rx_word_u8; | 460 | sspi->rx_word = spi_sirfsoc_rx_word_u8; |
461 | sspi->tx_word = spi_sirfsoc_tx_word_u8; | 461 | sspi->tx_word = spi_sirfsoc_tx_word_u8; |
462 | txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | | ||
463 | SIRFSOC_SPI_FIFO_WIDTH_BYTE; | ||
464 | rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | | ||
465 | SIRFSOC_SPI_FIFO_WIDTH_BYTE; | ||
466 | sspi->word_width = 1; | ||
467 | break; | 462 | break; |
468 | case 12: | 463 | case 12: |
469 | case 16: | 464 | case 16: |
@@ -471,26 +466,22 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
471 | SIRFSOC_SPI_TRAN_DAT_FORMAT_16; | 466 | SIRFSOC_SPI_TRAN_DAT_FORMAT_16; |
472 | sspi->rx_word = spi_sirfsoc_rx_word_u16; | 467 | sspi->rx_word = spi_sirfsoc_rx_word_u16; |
473 | sspi->tx_word = spi_sirfsoc_tx_word_u16; | 468 | sspi->tx_word = spi_sirfsoc_tx_word_u16; |
474 | txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | | ||
475 | SIRFSOC_SPI_FIFO_WIDTH_WORD; | ||
476 | rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | | ||
477 | SIRFSOC_SPI_FIFO_WIDTH_WORD; | ||
478 | sspi->word_width = 2; | ||
479 | break; | 469 | break; |
480 | case 32: | 470 | case 32: |
481 | regval |= SIRFSOC_SPI_TRAN_DAT_FORMAT_32; | 471 | regval |= SIRFSOC_SPI_TRAN_DAT_FORMAT_32; |
482 | sspi->rx_word = spi_sirfsoc_rx_word_u32; | 472 | sspi->rx_word = spi_sirfsoc_rx_word_u32; |
483 | sspi->tx_word = spi_sirfsoc_tx_word_u32; | 473 | sspi->tx_word = spi_sirfsoc_tx_word_u32; |
484 | txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | | ||
485 | SIRFSOC_SPI_FIFO_WIDTH_DWORD; | ||
486 | rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | | ||
487 | SIRFSOC_SPI_FIFO_WIDTH_DWORD; | ||
488 | sspi->word_width = 4; | ||
489 | break; | 474 | break; |
490 | default: | 475 | default: |
491 | BUG(); | 476 | BUG(); |
492 | } | 477 | } |
493 | 478 | ||
479 | sspi->word_width = DIV_ROUND_UP(bits_per_word, 8); | ||
480 | txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | | ||
481 | sspi->word_width; | ||
482 | rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | | ||
483 | sspi->word_width; | ||
484 | |||
494 | if (!(spi->mode & SPI_CS_HIGH)) | 485 | if (!(spi->mode & SPI_CS_HIGH)) |
495 | regval |= SIRFSOC_SPI_CS_IDLE_STAT; | 486 | regval |= SIRFSOC_SPI_CS_IDLE_STAT; |
496 | if (!(spi->mode & SPI_LSB_FIRST)) | 487 | if (!(spi->mode & SPI_LSB_FIRST)) |