spi: atmel: Make current_remaining_bytes to be int
authorAxel Lin <axel.lin@ingics.com>
Thu, 27 Mar 2014 01:26:38 +0000 (09:26 +0800)
committerMark Brown <broonie@linaro.org>
Mon, 14 Apr 2014 16:06:17 +0000 (17:06 +0100)
Don't use unsigned for current_remaining_bytes so we can check
current_remaining_bytes < 0 case.
Use int is enough for current_remaining_bytes.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-atmel.c

index 8005f986948173e55d5bc5a5387da80c8a5b9185..485e6cce94bf013471326058ce7119fc3c26c21b 100644 (file)
@@ -224,7 +224,7 @@ struct atmel_spi {
        struct platform_device  *pdev;
 
        struct spi_transfer     *current_transfer;
-       unsigned long           current_remaining_bytes;
+       int                     current_remaining_bytes;
        int                     done_status;
 
        struct completion       xfer_completion;
@@ -1110,6 +1110,8 @@ static int atmel_spi_one_transfer(struct spi_master *master,
                                atmel_spi_next_xfer_pio(master, xfer);
                        } else {
                                as->current_remaining_bytes -= len;
+                               if (as->current_remaining_bytes < 0)
+                                       as->current_remaining_bytes = 0;
                        }
                } else {
                        atmel_spi_next_xfer_pio(master, xfer);