spi: mpc8xxx: Simplify logic a bit
We do nothing in the loop if the "not empty" event was not detected. To simplify the logic, check if this is the case, and skip the execution of the loop early to reduce the nesting level and flag checking. Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
This commit is contained in:
parent
6409c6103a
commit
e4da4c2e0e
1 changed files with 12 additions and 9 deletions
|
@ -149,25 +149,28 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
|
||||||
bool have_ne = event & SPI_EV_NE;
|
bool have_ne = event & SPI_EV_NE;
|
||||||
bool have_nf = event & SPI_EV_NF;
|
bool have_nf = event & SPI_EV_NF;
|
||||||
|
|
||||||
if (have_ne) {
|
if (!have_ne)
|
||||||
tmpdin = in_be32(&spi->rx);
|
continue;
|
||||||
setbits_be32(&spi->event, SPI_EV_NE);
|
|
||||||
|
|
||||||
*(u32 *)din = (tmpdin << (32 - char_size));
|
tmpdin = in_be32(&spi->rx);
|
||||||
if (char_size == 32) {
|
setbits_be32(&spi->event, SPI_EV_NE);
|
||||||
/* Advance output buffer by 32 bits */
|
|
||||||
din += 4;
|
*(u32 *)din = (tmpdin << (32 - char_size));
|
||||||
}
|
if (char_size == 32) {
|
||||||
|
/* Advance output buffer by 32 bits */
|
||||||
|
din += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only bail when we've had both NE and NF events.
|
* Only bail when we've had both NE and NF events.
|
||||||
* This will cause timeouts on RO devices, so maybe
|
* This will cause timeouts on RO devices, so maybe
|
||||||
* in the future put an arbitrary delay after writing
|
* in the future put an arbitrary delay after writing
|
||||||
* the device. Arbitrary delays suck, though...
|
* the device. Arbitrary delays suck, though...
|
||||||
*/
|
*/
|
||||||
if (have_ne && have_nf)
|
if (have_nf)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tm >= SPI_TIMEOUT)
|
if (tm >= SPI_TIMEOUT)
|
||||||
debug("*** %s: Time out during SPI transfer\n",
|
debug("*** %s: Time out during SPI transfer\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
|
Loading…
Reference in a new issue