linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Ranostay <matt.ranostay@konsulko.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "open list:IIO SUBSYSTEM AND DRIVERS" <linux-iio@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v2 3/6] iio: chemical: atlas-sensor: Balance runtime pm + pm_runtime_resume_and_get()
Date: Sun, 16 May 2021 12:59:59 -0700	[thread overview]
Message-ID: <CAJCx=gmbeS11+JbAVxYR5q=mcq1ikomKeSmHhZ7UD2xnJa2+Qw@mail.gmail.com> (raw)
In-Reply-To: <20210516162103.1332291-4-jic23@kernel.org>

On Sun, May 16, 2021 at 9:22 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> The pm_runtime_put_noidle() call in remove isn't balanced with any get, so
> drop it.  Note this isn't a bug as the runtime pm core will not allow the
> reference count to go negative, making this a noop. However, it is
> confusing to the reader so let's drop it.
>
> pm_runtime_resume_and_get() replacement found using the coccicheck script
> under review at:
> https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/
>
> As pm_runtime_resume_and_get() returns <= 0 take advantage of that to
> change the error checking to if (ret) which is more in keeping with the
> rest of this driver.
>
> This is a prequel to taking a closer look at the runtime pm in IIO drivers
> in general.
>

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
>  drivers/iio/chemical/atlas-sensor.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> index 0fdb3b29c5eb..9cb99585b6ff 100644
> --- a/drivers/iio/chemical/atlas-sensor.c
> +++ b/drivers/iio/chemical/atlas-sensor.c
> @@ -410,11 +410,9 @@ static int atlas_buffer_postenable(struct iio_dev *indio_dev)
>         struct atlas_data *data = iio_priv(indio_dev);
>         int ret;
>
> -       ret = pm_runtime_get_sync(&data->client->dev);
> -       if (ret < 0) {
> -               pm_runtime_put_noidle(&data->client->dev);
> +       ret = pm_runtime_resume_and_get(&data->client->dev);
> +       if (ret)
>                 return ret;
> -       }
>
>         return atlas_set_interrupt(data, true);
>  }
> @@ -487,11 +485,9 @@ static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val)
>         int suspended = pm_runtime_suspended(dev);
>         int ret;
>
> -       ret = pm_runtime_get_sync(dev);
> -       if (ret < 0) {
> -               pm_runtime_put_noidle(dev);
> +       ret = pm_runtime_resume_and_get(dev);
> +       if (ret)
>                 return ret;
> -       }
>
>         if (suspended)
>                 msleep(data->chip->delay);
> @@ -741,7 +737,6 @@ static int atlas_remove(struct i2c_client *client)
>
>         pm_runtime_disable(&client->dev);
>         pm_runtime_set_suspended(&client->dev);
> -       pm_runtime_put_noidle(&client->dev);
>
>         return atlas_set_powermode(data, 0);
>  }
> --
> 2.31.1
>

  reply	other threads:[~2021-05-16 20:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16 16:20 [PATCH v2 0/6] IIO: Runtime PM related cleanups Jonathan Cameron
2021-05-16 16:20 ` [PATCH v2 1/6] iio: imu: mpu6050: Balance runtime pm + use pm_runtime_resume_and_get() Jonathan Cameron
2021-06-16  7:15   ` Mauro Carvalho Chehab
2021-06-16 12:45     ` Jonathan Cameron
2021-05-16 16:20 ` [PATCH v2 2/6] iio: adc: ads1015: Balance runtime pm + pm_runtime_resume_and_get() Jonathan Cameron
2021-06-16  7:15   ` Mauro Carvalho Chehab
2021-06-16 12:46     ` Jonathan Cameron
2021-05-16 16:21 ` [PATCH v2 3/6] iio: chemical: atlas-sensor: " Jonathan Cameron
2021-05-16 19:59   ` Matt Ranostay [this message]
2021-06-16  7:16   ` Mauro Carvalho Chehab
2021-06-16 12:47     ` Jonathan Cameron
2021-05-16 16:21 ` [PATCH v2 4/6] iio: prox: pulsed-light-v2: Fix misbalance runtime pm in error path Jonathan Cameron
2021-05-16 19:59   ` Matt Ranostay
2021-06-16  7:18   ` Mauro Carvalho Chehab
2021-06-16 12:54     ` Jonathan Cameron
2021-05-16 16:21 ` [PATCH v2 5/6] iio: prox: pulsed-light-v2: Use pm_runtime_resume_and_get() Jonathan Cameron
2021-05-16 20:01   ` Matt Ranostay
2021-06-16  7:19     ` Mauro Carvalho Chehab
2021-06-16 12:55       ` Jonathan Cameron
2021-05-16 16:21 ` [PATCH v2 6/6] iio: pressure: icp10100: Balance runtime pm + use pm_runtime_resume_and_get() Jonathan Cameron
2021-06-16  7:16   ` Mauro Carvalho Chehab
2021-06-16 12:56     ` 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='CAJCx=gmbeS11+JbAVxYR5q=mcq1ikomKeSmHhZ7UD2xnJa2+Qw@mail.gmail.com' \
    --to=matt.ranostay@konsulko.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=mchehab+huawei@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).