Using devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
struct iio_dev *indio_dev;
int ret;
struct iio_dev *indio_dev;
int ret;
- indio_dev = iio_device_alloc(sizeof(*st));
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
if (indio_dev == NULL)
return -ENOMEM;
ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
if (ret)
ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
if (ret)
ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev,
adis16400_trigger_handler);
if (ret)
ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev,
adis16400_trigger_handler);
if (ret)
/* Get the device into a sane initial state */
ret = adis16400_initial_setup(indio_dev);
/* Get the device into a sane initial state */
ret = adis16400_initial_setup(indio_dev);
error_cleanup_buffer:
adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
error_cleanup_buffer:
adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
-error_free_dev:
- iio_device_free(indio_dev);
adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
- iio_device_free(indio_dev);
-