diff options
author | Mario Six <mario.six@gdsys.cc> | 2019-04-29 01:58:52 +0530 |
---|---|---|
committer | Jagan Teki <jagan@amarulasolutions.com> | 2019-06-10 17:59:49 +0530 |
commit | 67adbaef5a842ebc8f58f9c30baa97e8d99fa4a6 (patch) | |
tree | d91ad6c5ae2cc6f7cb403229d45bf97923c5486d /drivers/spi/mpc8xxx_spi.c | |
parent | f6fcad5f2a889db6fb26afd71ed92dde00cb85e1 (diff) | |
download | u-boot-67adbaef5a842ebc8f58f9c30baa97e8d99fa4a6.tar.gz |
spi: mpc8xxx: Use get_timer
The comment before the transmission loop in conjunction with the
definition of SPI_TIMEOUT as 1000 implies that the loop is supposed to
have a timeout value of 1000 ms. But since there is no mdelay(1) or
similar in the loop body, the loop just runs 1000 times, without regard
for the time elapsed.
To correct this, use the standard get_timer functionality to properly
time out the loop after 1000 ms.
Signed-off-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'drivers/spi/mpc8xxx_spi.c')
-rw-r--r-- | drivers/spi/mpc8xxx_spi.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index e09e91c8e9..63e1a150f8 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -112,9 +112,9 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, /* Handle data in 32-bit chunks */ while (num_blks--) { - int tm; u32 tmpdout = 0; uchar xfer_bitlen = (bitlen >= 32 ? 32 : bitlen); + ulong start; clrbits_be32(&spi->mode, SPI_MODE_EN); @@ -148,7 +148,8 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, * or time out (1 second = 1000 ms) * The NE event must be read and cleared first */ - for (tm = 0; tm < SPI_TIMEOUT; ++tm) { + start = get_timer(0); + do { u32 event = in_be32(&spi->event); bool have_ne = event & SPI_EV_NE; bool have_nf = event & SPI_EV_NF; @@ -173,9 +174,11 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, */ if (have_nf) break; - } - if (tm >= SPI_TIMEOUT) + mdelay(1); + } while (get_timer(start) < SPI_TIMEOUT); + + if (get_timer(start) >= SPI_TIMEOUT) debug("*** %s: Time out during SPI transfer\n", __func__); |