mmc/sdhci: use PIO - scatterlist wrappers
PATCH 2/2 mmc/sdhci: use PIO - scatterlist wrappers
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 <[email protected]>
drivers/mmc/host/sdhci.c +9 -64
@@ -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);