linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Dan Murphy <dmurphy@ti.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<robh+dt@kernel.org>
Subject: Re: [PATCH v2 4/4] iio: ti-ads8688: Migrate to device managed IIO calls
Date: Sun, 16 Dec 2018 11:10:25 +0000	[thread overview]
Message-ID: <20181216111025.0be9cb9e@archlinux> (raw)
In-Reply-To: <20181211191207.21900-4-dmurphy@ti.com>

On Tue, 11 Dec 2018 13:12:07 -0600
Dan Murphy <dmurphy@ti.com> wrote:

> Migrate the driver to use the devm IIO calls as opposed to
> the unmanaged calls.
> 
> Signed-off-by: Dan Murphy <dmurphy@ti.com>
The remove order should always be the opposite of probe.
As devm cleanup is done 'after' whatever is in the remove function
you should never mix and match between managed and unmanaged.

That's not to say this can't be done, but it should also handle
the regulator disables.  For that
devm_add_action_or_reset is what you want.  As you need to check
the regulator is not an error, you would need a little utility function.

Jonathan
> ---
> 
> v2 - New patch
> 
>  drivers/iio/adc/ti-ads8688.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c
> index 3597bc0697ee..8f42103a1fd9 100644
> --- a/drivers/iio/adc/ti-ads8688.c
> +++ b/drivers/iio/adc/ti-ads8688.c
> @@ -462,21 +462,21 @@ static int ads8688_probe(struct spi_device *spi)
>  
>  	mutex_init(&st->lock);
>  
> -	ret = iio_triggered_buffer_setup(indio_dev, NULL, ads8688_trigger_handler, NULL);
> +	ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL,
> +					      ads8688_trigger_handler, NULL);
>  	if (ret < 0) {
>  		dev_err(&spi->dev, "iio triggered buffer setup failed\n");
>  		goto err_regulator_disable;
>  	}
>  
> -	ret = iio_device_register(indio_dev);
> -	if (ret)
> -		goto err_buffer_cleanup;
> +	ret = devm_iio_device_register(&spi->dev, indio_dev);
> +	if (ret < 0) {
> +		dev_err(&spi->dev, "iio device registration failed\n");
> +		goto err_regulator_disable;
> +	}
>  
>  	return 0;
>  
> -err_buffer_cleanup:
> -	iio_triggered_buffer_cleanup(indio_dev);
> -
>  err_regulator_disable:
>  	if (!IS_ERR(st->reg))
>  		regulator_disable(st->reg);
> @@ -489,9 +489,6 @@ static int ads8688_remove(struct spi_device *spi)
>  	struct iio_dev *indio_dev = spi_get_drvdata(spi);
>  	struct ads8688_state *st = iio_priv(indio_dev);
>  
> -	iio_device_unregister(indio_dev);
> -	iio_triggered_buffer_cleanup(indio_dev);
> -
>  	if (!IS_ERR(st->reg))
>  		regulator_disable(st->reg);
>  


  reply	other threads:[~2018-12-16 11:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 19:12 [PATCH v2 1/4] iio: ti-ads124s08: Add DT binding documentation Dan Murphy
2018-12-11 19:12 ` [PATCH v2 2/4] iio: adc: Add the TI ads124s08 ADC code Dan Murphy
2018-12-16 11:04   ` Jonathan Cameron
2018-12-11 19:12 ` [PATCH v2 3/4] iio: ti-ads8688: Update buffer allocation for timestamps Dan Murphy
2018-12-16 11:06   ` Jonathan Cameron
2018-12-19 17:45     ` Dan Murphy
2018-12-11 19:12 ` [PATCH v2 4/4] iio: ti-ads8688: Migrate to device managed IIO calls Dan Murphy
2018-12-16 11:10   ` Jonathan Cameron [this message]
2018-12-16 10:52 ` [PATCH v2 1/4] iio: ti-ads124s08: Add DT binding documentation 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=20181216111025.0be9cb9e@archlinux \
    --to=jic23@kernel.org \
    --cc=dmurphy@ti.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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).