summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorTom Rini <trini@ti.com>2014-06-11 15:40:11 (GMT)
committerTom Rini <trini@ti.com>2014-06-11 15:40:11 (GMT)
commit28b62f0de361ae640eb286969536a236cc8febda (patch)
tree6c36f500b3d8ed64e0b79a0f043c819a2aad66b5 /drivers/spi
parent61e76f53708cf082ef9061a140b57df3513b8ba1 (diff)
parent1f436a6ddf7eb7f2da1c8df6c13100429baf844a (diff)
downloadu-boot-28b62f0de361ae640eb286969536a236cc8febda.tar.xz
Merge branch 'master' of git://git.denx.de/u-boot-spi
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/soft_spi.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c
index 5d22351..c969be3 100644
--- a/drivers/spi/soft_spi.c
+++ b/drivers/spi/soft_spi.c
@@ -136,10 +136,14 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
/*
* Check if it is time to work on a new byte.
*/
- if((j % 8) == 0) {
- tmpdout = *txd++;
+ if ((j % 8) == 0) {
+ if (txd)
+ tmpdout = *txd++;
+ else
+ tmpdout = 0;
if(j != 0) {
- *rxd++ = tmpdin;
+ if (rxd)
+ *rxd++ = tmpdin;
}
tmpdin = 0;
}
@@ -164,9 +168,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
* bits over to left-justify them. Then store the last byte
* read in.
*/
- if((bitlen % 8) != 0)
- tmpdin <<= 8 - (bitlen % 8);
- *rxd++ = tmpdin;
+ if (rxd) {
+ if ((bitlen % 8) != 0)
+ tmpdin <<= 8 - (bitlen % 8);
+ *rxd++ = tmpdin;
+ }
if (flags & SPI_XFER_END)
spi_cs_deactivate(slave);