linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linus.walleij@stericsson.com (Linus Walleij)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mmci: calculate remaining bytes at error correctly
Date: Thu, 27 Jan 2011 15:02:56 +0100	[thread overview]
Message-ID: <mailman.133.1296146619.1530.linux-arm-kernel@lists.infradead.org> (raw)

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

             reply	other threads:[~2011-01-27 14:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 14:02 Linus Walleij [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-01-27 14:14 [PATCH] mmci: calculate remaining bytes at error correctly 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mailman.133.1296146619.1530.linux-arm-kernel@lists.infradead.org \
    --to=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).