[PATCH v3 4/7] i2c: designware: Use runtime PM macro for auto-cleanup
From: Benoît Monin
Date: Wed Nov 19 2025 - 10:05:56 EST
Simplify runtime PM handling in i2c_dw_xfer() by using the
pm_runtime_active_auto_try guard. This adds the proper handling for
runtime PM resume errors and allows us to get rid of the done_nolock
label.
Signed-off-by: Benoît Monin <benoit.monin@xxxxxxxxxxx>
---
drivers/i2c/busses/i2c-designware-master.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index ec4fc2708d03..fe708c7cd282 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -811,12 +811,13 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
dev_dbg(dev->dev, "%s: msgs: %d\n", __func__, num);
- pm_runtime_get_sync(dev->dev);
+ ACQUIRE(pm_runtime_active_auto_try, pm)(dev->dev);
+ if (ACQUIRE_ERR(pm_runtime_active_auto_try, &pm))
+ return -ENXIO;
switch (dev->flags & MODEL_MASK) {
case MODEL_AMD_NAVI_GPU:
- ret = amd_i2c_dw_xfer_quirk(adap, msgs, num);
- goto done_nolock;
+ return amd_i2c_dw_xfer_quirk(adap, msgs, num);
default:
break;
}
@@ -834,7 +835,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
ret = i2c_dw_acquire_lock(dev);
if (ret)
- goto done_nolock;
+ return ret;
ret = i2c_dw_wait_bus_not_busy(dev);
if (ret < 0)
@@ -899,9 +900,6 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
done:
i2c_dw_release_lock(dev);
-done_nolock:
- pm_runtime_put_autosuspend(dev->dev);
-
return ret;
}
--
2.51.1