devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Barry Song <21cnbao@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_device_alloc(sizeof(*st));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!indio_dev)
+ return -ENOMEM;
/* this is only used for removal purposes */
spi_set_drvdata(spi, indio_dev);
/* this is only used for removal purposes */
spi_set_drvdata(spi, indio_dev);
/* Get the device into a sane initial state */
ret = ade7759_initial_setup(indio_dev);
if (ret)
/* Get the device into a sane initial state */
ret = ade7759_initial_setup(indio_dev);
if (ret)
ret = iio_device_register(indio_dev);
if (ret)
ret = iio_device_register(indio_dev);
if (ret)
-
-error_free_dev:
- iio_device_free(indio_dev);
-error_ret:
- return ret;
}
/* fixme, confirm ordering in this function */
}
/* fixme, confirm ordering in this function */
iio_device_unregister(indio_dev);
ade7759_stop_device(&indio_dev->dev);
iio_device_unregister(indio_dev);
ade7759_stop_device(&indio_dev->dev);
- iio_device_free(indio_dev);