summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorMario Six <mario.six@gdsys.cc>2019-04-28 23:28:46 +0300
committerJagan Teki <jagan@amarulasolutions.com>2019-06-10 15:29:48 +0300
commit65f88e0408e8ddba827fb9ace1596591365f0b79 (patch)
tree26f49600f4006cf498e53abab95eb8926f0f0346 /drivers/spi
parente4da4c2e0e3f4686c104e45a1967587423f04e04 (diff)
downloadu-boot-65f88e0408e8ddba827fb9ace1596591365f0b79.tar.xz
spi: mpc8xxx: Reduce scope of loop variables
The transmission loop starts with setting some variables, which are only used inside the loop. Reduce the scope to the loop to make the declaration and initialization of these variables coincide. In the case of char_size this also always initializes the variable immediately with the final value actually used in the loop (instead of the placeholder value 32). Signed-off-by: Mario Six <mario.six@gdsys.cc> Acked-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/mpc8xxx_spi.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c
index a2e698ea17..2a0f3cc06a 100644
--- a/drivers/spi/mpc8xxx_spi.c
+++ b/drivers/spi/mpc8xxx_spi.c
@@ -88,10 +88,8 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
ulong flags)
{
spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi;
- uint tmpdout, tmpdin, event;
+ u32 tmpdin;
int num_blks = DIV_ROUND_UP(bitlen, 32);
- int tm;
- uchar char_size = 32;
debug("%s: slave %u:%u dout %08X din %08X bitlen %u\n", __func__,
slave->bus, slave->cs, *(uint *)dout, *(uint *)din, bitlen);
@@ -104,8 +102,9 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
/* Handle data in 32-bit chunks */
while (num_blks--) {
- tmpdout = 0;
- char_size = (bitlen >= 32 ? 32 : bitlen);
+ int tm;
+ u32 tmpdout = 0;
+ uchar char_size = (bitlen >= 32 ? 32 : bitlen);
/* Shift data so it's msb-justified */
tmpdout = *(u32 *)dout >> (32 - char_size);
@@ -145,7 +144,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
* The NE event must be read and cleared first
*/
for (tm = 0; tm < SPI_TIMEOUT; ++tm) {
- event = in_be32(&spi->event);
+ u32 event = in_be32(&spi->event);
bool have_ne = event & SPI_EV_NE;
bool have_nf = event & SPI_EV_NF;