spi/xilinx: Simplify data read from the Rx FIFO
The number of words in the read buffer will be exactly the same as the number of words written on write buffer, once the transaction has finished. Instead of cheking the rx_empty flags for every word simply save the number of words written by fill_tx_fifo. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
0240f94516
Коммит
c5d348dffa
|
@ -221,9 +221,10 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
|
||||||
return 0;
|
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;
|
u8 sr;
|
||||||
|
int n_words = 0;
|
||||||
|
|
||||||
/* Fill the Tx FIFO with as many bytes as possible */
|
/* Fill the Tx FIFO with as many bytes as possible */
|
||||||
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
|
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
|
||||||
|
@ -234,7 +235,10 @@ static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi)
|
||||||
xspi->write_fn(0, xspi->regs + XSPI_TXD_OFFSET);
|
xspi->write_fn(0, xspi->regs + XSPI_TXD_OFFSET);
|
||||||
xspi->remaining_bytes -= xspi->bits_per_word / 8;
|
xspi->remaining_bytes -= xspi->bits_per_word / 8;
|
||||||
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
|
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)
|
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)
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
u16 cr;
|
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
|
/* Start the transfer by not inhibiting the transmitter any
|
||||||
* longer
|
* longer
|
||||||
|
@ -282,11 +286,8 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
|
||||||
xspi->regs + XSPI_CR_OFFSET);
|
xspi->regs + XSPI_CR_OFFSET);
|
||||||
|
|
||||||
/* Read out all the data from the Rx FIFO */
|
/* Read out all the data from the Rx FIFO */
|
||||||
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
|
while (n_words--)
|
||||||
while ((sr & XSPI_SR_RX_EMPTY_MASK) == 0) {
|
|
||||||
xspi->rx_fn(xspi);
|
xspi->rx_fn(xspi);
|
||||||
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See if there is more data to send */
|
/* See if there is more data to send */
|
||||||
if (xspi->remaining_bytes <= 0)
|
if (xspi->remaining_bytes <= 0)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче