drivers/i2c/busses/i2c-qcom-geni.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
The current implementation manually calls pm_runtime_enable() in probe()
and pm_runtime_disable() in remove() and error paths. This pattern is
error-prone and requires careful cleanup in all failure paths. Using the
devres-managed variant eliminates this complexity.
Migrate from manual pm_runtime_enable()/pm_runtime_disable() calls to
the devres-managed devm_pm_runtime_enable() API. This simplifies the
driver by automatically handling runtime PM cleanup when the device is
removed or probe fails. This helps with Simplified error handling and
Automatic cleanup.
Signed-off-by: Mukesh Kumar Savaliya <mukesh.savaliya@oss.qualcomm.com>
---
v1->v2:
- Fix runtime PM init ordering by calling devm_pm_runtime_enable() after PM state setup.
- Remove unnecessary commit message details.
- Address review feedback from Konrad Dybcio.
Link to v1: https://lore.kernel.org/all/20260710121356.4054600-1-mukesh.savaliya@oss.qualcomm.com/
---
drivers/i2c/busses/i2c-qcom-geni.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 96dbf04138be..d5c977e34994 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -1126,27 +1126,25 @@ static int geni_i2c_probe(struct platform_device *pdev)
gi2c->adap.dev.of_node = dev->of_node;
strscpy(gi2c->adap.name, "Geni-I2C", sizeof(gi2c->adap.name));
- pm_runtime_set_suspended(gi2c->se.dev);
- pm_runtime_set_autosuspend_delay(gi2c->se.dev, I2C_AUTO_SUSPEND_DELAY);
- pm_runtime_use_autosuspend(gi2c->se.dev);
- pm_runtime_enable(gi2c->se.dev);
+ pm_runtime_set_suspended(dev);
+ pm_runtime_set_autosuspend_delay(dev, I2C_AUTO_SUSPEND_DELAY);
+ pm_runtime_use_autosuspend(dev);
+
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
ret = geni_i2c_init(gi2c);
- if (ret < 0) {
- pm_runtime_disable(gi2c->se.dev);
+ if (ret < 0)
return ret;
- }
ret = i2c_add_adapter(&gi2c->adap);
- if (ret) {
- dev_err_probe(dev, ret, "Error adding i2c adapter\n");
- pm_runtime_disable(gi2c->se.dev);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "Error adding i2c adapter\n");
dev_dbg(dev, "Geni-I2C adaptor successfully added\n");
- return ret;
+ return 0;
}
static void geni_i2c_remove(struct platform_device *pdev)
@@ -1155,7 +1153,6 @@ static void geni_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&gi2c->adap);
release_gpi_dma(gi2c);
- pm_runtime_disable(gi2c->se.dev);
}
static void geni_i2c_shutdown(struct platform_device *pdev)
--
2.43.0
On 7/13/26 8:41 AM, Mukesh Kumar Savaliya wrote: > The current implementation manually calls pm_runtime_enable() in probe() > and pm_runtime_disable() in remove() and error paths. This pattern is > error-prone and requires careful cleanup in all failure paths. Using the > devres-managed variant eliminates this complexity. > > Migrate from manual pm_runtime_enable()/pm_runtime_disable() calls to > the devres-managed devm_pm_runtime_enable() API. This simplifies the > driver by automatically handling runtime PM cleanup when the device is > removed or probe fails. This helps with Simplified error handling and > Automatic cleanup. > > Signed-off-by: Mukesh Kumar Savaliya <mukesh.savaliya@oss.qualcomm.com> > --- Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Konrad
© 2016 - 2026 Red Hat, Inc.