[PATCH] atmel_spi: add mesg->actual_length, so devices can use it for read/write

Michael Grzeschik m.grzeschik at pengutronix.de
Thu Nov 24 09:32:39 EST 2011


Without this i.e. the m25p driver is not working properly.

Its used to calculate the return value of the read/write function of
some devices. If the value is missing, barebox would always
miscalculate the next transfer sizes.

Signed-off-by: Michael Grzeschik <m.grzeschik at pengutronix.de>
---
 drivers/spi/atmel_spi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index faa03b1..47e6756 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -190,6 +190,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 	struct spi_transfer *t		= NULL;
 	unsigned int bits		= spi->bits_per_word;
 
+	mesg->actual_length = 0;
 	ret = master->setup(spi);
 	if (ret < 0) {
 		dev_dbg(master->dev, "transfer: master setup failed\n");
@@ -210,6 +211,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 		u32 tx_val;
 		int i = 0, rx_val;
 
+		mesg->actual_length += t->len;
 		if (bits <= 8) {
 			const u8 *txbuf = t->tx_buf;
 			u8 *rxbuf = t->rx_buf;
-- 
1.7.7.1




More information about the barebox mailing list