spi: img-spfi: check for timeout error before proceeding
authorSifan Naeem <sifan.naeem@imgtec.com>
Mon, 27 Jul 2015 12:11:15 +0000 (13:11 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 29 Jul 2015 13:51:41 +0000 (14:51 +0100)
Calling spfi_wait_all_done is not required if the transfer has timed
out before all data is transferred.

spfi_wait_all_done polls for Alldone interrupt which is triggered to
mark the transfer as complete and to indicate it is now safe to issue
a new transfer.

Fixes: 8c2c8c0 ("spi: img-spfi: Control CS lines with GPIO")
Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com>
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
drivers/spi/spi-img-spfi.c

index 788e2b176a4f7707051bcc325538e7d2a6d599f4..83b97418fc8d3437a3214a818e8f384a261c2d5e 100644 (file)
@@ -266,15 +266,15 @@ static int img_spfi_start_pio(struct spi_master *master,
                cpu_relax();
        }
 
-       ret = spfi_wait_all_done(spfi);
-       if (ret < 0)
-               return ret;
-
        if (rx_bytes > 0 || tx_bytes > 0) {
                dev_err(spfi->dev, "PIO transfer timed out\n");
                return -ETIMEDOUT;
        }
 
+       ret = spfi_wait_all_done(spfi);
+       if (ret < 0)
+               return ret;
+
        return 0;
 }