From 0c3b97487d15a452f1fa7bfd9b6f1bd1a31d538d Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 27 Mar 2014 09:26:38 +0800 Subject: spi: atmel: Make current_remaining_bytes to be int 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 Signed-off-by: Wenyou Yang Signed-off-by: Mark Brown --- drivers/spi/spi-atmel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/spi/spi-atmel.c') diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 8005f986948..485e6cce94b 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -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); -- cgit v1.2.3-70-g09d2 From b112f0585edd1c10e4986373d93ab0d95d12da82 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Tue, 6 May 2014 17:44:41 +0200 Subject: spi: atmel: fix incorrect comparison 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 Acked-by: Nicolas Ferre Signed-off-by: Mark Brown --- drivers/spi/spi-atmel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/spi/spi-atmel.c') diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 485e6cce94b..e6fe837d49f 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -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--; -- cgit v1.2.3-70-g09d2