staging: iio: mxs-lradc: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
a8b168a15f
commit
073c33d552
|
@ -909,7 +909,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Allocate the IIO device. */
|
/* Allocate the IIO device. */
|
||||||
iio = iio_device_alloc(sizeof(*lradc));
|
iio = devm_iio_device_alloc(dev, sizeof(*lradc));
|
||||||
if (!iio) {
|
if (!iio) {
|
||||||
dev_err(dev, "Failed to allocate IIO device\n");
|
dev_err(dev, "Failed to allocate IIO device\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -921,10 +921,8 @@ static int mxs_lradc_probe(struct platform_device *pdev)
|
||||||
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
lradc->dev = &pdev->dev;
|
lradc->dev = &pdev->dev;
|
||||||
lradc->base = devm_ioremap_resource(dev, iores);
|
lradc->base = devm_ioremap_resource(dev, iores);
|
||||||
if (IS_ERR(lradc->base)) {
|
if (IS_ERR(lradc->base))
|
||||||
ret = PTR_ERR(lradc->base);
|
return PTR_ERR(lradc->base);
|
||||||
goto err_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_WORK(&lradc->ts_work, mxs_lradc_ts_work);
|
INIT_WORK(&lradc->ts_work, mxs_lradc_ts_work);
|
||||||
|
|
||||||
|
@ -944,16 +942,14 @@ static int mxs_lradc_probe(struct platform_device *pdev)
|
||||||
/* Grab all IRQ sources */
|
/* Grab all IRQ sources */
|
||||||
for (i = 0; i < of_cfg->irq_count; i++) {
|
for (i = 0; i < of_cfg->irq_count; i++) {
|
||||||
lradc->irq[i] = platform_get_irq(pdev, i);
|
lradc->irq[i] = platform_get_irq(pdev, i);
|
||||||
if (lradc->irq[i] < 0) {
|
if (lradc->irq[i] < 0)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto err_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = devm_request_irq(dev, lradc->irq[i],
|
ret = devm_request_irq(dev, lradc->irq[i],
|
||||||
mxs_lradc_handle_irq, 0,
|
mxs_lradc_handle_irq, 0,
|
||||||
of_cfg->irq_name[i], iio);
|
of_cfg->irq_name[i], iio);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_addr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, iio);
|
platform_set_drvdata(pdev, iio);
|
||||||
|
@ -973,7 +969,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
|
||||||
&mxs_lradc_trigger_handler,
|
&mxs_lradc_trigger_handler,
|
||||||
&mxs_lradc_buffer_ops);
|
&mxs_lradc_buffer_ops);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_addr;
|
return ret;
|
||||||
|
|
||||||
ret = mxs_lradc_trigger_init(iio);
|
ret = mxs_lradc_trigger_init(iio);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -1004,8 +1000,6 @@ err_dev:
|
||||||
mxs_lradc_trigger_remove(iio);
|
mxs_lradc_trigger_remove(iio);
|
||||||
err_trig:
|
err_trig:
|
||||||
iio_triggered_buffer_cleanup(iio);
|
iio_triggered_buffer_cleanup(iio);
|
||||||
err_addr:
|
|
||||||
iio_device_free(iio);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,7 +1015,6 @@ static int mxs_lradc_remove(struct platform_device *pdev)
|
||||||
iio_device_unregister(iio);
|
iio_device_unregister(iio);
|
||||||
iio_triggered_buffer_cleanup(iio);
|
iio_triggered_buffer_cleanup(iio);
|
||||||
mxs_lradc_trigger_remove(iio);
|
mxs_lradc_trigger_remove(iio);
|
||||||
iio_device_free(iio);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue