All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] mmc: mmci: Bugfix in pio read for small packets
@ 2011-09-27  7:46 ` Ulf Hansson
  0 siblings, 0 replies; 24+ messages in thread
From: Ulf Hansson @ 2011-09-27  7:46 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: Russell King, Ulf Hansson, Lee Jones, Stefan Nilsson XK

From: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>

Corrects a bug in pio read when reading packets < 4 bytes. These
small packets are only relevant for SDIO transfers.

Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com>
---
 drivers/mmc/host/mmci.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 40e4c05..8831b2f 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -776,7 +776,24 @@ static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int rema
 		if (count <= 0)
 			break;
 
-		readsl(base + MMCIFIFO, ptr, count >> 2);
+		/*
+		 * SDIO especially may want to receive something that is
+		 * not divisible by 4 (as opposed to card sectors
+		 * etc). Therefore make sure we always read the last bytes
+		 * out of the FIFO.
+		 */
+		switch (count) {
+		case 1:
+		case 3:
+			readsb(base + MMCIFIFO, ptr, count);
+			break;
+		case 2:
+			readsw(base + MMCIFIFO, ptr, 1);
+			break;
+		default:
+			readsl(base + MMCIFIFO, ptr, count >> 2);
+			break;
+		}
 
 		ptr += count;
 		remain -= count;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2011-10-14  8:08 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27  7:46 [PATCH 1/4] mmc: mmci: Bugfix in pio read for small packets Ulf Hansson
2011-09-27  7:46 ` Ulf Hansson
2011-10-01 16:09 ` Russell King - ARM Linux
2011-10-01 16:09   ` Russell King - ARM Linux
2011-10-03  7:08   ` Stefan Nilsson XK
2011-10-03  7:08     ` Stefan Nilsson XK
2011-10-07 13:38     ` Ulf Hansson
2011-10-07 13:38       ` Ulf Hansson
2011-10-07 19:11       ` Russell King - ARM Linux
2011-10-07 19:11         ` Russell King - ARM Linux
2011-10-14  7:38         ` Stefan Nilsson XK
2011-10-14  7:38           ` Stefan Nilsson XK
2011-10-07 13:45   ` Ulf Hansson
2011-10-07 13:45     ` Ulf Hansson
2011-10-08  9:10     ` Russell King - ARM Linux
2011-10-08  9:10       ` Russell King - ARM Linux
2011-10-09  6:59       ` Linus Walleij
2011-10-09  6:59         ` Linus Walleij
2011-10-10  8:23         ` Ulf Hansson
2011-10-10  8:23           ` Ulf Hansson
2011-10-13 15:48           ` Russell King - ARM Linux
2011-10-13 15:48             ` Russell King - ARM Linux
2011-10-14  8:07             ` Ulf Hansson
2011-10-14  8:07               ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.