]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/spi/mpc52xx_psc_spi.c
mpc52xx_psc_spi: fix block transfer
[karo-tx-linux.git] / drivers / spi / mpc52xx_psc_spi.c
index 90729469d481dced3ae3e70d1c284df22e385acf..f200661c5661bd745cf154f922358b4177c9a4e3 100644 (file)
@@ -148,7 +148,6 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
        unsigned rfalarm;
        unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
        unsigned recv_at_once;
-       unsigned bpw = mps->bits_per_word / 8;
 
        if (!t->tx_buf && !t->rx_buf && t->len)
                return -EINVAL;
@@ -164,22 +163,15 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
                }
 
                dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
-               if (tx_buf) {
-                       for (; send_at_once; sb++, send_at_once--) {
-                               /* set EOF flag */
-                               if (mps->bits_per_word
-                                               && (sb + 1) % bpw == 0)
-                                       out_8(&psc->ircr2, 0x01);
+               for (; send_at_once; sb++, send_at_once--) {
+                       /* set EOF flag before the last word is sent */
+                       if (send_at_once == 1)
+                               out_8(&psc->ircr2, 0x01);
+
+                       if (tx_buf)
                                out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]);
-                       }
-               } else {
-                       for (; send_at_once; sb++, send_at_once--) {
-                               /* set EOF flag */
-                               if (mps->bits_per_word
-                                               && ((sb + 1) % bpw) == 0)
-                                       out_8(&psc->ircr2, 0x01);
+                       else
                                out_8(&psc->mpc52xx_psc_buffer_8, 0);
-                       }
                }