2009-07-10 18:19:57

by Nicolas Pitre

[permalink] [raw]
Subject: [PATCH] mvsdio: fix handling of partial word at the end of PIO transfer

Standard data flow for MMC/SD/SDIO cards requires that the mvsdio
controller be set for big endian operation. This is causing problems
with buffers which length is not a multiple of 4 bytes as the last
partial word doesn't get shifted all the way and stored properly in
memory. Let's compensate for this.

Signed-off-by: Nicolas Pitre <[email protected]>
CC: [email protected]
---
diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
index b56d72f..34e2348 100644
--- a/drivers/mmc/host/mvsdio.c
+++ b/drivers/mmc/host/mvsdio.c
@@ -384,7 +384,7 @@ static irqreturn_t mvsd_irq(int irq, void *dev)
u16 val[2] = {0, 0};
val[0] = mvsd_read(MVSD_FIFO);
val[1] = mvsd_read(MVSD_FIFO);
- memcpy(p, &val, s);
+ memcpy(p, ((void *)&val) + 4 - s, s);
s = 0;
intr_status = mvsd_read(MVSD_NOR_INTR_STATUS);
}
@@ -423,7 +423,7 @@ static irqreturn_t mvsd_irq(int irq, void *dev)
if (s < 4) {
if (s && (intr_status & MVSD_NOR_TX_AVAIL)) {
u16 val[2] = {0, 0};
- memcpy(&val, p, s);
+ memcpy(((void *)&val) + 4 - s, p, s);
mvsd_write(MVSD_FIFO, val[0]);
mvsd_write(MVSD_FIFO, val[1]);
s = 0;


2009-07-31 09:44:55

by Pierre Ossman

[permalink] [raw]
Subject: Re: [PATCH] mvsdio: fix handling of partial word at the end of PIO transfer

On Fri, 10 Jul 2009 14:19:42 -0400 (EDT)
Nicolas Pitre <[email protected]> wrote:

> Standard data flow for MMC/SD/SDIO cards requires that the mvsdio
> controller be set for big endian operation. This is causing problems
> with buffers which length is not a multiple of 4 bytes as the last
> partial word doesn't get shifted all the way and stored properly in
> memory. Let's compensate for this.
>
> Signed-off-by: Nicolas Pitre <[email protected]>
> CC: [email protected]
> ---

Queued.

--
-- Pierre Ossman

WARNING: This correspondence is being monitored by the
Swedish government. Make sure your server uses encryption
for SMTP traffic and consider using PGP for end-to-end
encryption.


Attachments:
signature.asc (198.00 B)