linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: Brian Masney <masneyb@onstation.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: tsl2772: Use device-managed API
Date: Sat, 27 Jul 2019 12:57:49 +0100	[thread overview]
Message-ID: <20190727125749.63297c28@archlinux> (raw)
In-Reply-To: <20190726123058.22915-1-hslester96@gmail.com>

On Fri, 26 Jul 2019 20:30:58 +0800
Chuhong Yuan <hslester96@gmail.com> wrote:

> Use devm_iio_device_register to simplify
> the code.
> 
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>

Please try to pick up on likely reviewers in your cc list.  In this case
Brian did a lot of work cleaning these drivers up so I've added him.
Not everyone keeps up with the linux-iio list for some reason ;)

Immediate thought was that you had broken the ordering but turns out
it is already buggy.

As things stand, we remove the userspace interfaces (iio_device_unregister)
after turning off the power.   This is obviously a bad idea and also
form a purely "obviously correct" stand point, we aren't doing the reverse
of probe.

So, I 'think' the right option is to reorder remove so that the power left
on until after the iio_device_unregister call. At that point, we can't
use devm_iio_device_register as we'll have the same incorrect ordering
we currently have.

Brian, you looked at this driver most recently.  Thoughts?

Thanks,

Jonathan



> ---
>  drivers/iio/light/tsl2772.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
> index 83cece921843..aa5891d105e8 100644
> --- a/drivers/iio/light/tsl2772.c
> +++ b/drivers/iio/light/tsl2772.c
> @@ -1877,7 +1877,7 @@ static int tsl2772_probe(struct i2c_client *clientp,
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = iio_device_register(indio_dev);
> +	ret = devm_iio_device_register(&clientp->dev, indio_dev);
>  	if (ret) {
>  		tsl2772_chip_off(indio_dev);
>  		dev_err(&clientp->dev,
> @@ -1928,8 +1928,6 @@ static int tsl2772_remove(struct i2c_client *client)
>  
>  	tsl2772_chip_off(indio_dev);
>  
> -	iio_device_unregister(indio_dev);
> -
>  	return 0;
>  }
>  


  reply	other threads:[~2019-07-27 11:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 12:30 [PATCH] iio: tsl2772: Use device-managed API Chuhong Yuan
2019-07-27 11:57 ` Jonathan Cameron [this message]
2019-07-28  8:31   ` Brian Masney
2019-07-29  3:03     ` Chuhong Yuan
2019-07-29  8:03       ` Brian Masney
2019-07-29 11:08         ` Jonathan Cameron
2019-07-29 13:02           ` Chuhong Yuan
2019-07-29 13:51           ` Brian Masney

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=20190727125749.63297c28@archlinux \
    --to=jic23@kernel.org \
    --cc=hslester96@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masneyb@onstation.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).