aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2015-01-28 07:23:50 -0500
committerMark Brown <broonie@kernel.org>2015-01-28 14:42:43 -0500
commit17aaaa80327107843f8ea6d2629ab5f733fc01aa (patch)
treed589e3bfc876315f75156948d3b14c59335a30c2 /drivers/spi
parentd79b2d073ae4eeb79ce1aa27c96fe9e3f7582e97 (diff)
spi/xilinx: Convert bits_per_word in bytes_per_word
Simplify the code by using the unit used on most of the code logic. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-xilinx.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 8ed306e44df7..b16fccfe69bf 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -87,7 +87,7 @@ struct xilinx_spi {
87 u8 *rx_ptr; /* pointer in the Tx buffer */ 87 u8 *rx_ptr; /* pointer in the Tx buffer */
88 const u8 *tx_ptr; /* pointer in the Rx buffer */ 88 const u8 *tx_ptr; /* pointer in the Rx buffer */
89 int remaining_words; /* the number of words left to transfer */ 89 int remaining_words; /* the number of words left to transfer */
90 u8 bits_per_word; 90 u8 bytes_per_word;
91 int buffer_size; /* buffer size in words */ 91 int buffer_size; /* buffer size in words */
92 u32 cs_inactive; /* Level of the CS pins when inactive*/ 92 u32 cs_inactive; /* Level of the CS pins when inactive*/
93 unsigned int (*read_fn)(void __iomem *); 93 unsigned int (*read_fn)(void __iomem *);
@@ -121,7 +121,7 @@ static void xilinx_spi_tx(struct xilinx_spi *xspi)
121 return; 121 return;
122 } 122 }
123 xspi->write_fn(*(u32 *)(xspi->tx_ptr), xspi->regs + XSPI_TXD_OFFSET); 123 xspi->write_fn(*(u32 *)(xspi->tx_ptr), xspi->regs + XSPI_TXD_OFFSET);
124 xspi->tx_ptr += xspi->bits_per_word / 8; 124 xspi->tx_ptr += xspi->bytes_per_word;
125} 125}
126 126
127static void xilinx_spi_rx(struct xilinx_spi *xspi) 127static void xilinx_spi_rx(struct xilinx_spi *xspi)
@@ -131,19 +131,19 @@ static void xilinx_spi_rx(struct xilinx_spi *xspi)
131 if (!xspi->rx_ptr) 131 if (!xspi->rx_ptr)
132 return; 132 return;
133 133
134 switch (xspi->bits_per_word) { 134 switch (xspi->bytes_per_word) {
135 case 8: 135 case 1:
136 *(u8 *)(xspi->rx_ptr) = data; 136 *(u8 *)(xspi->rx_ptr) = data;
137 break; 137 break;
138 case 16: 138 case 2:
139 *(u16 *)(xspi->rx_ptr) = data; 139 *(u16 *)(xspi->rx_ptr) = data;
140 break; 140 break;
141 case 32: 141 case 4:
142 *(u32 *)(xspi->rx_ptr) = data; 142 *(u32 *)(xspi->rx_ptr) = data;
143 break; 143 break;
144 } 144 }
145 145
146 xspi->rx_ptr += xspi->bits_per_word / 8; 146 xspi->rx_ptr += xspi->bytes_per_word;
147} 147}
148 148
149static void xspi_init_hw(struct xilinx_spi *xspi) 149static void xspi_init_hw(struct xilinx_spi *xspi)
@@ -246,7 +246,7 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
246 246
247 xspi->tx_ptr = t->tx_buf; 247 xspi->tx_ptr = t->tx_buf;
248 xspi->rx_ptr = t->rx_buf; 248 xspi->rx_ptr = t->rx_buf;
249 xspi->remaining_words = (t->len * 8) / xspi->bits_per_word; 249 xspi->remaining_words = t->len / xspi->bytes_per_word;
250 reinit_completion(&xspi->done); 250 reinit_completion(&xspi->done);
251 251
252 while (xspi->remaining_words) { 252 while (xspi->remaining_words) {
@@ -410,7 +410,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
410 } 410 }
411 411
412 master->bits_per_word_mask = SPI_BPW_MASK(bits_per_word); 412 master->bits_per_word_mask = SPI_BPW_MASK(bits_per_word);
413 xspi->bits_per_word = bits_per_word; 413 xspi->bytes_per_word = bits_per_word / 8;
414 xspi->buffer_size = xilinx_spi_find_buffer_size(xspi); 414 xspi->buffer_size = xilinx_spi_find_buffer_size(xspi);
415 415
416 xspi->irq = platform_get_irq(pdev, 0); 416 xspi->irq = platform_get_irq(pdev, 0);