From 6aed4ee9b4610cd1e0315c90855b32e59ee81a15 Mon Sep 17 00:00:00 2001 From: Ben Nizette Date: Mon, 14 Dec 2009 22:20:20 -0800 Subject: 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 Cc: Haavard Skinnemoen Cc: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Grant Likely --- drivers/spi/atmel_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/spi/atmel_spi.c') diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index f5b3fdb..8ce70cb 100644 --- a/drivers/spi/atmel_spi.c +++ b/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 */ if (xfer->rx_buf) - *rx_dma = xfer->rx_dma + xfer->len - len; + *rx_dma = xfer->rx_dma + xfer->len - *plen; else { *rx_dma = as->buffer_dma; if (len > BUFFER_SIZE) len = BUFFER_SIZE; } if (xfer->tx_buf) - *tx_dma = xfer->tx_dma + xfer->len - len; + *tx_dma = xfer->tx_dma + xfer->len - *plen; else { *tx_dma = as->buffer_dma; if (len > BUFFER_SIZE) -- cgit v1.1 From 905aa0ae91798feb4e12d6237496d269dc2f4962 Mon Sep 17 00:00:00 2001 From: hartleys Date: Mon, 14 Dec 2009 22:22:25 +0000 Subject: spi: atmel_spi.c: use resource_size() Signed-off-by: H Hartley Sweeten Cc: Haavard Skinnemoen Signed-off-by: Grant Likely --- drivers/spi/atmel_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/spi/atmel_spi.c') diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 8ce70cb..d21c24e 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -788,7 +788,7 @@ static int __init atmel_spi_probe(struct platform_device *pdev) spin_lock_init(&as->lock); INIT_LIST_HEAD(&as->queue); as->pdev = pdev; - as->regs = ioremap(regs->start, (regs->end - regs->start) + 1); + as->regs = ioremap(regs->start, resource_size(regs)); if (!as->regs) goto out_free_buffer; as->irq = irq; -- cgit v1.1