提交 b4dd05de 编写于 作者: L Laurent Pinchart 提交者: Mark Brown

spi: sh-msiof: Use devm_* managed allocators

This simplifies error and cleanup code paths.
Signed-off-by: NLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 7ad35442
...@@ -635,8 +635,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) ...@@ -635,8 +635,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
master = spi_alloc_master(&pdev->dev, sizeof(struct sh_msiof_spi_priv)); master = spi_alloc_master(&pdev->dev, sizeof(struct sh_msiof_spi_priv));
if (master == NULL) { if (master == NULL) {
dev_err(&pdev->dev, "failed to allocate spi master\n"); dev_err(&pdev->dev, "failed to allocate spi master\n");
ret = -ENOMEM; return -ENOMEM;
goto err0;
} }
p = spi_master_get_devdata(master); p = spi_master_get_devdata(master);
...@@ -655,32 +654,32 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) ...@@ -655,32 +654,32 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
init_completion(&p->done); init_completion(&p->done);
p->clk = clk_get(&pdev->dev, NULL); p->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(p->clk)) { if (IS_ERR(p->clk)) {
dev_err(&pdev->dev, "cannot get clock\n"); dev_err(&pdev->dev, "cannot get clock\n");
ret = PTR_ERR(p->clk); ret = PTR_ERR(p->clk);
goto err1; goto err1;
} }
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
i = platform_get_irq(pdev, 0); i = platform_get_irq(pdev, 0);
if (!r || i < 0) { if (i < 0) {
dev_err(&pdev->dev, "cannot get platform resources\n"); dev_err(&pdev->dev, "cannot get platform IRQ\n");
ret = -ENOENT; ret = -ENOENT;
goto err2; goto err1;
} }
p->mapbase = ioremap_nocache(r->start, resource_size(r));
if (!p->mapbase) { r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dev_err(&pdev->dev, "unable to ioremap\n"); p->mapbase = devm_ioremap_resource(&pdev->dev, r);
ret = -ENXIO; if (IS_ERR(p->mapbase)) {
goto err2; ret = PTR_ERR(p->mapbase);
goto err1;
} }
ret = request_irq(i, sh_msiof_spi_irq, 0, ret = devm_request_irq(&pdev->dev, i, sh_msiof_spi_irq, 0,
dev_name(&pdev->dev), p); dev_name(&pdev->dev), p);
if (ret) { if (ret) {
dev_err(&pdev->dev, "unable to request irq\n"); dev_err(&pdev->dev, "unable to request irq\n");
goto err3; goto err1;
} }
p->pdev = pdev; p->pdev = pdev;
...@@ -719,13 +718,8 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) ...@@ -719,13 +718,8 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
return 0; return 0;
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err3:
iounmap(p->mapbase);
err2:
clk_put(p->clk);
err1: err1:
spi_master_put(master); spi_master_put(master);
err0:
return ret; return ret;
} }
...@@ -737,9 +731,6 @@ static int sh_msiof_spi_remove(struct platform_device *pdev) ...@@ -737,9 +731,6 @@ static int sh_msiof_spi_remove(struct platform_device *pdev)
ret = spi_bitbang_stop(&p->bitbang); ret = spi_bitbang_stop(&p->bitbang);
if (!ret) { if (!ret) {
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
free_irq(platform_get_irq(pdev, 0), p);
iounmap(p->mapbase);
clk_put(p->clk);
spi_master_put(p->bitbang.master); spi_master_put(p->bitbang.master);
} }
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册