diff mbox series

[03/10] iio: adis16136: Use Managed device functions

Message ID 20200915093345.85614-4-nuno.sa@analog.com (mailing list archive)
State New, archived
Headers show
Series Use ADIS devm functions for trigger/buffer setup | expand

Commit Message

Nuno Sa 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/gyro/adis16136.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Jonathan Cameron Sept. 15, 2020, 10:06 a.m. UTC | #1
On Tue, 15 Sep 2020 11:33:38 +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/gyro/adis16136.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
> index d8a96f6bbae2..a4b060d9d23f 100644
> --- a/drivers/iio/gyro/adis16136.c
> +++ b/drivers/iio/gyro/adis16136.c
> @@ -552,13 +552,13 @@ static int adis16136_probe(struct spi_device *spi)
>  	if (ret)
>  		return ret;
>  
> -	ret = adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL);
> +	ret = devm_adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL);
>  	if (ret)
>  		return ret;
>  
>  	ret = adis16136_initial_setup(indio_dev);
>  	if (ret)
> -		goto error_cleanup_buffer;
> +		return ret;
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret)
> @@ -570,21 +570,16 @@ static int adis16136_probe(struct spi_device *spi)
>  
>  error_stop_device:
>  	adis16136_stop_device(indio_dev);
> -error_cleanup_buffer:
> -	adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev);
>  	return ret;
>  }
>  
>  static int adis16136_remove(struct spi_device *spi)
>  {
>  	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -	struct adis16136 *adis16136 = iio_priv(indio_dev);
>  
>  	iio_device_unregister(indio_dev);
>  	adis16136_stop_device(indio_dev);

As adis16136_stop_device() is always run in remove, I'd suggest using
devm_add_action_or_reset at appropriate place in probe to use
the automated unrolling for that as well, letting you get rid of this
remove function.

>  
> -	adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev);
> -
>  	return 0;
>  }
>
diff mbox series

Patch

diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
index d8a96f6bbae2..a4b060d9d23f 100644
--- a/drivers/iio/gyro/adis16136.c
+++ b/drivers/iio/gyro/adis16136.c
@@ -552,13 +552,13 @@  static int adis16136_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	ret = adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL);
+	ret = devm_adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL);
 	if (ret)
 		return ret;
 
 	ret = adis16136_initial_setup(indio_dev);
 	if (ret)
-		goto error_cleanup_buffer;
+		return ret;
 
 	ret = iio_device_register(indio_dev);
 	if (ret)
@@ -570,21 +570,16 @@  static int adis16136_probe(struct spi_device *spi)
 
 error_stop_device:
 	adis16136_stop_device(indio_dev);
-error_cleanup_buffer:
-	adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev);
 	return ret;
 }
 
 static int adis16136_remove(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-	struct adis16136 *adis16136 = iio_priv(indio_dev);
 
 	iio_device_unregister(indio_dev);
 	adis16136_stop_device(indio_dev);
 
-	adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev);
-
 	return 0;
 }