linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Beniamin Bia <beniamin.bia@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<knaack.h@gmx.de>, <pmeerw@pmeerw.net>,
	<Michael.Hennerich@analog.com>, <biabeniamin@outlook.com>
Subject: Re: [PATCH 4/4] iio: adc: ad7476: implement devm_add_action_or_reset
Date: Sun, 15 Mar 2020 13:18:06 +0000	[thread overview]
Message-ID: <20200315131806.61e1d3f8@archlinux> (raw)
In-Reply-To: <20200311084328.17680-4-beniamin.bia@analog.com>

On Wed, 11 Mar 2020 10:43:28 +0200
Beniamin Bia <beniamin.bia@analog.com> wrote:

> Use devm_add_action_or_reset to automatically disable the device
> when it is removed or an error occurs during probe routine.
> 
> Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Applied,

Thanks,

Jonathan
> ---
>  drivers/iio/adc/ad7476.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index cd7d42df2033..e9984a38fc4c 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -256,6 +256,13 @@ static const struct iio_info ad7476_info = {
>  	.read_raw = &ad7476_read_raw,
>  };
>  
> +static void ad7476_reg_disable(void *data)
> +{
> +	struct ad7476_state *st = data;
> +
> +	regulator_disable(st->reg);
> +}
> +
>  static int ad7476_probe(struct spi_device *spi)
>  {
>  	struct ad7476_state *st;
> @@ -278,6 +285,11 @@ static int ad7476_probe(struct spi_device *spi)
>  	if (ret)
>  		return ret;
>  
> +	ret = devm_add_action_or_reset(&spi->dev, ad7476_reg_disable,
> +				       st);
> +	if (ret)
> +		return ret;
> +
>  	st->convst_gpio = devm_gpiod_get_optional(&spi->dev,
>  						  "adi,conversion-start",
>  						  GPIOD_OUT_LOW);
> @@ -328,18 +340,6 @@ static int ad7476_probe(struct spi_device *spi)
>  	return ret;
>  }
>  
> -static int ad7476_remove(struct spi_device *spi)
> -{
> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -	struct ad7476_state *st = iio_priv(indio_dev);
> -
> -	iio_device_unregister(indio_dev);
> -	iio_triggered_buffer_cleanup(indio_dev);
> -	regulator_disable(st->reg);
> -
> -	return 0;
> -}
> -
>  static const struct spi_device_id ad7476_id[] = {
>  	{"ad7091", ID_AD7091R},
>  	{"ad7091r", ID_AD7091R},
> @@ -377,7 +377,6 @@ static struct spi_driver ad7476_driver = {
>  		.name	= "ad7476",
>  	},
>  	.probe		= ad7476_probe,
> -	.remove		= ad7476_remove,
>  	.id_table	= ad7476_id,
>  };
>  module_spi_driver(ad7476_driver);


  reply	other threads:[~2020-03-15 13:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11  8:43 [PATCH 1/4] iio: adc: ad7476: Generate CONVST signal internally Beniamin Bia
2020-03-11  8:43 ` [PATCH 2/4] iio: adc: ad7476: Add IIO_CHAN_INFO_RAW for AD7091R Beniamin Bia
2020-03-15 13:16   ` Jonathan Cameron
2020-03-11  8:43 ` [PATCH 3/4] iio: adc: ad7476: Add AD7091 support Beniamin Bia
2020-03-15 13:17   ` Jonathan Cameron
2020-03-11  8:43 ` [PATCH 4/4] iio: adc: ad7476: implement devm_add_action_or_reset Beniamin Bia
2020-03-15 13:18   ` Jonathan Cameron [this message]
2020-03-15 13:15 ` [PATCH 1/4] iio: adc: ad7476: Generate CONVST signal internally Jonathan Cameron

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=20200315131806.61e1d3f8@archlinux \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=beniamin.bia@analog.com \
    --cc=biabeniamin@outlook.com \
    --cc=knaack.h@gmx.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).