mmc: msm_sdcc: Fix bug in PIO mode when data size is not word aligned
authorSahitya Tummala <stummala@codeaurora.org>
Wed, 8 Dec 2010 09:33:06 +0000 (15:03 +0530)
committerDavid Brown <davidb@codeaurora.org>
Mon, 20 Dec 2010 20:28:31 +0000 (12:28 -0800)
The current code for PIO doesn't transfer whole data when data size
is not in multiple of 4 bytes. The last few bytes are not written to
the card resulting in no DATAEND interrupt from SDCC. This patch
allows data transfer for non-aligned data size in PIO mode.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
drivers/mmc/host/msm_sdcc.c

index 81ed16fb42b5c11d7a01548a2a239c0702df9be5..9badc51bc4db3c642301c48bc4de9177684553b5 100644 (file)
@@ -613,6 +613,9 @@ msmsdcc_pio_read(struct msmsdcc_host *host, char *buffer, unsigned int remain)
        uint32_t        *ptr = (uint32_t *) buffer;
        int             count = 0;
 
+       if (remain % 4)
+               remain = ((remain >> 2) + 1) << 2;
+
        while (msmsdcc_readl(host, MMCISTATUS) & MCI_RXDATAAVLBL) {
                *ptr = msmsdcc_readl(host, MMCIFIFO + (count % MCI_FIFOSIZE));
                ptr++;
@@ -633,13 +636,14 @@ msmsdcc_pio_write(struct msmsdcc_host *host, char *buffer,
        char *ptr = buffer;
 
        do {
-               unsigned int count, maxcnt;
+               unsigned int count, maxcnt, sz;
 
                maxcnt = status & MCI_TXFIFOEMPTY ? MCI_FIFOSIZE :
                                                    MCI_FIFOHALFSIZE;
                count = min(remain, maxcnt);
 
-               writesl(base + MMCIFIFO, ptr, count >> 2);
+               sz = count % 4 ? (count >> 2) + 1 : (count >> 2);
+               writesl(base + MMCIFIFO, ptr, sz);
                ptr += count;
                remain -= count;
 
This page took 0.025237 seconds and 5 git commands to generate.