Re: [PATCH 6/8] i2c: nomadik: handle pm_runtime errors

From: Dmitry Guzman

Date: Mon Nov 09 2026 - 03:21:03 EST


Hi Wolfram,

On Mon, 9 Nov 2026 08:15:29 +0100
Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> wrote:

> > Testbots revealed a smatch warning:
> >
> > drivers/i2c/busses/i2c-nomadik.c:737 nmk_i2c_xfer() warn: pm_runtime_get_sync() also returns 1 on success
> >
> > I will fix it here.
>
> Like this:
>
> diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
> index 104da275ff91..8cf1d443a25c 100644
> --- a/drivers/i2c/busses/i2c-nomadik.c
> +++ b/drivers/i2c/busses/i2c-nomadik.c
> @@ -734,13 +734,13 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
> struct nmk_i2c_dev *priv = i2c_get_adapdata(i2c_adap);
>
> status = pm_runtime_get_sync(&priv->adev->dev);
> - if (status)
> + if (status < 0)
> return status;

There is another problem with this patch:

include/linux/pm_runtime.h:

> * Note that the runtime PM usage counter of @dev remains incremented in all
> * cases, even if it returns an error code. Consider using
> * pm_runtime_resume_and_get() instead, especially if the return value is
> * checked by the caller, as this is likely to result in cleaner code.

I think we just need to replace pm_runtime_get_sync(&priv->adev->dev) with
pm_runtime_resume_and_get(&priv->adev->dev).

This solves both the positive return code issue and the usage counter leak.

Do you agree?

Best regards,
--
Dmitry Guzman <Dmitry.Guzman@xxxxxxxxxxxx>