[PATCH] i2c: hix5hd2: fix autosuspend cleanup

From: Guangshuo Li

Date: Wed Aug 12 2026 - 04:31:25 EST


hix5hd2_i2c_probe() calls pm_runtime_use_autosuspend(), but the probe
failure and remove paths do not call the matching
pm_runtime_dont_use_autosuspend() before disabling runtime PM.

If the autosuspend delay is set to a negative value while autosuspend
is enabled, the runtime PM core increments usage_count to prevent
runtime suspend. Without undoing the autosuspend setting during
teardown, this reference is not dropped and usage_count remains
unbalanced.

Use devm_pm_runtime_set_active_enabled() to manage the runtime PM
state. Its managed cleanup disables autosuspend and runtime PM and
restores the suspended state on probe failure and driver removal.
Remove the now redundant manual runtime PM cleanup.

This issue was found by manual code inspection.

Fixes: 15ef27756b23 ("i2c: hix5hd2: add i2c controller driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
---
drivers/i2c/busses/i2c-hix5hd2.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c
index 95ab910b80c0..f3b967316a2d 100644
--- a/drivers/i2c/busses/i2c-hix5hd2.c
+++ b/drivers/i2c/busses/i2c-hix5hd2.c
@@ -449,18 +449,13 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)

pm_runtime_set_autosuspend_delay(priv->dev, MSEC_PER_SEC);
pm_runtime_use_autosuspend(priv->dev);
- pm_runtime_set_active(priv->dev);
- pm_runtime_enable(priv->dev);
+ ret = devm_pm_runtime_set_active_enabled(priv->dev);
+ if (ret)
+ return ret;

ret = i2c_add_adapter(&priv->adap);
if (ret < 0)
- goto err_runtime;
-
- return ret;
-
-err_runtime:
- pm_runtime_disable(priv->dev);
- pm_runtime_set_suspended(priv->dev);
+ return ret;

return ret;
}
@@ -470,8 +465,6 @@ static void hix5hd2_i2c_remove(struct platform_device *pdev)
struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);

i2c_del_adapter(&priv->adap);
- pm_runtime_disable(priv->dev);
- pm_runtime_set_suspended(priv->dev);
}

static int hix5hd2_i2c_runtime_suspend(struct device *dev)
--
2.43.0