davinci_mmc fixes
v4 cover davinci_mmc fixes
This fixes a compiler warning in the "fix unwinding in probe" patch where ret was used uninitalized.
David Lechner (3):
mmc: davinci: fix unwinding in probe
mmc: davinci: prepare clock
ARM: davinci: remove mmc dma resources
arch/arm/mach-davinci/devices-da8xx.c | 20 ------- arch/arm/mach-davinci/devices.c | 16 ------ drivers/mmc/host/davinci_mmc.c | 100 ++++++++++++++-------------------- 3 files changed, 40 insertions(+), 96 deletions(-)
Signature · 1 line
1.9.1
PATCH v4 1/3 mmc: davinci: fix unwinding in probe
Unwiding from an error in davinci_mmcsd_probe was a mess. Some errors were not handled and not all paths unwound correctly. Also using devm_ where possible to simplify things.
---
v4 change: set ret before goto ioremap_fail.
drivers/mmc/host/davinci_mmc.c | 100 +++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 60 deletions(-)
drivers/mmc/host/davinci_mmc.c +40 -60
@@ -1205,7 +1205,7 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)struct mmc_davinci_host *host =NULL ;struct mmc_host *mmc =NULL ;struct resource *r, *mem =NULL ; -int ret =0 , irq =0 ; +int ret, irq;size_t mem_size;const struct platform_device_id *id_entry;
@@ -1215,38 +1215,40 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)return -ENOENT ; } - ret = -ENODEV ; r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); irq =platform_get_irq (pdev,0 );if (!r || irq ==NO_IRQ ) - goto out; +return -ENODEV ; - ret = -EBUSY ; mem_size =resource_size (r); - mem =request_mem_region (r->start, mem_size, pdev->name); + mem =devm_request_mem_region (&pdev->dev, r->start, mem_size, + pdev->name);if (!mem) - goto out; +return -EBUSY ; - ret = -ENOMEM ; mmc =mmc_alloc_host (sizeof (struct mmc_davinci_host ), &pdev->dev);if (!mmc) - goto out; +return -ENOMEM ; host =mmc_priv (mmc); host->mmc = mmc;/* Important */ host->mem_res = mem; - host->base =ioremap (mem->start, mem_size); -if (!host->base) - goto out; + host->base =devm_ioremap (&pdev->dev, mem->start, mem_size); +if (!host->base) { + ret = -ENOMEM ; + goto ioremap_fail; + } - ret = -ENXIO ; - host->clk =clk_get (&pdev->dev,NULL ); + host->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (host->clk)) { ret =PTR_ERR (host->clk); - goto out; + goto clk_get_fail; } -clk_enable (host->clk); + ret =clk_enable (host->clk); +if (ret) + goto clk_enable_fail; + host->mmc_input_clk =clk_get_rate (host->clk);init_mmcsd_host (host);
@@ -1264,7 +1266,7 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)if (host->use_dma) { ret =davinci_acquire_dma_channels (host);if (ret == -EPROBE_DEFER ) - goto out; + goto dma_probe_defer;else if (ret) host->use_dma =0 ; }
@@ -1321,15 +1323,17 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev) ret =mmc_add_host (mmc);if (ret <0 ) - goto out; + goto mmc_add_host_fail; - ret =request_irq (irq, mmc_davinci_irq,0 ,mmc_hostname (mmc), host); + ret =devm_request_irq (&pdev->dev, irq, mmc_davinci_irq,0 , +mmc_hostname (mmc), host);if (ret) - goto out; + goto request_irq_fail;if (host->sdio_irq >=0 ) { - ret =request_irq (host->sdio_irq, mmc_davinci_sdio_irq,0 , -mmc_hostname (mmc), host); + ret =devm_request_irq (&pdev->dev, host->sdio_irq, + mmc_davinci_sdio_irq,0 , +mmc_hostname (mmc), host);if (!ret) mmc->caps |=MMC_CAP_SDIO_IRQ ; }
@@ -1342,28 +1346,18 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)return 0 ; -out: +request_irq_fail: +mmc_remove_host (mmc); +mmc_add_host_fail:mmc_davinci_cpufreq_deregister (host); cpu_freq_fail: -if (host) { -davinci_release_dma_channels (host); - -if (host->clk) { -clk_disable (host->clk); -clk_put (host->clk); - } - -if (host->base) -iounmap (host->base); - } - -if (mmc) -mmc_free_host (mmc); - -if (mem) -release_resource (mem); - -dev_dbg (&pdev->dev,"probe err %d\n" , ret); +davinci_release_dma_channels (host); +dma_probe_defer: +clk_disable (host->clk); +clk_enable_fail: +clk_get_fail: +ioremap_fail: +mmc_free_host (mmc);return ret; }
@@ -1372,25 +1366,11 @@ static int __exit davinci_mmcsd_remove(struct platform_device *pdev) {struct mmc_davinci_host *host =platform_get_drvdata (pdev); -if (host) { -mmc_davinci_cpufreq_deregister (host); - -mmc_remove_host (host->mmc); -free_irq (host->mmc_irq, host); -if (host->mmc->caps &MMC_CAP_SDIO_IRQ ) -free_irq (host->sdio_irq, host); - -davinci_release_dma_channels (host); - -clk_disable (host->clk); -clk_put (host->clk); - -iounmap (host->base); - -release_resource (host->mem_res); - -mmc_free_host (host->mmc); - } +mmc_remove_host (host->mmc); +mmc_davinci_cpufreq_deregister (host); +davinci_release_dma_channels (host); +clk_disable (host->clk); +mmc_free_host (host->mmc);return 0 ; }
Signature · 1 line
1.9.1
PATCH v4 2/3 mmc: davinci: prepare clock
In reply to David LechnerWhen trying to use this driver with the common clock framework, enabling the clock fails because it was not prepared. This fixes the problem by calling clk_prepare and clk_enable in a single function. Ditto for clk_disable_unprepare.
---
no change
drivers/mmc/host/davinci_mmc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/host/davinci_mmc.c +5 -5
@@ -1245,9 +1245,9 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev) ret =PTR_ERR (host->clk); goto clk_get_fail; } - ret =clk_enable (host->clk); + ret =clk_prepare_enable (host->clk);if (ret) - goto clk_enable_fail; + goto clk_prepare_enable_fail; host->mmc_input_clk =clk_get_rate (host->clk);
@@ -1353,8 +1353,8 @@ mmc_add_host_fail: cpu_freq_fail:davinci_release_dma_channels (host); dma_probe_defer: -clk_disable (host->clk); -clk_enable_fail: +clk_disable_unprepare (host->clk); +clk_prepare_enable_fail: clk_get_fail: ioremap_fail:mmc_free_host (mmc);
@@ -1369,7 +1369,7 @@ static int __exit davinci_mmcsd_remove(struct platform_device *pdev)mmc_remove_host (host->mmc);mmc_davinci_cpufreq_deregister (host);davinci_release_dma_channels (host); -clk_disable (host->clk); +clk_disable_unprepare (host->clk);mmc_free_host (host->mmc);return 0 ;
Signature · 1 line
1.9.1
PATCH v4 3/3 ARM: davinci: remove mmc dma resources
In reply to David LechnerThe davinci_mmc driver no longer uses platform resources for getting dma channels. Instead lookup is now done using dma_slave_map.
---
no change
arch/arm/mach-davinci/devices-da8xx.c | 20 -------------------- arch/arm/mach-davinci/devices.c | 16 ---------------- 2 files changed, 36 deletions(-)
arch/arm/mach-davinci/devices-da8xx.c +0 -20
@@ -751,16 +751,6 @@ static struct resource da8xx_mmcsd0_resources[] = { .end = IRQ_DA8XX_MMCSDINT0, .flags = IORESOURCE_IRQ, }, - {/* DMA RX */ - .start = DA8XX_DMA_MMCSD0_RX, - .end = DA8XX_DMA_MMCSD0_RX, - .flags = IORESOURCE_DMA, - }, - {/* DMA TX */ - .start = DA8XX_DMA_MMCSD0_TX, - .end = DA8XX_DMA_MMCSD0_TX, - .flags = IORESOURCE_DMA, - }, }; static struct platform_device da8xx_mmcsd0_device = {
@@ -788,16 +778,6 @@ static struct resource da850_mmcsd1_resources[] = { .end = IRQ_DA850_MMCSDINT0_1, .flags = IORESOURCE_IRQ, }, - {/* DMA RX */ - .start = DA850_DMA_MMCSD1_RX, - .end = DA850_DMA_MMCSD1_RX, - .flags = IORESOURCE_DMA, - }, - {/* DMA TX */ - .start = DA850_DMA_MMCSD1_TX, - .end = DA850_DMA_MMCSD1_TX, - .flags = IORESOURCE_DMA, - }, }; static struct platform_device da850_mmcsd1_device = {
arch/arm/mach-davinci/devices.c +0 -16
@@ -144,14 +144,6 @@ static struct resource mmcsd0_resources[] = { .start = IRQ_SDIOINT, .flags = IORESOURCE_IRQ, }, -/* DMA channels: RX, then TX */ - { - .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCRXEVT), - .flags = IORESOURCE_DMA, - }, { - .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCTXEVT), - .flags = IORESOURCE_DMA, - }, }; static struct platform_device davinci_mmcsd0_device = {
@@ -181,14 +173,6 @@ static struct resource mmcsd1_resources[] = { .start = IRQ_DM355_SDIOINT1, .flags = IORESOURCE_IRQ, }, -/* DMA channels: RX, then TX */ - { - .start = EDMA_CTLR_CHAN(0, 30), /* rx */ - .flags = IORESOURCE_DMA, - }, { - .start = EDMA_CTLR_CHAN(0, 31), /* tx */ - .flags = IORESOURCE_DMA, - }, }; static struct platform_device davinci_mmcsd1_device = {
Signature · 1 line
1.9.1
Ulf Hansson
AppliedQuoted 8 lines · David Lechner
This fixes a compiler warning in the "fix unwinding in probe" patch where ret was used uninitalized.
David Lechner (3):
mmc: davinci: fix unwinding in probe
mmc: davinci: prepare clock
ARM: davinci: remove mmc dma resources
Quoted 8 lines
arch/arm/mach-davinci/devices-da8xx.c | 20 ------- arch/arm/mach-davinci/devices.c | 16 ------ drivers/mmc/host/davinci_mmc.c | 100 ++++++++++++++-------------------- 3 files changed, 40 insertions(+), 96 deletions(-)--
1.9.1
Thanks, applied for next!
Kind regards
Uffe