Re: [PATCH] iio: accel: kxcjk-1013: disable autosuspend on remove
From: Jonathan Cameron
Date: Sun Sep 20 2026 - 22:03:01 EST
On Thu, 17 Sep 2026 08:04:12 +0300
Matti Vaittinen <mazziesaccount@xxxxxxxxx> wrote:
> On 14/09/2026 14:20, Guangshuo Li wrote:
> > kxcjk1013_probe() enables runtime PM autosuspend with
> > pm_runtime_use_autosuspend(). The probe error path correctly undoes
> > this setting with pm_runtime_dont_use_autosuspend(), but the normal
> > remove path only disables runtime PM.
> >
> > The runtime PM API requires pm_runtime_use_autosuspend() to be undone
> > with pm_runtime_dont_use_autosuspend() at driver exit unless runtime PM
> > was enabled with devm_pm_runtime_enable(). Leaving the autosuspend flag
> > set therefore leaves the runtime PM state incompletely cleaned up after
> > the driver is unbound.
> >
> > Add the missing pm_runtime_dont_use_autosuspend() call to the remove
> > path.
> >
> > This issue was found by manual code inspection.
> >
> > Fixes: 124e1b1d0924 ("iio: accel: kxcjk-1013: support runtime pm")
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
> > ---
> > drivers/iio/accel/kxcjk-1013.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> > index 166fb786425f..c6b030f64be1 100644
> > --- a/drivers/iio/accel/kxcjk-1013.c
> > +++ b/drivers/iio/accel/kxcjk-1013.c
> > @@ -1547,6 +1547,7 @@ static void kxcjk1013_remove(struct i2c_client *client)
> >
> > iio_device_unregister(indio_dev);
> >
> > + pm_runtime_dont_use_autosuspend(&client->dev);
> > pm_runtime_disable(&client->dev);
> > pm_runtime_set_suspended(&client->dev);
> >
>
> I am not sure if it matters, but it bugs me a bit to see that the
> clean-up path for PM here, and clean-up path at probe error, do still
> not have same steps. As far as I see the probe error path omits the
> pm_runtime_set_suspended(). Do you think this should/could be fixed?
>
> Oh, and if it is fine as it is - I would really appreciate education as
> to why :)
I'll go with it probably isn't fine. But honestly I haven't chased exactly
what happens around that stuff on a failed driver probe.
>
> Other than that:
>
> Reviewed-by: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
>
> (I know I am late with the tag as Jonathan applied this already - I
> suppose it's still Ok to say I am "Ok" with the fix :] )
>
Absolutely!
Jonathan
> Yours,
> -- Matti
>