linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Martin Kaiser <martin@kaiser.cx>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: max5481: use devres for iio device registration
Date: Sun, 18 Aug 2019 18:18:53 +0100	[thread overview]
Message-ID: <20190818181853.106171a7@archlinux> (raw)
In-Reply-To: <20190814092144.10980-1-martin@kaiser.cx>

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);
>  }


      reply	other threads:[~2019-08-18 17:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14  9:21 [PATCH] iio: max5481: use devres for iio device registration Martin Kaiser
2019-08-18 17:18 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190818181853.106171a7@archlinux \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@kaiser.cx \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).