Merge remote-tracking branch 'spi/fix/mcspi' into spi-linus
authorMark Brown <broonie@linaro.org>
Fri, 25 Oct 2013 08:51:19 +0000 (09:51 +0100)
committerMark Brown <broonie@linaro.org>
Fri, 25 Oct 2013 08:51:19 +0000 (09:51 +0100)
drivers/spi/spi-omap2-mcspi.c

index ed4af47..32dca0c 100644 (file)
@@ -276,7 +276,7 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
        struct omap2_mcspi_cs *cs = spi->controller_state;
        struct omap2_mcspi *mcspi;
        unsigned int wcnt;
-       int fifo_depth, bytes_per_word;
+       int max_fifo_depth, fifo_depth, bytes_per_word;
        u32 chconf, xferlevel;
 
        mcspi = spi_master_get_devdata(master);
@@ -287,7 +287,12 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
                if (t->len % bytes_per_word != 0)
                        goto disable_fifo;
 
-               fifo_depth = gcd(t->len, OMAP2_MCSPI_MAX_FIFODEPTH);
+               if (t->rx_buf != NULL && t->tx_buf != NULL)
+                       max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH / 2;
+               else
+                       max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH;
+
+               fifo_depth = gcd(t->len, max_fifo_depth);
                if (fifo_depth < 2 || fifo_depth % bytes_per_word != 0)
                        goto disable_fifo;
 
@@ -299,7 +304,8 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
                if (t->rx_buf != NULL) {
                        chconf |= OMAP2_MCSPI_CHCONF_FFER;
                        xferlevel |= (fifo_depth - 1) << 8;
-               } else {
+               }
+               if (t->tx_buf != NULL) {
                        chconf |= OMAP2_MCSPI_CHCONF_FFET;
                        xferlevel |= fifo_depth - 1;
                }