diff options
author | Brian Niebuhr <bniebuhr@efjohnson.com> | 2010-08-19 07:12:42 -0400 |
---|---|---|
committer | Sekhar Nori <nsekhar@ti.com> | 2010-11-18 08:08:28 -0500 |
commit | b7ab24a0da96c8fc6d551ea87e82692299df6ac6 (patch) | |
tree | 4bd08aeeb692fa29873f21803eb4c480dba5c730 /drivers | |
parent | 6321be60edac6037ea76e9beef375c6ae2961765 (diff) |
spi: davinci: simplify calculation of edma acount value
The EDMA acount (called data_type in davinci_spi_bufs_dma())
is simply the bytes_per_word obtained in the transfer setup
function. The current code calculates the acount value from
bytes_per_word in a convoluted manner. Simplify the code.
Signed-off-by: Brian Niebuhr <bniebuhr@efjohnson.com>
Tested-By: Michael Williamson <michael.williamson@criticallink.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/davinci_spi.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index f1c3502c2d01..b0b338fc4466 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c | |||
@@ -39,9 +39,6 @@ | |||
39 | #define CS_DEFAULT 0xFF | 39 | #define CS_DEFAULT 0xFF |
40 | 40 | ||
41 | #define SPI_BUFSIZ (SMP_CACHE_BYTES + 1) | 41 | #define SPI_BUFSIZ (SMP_CACHE_BYTES + 1) |
42 | #define DAVINCI_DMA_DATA_TYPE_S8 0x01 | ||
43 | #define DAVINCI_DMA_DATA_TYPE_S16 0x02 | ||
44 | #define DAVINCI_DMA_DATA_TYPE_S32 0x04 | ||
45 | 42 | ||
46 | #define SPIFMT_PHASE_MASK BIT(16) | 43 | #define SPIFMT_PHASE_MASK BIT(16) |
47 | #define SPIFMT_POLARITY_MASK BIT(17) | 44 | #define SPIFMT_POLARITY_MASK BIT(17) |
@@ -729,19 +726,14 @@ static int davinci_spi_bufs_pio(struct spi_device *spi, struct spi_transfer *t) | |||
729 | return t->len; | 726 | return t->len; |
730 | } | 727 | } |
731 | 728 | ||
732 | #define DAVINCI_DMA_DATA_TYPE_S8 0x01 | ||
733 | #define DAVINCI_DMA_DATA_TYPE_S16 0x02 | ||
734 | #define DAVINCI_DMA_DATA_TYPE_S32 0x04 | ||
735 | |||
736 | static int davinci_spi_bufs_dma(struct spi_device *spi, struct spi_transfer *t) | 729 | static int davinci_spi_bufs_dma(struct spi_device *spi, struct spi_transfer *t) |
737 | { | 730 | { |
738 | struct davinci_spi *davinci_spi; | 731 | struct davinci_spi *davinci_spi; |
739 | int int_status = 0; | 732 | int int_status = 0; |
740 | int count, temp_count; | 733 | int count, temp_count; |
741 | u8 conv = 1; | ||
742 | u32 data1_reg_val; | 734 | u32 data1_reg_val; |
743 | struct davinci_spi_dma *davinci_spi_dma; | 735 | struct davinci_spi_dma *davinci_spi_dma; |
744 | int word_len, data_type, ret; | 736 | int data_type, ret; |
745 | unsigned long tx_reg, rx_reg; | 737 | unsigned long tx_reg, rx_reg; |
746 | struct device *sdev; | 738 | struct device *sdev; |
747 | 739 | ||
@@ -757,8 +749,8 @@ static int davinci_spi_bufs_dma(struct spi_device *spi, struct spi_transfer *t) | |||
757 | davinci_spi->rx = t->rx_buf; | 749 | davinci_spi->rx = t->rx_buf; |
758 | 750 | ||
759 | /* convert len to words based on bits_per_word */ | 751 | /* convert len to words based on bits_per_word */ |
760 | conv = davinci_spi->bytes_per_word[spi->chip_select]; | 752 | data_type = davinci_spi->bytes_per_word[spi->chip_select]; |
761 | davinci_spi->count = t->len / conv; | 753 | davinci_spi->count = t->len / data_type; |
762 | 754 | ||
763 | data1_reg_val = ioread32(davinci_spi->base + SPIDAT1); | 755 | data1_reg_val = ioread32(davinci_spi->base + SPIDAT1); |
764 | 756 | ||
@@ -767,17 +759,6 @@ static int davinci_spi_bufs_dma(struct spi_device *spi, struct spi_transfer *t) | |||
767 | init_completion(&davinci_spi_dma->dma_rx_completion); | 759 | init_completion(&davinci_spi_dma->dma_rx_completion); |
768 | init_completion(&davinci_spi_dma->dma_tx_completion); | 760 | init_completion(&davinci_spi_dma->dma_tx_completion); |
769 | 761 | ||
770 | word_len = conv * 8; | ||
771 | |||
772 | if (word_len <= 8) | ||
773 | data_type = DAVINCI_DMA_DATA_TYPE_S8; | ||
774 | else if (word_len <= 16) | ||
775 | data_type = DAVINCI_DMA_DATA_TYPE_S16; | ||
776 | else if (word_len <= 32) | ||
777 | data_type = DAVINCI_DMA_DATA_TYPE_S32; | ||
778 | else | ||
779 | return -EINVAL; | ||
780 | |||
781 | ret = davinci_spi_bufs_prep(spi, davinci_spi); | 762 | ret = davinci_spi_bufs_prep(spi, davinci_spi); |
782 | if (ret) | 763 | if (ret) |
783 | return ret; | 764 | return ret; |