Re: [PATCH v3 2/2] iio: gyro: mpu3050-core: fix pm_runtime error handling
From: Andy Shevchenko
Date: Mon Feb 09 2026 - 08:35:51 EST
On Mon, Feb 09, 2026 at 02:02:16PM +0200, Antoniu Miclaus wrote:
> pm_runtime_get_sync() does not check its return value, allowing the
> driver to access hardware that may fail to resume. Use
Try to make lines more filled, this can be achieved by moving "the":
pm_runtime_get_sync() does not check its return value, allowing
the driver to access hardware that may fail to resume. Use
> pm_runtime_resume_and_get() which propagates errors and avoids
> incrementing the usage count on failure.
>
> In preenable, add pm_runtime_put_autosuspend() on set_8khz_samplerate()
> failure since postdisable does not run when preenable fails.
...
> 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;
These 4 LoCs can be replaced with
return ret;
> }
--
With Best Regards,
Andy Shevchenko