linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: Jens Axboe <axboe@kernel.dk>, Pierre Ossman <drzeus-mmc@drzeus.cx>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 02/02] mmc/sdhci: use PIO - scatterlist wrappers
Date: Fri, 6 Feb 2009 21:44:41 +0100	[thread overview]
Message-ID: <20090206204441.GC13217@rere.qmqm.pl> (raw)

Use sg_dwiter_*_io() in sdhci_*_block_pio(). This assumes that
buffer sizes are multiple of 4 when transferring more than one
block consecutively.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

diff -urN b/drivers/mmc/host/sdhci.c c/drivers/mmc/host/sdhci.c
--- b/drivers/mmc/host/sdhci.c	2008-12-25 00:26:37.000000000 +0100
+++ c/drivers/mmc/host/sdhci.c	2009-02-03 00:12:23.000000000 +0100
@@ -176,44 +176,17 @@
 static void sdhci_read_block_pio(struct sdhci_host *host)
 {
 	unsigned long flags;
-	size_t blksize, len, chunk;
-	u32 uninitialized_var(scratch);
-	u8 *buf;
+	size_t blksize;
 
 	DBG("PIO reading\n");
 
-	blksize = host->data->blksz;
-	chunk = 0;
+	blksize = (host->data->blksz + 3) >> 2;
 
 	local_irq_save(flags);
 
-	while (blksize) {
-		if (!sg_miter_next(&host->sg_miter))
-			BUG();
-
-		len = min(host->sg_miter.length, blksize);
-
-		blksize -= len;
-		host->sg_miter.consumed = len;
-
-		buf = host->sg_miter.addr;
-
-		while (len) {
-			if (chunk == 0) {
-				scratch = readl(host->ioaddr + SDHCI_BUFFER);
-				chunk = 4;
-			}
-
-			*buf = scratch & 0xFF;
-
-			buf++;
-			scratch >>= 8;
-			chunk--;
-			len--;
-		}
-	}
-
-	sg_miter_stop(&host->sg_miter);
+	sg_dwiter_write_from_io(&host->sg_miter,
+		host->ioaddr + SDHCI_BUFFER, blksize);
+	sg_miter_stop_writing(&host->sg_miter);
 
 	local_irq_restore(flags);
 }
@@ -221,44 +194,16 @@
 static void sdhci_write_block_pio(struct sdhci_host *host)
 {
 	unsigned long flags;
-	size_t blksize, len, chunk;
-	u32 scratch;
-	u8 *buf;
+	size_t blksize;
 
 	DBG("PIO writing\n");
 
-	blksize = host->data->blksz;
-	chunk = 0;
-	scratch = 0;
+	blksize = (host->data->blksz + 3) >> 2;
 
 	local_irq_save(flags);
 
-	while (blksize) {
-		if (!sg_miter_next(&host->sg_miter))
-			BUG();
-
-		len = min(host->sg_miter.length, blksize);
-
-		blksize -= len;
-		host->sg_miter.consumed = len;
-
-		buf = host->sg_miter.addr;
-
-		while (len) {
-			scratch |= (u32)*buf << (chunk * 8);
-
-			buf++;
-			chunk++;
-			len--;
-
-			if ((chunk == 4) || ((len == 0) && (blksize == 0))) {
-				writel(scratch, host->ioaddr + SDHCI_BUFFER);
-				chunk = 0;
-				scratch = 0;
-			}
-		}
-	}
-
+	sg_dwiter_read_to_io(&host->sg_miter,
+		host->ioaddr + SDHCI_BUFFER, blksize);
 	sg_miter_stop(&host->sg_miter);
 
 	local_irq_restore(flags);

                 reply	other threads:[~2009-02-06 20:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090206204441.GC13217@rere.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=axboe@kernel.dk \
    --cc=drzeus-mmc@drzeus.cx \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 02/02] mmc/sdhci: use PIO - scatterlist wrappers' \
    /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

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).