Commit 71b0621e authored by Christian Lütke-Stetzkamp's avatar Christian Lütke-Stetzkamp Committed by Greg Kroah-Hartman

staging: mt7621-mmc: Start cleanup of msdc_dma_config

Currently the msdc_dma_config function has some variables, that are
not needed, uses the macro msdc_init_bd that is only used here and
does not use the for_each_sg iterator. That last fact could cause a
bug if the scatterlist is chained.

The function is changed to remove these things, but none of the
changes should change the behavior of it (despite the case of a linked
scatterlist).
Signed-off-by: default avatarChristian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f4516eb5
...@@ -209,15 +209,6 @@ static int msdc_rsp[] = { ...@@ -209,15 +209,6 @@ static int msdc_rsp[] = {
((struct gpd *)_gpd)->blknum = blknum; \ ((struct gpd *)_gpd)->blknum = blknum; \
} while (0) } while (0)
#define msdc_init_bd(_bd, blkpad, dwpad, dptr, dlen) \
do { \
BUG_ON(dlen > 0xFFFFUL); \
((struct bd *)_bd)->blkpad = blkpad; \
((struct bd *)_bd)->dwpad = dwpad; \
((struct bd *)_bd)->ptr = (void *)dptr; \
((struct bd *)_bd)->buflen = dlen; \
} while (0)
#define msdc_txfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 16) #define msdc_txfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_TXCNT) >> 16)
#define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0) #define msdc_rxfifocnt() ((sdr_read32(MSDC_FIFOCS) & MSDC_FIFOCS_RXCNT) >> 0)
#define msdc_fifo_write32(v) sdr_write32(MSDC_TXDATA, (v)) #define msdc_fifo_write32(v) sdr_write32(MSDC_TXDATA, (v))
...@@ -1260,9 +1251,8 @@ static u8 msdc_dma_calcs(u8 *buf, u32 len) ...@@ -1260,9 +1251,8 @@ static u8 msdc_dma_calcs(u8 *buf, u32 len)
static int msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) static int msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma)
{ {
u32 base = host->base; u32 base = host->base;
u32 sglen = dma->sglen;
//u32 i, j, num, bdlen, arg, xfersz; //u32 i, j, num, bdlen, arg, xfersz;
u32 j, num, bdlen; u32 j, num;
u8 blkpad, dwpad, chksum; u8 blkpad, dwpad, chksum;
struct scatterlist *sg = dma->sg; struct scatterlist *sg = dma->sg;
struct gpd *gpd; struct gpd *gpd;
...@@ -1291,12 +1281,11 @@ static int msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) ...@@ -1291,12 +1281,11 @@ static int msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma)
chksum = (dma->flags & DMA_FLAG_EN_CHKSUM) ? 1 : 0; chksum = (dma->flags & DMA_FLAG_EN_CHKSUM) ? 1 : 0;
/* calculate the required number of gpd */ /* calculate the required number of gpd */
num = (sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD; num = (dma->sglen + MAX_BD_PER_GPD - 1) / MAX_BD_PER_GPD;
BUG_ON(num != 1); BUG_ON(num != 1);
gpd = dma->gpd; gpd = dma->gpd;
bd = dma->bd; bd = dma->bd;
bdlen = sglen;
/* modify gpd*/ /* modify gpd*/
//gpd->intr = 0; //gpd->intr = 0;
...@@ -1306,19 +1295,23 @@ static int msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma) ...@@ -1306,19 +1295,23 @@ static int msdc_dma_config(struct msdc_host *host, struct msdc_dma *dma)
gpd->chksum = (chksum ? msdc_dma_calcs((u8 *)gpd, 16) : 0); gpd->chksum = (chksum ? msdc_dma_calcs((u8 *)gpd, 16) : 0);
/* modify bd*/ /* modify bd*/
for (j = 0; j < bdlen; j++) { for_each_sg(dma->sg, sg, dma->sglen, j) {
msdc_init_bd(&bd[j], blkpad, dwpad, sg_dma_address(sg), sg_dma_len(sg)); bd[j].blkpad = blkpad;
if (j == bdlen - 1) bd[j].dwpad = dwpad;
bd[j].ptr = (void *)sg_dma_address(sg);
bd[j].buflen = sg_dma_len(sg);
if (j == dma->sglen - 1)
bd[j].eol = 1; /* the last bd */ bd[j].eol = 1; /* the last bd */
else else
bd[j].eol = 0; bd[j].eol = 0;
bd[j].chksum = 0; /* checksume need to clear first */ bd[j].chksum = 0; /* checksume need to clear first */
bd[j].chksum = (chksum ? msdc_dma_calcs((u8 *)(&bd[j]), 16) : 0); bd[j].chksum = (chksum ? msdc_dma_calcs((u8 *)(&bd[j]), 16) : 0);
sg++;
} }
dma->used_gpd += 2; dma->used_gpd += 2;
dma->used_bd += bdlen; dma->used_bd += dma->sglen;
sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, chksum); sdr_set_field(MSDC_DMA_CFG, MSDC_DMA_CFG_DECSEN, chksum);
sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ, sdr_set_field(MSDC_DMA_CTRL, MSDC_DMA_CTRL_BRUSTSZ,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment