Commit a0648130 authored by Sachin Kamat's avatar Sachin Kamat Committed by Jonathan Cameron

iio: adc: ti_am335x_adc: Use devm_iio_device_alloc

Using devm_iio_device_alloc makes code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Cc: Rachna Patil <rachna@ti.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 224b995a
...@@ -202,11 +202,11 @@ static int tiadc_probe(struct platform_device *pdev) ...@@ -202,11 +202,11 @@ static int tiadc_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
indio_dev = iio_device_alloc(sizeof(struct tiadc_device)); indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct tiadc_device));
if (indio_dev == NULL) { if (indio_dev == NULL) {
dev_err(&pdev->dev, "failed to allocate iio device\n"); dev_err(&pdev->dev, "failed to allocate iio device\n");
err = -ENOMEM; return -ENOMEM;
goto err_ret;
} }
adc_dev = iio_priv(indio_dev); adc_dev = iio_priv(indio_dev);
...@@ -227,7 +227,7 @@ static int tiadc_probe(struct platform_device *pdev) ...@@ -227,7 +227,7 @@ static int tiadc_probe(struct platform_device *pdev)
err = tiadc_channel_init(indio_dev, adc_dev->channels); err = tiadc_channel_init(indio_dev, adc_dev->channels);
if (err < 0) if (err < 0)
goto err_free_device; return err;
err = iio_device_register(indio_dev); err = iio_device_register(indio_dev);
if (err) if (err)
...@@ -239,9 +239,6 @@ static int tiadc_probe(struct platform_device *pdev) ...@@ -239,9 +239,6 @@ static int tiadc_probe(struct platform_device *pdev)
err_free_channels: err_free_channels:
tiadc_channels_remove(indio_dev); tiadc_channels_remove(indio_dev);
err_free_device:
iio_device_free(indio_dev);
err_ret:
return err; return err;
} }
...@@ -257,8 +254,6 @@ static int tiadc_remove(struct platform_device *pdev) ...@@ -257,8 +254,6 @@ static int tiadc_remove(struct platform_device *pdev)
step_en = get_adc_step_mask(adc_dev); step_en = get_adc_step_mask(adc_dev);
am335x_tsc_se_clr(adc_dev->mfd_tscadc, step_en); am335x_tsc_se_clr(adc_dev->mfd_tscadc, step_en);
iio_device_free(indio_dev);
return 0; return 0;
} }
......
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