linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 02/02] mmc/sdhci: use PIO - scatterlist wrappers
@ 2009-02-06 20:44 Michał Mirosław
  0 siblings, 0 replies; only message in thread
From: Michał Mirosław @ 2009-02-06 20:44 UTC (permalink / raw)
  To: Jens Axboe, Pierre Ossman; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-06 20:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-06 20:44 [PATCH 02/02] mmc/sdhci: use PIO - scatterlist wrappers Michał Mirosław

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