linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmci: calculate remaining bytes at error correctly
@ 2011-01-27 14:02 Linus Walleij
  0 siblings, 0 replies; 21+ messages in thread
From: Linus Walleij @ 2011-01-27 14:02 UTC (permalink / raw)
  To: linux-arm-kernel

The MMCIDATACNT register contain the number of byte left at error
not the number of words, so loose the << 2 thing. Further if CRC
fails on the first block, we may end up with a negative number
of transferred bytes which is not good, and the formula was in
wrong order.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/mmc/host/mmci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 2de12fe..1870e74 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -283,13 +283,13 @@ mmci_data_irq(struct mmci_host *host, struct
mmc_data *data,
                u32 remain, success;

                /* Calculate how far we are into the transfer */
-               remain =3D readl(host->base + MMCIDATACNT) << 2;
+               remain =3D readl(host->base + MMCIDATACNT);
                success =3D data->blksz * data->blocks - remain;

                dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status
%08x)\n", status);
                if (status & MCI_DATACRCFAIL) {
                        /* Last block was not successful */
-                       host->data_xfered =3D ((success / data->blksz) -
1 * data->blksz);
+                       host->data_xfered =3D ((success - 1) /
data->blksz) * data->blksz;
                        data->error =3D -EILSEQ;
                } else if (status & MCI_DATATIMEOUT) {
                        host->data_xfered =3D success;
--=20
1.7.3.2

I'll put it in the patch tracker for consideration...

Thanks
Linus Walleij

^ permalink raw reply related	[flat|nested] 21+ messages in thread
* [PATCH] mmci: calculate remaining bytes at error correctly
@ 2011-01-27 14:14 Linus Walleij
  2011-01-27 16:36 ` Russell King - ARM Linux
  2011-01-30 21:28 ` Russell King - ARM Linux
  0 siblings, 2 replies; 21+ messages in thread
From: Linus Walleij @ 2011-01-27 14:14 UTC (permalink / raw)
  To: linux-arm-kernel

The MMCIDATACNT register contain the number of byte left at error
not the number of words, so loose the << 2 thing. Further if CRC
fails on the first block, we may end up with a negative number
of transferred bytes which is not good, and the formula was in
wrong order.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/mmc/host/mmci.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 2de12fe..ec2db8c 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -283,13 +283,16 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
 		u32 remain, success;
 
 		/* Calculate how far we are into the transfer */
-		remain = readl(host->base + MMCIDATACNT) << 2;
+		remain = readl(host->base + MMCIDATACNT);
 		success = data->blksz * data->blocks - remain;
 
 		dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status);
 		if (status & MCI_DATACRCFAIL) {
 			/* Last block was not successful */
-			host->data_xfered = ((success / data->blksz) - 1 * data->blksz);
+			if (success <= data->blksz)
+				host->data_xfered = 0;
+			else
+				host->data_xfered = ((success / data->blksz) - 1) * data->blksz;
 			data->error = -EILSEQ;
 		} else if (status & MCI_DATATIMEOUT) {
 			host->data_xfered = success;
-- 
1.7.3.2

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

end of thread, other threads:[~2011-02-04 13:24 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-27 14:02 [PATCH] mmci: calculate remaining bytes at error correctly Linus Walleij
  -- strict thread matches above, loose matches on Subject: below --
2011-01-27 14:14 Linus Walleij
2011-01-27 16:36 ` Russell King - ARM Linux
2011-01-27 16:43   ` Linus Walleij
2011-01-27 16:47     ` Russell King - ARM Linux
2011-01-30 21:28 ` Russell King - ARM Linux
2011-01-30 21:29   ` Russell King - ARM Linux
2011-01-31 10:24     ` Linus Walleij
2011-02-03  0:30       ` Russell King - ARM Linux
2011-02-03 14:00         ` Russell King - ARM Linux
2011-02-04 13:24           ` Linus Walleij
2011-01-31 10:17   ` Linus Walleij
2011-01-31 10:27     ` Russell King - ARM Linux
2011-01-31 10:31       ` Linus Walleij
2011-01-31 10:40         ` Russell King - ARM Linux
2011-01-31 13:53           ` Linus Walleij
2011-01-31 14:00             ` Russell King - ARM Linux
2011-01-31 12:00   ` Sergei Shtylyov
2011-01-31 12:25     ` Russell King - ARM Linux
2011-01-31 12:31       ` Sergei Shtylyov
2011-02-01 23:40         ` Russell King - ARM Linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).