提交 f8837532 编写于 作者: S Sachin Kamat 提交者: Jonathan Cameron

iio: at91: Use devm_iio_device_alloc

Using devm_iio_device_alloc makes code simpler.
Signed-off-by: NSachin Kamat <sachin.kamat@linaro.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 3ef50f88
...@@ -589,11 +589,9 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -589,11 +589,9 @@ static int at91_adc_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
u32 reg; u32 reg;
idev = iio_device_alloc(sizeof(struct at91_adc_state)); idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
if (idev == NULL) { if (!idev)
ret = -ENOMEM; return -ENOMEM;
goto error_ret;
}
st = iio_priv(idev); st = iio_priv(idev);
...@@ -604,8 +602,7 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -604,8 +602,7 @@ static int at91_adc_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, "No platform data available.\n"); dev_err(&pdev->dev, "No platform data available.\n");
ret = -EINVAL; return -EINVAL;
goto error_free_device;
} }
platform_set_drvdata(pdev, idev); platform_set_drvdata(pdev, idev);
...@@ -618,16 +615,14 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -618,16 +615,14 @@ static int at91_adc_probe(struct platform_device *pdev)
st->irq = platform_get_irq(pdev, 0); st->irq = platform_get_irq(pdev, 0);
if (st->irq < 0) { if (st->irq < 0) {
dev_err(&pdev->dev, "No IRQ ID is designated\n"); dev_err(&pdev->dev, "No IRQ ID is designated\n");
ret = -ENODEV; return -ENODEV;
goto error_free_device;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
st->reg_base = devm_ioremap_resource(&pdev->dev, res); st->reg_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(st->reg_base)) { if (IS_ERR(st->reg_base)) {
ret = PTR_ERR(st->reg_base); return PTR_ERR(st->reg_base);
goto error_free_device;
} }
/* /*
...@@ -642,7 +637,7 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -642,7 +637,7 @@ static int at91_adc_probe(struct platform_device *pdev)
idev); idev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to allocate IRQ.\n"); dev_err(&pdev->dev, "Failed to allocate IRQ.\n");
goto error_free_device; return ret;
} }
st->clk = devm_clk_get(&pdev->dev, "adc_clk"); st->clk = devm_clk_get(&pdev->dev, "adc_clk");
...@@ -752,9 +747,6 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -752,9 +747,6 @@ static int at91_adc_probe(struct platform_device *pdev)
clk_disable_unprepare(st->clk); clk_disable_unprepare(st->clk);
error_free_irq: error_free_irq:
free_irq(st->irq, idev); free_irq(st->irq, idev);
error_free_device:
iio_device_free(idev);
error_ret:
return ret; return ret;
} }
...@@ -769,7 +761,6 @@ static int at91_adc_remove(struct platform_device *pdev) ...@@ -769,7 +761,6 @@ static int at91_adc_remove(struct platform_device *pdev)
clk_disable_unprepare(st->adc_clk); clk_disable_unprepare(st->adc_clk);
clk_disable_unprepare(st->clk); clk_disable_unprepare(st->clk);
free_irq(st->irq, idev); free_irq(st->irq, idev);
iio_device_free(idev);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册