Commit c8eaed45 authored by Sachin Kamat's avatar Sachin Kamat Committed by Lee Jones

mfd: davinci_voicecodec: Convert to use devm_* APIs

devm_* APIs are device managed and make code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent e5784388
...@@ -46,7 +46,7 @@ void davinci_vc_write(struct davinci_vc *davinci_vc, ...@@ -46,7 +46,7 @@ void davinci_vc_write(struct davinci_vc *davinci_vc,
static int __init davinci_vc_probe(struct platform_device *pdev) static int __init davinci_vc_probe(struct platform_device *pdev)
{ {
struct davinci_vc *davinci_vc; struct davinci_vc *davinci_vc;
struct resource *res, *mem; struct resource *res;
struct mfd_cell *cell = NULL; struct mfd_cell *cell = NULL;
int ret; int ret;
...@@ -58,7 +58,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev) ...@@ -58,7 +58,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
davinci_vc->clk = clk_get(&pdev->dev, NULL); davinci_vc->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(davinci_vc->clk)) { if (IS_ERR(davinci_vc->clk)) {
dev_dbg(&pdev->dev, dev_dbg(&pdev->dev,
"could not get the clock for voice codec\n"); "could not get the clock for voice codec\n");
...@@ -67,35 +67,18 @@ static int __init davinci_vc_probe(struct platform_device *pdev) ...@@ -67,35 +67,18 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
clk_enable(davinci_vc->clk); clk_enable(davinci_vc->clk);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "no mem resource\n");
ret = -ENODEV;
goto fail2;
}
davinci_vc->pbase = res->start;
davinci_vc->base_size = resource_size(res);
mem = request_mem_region(davinci_vc->pbase, davinci_vc->base_size, davinci_vc->base = devm_ioremap_resource(&pdev->dev, res);
pdev->name); if (IS_ERR(davinci_vc->base)) {
if (!mem) { ret = PTR_ERR(davinci_vc->base);
dev_err(&pdev->dev, "VCIF region already claimed\n"); goto fail;
ret = -EBUSY;
goto fail2;
}
davinci_vc->base = ioremap(davinci_vc->pbase, davinci_vc->base_size);
if (!davinci_vc->base) {
dev_err(&pdev->dev, "can't ioremap mem resource.\n");
ret = -ENOMEM;
goto fail3;
} }
res = platform_get_resource(pdev, IORESOURCE_DMA, 0); res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
if (!res) { if (!res) {
dev_err(&pdev->dev, "no DMA resource\n"); dev_err(&pdev->dev, "no DMA resource\n");
ret = -ENXIO; ret = -ENXIO;
goto fail4; goto fail;
} }
davinci_vc->davinci_vcif.dma_tx_channel = res->start; davinci_vc->davinci_vcif.dma_tx_channel = res->start;
...@@ -106,7 +89,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev) ...@@ -106,7 +89,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
if (!res) { if (!res) {
dev_err(&pdev->dev, "no DMA resource\n"); dev_err(&pdev->dev, "no DMA resource\n");
ret = -ENXIO; ret = -ENXIO;
goto fail4; goto fail;
} }
davinci_vc->davinci_vcif.dma_rx_channel = res->start; davinci_vc->davinci_vcif.dma_rx_channel = res->start;
...@@ -132,19 +115,13 @@ static int __init davinci_vc_probe(struct platform_device *pdev) ...@@ -132,19 +115,13 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
DAVINCI_VC_CELLS, NULL, 0, NULL); DAVINCI_VC_CELLS, NULL, 0, NULL);
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "fail to register client devices\n"); dev_err(&pdev->dev, "fail to register client devices\n");
goto fail4; goto fail;
} }
return 0; return 0;
fail4: fail:
iounmap(davinci_vc->base);
fail3:
release_mem_region(davinci_vc->pbase, davinci_vc->base_size);
fail2:
clk_disable(davinci_vc->clk); clk_disable(davinci_vc->clk);
clk_put(davinci_vc->clk);
davinci_vc->clk = NULL;
return ret; return ret;
} }
...@@ -155,12 +132,7 @@ static int davinci_vc_remove(struct platform_device *pdev) ...@@ -155,12 +132,7 @@ static int davinci_vc_remove(struct platform_device *pdev)
mfd_remove_devices(&pdev->dev); mfd_remove_devices(&pdev->dev);
iounmap(davinci_vc->base);
release_mem_region(davinci_vc->pbase, davinci_vc->base_size);
clk_disable(davinci_vc->clk); clk_disable(davinci_vc->clk);
clk_put(davinci_vc->clk);
davinci_vc->clk = NULL;
return 0; return 0;
} }
......
...@@ -112,8 +112,6 @@ struct davinci_vc { ...@@ -112,8 +112,6 @@ struct davinci_vc {
/* Memory resources */ /* Memory resources */
void __iomem *base; void __iomem *base;
resource_size_t pbase;
size_t base_size;
/* MFD cells */ /* MFD cells */
struct mfd_cell cells[DAVINCI_VC_CELLS]; struct mfd_cell cells[DAVINCI_VC_CELLS];
......
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