* [PATCH] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get()
@ 2026-01-30 15:32 Antoniu Miclaus
2026-01-30 15:32 ` [PATCH] iio: gyro: mpu3050-core: " Antoniu Miclaus
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Antoniu Miclaus @ 2026-01-30 15:32 UTC (permalink / raw)
To: Linus Walleij, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
Cc: Antoniu Miclaus
Use pm_runtime_resume_and_get() in bypass_select() and return its
result directly. Unlike pm_runtime_get_sync(), it doesn't increment
the refcount on failure.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/gyro/mpu3050-i2c.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/iio/gyro/mpu3050-i2c.c b/drivers/iio/gyro/mpu3050-i2c.c
index 092878f2c886..6549b22e643d 100644
--- a/drivers/iio/gyro/mpu3050-i2c.c
+++ b/drivers/iio/gyro/mpu3050-i2c.c
@@ -19,8 +19,7 @@ static int mpu3050_i2c_bypass_select(struct i2c_mux_core *mux, u32 chan_id)
struct mpu3050 *mpu3050 = i2c_mux_priv(mux);
/* Just power up the device, that is all that is needed */
- pm_runtime_get_sync(mpu3050->dev);
- return 0;
+ return pm_runtime_resume_and_get(mpu3050->dev);
}
static int mpu3050_i2c_bypass_deselect(struct i2c_mux_core *mux, u32 chan_id)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] iio: gyro: mpu3050-core: use pm_runtime_resume_and_get()
2026-01-30 15:32 [PATCH] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get() Antoniu Miclaus
@ 2026-01-30 15:32 ` Antoniu Miclaus
2026-02-03 0:21 ` Linus Walleij
2026-01-31 16:41 ` [PATCH] iio: gyro: mpu3050-i2c: " Jonathan Cameron
2026-02-03 11:13 ` Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
From: Antoniu Miclaus @ 2026-01-30 15:32 UTC (permalink / raw)
To: Linus Walleij, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
Cc: Antoniu Miclaus
Use pm_runtime_resume_and_get() in mpu3050_read_raw() and
mpu3050_buffer_preenable(), adding proper error handling. In
preenable, call pm_runtime_put_autosuspend() if set_8khz_samplerate()
fails since postdisable won't be called on preenable failure.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/gyro/mpu3050-core.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index ee2fcd20545d..1cc421eb4782 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -322,7 +322,9 @@ static int mpu3050_read_raw(struct iio_dev *indio_dev,
}
case IIO_CHAN_INFO_RAW:
/* Resume device */
- pm_runtime_get_sync(mpu3050->dev);
+ ret = pm_runtime_resume_and_get(mpu3050->dev);
+ if (ret)
+ return ret;
mutex_lock(&mpu3050->lock);
ret = mpu3050_set_8khz_samplerate(mpu3050);
@@ -647,12 +649,19 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p)
static int mpu3050_buffer_preenable(struct iio_dev *indio_dev)
{
struct mpu3050 *mpu3050 = iio_priv(indio_dev);
+ int ret;
- pm_runtime_get_sync(mpu3050->dev);
+ ret = pm_runtime_resume_and_get(mpu3050->dev);
+ if (ret)
+ return ret;
/* Unless we have OUR trigger active, run at full speed */
- if (!mpu3050->hw_irq_trigger)
- return mpu3050_set_8khz_samplerate(mpu3050);
+ if (!mpu3050->hw_irq_trigger) {
+ ret = mpu3050_set_8khz_samplerate(mpu3050);
+ if (ret)
+ pm_runtime_put_autosuspend(mpu3050->dev);
+ return ret;
+ }
return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get()
2026-01-30 15:32 [PATCH] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get() Antoniu Miclaus
2026-01-30 15:32 ` [PATCH] iio: gyro: mpu3050-core: " Antoniu Miclaus
@ 2026-01-31 16:41 ` Jonathan Cameron
2026-02-03 9:39 ` Nuno Sá
2026-02-03 11:13 ` Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2026-01-31 16:41 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Linus Walleij, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Fri, 30 Jan 2026 17:32:26 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> Use pm_runtime_resume_and_get() in bypass_select() and return its
> result directly. Unlike pm_runtime_get_sync(), it doesn't increment
> the refcount on failure.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Please always put a cover letter on anything with more than one patch.
Provides both a nice name for the series in patchwork etc and a
single place to reply.
Are these fixes? What is side effect of the wrong ref count?
> ---
> drivers/iio/gyro/mpu3050-i2c.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/iio/gyro/mpu3050-i2c.c b/drivers/iio/gyro/mpu3050-i2c.c
> index 092878f2c886..6549b22e643d 100644
> --- a/drivers/iio/gyro/mpu3050-i2c.c
> +++ b/drivers/iio/gyro/mpu3050-i2c.c
> @@ -19,8 +19,7 @@ static int mpu3050_i2c_bypass_select(struct i2c_mux_core *mux, u32 chan_id)
> struct mpu3050 *mpu3050 = i2c_mux_priv(mux);
>
> /* Just power up the device, that is all that is needed */
> - pm_runtime_get_sync(mpu3050->dev);
> - return 0;
> + return pm_runtime_resume_and_get(mpu3050->dev);
> }
>
> static int mpu3050_i2c_bypass_deselect(struct i2c_mux_core *mux, u32 chan_id)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: gyro: mpu3050-core: use pm_runtime_resume_and_get()
2026-01-30 15:32 ` [PATCH] iio: gyro: mpu3050-core: " Antoniu Miclaus
@ 2026-02-03 0:21 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2026-02-03 0:21 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Fri, Jan 30, 2026 at 4:34 PM Antoniu Miclaus
<antoniu.miclaus@analog.com> wrote:
> Use pm_runtime_resume_and_get() in mpu3050_read_raw() and
> mpu3050_buffer_preenable(), adding proper error handling. In
> preenable, call pm_runtime_put_autosuspend() if set_8khz_samplerate()
> fails since postdisable won't be called on preenable failure.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get()
2026-01-31 16:41 ` [PATCH] iio: gyro: mpu3050-i2c: " Jonathan Cameron
@ 2026-02-03 9:39 ` Nuno Sá
0 siblings, 0 replies; 6+ messages in thread
From: Nuno Sá @ 2026-02-03 9:39 UTC (permalink / raw)
To: Jonathan Cameron, Antoniu Miclaus
Cc: Linus Walleij, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Sat, 2026-01-31 at 16:41 +0000, Jonathan Cameron wrote:
> On Fri, 30 Jan 2026 17:32:26 +0200
> Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
>
> > Use pm_runtime_resume_and_get() in bypass_select() and return its
> > result directly. Unlike pm_runtime_get_sync(), it doesn't increment
> > the refcount on failure.
> >
> > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
>
> Please always put a cover letter on anything with more than one patch.
> Provides both a nice name for the series in patchwork etc and a
> single place to reply.
>
> Are these fixes? What is side effect of the wrong ref count?
Yeps, at first glance I would count this as a fix...
- Nuno Sá
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get()
2026-01-30 15:32 [PATCH] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get() Antoniu Miclaus
2026-01-30 15:32 ` [PATCH] iio: gyro: mpu3050-core: " Antoniu Miclaus
2026-01-31 16:41 ` [PATCH] iio: gyro: mpu3050-i2c: " Jonathan Cameron
@ 2026-02-03 11:13 ` Andy Shevchenko
2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-02-03 11:13 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Linus Walleij, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Fri, Jan 30, 2026 at 05:32:26PM +0200, Antoniu Miclaus wrote:
> Use pm_runtime_resume_and_get() in bypass_select() and return its
> result directly. Unlike pm_runtime_get_sync(), it doesn't increment
> the refcount on failure.
...
> /* Just power up the device, that is all that is needed */
> - pm_runtime_get_sync(mpu3050->dev);
> - return 0;
> + return pm_runtime_resume_and_get(mpu3050->dev);
Will it also return positive values?
...
Same Q to the next change.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-03 11:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-30 15:32 [PATCH] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get() Antoniu Miclaus
2026-01-30 15:32 ` [PATCH] iio: gyro: mpu3050-core: " Antoniu Miclaus
2026-02-03 0:21 ` Linus Walleij
2026-01-31 16:41 ` [PATCH] iio: gyro: mpu3050-i2c: " Jonathan Cameron
2026-02-03 9:39 ` Nuno Sá
2026-02-03 11:13 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome