diff options
Diffstat (limited to 'drivers/spi/spi-atmel.c')
| -rw-r--r-- | drivers/spi/spi-atmel.c | 12 | 
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 8005f9869481..92a6f0d93233 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; @@ -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--; @@ -1110,13 +1111,18 @@ 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);  		} +		/* interrupts are disabled, so free the lock for schedule */ +		atmel_spi_unlock(as);  		ret = wait_for_completion_timeout(&as->xfer_completion,  							SPI_DMA_TIMEOUT); +		atmel_spi_lock(as);  		if (WARN_ON(ret == 0)) {  			dev_err(&spi->dev,  				"spi trasfer timeout, err %d\n", ret);  |