[U-Boot] [PATCH 5/7] spi: altera: Clean up the use of variable d
Marek Vasut
marex at denx.de
Sun Oct 19 20:43:37 CEST 2014
The variable d is used in rather questionable way. Rework the code
a bit so it's clearer what it does. Also, rename the variable from
d to data to make it's name less mysterious. Finally, change it's
data type to uint32_t , since it's accessed as a 32bit number.
Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Chin Liang See <clsee at altera.com>
Cc: Dinh Nguyen <dinguyen at altera.com>
Cc: Albert Aribaud <albert.u.boot at aribaud.net>
Cc: Tom Rini <trini at ti.com>
Cc: Wolfgang Denk <wd at denx.de>
Cc: Pavel Machek <pavel at denx.de>
Cc: Jagannadha Sutradharudu Teki <jagannadh.teki at gmail.com>
---
drivers/spi/altera_spi.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c
index ee65ec2..3065e96 100644
--- a/drivers/spi/altera_spi.c
+++ b/drivers/spi/altera_spi.c
@@ -126,11 +126,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
{
struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
/* assume spi core configured to do 8 bit transfers */
- uint bytes = bitlen / 8;
- const uchar *txp = dout;
- uchar *rxp = din;
+ unsigned int bytes = bitlen / 8;
+ const unsigned char *txp = dout;
+ unsigned char *rxp = din;
int timeout = 10000;
- uint32_t reg;
+ uint32_t reg, data;
debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
slave->bus, slave->cs, bitlen, bytes, flags);
@@ -151,10 +151,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
spi_cs_activate(slave);
while (bytes--) {
- uchar d = txp ? *txp++ : CONFIG_ALTERA_SPI_IDLE_VAL;
+ if (txp)
+ data = *txp++;
+ else
+ data = CONFIG_ALTERA_SPI_IDLE_VAL;
- debug("%s: tx:%x ", __func__, d);
- writel(d, &altspi->regs->txdata);
+ debug("%s: tx:%x ", __func__, data);
+ writel(data, &altspi->regs->txdata);
while (--timeout) {
reg = readl(&altspi->regs->status);
@@ -167,11 +170,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
goto done;
}
- d = readl(&altspi->regs->rxdata);
+ data = readl(&altspi->regs->rxdata);
if (rxp)
- *rxp++ = d;
+ *rxp++ = data & 0xff;
- debug("rx:%x\n", d);
+ debug("rx:%x\n", data);
}
done:
--
2.1.1
More information about the U-Boot
mailing list