Using devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
return -EINVAL;
}
- indio_dev = iio_device_alloc(sizeof(*als));
+ indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*als));
if (!indio_dev)
return -ENOMEM;
if (als->irq) {
ret = lm3533_als_setup_irq(als, indio_dev);
if (ret)
- goto err_free_dev;
+ return ret;
}
ret = lm3533_als_setup(als, pdata);
err_free_irq:
if (als->irq)
free_irq(als->irq, indio_dev);
-err_free_dev:
- iio_device_free(indio_dev);
return ret;
}
lm3533_als_disable(als);
if (als->irq)
free_irq(als->irq, indio_dev);
- iio_device_free(indio_dev);
return 0;
}