Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <aardelean@deviqon.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH 2/2] iio: proximity: rfd77402: convert probe to device-managed functions
Date: Sat, 3 Jul 2021 18:06:58 +0100	[thread overview]
Message-ID: <20210703180658.64867287@jic23-huawei> (raw)
In-Reply-To: <20210630131636.1563148-2-aardelean@deviqon.com>

On Wed, 30 Jun 2021 16:16:36 +0300
Alexandru Ardelean <aardelean@deviqon.com> wrote:

> This change converts the probe hook to register the IIO device with
> devm_iio_device_register() and register a hook with
> devm_add_action_or_reset() to put the device in powerdown when the driver
> gets unloaded.
> 
> Since the PM suspend/resume functions need only a reference to the
> i2c_client object (which can be obtained from the base device object), the
> i2c_set_clientdata() call can be removed.
> 
> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Fine as well, but more time on list probably good for it!

J
> ---
>  drivers/iio/proximity/rfd77402.c | 27 ++++++++-------------------
>  1 file changed, 8 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77402.c
> index f349526421f3..8c06d02139b6 100644
> --- a/drivers/iio/proximity/rfd77402.c
> +++ b/drivers/iio/proximity/rfd77402.c
> @@ -252,6 +252,11 @@ static int rfd77402_powerdown(struct i2c_client *client)
>  				  RFD77402_STATUS_STANDBY);
>  }
>  
> +static void rfd77402_disable(void *client)
> +{
> +	rfd77402_powerdown(client);
> +}
> +
>  static int rfd77402_probe(struct i2c_client *client,
>  			  const struct i2c_device_id *id)
>  {
> @@ -270,7 +275,6 @@ static int rfd77402_probe(struct i2c_client *client,
>  		return -ENOMEM;
>  
>  	data = iio_priv(indio_dev);
> -	i2c_set_clientdata(client, indio_dev);
>  	data->client = client;
>  	mutex_init(&data->lock);
>  
> @@ -284,25 +288,11 @@ static int rfd77402_probe(struct i2c_client *client,
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = iio_device_register(indio_dev);
> +	ret = devm_add_action_or_reset(&client->dev, rfd77402_disable, client);
>  	if (ret)
> -		goto err_powerdown;
> -
> -	return 0;
> -
> -err_powerdown:
> -	rfd77402_powerdown(client);
> -	return ret;
> -}
> -
> -static int rfd77402_remove(struct i2c_client *client)
> -{
> -	struct iio_dev *indio_dev = i2c_get_clientdata(client);
> -
> -	iio_device_unregister(indio_dev);
> -	rfd77402_powerdown(client);
> +		return ret;
>  
> -	return 0;
> +	return devm_iio_device_register(&client->dev, indio_dev);
>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> @@ -331,7 +321,6 @@ static struct i2c_driver rfd77402_driver = {
>  		.pm     = &rfd77402_pm_ops,
>  	},
>  	.probe  = rfd77402_probe,
> -	.remove = rfd77402_remove,
>  	.id_table = rfd77402_id,
>  };
>  


  reply	other threads:[~2021-07-03 17:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-30 13:16 [PATCH 1/2] iio: proximity: rfd77402: use i2c_client for rfd77402_{init,powerdown}() Alexandru Ardelean
2021-06-30 13:16 ` [PATCH 2/2] iio: proximity: rfd77402: convert probe to device-managed functions Alexandru Ardelean
2021-07-03 17:06   ` Jonathan Cameron [this message]
2021-07-03 17:05 ` [PATCH 1/2] iio: proximity: rfd77402: use i2c_client for rfd77402_{init,powerdown}() Jonathan Cameron
2021-07-17 17:50   ` 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=20210703180658.64867287@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=aardelean@deviqon.com \
    --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