diff options
author | Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> | 2015-01-28 07:23:49 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-01-28 14:42:43 -0500 |
commit | d79b2d073ae4eeb79ce1aa27c96fe9e3f7582e97 (patch) | |
tree | 092094893ad3a835448691dc5cb5288c9de51ee3 /drivers/spi/spi-xilinx.c | |
parent | c30929415a3d7f186da888d322f93150af308287 (diff) |
spi/xilinx: Convert remainding_bytes in remaining words
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/spi-xilinx.c')
-rw-r--r-- | drivers/spi/spi-xilinx.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 6ce1066be98b..8ed306e44df7 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c | |||
@@ -86,7 +86,7 @@ struct xilinx_spi { | |||
86 | 86 | ||
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_bytes; /* the number of bytes left to transfer */ | 89 | int remaining_words; /* the number of words left to transfer */ |
90 | u8 bits_per_word; | 90 | u8 bits_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*/ |
@@ -231,7 +231,7 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi, | |||
231 | 231 | ||
232 | static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi, int n_words) | 232 | static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi, int n_words) |
233 | { | 233 | { |
234 | xspi->remaining_bytes -= n_words * xspi->bits_per_word / 8; | 234 | xspi->remaining_words -= n_words; |
235 | 235 | ||
236 | while (n_words--) | 236 | while (n_words--) |
237 | xilinx_spi_tx(xspi); | 237 | xilinx_spi_tx(xspi); |
@@ -246,15 +246,14 @@ 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_bytes = t->len; | 249 | xspi->remaining_words = (t->len * 8) / xspi->bits_per_word; |
250 | reinit_completion(&xspi->done); | 250 | reinit_completion(&xspi->done); |
251 | 251 | ||
252 | while (xspi->remaining_bytes) { | 252 | while (xspi->remaining_words) { |
253 | u16 cr = 0; | 253 | u16 cr = 0; |
254 | int n_words; | 254 | int n_words; |
255 | 255 | ||
256 | n_words = (xspi->remaining_bytes * 8) / xspi->bits_per_word; | 256 | n_words = min(xspi->remaining_words, xspi->buffer_size); |
257 | n_words = min(n_words, xspi->buffer_size); | ||
258 | 257 | ||
259 | xilinx_spi_fill_tx_fifo(xspi, n_words); | 258 | xilinx_spi_fill_tx_fifo(xspi, n_words); |
260 | 259 | ||
@@ -286,7 +285,7 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) | |||
286 | xilinx_spi_rx(xspi); | 285 | xilinx_spi_rx(xspi); |
287 | } | 286 | } |
288 | 287 | ||
289 | return t->len - xspi->remaining_bytes; | 288 | return t->len; |
290 | } | 289 | } |
291 | 290 | ||
292 | 291 | ||