summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMario Six <mario.six@gdsys.cc>2019-04-29 01:58:44 +0530
committerJagan Teki <jagan@amarulasolutions.com>2019-06-10 17:59:48 +0530
commit6409c6103a869271a0a2c109f5262c94a0609add (patch)
tree5a3434b8d4a527bc7d9cc2e656fd51117d70db65 /drivers
parent76c82afef353aa4f36a22bf2d2ed5e53bba931f0 (diff)
spi: mpc8xxx: Get rid of is_read
Get rid of the is_read variable, and just keep the state of the "not empty" and "not full" events in two boolean variables within the loop body. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/mpc8xxx_spi.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c
index ca34570901..962ef710f8 100644
--- a/drivers/spi/mpc8xxx_spi.c
+++ b/drivers/spi/mpc8xxx_spi.c
@@ -90,7 +90,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi;
uint tmpdout, tmpdin, event;
int num_blks = DIV_ROUND_UP(bitlen, 32);
- int tm, is_read = 0;
+ int tm;
uchar char_size = 32;
debug("%s: slave %u:%u dout %08X din %08X bitlen %u\n", __func__,
@@ -144,12 +144,14 @@ 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, is_read = 0; tm < SPI_TIMEOUT; ++tm) {
+ for (tm = 0; tm < SPI_TIMEOUT; ++tm) {
event = in_be32(&spi->event);
- if (event & SPI_EV_NE) {
+ bool have_ne = event & SPI_EV_NE;
+ bool have_nf = event & SPI_EV_NF;
+
+ if (have_ne) {
tmpdin = in_be32(&spi->rx);
setbits_be32(&spi->event, SPI_EV_NE);
- is_read = 1;
*(u32 *)din = (tmpdin << (32 - char_size));
if (char_size == 32) {
@@ -163,7 +165,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
* in the future put an arbitrary delay after writing
* the device. Arbitrary delays suck, though...
*/
- if (is_read && (event & SPI_EV_NF))
+ if (have_ne && have_nf)
break;
}
if (tm >= SPI_TIMEOUT)