* [PATCH v2 0/2] iio: gyro: mpu3050: use pm_runtime_resume_and_get()
@ 2026-02-02 14:56 Antoniu Miclaus
2026-02-02 14:56 ` [PATCH v2 1/2] iio: gyro: mpu3050-i2c: " Antoniu Miclaus
2026-02-02 14:56 ` [PATCH v2 2/2] iio: gyro: mpu3050-core: " Antoniu Miclaus
0 siblings, 2 replies; 6+ messages in thread
From: Antoniu Miclaus @ 2026-02-02 14:56 UTC (permalink / raw)
To: Linus Walleij, Jonathan Cameron, Lars-Peter Clausen, linux-iio,
linux-kernel
Cc: Antoniu Miclaus
Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() across
the mpu3050 driver. Unlike pm_runtime_get_sync(), the usage count is
not incremented on error.
Changes in v2:
- Add cover letter
- Reword commit messages
Antoniu Miclaus (2):
iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get()
iio: gyro: mpu3050-core: use pm_runtime_resume_and_get()
drivers/iio/gyro/mpu3050-core.c | 17 +++++++++++++----
drivers/iio/gyro/mpu3050-i2c.c | 3 +--
2 files changed, 14 insertions(+), 6 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] iio: gyro: mpu3050-i2c: use pm_runtime_resume_and_get()
2026-02-02 14:56 [PATCH v2 0/2] iio: gyro: mpu3050: use pm_runtime_resume_and_get() Antoniu Miclaus
@ 2026-02-02 14:56 ` Antoniu Miclaus
2026-02-02 14:56 ` [PATCH v2 2/2] iio: gyro: mpu3050-core: " Antoniu Miclaus
1 sibling, 0 replies; 6+ messages in thread
From: Antoniu Miclaus @ 2026-02-02 14:56 UTC (permalink / raw)
To: Linus Walleij, Jonathan Cameron, Lars-Peter Clausen, linux-iio,
linux-kernel
Cc: Antoniu Miclaus
Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() in
bypass_select() and return its result directly. Unlike
pm_runtime_get_sync(), the usage count is not incremented on error.
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 related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] iio: gyro: mpu3050-core: use pm_runtime_resume_and_get()
2026-02-02 14:56 [PATCH v2 0/2] iio: gyro: mpu3050: use pm_runtime_resume_and_get() Antoniu Miclaus
2026-02-02 14:56 ` [PATCH v2 1/2] iio: gyro: mpu3050-i2c: " Antoniu Miclaus
@ 2026-02-02 14:56 ` Antoniu Miclaus
2026-02-03 9:45 ` Nuno Sá
2026-02-07 21:43 ` Linus Walleij
1 sibling, 2 replies; 6+ messages in thread
From: Antoniu Miclaus @ 2026-02-02 14:56 UTC (permalink / raw)
To: Linus Walleij, Jonathan Cameron, Lars-Peter Clausen, linux-iio,
linux-kernel
Cc: Antoniu Miclaus
Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() in
mpu3050_read_raw() and mpu3050_buffer_preenable(). Unlike
pm_runtime_get_sync(), the usage count is not incremented on error.
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 related [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/2] iio: gyro: mpu3050-core: use pm_runtime_resume_and_get()
2026-02-02 14:56 ` [PATCH v2 2/2] iio: gyro: mpu3050-core: " Antoniu Miclaus
@ 2026-02-03 9:45 ` Nuno Sá
2026-02-07 15:49 ` Jonathan Cameron
2026-02-07 21:43 ` Linus Walleij
1 sibling, 1 reply; 6+ messages in thread
From: Nuno Sá @ 2026-02-03 9:45 UTC (permalink / raw)
To: Antoniu Miclaus, Linus Walleij, Jonathan Cameron,
Lars-Peter Clausen, linux-iio, linux-kernel
On Mon, 2026-02-02 at 16:56 +0200, Antoniu Miclaus wrote:
> Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() in
> mpu3050_read_raw() and mpu3050_buffer_preenable(). Unlike
> pm_runtime_get_sync(), the usage count is not incremented on error.
>
> 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>
> ---
To me this is more than just reference counting. It's also about proper error handling.
- Nuno Sá
> 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);
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/2] iio: gyro: mpu3050-core: use pm_runtime_resume_and_get()
2026-02-03 9:45 ` Nuno Sá
@ 2026-02-07 15:49 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-02-07 15:49 UTC (permalink / raw)
To: Nuno Sá
Cc: Antoniu Miclaus, Linus Walleij, Lars-Peter Clausen, linux-iio,
linux-kernel
On Tue, 03 Feb 2026 09:45:34 +0000
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Mon, 2026-02-02 at 16:56 +0200, Antoniu Miclaus wrote:
> > Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() in
> > mpu3050_read_raw() and mpu3050_buffer_preenable(). Unlike
> > pm_runtime_get_sync(), the usage count is not incremented on error.
> >
> > 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>
> > ---
>
> To me this is more than just reference counting. It's also about proper error handling.
Agreed. I think these should both have fixes tags
and a commit message that calls out a little more clearly what is being fixed.
Jonathan
>
> - Nuno Sá
>
> > 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);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] iio: gyro: mpu3050-core: use pm_runtime_resume_and_get()
2026-02-02 14:56 ` [PATCH v2 2/2] iio: gyro: mpu3050-core: " Antoniu Miclaus
2026-02-03 9:45 ` Nuno Sá
@ 2026-02-07 21:43 ` Linus Walleij
1 sibling, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2026-02-07 21:43 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Linus Walleij, Jonathan Cameron, Lars-Peter Clausen, linux-iio,
linux-kernel
On Mon, Feb 2, 2026 at 3:57 PM Antoniu Miclaus
<antoniu.miclaus@analog.com> wrote:
> Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() in
> mpu3050_read_raw() and mpu3050_buffer_preenable(). Unlike
> pm_runtime_get_sync(), the usage count is not incremented on error.
>
> 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
end of thread, other threads:[~2026-02-07 21:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 14:56 [PATCH v2 0/2] iio: gyro: mpu3050: use pm_runtime_resume_and_get() Antoniu Miclaus
2026-02-02 14:56 ` [PATCH v2 1/2] iio: gyro: mpu3050-i2c: " Antoniu Miclaus
2026-02-02 14:56 ` [PATCH v2 2/2] iio: gyro: mpu3050-core: " Antoniu Miclaus
2026-02-03 9:45 ` Nuno Sá
2026-02-07 15:49 ` Jonathan Cameron
2026-02-07 21:43 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox