Commit d8dbb4b3 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mark Brown

ASoC: samsung: pcm: Conversion to use devm_ioremap_resource()

This simplifies the code a bit and removes a hard coded IO memory
region size.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 990fcfef
...@@ -499,13 +499,6 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) ...@@ -499,13 +499,6 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev)
pcm_pdata = pdev->dev.platform_data; pcm_pdata = pdev->dev.platform_data;
/* Check for availability of necessary resource */
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem_res) {
dev_err(&pdev->dev, "Unable to get register resource\n");
return -ENXIO;
}
if (pcm_pdata && pcm_pdata->cfg_gpio && pcm_pdata->cfg_gpio(pdev)) { if (pcm_pdata && pcm_pdata->cfg_gpio && pcm_pdata->cfg_gpio(pdev)) {
dev_err(&pdev->dev, "Unable to configure gpio\n"); dev_err(&pdev->dev, "Unable to configure gpio\n");
return -EINVAL; return -EINVAL;
...@@ -519,36 +512,26 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) ...@@ -519,36 +512,26 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev)
/* Default is 128fs */ /* Default is 128fs */
pcm->sclk_per_fs = 128; pcm->sclk_per_fs = 128;
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
pcm->regs = devm_ioremap_resource(&pdev->dev, mem_res);
if (IS_ERR(pcm->regs))
return PTR_ERR(pcm->regs);
pcm->cclk = devm_clk_get(&pdev->dev, "audio-bus"); pcm->cclk = devm_clk_get(&pdev->dev, "audio-bus");
if (IS_ERR(pcm->cclk)) { if (IS_ERR(pcm->cclk)) {
dev_err(&pdev->dev, "failed to get audio-bus\n"); dev_err(&pdev->dev, "failed to get audio-bus clock\n");
ret = PTR_ERR(pcm->cclk); return PTR_ERR(pcm->cclk);
goto err1;
} }
clk_prepare_enable(pcm->cclk); clk_prepare_enable(pcm->cclk);
/* record our pcm structure for later use in the callbacks */ /* record our pcm structure for later use in the callbacks */
dev_set_drvdata(&pdev->dev, pcm); dev_set_drvdata(&pdev->dev, pcm);
if (!request_mem_region(mem_res->start,
resource_size(mem_res), "samsung-pcm")) {
dev_err(&pdev->dev, "Unable to request register region\n");
ret = -EBUSY;
goto err2;
}
pcm->regs = ioremap(mem_res->start, 0x100);
if (pcm->regs == NULL) {
dev_err(&pdev->dev, "cannot ioremap registers\n");
ret = -ENXIO;
goto err3;
}
pcm->pclk = devm_clk_get(&pdev->dev, "pcm"); pcm->pclk = devm_clk_get(&pdev->dev, "pcm");
if (IS_ERR(pcm->pclk)) { if (IS_ERR(pcm->pclk)) {
dev_err(&pdev->dev, "failed to get pcm_clock\n"); dev_err(&pdev->dev, "failed to get pcm clock\n");
ret = -ENOENT; ret = PTR_ERR(pcm->pclk);
goto err4; goto err_dis_cclk;
} }
clk_prepare_enable(pcm->pclk); clk_prepare_enable(pcm->pclk);
...@@ -569,7 +552,7 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) ...@@ -569,7 +552,7 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev)
NULL, NULL); NULL, NULL);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to get register DMA: %d\n", ret); dev_err(&pdev->dev, "failed to get register DMA: %d\n", ret);
goto err5; goto err_dis_pclk;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
...@@ -578,36 +561,25 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) ...@@ -578,36 +561,25 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev)
&s3c_pcm_dai[pdev->id], 1); &s3c_pcm_dai[pdev->id], 1);
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "failed to get register DAI: %d\n", ret); dev_err(&pdev->dev, "failed to get register DAI: %d\n", ret);
goto err6; goto err_dis_pm;
} }
return 0; return 0;
err6:
err_dis_pm:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err5: err_dis_pclk:
clk_disable_unprepare(pcm->pclk); clk_disable_unprepare(pcm->pclk);
err4: err_dis_cclk:
iounmap(pcm->regs);
err3:
release_mem_region(mem_res->start, resource_size(mem_res));
err2:
clk_disable_unprepare(pcm->cclk); clk_disable_unprepare(pcm->cclk);
err1:
return ret; return ret;
} }
static int s3c_pcm_dev_remove(struct platform_device *pdev) static int s3c_pcm_dev_remove(struct platform_device *pdev)
{ {
struct s3c_pcm_info *pcm = &s3c_pcm[pdev->id]; struct s3c_pcm_info *pcm = &s3c_pcm[pdev->id];
struct resource *mem_res;
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
iounmap(pcm->regs);
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(mem_res->start, resource_size(mem_res));
clk_disable_unprepare(pcm->cclk); clk_disable_unprepare(pcm->cclk);
clk_disable_unprepare(pcm->pclk); clk_disable_unprepare(pcm->pclk);
......
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