From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Subject: Re: [PATCH v2 1/6] iio: imu: mpu6050: Balance runtime pm + use pm_runtime_resume_and_get()
Date: Wed, 16 Jun 2021 09:15:23 +0200 [thread overview]
Message-ID: <20210616091523.03e17b0b@coco.lan> (raw)
In-Reply-To: <20210516162103.1332291-2-jic23@kernel.org>
Em Sun, 16 May 2021 17:20:58 +0100
Jonathan Cameron <jic23@kernel.org> escreveu:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Remove an unblanced pm_runtime_put_sync_suspend() call
> in inv_pu_pm_disable(). Not this call is not a bug, because the runtime
> pm core will not allow the reference counter to go negative. It is
> however confusing and serves no purpose.
>
> pm_runtime_resume_and_get() case found using coccicheck script under
> review at:
> https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/
>
> pm_runtime_resume_and_get() returns <= 0 only so simplify related checks
> to bring this more inline with nearby calls.
>
> This is a prequel to taking a closer look at the runtime pm in IIO drivers
> in general.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
LGTM.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 19 ++++++-------------
> drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 6 ++----
> 2 files changed, 8 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 6244a07048df..4cae3765e327 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -570,11 +570,9 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
> freq_hz = INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider);
> period_us = 1000000 / freq_hz;
>
> - result = pm_runtime_get_sync(pdev);
> - if (result < 0) {
> - pm_runtime_put_noidle(pdev);
> + result = pm_runtime_resume_and_get(pdev);
> + if (result)
> return result;
> - }
>
> switch (chan->type) {
> case IIO_ANGL_VEL:
> @@ -812,11 +810,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
> return result;
>
> mutex_lock(&st->lock);
> - result = pm_runtime_get_sync(pdev);
> - if (result < 0) {
> - pm_runtime_put_noidle(pdev);
> + result = pm_runtime_resume_and_get(pdev);
> + if (result)
> goto error_write_raw_unlock;
> - }
>
> switch (mask) {
> case IIO_CHAN_INFO_SCALE:
> @@ -930,11 +926,9 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
> result = 0;
> goto fifo_rate_fail_unlock;
> }
> - result = pm_runtime_get_sync(pdev);
> - if (result < 0) {
> - pm_runtime_put_noidle(pdev);
> + result = pm_runtime_resume_and_get(pdev);
> + if (result)
> goto fifo_rate_fail_unlock;
> - }
>
> result = regmap_write(st->map, st->reg->sample_rate_div, d);
> if (result)
> @@ -1422,7 +1416,6 @@ static void inv_mpu_pm_disable(void *data)
> {
> struct device *dev = data;
>
> - pm_runtime_put_sync_suspend(dev);
> pm_runtime_disable(dev);
> }
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> index e21ba778595a..2d0e8cdd4848 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> @@ -173,11 +173,9 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable)
>
> if (enable) {
> scan = inv_scan_query(indio_dev);
> - result = pm_runtime_get_sync(pdev);
> - if (result < 0) {
> - pm_runtime_put_noidle(pdev);
> + result = pm_runtime_resume_and_get(pdev);
> + if (result)
> return result;
> - }
> /*
> * In case autosuspend didn't trigger, turn off first not
> * required sensors.
Thanks,
Mauro
next prev parent reply other threads:[~2021-06-16 7:15 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 [this message]
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
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=20210616091523.03e17b0b@coco.lan \
--to=mchehab+huawei@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=jic23@kernel.org \
--cc=jmaneyrol@invensense.com \
--cc=linux-iio@vger.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).