diff options
author | Christian Lütke-Stetzkamp <christian@lkamp.de> | 2018-04-18 17:27:41 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-23 15:37:54 +0200 |
commit | 8f2395586cf0dc74af01c2b232e6f4c539b9164d (patch) | |
tree | 094cbf41da2c1993f78ef29afe37a9a0af150de1 | |
parent | 134cca657d8e04e80a1db988faf485c8cfcef0a6 (diff) | |
download | linux-stable-8f2395586cf0dc74af01c2b232e6f4c539b9164d.tar.gz linux-stable-8f2395586cf0dc74af01c2b232e6f4c539b9164d.tar.bz2 linux-stable-8f2395586cf0dc74af01c2b232e6f4c539b9164d.zip |
staging: mt7621-mmc: Refactor msdc_init_gpd_bd
The msdc_init_gpd_bd function is currently hard to read, because of
old, commented out code and a while loop, where a for loop is much
easier to read. Refactor it to make the code more readable.
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/mt7621-mmc/sd.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 79436d36b99d..7f6e584c7836 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -2495,32 +2495,21 @@ static void msdc_init_gpd_bd(struct msdc_host *host, struct msdc_dma *dma) { struct gpd *gpd = dma->gpd; struct bd *bd = dma->bd; - struct bd *ptr, *prev; + int i; - /* we just support one gpd */ - int bdlen = MAX_BD_PER_GPD; + /* we just support one gpd, but gpd->next must be set for desc + * DMA. That's why we alloc 2 gpd structurs. + */ - /* init the 2 gpd */ memset(gpd, 0, sizeof(struct gpd) * 2); - //gpd->next = (void *)virt_to_phys(gpd + 1); /* pointer to a null gpd, bug! kmalloc <-> virt_to_phys */ - //gpd->next = (dma->gpd_addr + 1); /* bug */ - gpd->next = (void *)((u32)dma->gpd_addr + sizeof(struct gpd)); - //gpd->intr = 0; gpd->bdp = 1; /* hwo, cs, bd pointer */ - //gpd->ptr = (void*)virt_to_phys(bd); gpd->ptr = (void *)dma->bd_addr; /* physical address */ + gpd->next = (void *)((u32)dma->gpd_addr + sizeof(struct gpd)); - memset(bd, 0, sizeof(struct bd) * bdlen); - ptr = bd + bdlen - 1; - //ptr->eol = 1; /* 0 or 1 [Fix me]*/ - //ptr->next = 0; - - while (ptr != bd) { - prev = ptr - 1; - prev->next = (void *)(dma->bd_addr + sizeof(struct bd) * (ptr - bd)); - ptr = prev; - } + memset(bd, 0, sizeof(struct bd) * MAX_BD_NUM); + for (i = 0; i < (MAX_BD_NUM - 1); i++) + bd[i].next = (void *)(dma->bd_addr * sizeof(*bd) * (i + 1)); } static int msdc_drv_probe(struct platform_device *pdev) |