summaryrefslogtreecommitdiffstats
path: root/drivers/spi/soft_spi.c
diff options
context:
space:
mode:
authorTom Rini <trini@ti.com>2014-06-11 11:40:11 -0400
committerTom Rini <trini@ti.com>2014-06-11 11:40:11 -0400
commit28b62f0de361ae640eb286969536a236cc8febda (patch)
tree6c36f500b3d8ed64e0b79a0f043c819a2aad66b5 /drivers/spi/soft_spi.c
parent61e76f53708cf082ef9061a140b57df3513b8ba1 (diff)
parent1f436a6ddf7eb7f2da1c8df6c13100429baf844a (diff)
downloadblackbird-obmc-uboot-28b62f0de361ae640eb286969536a236cc8febda.tar.gz
blackbird-obmc-uboot-28b62f0de361ae640eb286969536a236cc8febda.zip
Merge branch 'master' of git://git.denx.de/u-boot-spi
Diffstat (limited to 'drivers/spi/soft_spi.c')
-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 5d22351290..c969be31eb 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);
OpenPOWER on IntegriCloud