diff mbox series

[3/3] iio: adc: ad7923: register device with devm_iio_device_register

Message ID b0146465d52f4e259f5f95c83c71e72f065093da.1616966903.git.lucas.p.stankus@gmail.com (mailing list archive)
State New, archived
Headers show
Series iio: adc: ad7923: convert driver resources routines to device-managed counterparts | expand

Commit Message

Lucas Stankus March 28, 2021, 9:46 p.m. UTC
Registers the device using the devm variant.
This is the final step of converting the ad7923 to only use devm routines,
meaning that the ad7923_remove() function is no longer needed to release
resources on device detach.

Signed-off-by: Lucas Stankus <lucas.p.stankus@gmail.com>
---
 drivers/iio/adc/ad7923.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

Comments

Lars-Peter Clausen March 29, 2021, 7:06 a.m. UTC | #1
On 3/28/21 11:46 PM, Lucas Stankus wrote:
> Registers the device using the devm variant.
> This is the final step of converting the ad7923 to only use devm routines,
> meaning that the ad7923_remove() function is no longer needed to release
> resources on device detach.
> 
> Signed-off-by: Lucas Stankus <lucas.p.stankus@gmail.com>

Hi,

Thanks for the patches.T his looks good, just one small comment.

> ---
>   drivers/iio/adc/ad7923.c | 12 +-----------
>   1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index d07eaf3111ed..f7af2f194789 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -356,16 +356,7 @@ static int ad7923_probe(struct spi_device *spi)
>   	if (ret)
>   		return ret;
>   
> -	return iio_device_register(indio_dev);
> -}
> -
> -static int ad7923_remove(struct spi_device *spi)
> -{
> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);

This removes the last user of get_drvdata() on the SPI device. This means you 
can also remove the spi_set_drvdata() in the probe function.

> -
> -	iio_device_unregister(indio_dev);
> -
> -	return 0;
> +	return devm_iio_device_register(&spi->dev, indio_dev);
>   }
Jonathan Cameron March 29, 2021, 11:18 a.m. UTC | #2
On Mon, 29 Mar 2021 09:06:14 +0200
Lars-Peter Clausen <lars@metafoo.de> wrote:

> On 3/28/21 11:46 PM, Lucas Stankus wrote:
> > Registers the device using the devm variant.
> > This is the final step of converting the ad7923 to only use devm routines,
> > meaning that the ad7923_remove() function is no longer needed to release
> > resources on device detach.
> > 
> > Signed-off-by: Lucas Stankus <lucas.p.stankus@gmail.com>  
> 
> Hi,
> 
> Thanks for the patches.T his looks good, just one small comment.

On basis of saving everyone time, I've fixed up the comment from Lars
below whilst applying.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to see if they can find anything we missed.

Thanks,

Jonathan

> 
> > ---
> >   drivers/iio/adc/ad7923.c | 12 +-----------
> >   1 file changed, 1 insertion(+), 11 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> > index d07eaf3111ed..f7af2f194789 100644
> > --- a/drivers/iio/adc/ad7923.c
> > +++ b/drivers/iio/adc/ad7923.c
> > @@ -356,16 +356,7 @@ static int ad7923_probe(struct spi_device *spi)
> >   	if (ret)
> >   		return ret;
> >   
> > -	return iio_device_register(indio_dev);
> > -}
> > -
> > -static int ad7923_remove(struct spi_device *spi)
> > -{
> > -	struct iio_dev *indio_dev = spi_get_drvdata(spi);  
> 
> This removes the last user of get_drvdata() on the SPI device. This means you 
> can also remove the spi_set_drvdata() in the probe function.
> 
> > -
> > -	iio_device_unregister(indio_dev);
> > -
> > -	return 0;
> > +	return devm_iio_device_register(&spi->dev, indio_dev);
> >   }
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index d07eaf3111ed..f7af2f194789 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -356,16 +356,7 @@  static int ad7923_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	return iio_device_register(indio_dev);
-}
-
-static int ad7923_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
-	iio_device_unregister(indio_dev);
-
-	return 0;
+	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
 static const struct spi_device_id ad7923_id[] = {
@@ -398,7 +389,6 @@  static struct spi_driver ad7923_driver = {
 		.of_match_table = ad7923_of_match,
 	},
 	.probe		= ad7923_probe,
-	.remove		= ad7923_remove,
 	.id_table	= ad7923_id,
 };
 module_spi_driver(ad7923_driver);