Commit 4c247470 authored by Sachin Kamat's avatar Sachin Kamat Committed by Jonathan Cameron

staging: iio: lis3l02dq: Use devm_iio_device_alloc

Using devm_iio_device_alloc makes code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent e8cac7f6
...@@ -668,11 +668,9 @@ static int lis3l02dq_probe(struct spi_device *spi) ...@@ -668,11 +668,9 @@ static int lis3l02dq_probe(struct spi_device *spi)
struct lis3l02dq_state *st; struct lis3l02dq_state *st;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
indio_dev = iio_device_alloc(sizeof *st); indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL) { if (!indio_dev)
ret = -ENOMEM; return -ENOMEM;
goto error_ret;
}
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
/* this is only used for removal purposes */ /* this is only used for removal purposes */
spi_set_drvdata(spi, indio_dev); spi_set_drvdata(spi, indio_dev);
...@@ -690,7 +688,7 @@ static int lis3l02dq_probe(struct spi_device *spi) ...@@ -690,7 +688,7 @@ static int lis3l02dq_probe(struct spi_device *spi)
ret = lis3l02dq_configure_buffer(indio_dev); ret = lis3l02dq_configure_buffer(indio_dev);
if (ret) if (ret)
goto error_free_dev; return ret;
ret = iio_buffer_register(indio_dev, ret = iio_buffer_register(indio_dev,
lis3l02dq_channels, lis3l02dq_channels,
...@@ -736,9 +734,6 @@ static int lis3l02dq_probe(struct spi_device *spi) ...@@ -736,9 +734,6 @@ static int lis3l02dq_probe(struct spi_device *spi)
iio_buffer_unregister(indio_dev); iio_buffer_unregister(indio_dev);
error_unreg_buffer_funcs: error_unreg_buffer_funcs:
lis3l02dq_unconfigure_buffer(indio_dev); lis3l02dq_unconfigure_buffer(indio_dev);
error_free_dev:
iio_device_free(indio_dev);
error_ret:
return ret; return ret;
} }
...@@ -786,8 +781,6 @@ static int lis3l02dq_remove(struct spi_device *spi) ...@@ -786,8 +781,6 @@ static int lis3l02dq_remove(struct spi_device *spi)
iio_buffer_unregister(indio_dev); iio_buffer_unregister(indio_dev);
lis3l02dq_unconfigure_buffer(indio_dev); lis3l02dq_unconfigure_buffer(indio_dev);
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