public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH 1/2] iio: gyro: mpu3050: Use devm_ to set up buffer
Date: Mon, 30 Nov 2020 20:51:50 +0000	[thread overview]
Message-ID: <20201130205150.052fb114@archlinux> (raw)
In-Reply-To: <20201130125915.1315667-1-linus.walleij@linaro.org>

On Mon, 30 Nov 2020 13:59:14 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:

> This makes use of devm_iio_triggered_buffer_setup() to
> save some minor overhead.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Hi Linus,

I'm very fussy about mixing devm and other cleanup.  Unless everything
that happens after this point is also managed, I'm not happy to see
an individual function made managed.  It may be safe, but
if fails the 'obviously safe' test.

Something odd going on here though.  We are currently removing the
buffer before we unregister the userspace interfaces to it.
That's not a good idea.  The remove order seems reverse from
what it should be...

Jonathan

> ---
>  drivers/iio/gyro/mpu3050-core.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
> index 00e58060968c..0d0850945d3a 100644
> --- a/drivers/iio/gyro/mpu3050-core.c
> +++ b/drivers/iio/gyro/mpu3050-core.c
> @@ -1203,9 +1203,10 @@ int mpu3050_common_probe(struct device *dev,
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  	indio_dev->name = name;
>  
> -	ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
> -					 mpu3050_trigger_handler,
> -					 &mpu3050_buffer_setup_ops);
> +	ret = devm_iio_triggered_buffer_setup(dev,
> +					indio_dev, iio_pollfunc_store_time,
> +					mpu3050_trigger_handler,
> +					&mpu3050_buffer_setup_ops);
>  	if (ret) {
>  		dev_err(dev, "triggered buffer setup failed\n");
>  		goto err_power_down;
> @@ -1214,7 +1215,7 @@ int mpu3050_common_probe(struct device *dev,
>  	ret = iio_device_register(indio_dev);
>  	if (ret) {
>  		dev_err(dev, "device register failed\n");
> -		goto err_cleanup_buffer;
> +		goto err_power_down;
>  	}
>  
>  	dev_set_drvdata(dev, indio_dev);
> @@ -1241,8 +1242,6 @@ int mpu3050_common_probe(struct device *dev,
>  
>  	return 0;
>  
> -err_cleanup_buffer:
> -	iio_triggered_buffer_cleanup(indio_dev);
>  err_power_down:
>  	mpu3050_power_down(mpu3050);
>  
> @@ -1258,7 +1257,6 @@ int mpu3050_common_remove(struct device *dev)
>  	pm_runtime_get_sync(dev);
>  	pm_runtime_put_noidle(dev);
>  	pm_runtime_disable(dev);
> -	iio_triggered_buffer_cleanup(indio_dev);
>  	if (mpu3050->irq)
>  		free_irq(mpu3050->irq, mpu3050);
>  	iio_device_unregister(indio_dev);


      parent reply	other threads:[~2020-11-30 20:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 12:59 [PATCH 1/2] iio: gyro: mpu3050: Use devm_ to set up buffer Linus Walleij
2020-11-30 12:59 ` [PATCH 2/2] iio: gyro: mpu3050: Store timestamp in poll function Linus Walleij
2020-11-30 21:07   ` Jonathan Cameron
2020-12-01 12:41     ` Linus Walleij
2020-11-30 20:51 ` 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=20201130205150.052fb114@archlinux \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@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