Browse Source

atmel_spi: fix dma addr calculation for len > BUFFER_SIZE

If len > BUFFER_LEN and !xfer->rx_buf we end up calculating the tx buffer
address as

*tx_dma = xfer->tx_dma + xfer->len - BUFFER_SIZE;

which is constant; i.e.  we just send the last BUFFER_SIZE data over again
until we've reached the right number of bytes.

This patch gets around this by using the /requested/ length when
calculating addresses.

Note there's no way len != *plen when we calculate the rx buffer address
but conceptually we should be using *plen and I don't want someone to come
through later, see the calculations for rx and tx are different and "clean
up" back to what we had.

Signed-off-by: Ben Nizette <bn@niasdigital.com>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Ben Nizette 15 years ago
parent
commit
6aed4ee9b4
1 changed files with 2 additions and 2 deletions
  1. 2 2
      drivers/spi/atmel_spi.c

+ 2 - 2
drivers/spi/atmel_spi.c

@@ -189,14 +189,14 @@ static void atmel_spi_next_xfer_data(struct spi_master *master,
 
 
 	/* use scratch buffer only when rx or tx data is unspecified */
 	/* use scratch buffer only when rx or tx data is unspecified */
 	if (xfer->rx_buf)
 	if (xfer->rx_buf)
-		*rx_dma = xfer->rx_dma + xfer->len - len;
+		*rx_dma = xfer->rx_dma + xfer->len - *plen;
 	else {
 	else {
 		*rx_dma = as->buffer_dma;
 		*rx_dma = as->buffer_dma;
 		if (len > BUFFER_SIZE)
 		if (len > BUFFER_SIZE)
 			len = BUFFER_SIZE;
 			len = BUFFER_SIZE;
 	}
 	}
 	if (xfer->tx_buf)
 	if (xfer->tx_buf)
-		*tx_dma = xfer->tx_dma + xfer->len - len;
+		*tx_dma = xfer->tx_dma + xfer->len - *plen;
 	else {
 	else {
 		*tx_dma = as->buffer_dma;
 		*tx_dma = as->buffer_dma;
 		if (len > BUFFER_SIZE)
 		if (len > BUFFER_SIZE)