diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-08-24 19:48:00 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-28 20:20:25 +0100 |
commit | 4c247470531d437acf3b78b8d2bd08222395ecc9 (patch) | |
tree | 3908653dcc8232ee002542b53bee52dcd065a006 /drivers/staging | |
parent | e8cac7f61452d45cd4bca8cb11c139edc9633f38 (diff) | |
download | op-kernel-dev-4c247470531d437acf3b78b8d2bd08222395ecc9.zip op-kernel-dev-4c247470531d437acf3b78b8d2bd08222395ecc9.tar.gz |
staging: iio: lis3l02dq: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/iio/accel/lis3l02dq_core.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 8ed75a9..bb852dc 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -668,11 +668,9 @@ static int lis3l02dq_probe(struct spi_device *spi) struct lis3l02dq_state *st; struct iio_dev *indio_dev; - 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; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -690,7 +688,7 @@ static int lis3l02dq_probe(struct spi_device *spi) ret = lis3l02dq_configure_buffer(indio_dev); if (ret) - goto error_free_dev; + return ret; ret = iio_buffer_register(indio_dev, lis3l02dq_channels, @@ -736,9 +734,6 @@ error_uninitialize_buffer: iio_buffer_unregister(indio_dev); error_unreg_buffer_funcs: lis3l02dq_unconfigure_buffer(indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -786,8 +781,6 @@ static int lis3l02dq_remove(struct spi_device *spi) iio_buffer_unregister(indio_dev); lis3l02dq_unconfigure_buffer(indio_dev); - iio_device_free(indio_dev); - return 0; } |