diff mbox series

[01/10] iio: adis16201: Use Managed device functions

Message ID 20200915093345.85614-2-nuno.sa@analog.com
State New
Headers show
Series Use ADIS devm functions for trigger/buffer setup | expand

Commit Message

Nuno Sá Sept. 15, 2020, 9:33 a.m. UTC
Use the adis managed device functions to setup the buffer and the trigger.
The ultimate goal will be to completely drop the non devm version from
the lib.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/accel/adis16201.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

Comments

Jonathan Cameron Sept. 15, 2020, 10:05 a.m. UTC | #1
On Tue, 15 Sep 2020 11:33:36 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Use the adis managed device functions to setup the buffer and the trigger.
> The ultimate goal will be to completely drop the non devm version from
> the lib.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/accel/adis16201.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
> index 59a24c355a1a..a375ec25448a 100644
> --- a/drivers/iio/accel/adis16201.c
> +++ b/drivers/iio/accel/adis16201.c
> @@ -281,32 +281,22 @@ static int adis16201_probe(struct spi_device *spi)
>  	if (ret)
>  		return ret;
>  
> -	ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> +	ret = devm_adis_setup_buffer_and_trigger(st, indio_dev, NULL);
>  	if (ret)
>  		return ret;
>  
>  	ret = adis_initial_startup(st);
>  	if (ret)
> -		goto error_cleanup_buffer_trigger;
> -
> -	ret = iio_device_register(indio_dev);
> -	if (ret < 0)
> -		goto error_cleanup_buffer_trigger;
> -
> -	return 0;
> +		return ret;
>  
> -error_cleanup_buffer_trigger:
> -	adis_cleanup_buffer_and_trigger(st, indio_dev);
> -	return ret;
> +	return iio_device_register(indio_dev);
>  }
>  
>  static int adis16201_remove(struct spi_device *spi)
>  {
>  	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -	struct adis *st = iio_priv(indio_dev);
>  
>  	iio_device_unregister(indio_dev);

If all you have left in remove is a call to iio_device_unregister()
why not just use devm_iio_device_register in probe and drop the
remove function entirely?

> -	adis_cleanup_buffer_and_trigger(st, indio_dev);
>  
>  	return 0;
>  }
diff mbox series

Patch

diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
index 59a24c355a1a..a375ec25448a 100644
--- a/drivers/iio/accel/adis16201.c
+++ b/drivers/iio/accel/adis16201.c
@@ -281,32 +281,22 @@  static int adis16201_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
+	ret = devm_adis_setup_buffer_and_trigger(st, indio_dev, NULL);
 	if (ret)
 		return ret;
 
 	ret = adis_initial_startup(st);
 	if (ret)
-		goto error_cleanup_buffer_trigger;
-
-	ret = iio_device_register(indio_dev);
-	if (ret < 0)
-		goto error_cleanup_buffer_trigger;
-
-	return 0;
+		return ret;
 
-error_cleanup_buffer_trigger:
-	adis_cleanup_buffer_and_trigger(st, indio_dev);
-	return ret;
+	return iio_device_register(indio_dev);
 }
 
 static int adis16201_remove(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-	struct adis *st = iio_priv(indio_dev);
 
 	iio_device_unregister(indio_dev);
-	adis_cleanup_buffer_and_trigger(st, indio_dev);
 
 	return 0;
 }