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.ruder@elecsyscorp.com>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
                /*
                 * 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;
                }
         * 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);