diff options
-rw-r--r-- | drivers/spi/spi-xilinx.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index e1d9a2003ae6..416b227eb302 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c | |||
@@ -221,9 +221,10 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi, | |||
221 | return 0; | 221 | return 0; |
222 | } | 222 | } |
223 | 223 | ||
224 | static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi) | 224 | static int xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi) |
225 | { | 225 | { |
226 | u8 sr; | 226 | u8 sr; |
227 | int n_words = 0; | ||
227 | 228 | ||
228 | /* Fill the Tx FIFO with as many bytes as possible */ | 229 | /* Fill the Tx FIFO with as many bytes as possible */ |
229 | sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET); | 230 | sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET); |
@@ -234,7 +235,10 @@ static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi) | |||
234 | xspi->write_fn(0, xspi->regs + XSPI_TXD_OFFSET); | 235 | xspi->write_fn(0, xspi->regs + XSPI_TXD_OFFSET); |
235 | xspi->remaining_bytes -= xspi->bits_per_word / 8; | 236 | xspi->remaining_bytes -= xspi->bits_per_word / 8; |
236 | sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET); | 237 | sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET); |
238 | n_words++; | ||
237 | } | 239 | } |
240 | |||
241 | return n_words; | ||
238 | } | 242 | } |
239 | 243 | ||
240 | static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) | 244 | static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) |
@@ -259,9 +263,9 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) | |||
259 | 263 | ||
260 | for (;;) { | 264 | for (;;) { |
261 | u16 cr; | 265 | u16 cr; |
262 | u8 sr; | 266 | int n_words; |
263 | 267 | ||
264 | xilinx_spi_fill_tx_fifo(xspi); | 268 | n_words = xilinx_spi_fill_tx_fifo(xspi); |
265 | 269 | ||
266 | /* Start the transfer by not inhibiting the transmitter any | 270 | /* Start the transfer by not inhibiting the transmitter any |
267 | * longer | 271 | * longer |
@@ -282,11 +286,8 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) | |||
282 | xspi->regs + XSPI_CR_OFFSET); | 286 | xspi->regs + XSPI_CR_OFFSET); |
283 | 287 | ||
284 | /* Read out all the data from the Rx FIFO */ | 288 | /* Read out all the data from the Rx FIFO */ |
285 | sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET); | 289 | while (n_words--) |
286 | while ((sr & XSPI_SR_RX_EMPTY_MASK) == 0) { | ||
287 | xspi->rx_fn(xspi); | 290 | xspi->rx_fn(xspi); |
288 | sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET); | ||
289 | } | ||
290 | 291 | ||
291 | /* See if there is more data to send */ | 292 | /* See if there is more data to send */ |
292 | if (xspi->remaining_bytes <= 0) | 293 | if (xspi->remaining_bytes <= 0) |