spi: atmel: fix incorrect comparison
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>
Tue, 6 May 2014 15:44:41 +0000 (17:44 +0200)
committerMark Brown <broonie@linaro.org>
Wed, 7 May 2014 19:50:20 +0000 (20:50 +0100)
Found using smatch:
drivers/spi/spi-atmel.c:878 atmel_spi_pump_pio_data() warn: unsigned
'as->current_remaining_bytes' is never less than zero.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-atmel.c

index 485e6cce94bf013471326058ce7119fc3c26c21b..e6fe837d49fb0c3b8a2ebd0b93256b8d2fdbbfa8 100644 (file)
@@ -874,8 +874,9 @@ atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer)
                spi_readl(as, RDR);
        }
        if (xfer->bits_per_word > 8) {
-               as->current_remaining_bytes -= 2;
-               if (as->current_remaining_bytes < 0)
+               if (as->current_remaining_bytes > 2)
+                       as->current_remaining_bytes -= 2;
+               else
                        as->current_remaining_bytes = 0;
        } else {
                as->current_remaining_bytes--;
This page took 0.025709 seconds and 5 git commands to generate.