Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] iio: max5481: use devres for iio device registration
@ 2019-08-14  9:21 Martin Kaiser
  2019-08-18 17:18 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kaiser @ 2019-08-14  9:21 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
	Lars-Peter Clausen
  Cc: linux-iio, linux-kernel, Martin Kaiser

Replace iio_device_register with the devres variant and drop the
explicit function call to unregister the iio device.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/iio/potentiometer/max5481.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iio/potentiometer/max5481.c b/drivers/iio/potentiometer/max5481.c
index 732375b6d131..40b7212e68dc 100644
--- a/drivers/iio/potentiometer/max5481.c
+++ b/drivers/iio/potentiometer/max5481.c
@@ -162,7 +162,7 @@ static int max5481_probe(struct spi_device *spi)
 	if (ret < 0)
 		return ret;
 
-	return iio_device_register(indio_dev);
+	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
 static int max5481_remove(struct spi_device *spi)
@@ -170,8 +170,6 @@ static int max5481_remove(struct spi_device *spi)
 	struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev);
 	struct max5481_data *data = iio_priv(indio_dev);
 
-	iio_device_unregister(indio_dev);
-
 	/* save wiper reg to NV reg */
 	return max5481_write_cmd(data, MAX5481_COPY_AB_TO_NV, 0);
 }
-- 
2.11.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: max5481: use devres for iio device registration
  2019-08-14  9:21 [PATCH] iio: max5481: use devres for iio device registration Martin Kaiser
@ 2019-08-18 17:18 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-08-18 17:18 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Hartmut Knaack, Peter Meerwald-Stadler, Lars-Peter Clausen,
	linux-iio, linux-kernel

On Wed, 14 Aug 2019 11:21:44 +0200
Martin Kaiser <martin@kaiser.cx> wrote:

> Replace iio_device_register with the devres variant and drop the
> explicit function call to unregister the iio device.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
This changes the order of removal compared to probe as now we don't remove
the userspace interface before storing to non volatile memory.

Admittedly it's a pretty unlikely race to hit but I don't want to set
a precedent of judging just how unlikely a race is.

I'm also not keen to use dev_add_action_or_reset for this one as the
action in remove is not balanced to one in probe - I want to see it
clearly laid out in code, as it currently is.

So a no on this sort of change in this particular driver.

Thanks,

Jonathan

> ---
>  drivers/iio/potentiometer/max5481.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/potentiometer/max5481.c b/drivers/iio/potentiometer/max5481.c
> index 732375b6d131..40b7212e68dc 100644
> --- a/drivers/iio/potentiometer/max5481.c
> +++ b/drivers/iio/potentiometer/max5481.c
> @@ -162,7 +162,7 @@ static int max5481_probe(struct spi_device *spi)
>  	if (ret < 0)
>  		return ret;
>  
> -	return iio_device_register(indio_dev);
> +	return devm_iio_device_register(&spi->dev, indio_dev);
>  }
>  
>  static int max5481_remove(struct spi_device *spi)
> @@ -170,8 +170,6 @@ static int max5481_remove(struct spi_device *spi)
>  	struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev);
>  	struct max5481_data *data = iio_priv(indio_dev);
>  
> -	iio_device_unregister(indio_dev);
> -
>  	/* save wiper reg to NV reg */
>  	return max5481_write_cmd(data, MAX5481_COPY_AB_TO_NV, 0);
>  }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14  9:21 [PATCH] iio: max5481: use devres for iio device registration Martin Kaiser
2019-08-18 17:18 ` Jonathan Cameron

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox