From 26d25ae3f0d8ffe350aacc75b71198d6b35bd1f4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 2 Sep 2011 17:14:40 +0100 Subject: staging:iio: rework of attribute registration. This set also includes quite a number of bug fixes of particularly remove functions. Necessary due to issue pointed out in Bart Van Assche's patch: docs/driver-model: Document device.groups V2: Rebase due to patch reordering. V3: Pull various error fixes and cleanups out into their own patches. Signed-off-by: Jonathan Cameron Acked-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/lis3l02dq_core.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'drivers/staging/iio/accel/lis3l02dq_core.c') diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 61d114a8b19..ee91cc719bc 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -663,7 +663,7 @@ static const struct iio_info lis3l02dq_info = { static int __devinit lis3l02dq_probe(struct spi_device *spi) { - int ret, regdone = 0; + int ret; struct lis3l02dq_state *st; struct iio_dev *indio_dev; @@ -690,11 +690,6 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) if (ret) goto error_free_dev; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unreg_ring_funcs; - regdone = 1; - ret = iio_ring_buffer_register(indio_dev, lis3l02dq_channels, ARRAY_SIZE(lis3l02dq_channels)); @@ -722,6 +717,11 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) ret = lis3l02dq_initial_setup(indio_dev); if (ret) goto error_remove_trigger; + + ret = iio_device_register(indio_dev); + if (ret) + goto error_remove_trigger; + return 0; error_remove_trigger: @@ -735,9 +735,6 @@ error_uninitialize_ring: error_unreg_ring_funcs: lis3l02dq_unconfigure_ring(indio_dev); error_free_dev: - if (regdone) - iio_device_unregister(indio_dev); - else iio_free_device(indio_dev); error_ret: return ret; @@ -790,9 +787,8 @@ static int lis3l02dq_remove(struct spi_device *spi) lis3l02dq_remove_trigger(indio_dev); iio_ring_buffer_unregister(indio_dev); lis3l02dq_unconfigure_ring(indio_dev); - iio_device_unregister(indio_dev); - return 0; + iio_device_unregister(indio_dev); err_ret: return ret; -- cgit v1.2.3