diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-08-24 14:48:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-28 15:20:25 -0400 |
commit | 4c247470531d437acf3b78b8d2bd08222395ecc9 (patch) | |
tree | 3908653dcc8232ee002542b53bee52dcd065a006 | |
parent | e8cac7f61452d45cd4bca8cb11c139edc9633f38 (diff) |
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>
-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 8ed75a94f465..bb852dc9c987 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) | |||
668 | struct lis3l02dq_state *st; | 668 | struct lis3l02dq_state *st; |
669 | struct iio_dev *indio_dev; | 669 | struct iio_dev *indio_dev; |
670 | 670 | ||
671 | indio_dev = iio_device_alloc(sizeof *st); | 671 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
672 | if (indio_dev == NULL) { | 672 | if (!indio_dev) |
673 | ret = -ENOMEM; | 673 | return -ENOMEM; |
674 | goto error_ret; | ||
675 | } | ||
676 | st = iio_priv(indio_dev); | 674 | st = iio_priv(indio_dev); |
677 | /* this is only used for removal purposes */ | 675 | /* this is only used for removal purposes */ |
678 | spi_set_drvdata(spi, indio_dev); | 676 | spi_set_drvdata(spi, indio_dev); |
@@ -690,7 +688,7 @@ static int lis3l02dq_probe(struct spi_device *spi) | |||
690 | 688 | ||
691 | ret = lis3l02dq_configure_buffer(indio_dev); | 689 | ret = lis3l02dq_configure_buffer(indio_dev); |
692 | if (ret) | 690 | if (ret) |
693 | goto error_free_dev; | 691 | return ret; |
694 | 692 | ||
695 | ret = iio_buffer_register(indio_dev, | 693 | ret = iio_buffer_register(indio_dev, |
696 | lis3l02dq_channels, | 694 | lis3l02dq_channels, |
@@ -736,9 +734,6 @@ error_uninitialize_buffer: | |||
736 | iio_buffer_unregister(indio_dev); | 734 | iio_buffer_unregister(indio_dev); |
737 | error_unreg_buffer_funcs: | 735 | error_unreg_buffer_funcs: |
738 | lis3l02dq_unconfigure_buffer(indio_dev); | 736 | lis3l02dq_unconfigure_buffer(indio_dev); |
739 | error_free_dev: | ||
740 | iio_device_free(indio_dev); | ||
741 | error_ret: | ||
742 | return ret; | 737 | return ret; |
743 | } | 738 | } |
744 | 739 | ||
@@ -786,8 +781,6 @@ static int lis3l02dq_remove(struct spi_device *spi) | |||
786 | iio_buffer_unregister(indio_dev); | 781 | iio_buffer_unregister(indio_dev); |
787 | lis3l02dq_unconfigure_buffer(indio_dev); | 782 | lis3l02dq_unconfigure_buffer(indio_dev); |
788 | 783 | ||
789 | iio_device_free(indio_dev); | ||
790 | |||
791 | return 0; | 784 | return 0; |
792 | } | 785 | } |
793 | 786 | ||