From: Stefan Nilsson XK <[email protected]>

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 <[email protected]>
Signed-off-by: Stefan Nilsson XK <[email protected]>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to