Browse Source

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 <axel.lin@ingics.com>
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Axel Lin 11 years ago
parent
commit
0c3b97487d
1 changed files with 3 additions and 1 deletions
  1. 3 1
      drivers/spi/spi-atmel.c

+ 3 - 1
drivers/spi/spi-atmel.c

@@ -224,7 +224,7 @@ struct atmel_spi {
 	struct platform_device	*pdev;
 	struct platform_device	*pdev;
 
 
 	struct spi_transfer	*current_transfer;
 	struct spi_transfer	*current_transfer;
-	unsigned long		current_remaining_bytes;
+	int			current_remaining_bytes;
 	int			done_status;
 	int			done_status;
 
 
 	struct completion	xfer_completion;
 	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);
 				atmel_spi_next_xfer_pio(master, xfer);
 			} else {
 			} else {
 				as->current_remaining_bytes -= len;
 				as->current_remaining_bytes -= len;
+				if (as->current_remaining_bytes < 0)
+					as->current_remaining_bytes = 0;
 			}
 			}
 		} else {
 		} else {
 			atmel_spi_next_xfer_pio(master, xfer);
 			atmel_spi_next_xfer_pio(master, xfer);