Commit 1c459de1 authored by Daniel Mack's avatar Daniel Mack Committed by Mark Brown

ARM: pxa: ssp: use devm_ functions

Use devm_ functions to allocate memory, ioremap, clk_get etc to clean up
the error unwind path.
Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
Acked-by: default avatarHaojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent a6e56c28
...@@ -94,19 +94,16 @@ static int pxa_ssp_probe(struct platform_device *pdev) ...@@ -94,19 +94,16 @@ static int pxa_ssp_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
struct ssp_device *ssp; struct ssp_device *ssp;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int ret = 0;
ssp = kzalloc(sizeof(struct ssp_device), GFP_KERNEL); ssp = devm_kzalloc(dev, sizeof(struct ssp_device), GFP_KERNEL);
if (ssp == NULL) if (ssp == NULL)
return -ENOMEM; return -ENOMEM;
ssp->pdev = pdev; ssp->pdev = pdev;
ssp->clk = clk_get(dev, NULL); ssp->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ssp->clk)) { if (IS_ERR(ssp->clk))
ret = PTR_ERR(ssp->clk); return PTR_ERR(ssp->clk);
goto err_free;
}
if (dev->of_node) { if (dev->of_node) {
struct of_phandle_args dma_spec; struct of_phandle_args dma_spec;
...@@ -148,32 +145,28 @@ static int pxa_ssp_probe(struct platform_device *pdev) ...@@ -148,32 +145,28 @@ static int pxa_ssp_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) { if (res == NULL) {
dev_err(dev, "no memory resource defined\n"); dev_err(dev, "no memory resource defined\n");
ret = -ENODEV; return -ENODEV;
goto err_free_clk;
} }
res = request_mem_region(res->start, resource_size(res), res = devm_request_mem_region(dev, res->start, resource_size(res),
pdev->name); pdev->name);
if (res == NULL) { if (res == NULL) {
dev_err(dev, "failed to request memory resource\n"); dev_err(dev, "failed to request memory resource\n");
ret = -EBUSY; return -EBUSY;
goto err_free_clk;
} }
ssp->phys_base = res->start; ssp->phys_base = res->start;
ssp->mmio_base = ioremap(res->start, resource_size(res)); ssp->mmio_base = devm_ioremap(dev, res->start, resource_size(res));
if (ssp->mmio_base == NULL) { if (ssp->mmio_base == NULL) {
dev_err(dev, "failed to ioremap() registers\n"); dev_err(dev, "failed to ioremap() registers\n");
ret = -ENODEV; return -ENODEV;
goto err_free_mem;
} }
ssp->irq = platform_get_irq(pdev, 0); ssp->irq = platform_get_irq(pdev, 0);
if (ssp->irq < 0) { if (ssp->irq < 0) {
dev_err(dev, "no IRQ resource defined\n"); dev_err(dev, "no IRQ resource defined\n");
ret = -ENODEV; return -ENODEV;
goto err_free_io;
} }
if (dev->of_node) { if (dev->of_node) {
...@@ -198,17 +191,8 @@ static int pxa_ssp_probe(struct platform_device *pdev) ...@@ -198,17 +191,8 @@ static int pxa_ssp_probe(struct platform_device *pdev)
mutex_unlock(&ssp_lock); mutex_unlock(&ssp_lock);
platform_set_drvdata(pdev, ssp); platform_set_drvdata(pdev, ssp);
return 0;
err_free_io: return 0;
iounmap(ssp->mmio_base);
err_free_mem:
release_mem_region(res->start, resource_size(res));
err_free_clk:
clk_put(ssp->clk);
err_free:
kfree(ssp);
return ret;
} }
static int pxa_ssp_remove(struct platform_device *pdev) static int pxa_ssp_remove(struct platform_device *pdev)
......
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