i2c: xiic: Fix pm_runtime_set_suspended() with runtime pm enabled
authorJinjie Ruan <ruanjinjie@huawei.com>
Mon, 23 Sep 2024 03:42:50 +0000 (11:42 +0800)
committerAndi Shyti <andi.shyti@kernel.org>
Fri, 27 Sep 2024 09:48:21 +0000 (11:48 +0200)
It is not valid to call pm_runtime_set_suspended() for devices
with runtime PM enabled because it returns -EAGAIN if it is enabled
already and working. So, call pm_runtime_disable() before to fix it.

Fixes: 36ecbcab84d0 ("i2c: xiic: Implement power management")
Cc: <stable@vger.kernel.org> # v4.6+
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
drivers/i2c/busses/i2c-xiic.c

index 4c89aad02451dbe46cb33ba25441f40d0ea9623b..1d68177241a6b3b513bf5d356b6b11ef65f15b53 100644 (file)
@@ -1337,8 +1337,8 @@ static int xiic_i2c_probe(struct platform_device *pdev)
        return 0;
 
 err_pm_disable:
-       pm_runtime_set_suspended(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
+       pm_runtime_set_suspended(&pdev->dev);
 
        return ret;
 }