On Fri, Apr 25, 2014 at 12:09 AM, Andrew Ruder <andrew.ru...@elecsyscorp.com> wrote: > This mirrors the conventions used in other SPI drivers (kirkwood, > davinci, atmel, et al) where the din/dout buffer can be NULL when the > received/transmitted data isn't important. This reduces the need for > allocating additional buffers when write-only/read-only functionality is > needed. > > In the din == NULL case, the received data is simply not stored. In the > dout == NULL case, zeroes are transmitted. > > Signed-off-by: Andrew Ruder <andrew.ru...@elecsyscorp.com> > Cc: Jean-Christophe PLAGNIOL-VILLARD <plagn...@jcrosoft.com> > Cc: Jagan Teki <jagannadh.t...@gmail.com> > --- > Cleaned up errors/warnings from checkpatch.pl. I'm surprised they were > flagged > by the script since the actual ERRORs were all on lines I didn't change but > were > only included in the context. > > scripts/checkpatch.pl 0001-spi-soft_spi-Support-NULL-din-dout-buffers.patch > total: 0 errors, 0 warnings, 0 checks, 31 lines checked > > drivers/spi/soft_spi.c | 18 ++++++++++++------ > 1 file 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); > -- > 1.9.0.rc3.12.gbc97e2d >
Applied to u-boot-spi/master thanks! -- Jagan. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot