aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@stericsson.com>2011-12-13 17:08:04 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-01-20 00:00:59 +0000
commit393e5e24165d0bef60489ecd0baef085e9af2e5a (patch)
tree0efc337ae8fe9775b2f3b8ce724e496aa5aa6220 /drivers
parentARM: 7227/1: mmc: mmci: Prepare for SDIO before setting up DMA job (diff)
downloadlinux-dev-393e5e24165d0bef60489ecd0baef085e9af2e5a.tar.xz
linux-dev-393e5e24165d0bef60489ecd0baef085e9af2e5a.zip
ARM: 7230/1: mmc: mmci: Fix PIO read for small SDIO packets
Corrects a bug in MMCI host driver which silently causes small reads (< 4 bytes as only used in SDIO) from PL-18X to fail. Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Signed-off-by: Fredrik Soderstedt <fredrik.soderstedt@stericsson.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/host/mmci.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index b09ccb7223e5..1f8832699cdf 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -794,7 +794,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 send something that is
+ * not divisible by 4 (as opposed to card sectors
+ * etc). Therefore make sure to always read the last bytes
+ * while only doing full 32-bit reads towards the FIFO.
+ */
+ if (unlikely(count & 0x3)) {
+ if (count < 4) {
+ unsigned char buf[4];
+ readsl(base + MMCIFIFO, buf, 1);
+ memcpy(ptr, buf, count);
+ } else {
+ readsl(base + MMCIFIFO, ptr, count >> 2);
+ count &= ~0x3;
+ }
+ } else {
+ readsl(base + MMCIFIFO, ptr, count >> 2);
+ }
ptr += count;
remain -= count;