return 0;
}
-static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi)
+static int xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi)
{
u8 sr;
+ int n_words = 0;
/* Fill the Tx FIFO with as many bytes as possible */
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
xspi->write_fn(0, xspi->regs + XSPI_TXD_OFFSET);
xspi->remaining_bytes -= xspi->bits_per_word / 8;
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
+ n_words++;
}
+
+ return n_words;
}
static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
for (;;) {
u16 cr;
- u8 sr;
+ int n_words;
- xilinx_spi_fill_tx_fifo(xspi);
+ n_words = xilinx_spi_fill_tx_fifo(xspi);
/* Start the transfer by not inhibiting the transmitter any
* longer
xspi->regs + XSPI_CR_OFFSET);
/* Read out all the data from the Rx FIFO */
- sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
- while ((sr & XSPI_SR_RX_EMPTY_MASK) == 0) {
+ while (n_words--)
xspi->rx_fn(xspi);
- sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
- }
/* See if there is more data to send */
if (xspi->remaining_bytes <= 0)