mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 06:24:17 +00:00
DW SPI: refactor poll_transfer functions
There is no sense in waiting for RX data in dw_reader function: there is no chance that RX data will appear in RX FIFO if RX FIFO is empty after previous TX write in dw_writer function. So get rid of this waiting. After that we can get rid of dw_reader return value and make it returning void. After that we can get rid of dw_reader return value check in poll_transfer function. With these changes we're getting closer to Linux DW SPI driver. Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
This commit is contained in:
parent
fc282c7bcb
commit
d3d8aaec74
1 changed files with 4 additions and 22 deletions
|
@ -286,28 +286,16 @@ static void dw_writer(struct dw_spi_priv *priv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dw_reader(struct dw_spi_priv *priv)
|
static void dw_reader(struct dw_spi_priv *priv)
|
||||||
{
|
{
|
||||||
unsigned start = get_timer(0);
|
u32 max = rx_max(priv);
|
||||||
u32 max;
|
|
||||||
u16 rxw;
|
u16 rxw;
|
||||||
|
|
||||||
/* Wait for rx data to be ready */
|
|
||||||
while (rx_max(priv) == 0) {
|
|
||||||
if (get_timer(start) > RX_TIMEOUT)
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
max = rx_max(priv);
|
|
||||||
|
|
||||||
while (max--) {
|
while (max--) {
|
||||||
rxw = dw_readw(priv, DW_SPI_DR);
|
rxw = dw_readw(priv, DW_SPI_DR);
|
||||||
debug("%s: rx=0x%02x\n", __func__, rxw);
|
debug("%s: rx=0x%02x\n", __func__, rxw);
|
||||||
|
|
||||||
/*
|
/* Care about rx if the transfer's original "rx" is not null */
|
||||||
* Care about rx only if the transfer's original "rx" is
|
|
||||||
* not null
|
|
||||||
*/
|
|
||||||
if (priv->rx_end - priv->len) {
|
if (priv->rx_end - priv->len) {
|
||||||
if (priv->bits_per_word == 8)
|
if (priv->bits_per_word == 8)
|
||||||
*(u8 *)(priv->rx) = rxw;
|
*(u8 *)(priv->rx) = rxw;
|
||||||
|
@ -316,19 +304,13 @@ static int dw_reader(struct dw_spi_priv *priv)
|
||||||
}
|
}
|
||||||
priv->rx += priv->bits_per_word >> 3;
|
priv->rx += priv->bits_per_word >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int poll_transfer(struct dw_spi_priv *priv)
|
static int poll_transfer(struct dw_spi_priv *priv)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
dw_writer(priv);
|
dw_writer(priv);
|
||||||
ret = dw_reader(priv);
|
dw_reader(priv);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
} while (priv->rx_end > priv->rx);
|
} while (priv->rx_end > priv->rx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue