* [PATCH] i2c: qcom-geni: Use devm_pm_runtime_enable() for PM management
@ 2026-07-10 12:13 Mukesh Kumar Savaliya
2026-07-10 12:29 ` Konrad Dybcio
0 siblings, 1 reply; 2+ messages in thread
From: Mukesh Kumar Savaliya @ 2026-07-10 12:13 UTC (permalink / raw)
To: viken.dadhaniya, andi.shyti, linux-arm-msm, linux-i2c,
linux-kernel
Cc: Mukesh Kumar Savaliya
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.
Changes:
- Replace pm_runtime_enable() with devm_pm_runtime_enable() in probe()
- Remove pm_runtime_disable() from remove() function
- Remove pm_runtime_disable() from probe() error paths after
geni_i2c_init() and i2c_add_adapter()
- Use 'dev' pointer consistently instead of 'gi2c->se.dev' for PM APIs
Signed-off-by: Mukesh Kumar Savaliya <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..6d6c2fa287ca 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);
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
+
+ pm_runtime_set_suspended(dev);
+ pm_runtime_set_autosuspend_delay(dev, I2C_AUTO_SUSPEND_DELAY);
+ pm_runtime_use_autosuspend(dev);
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: qcom-geni: Use devm_pm_runtime_enable() for PM management
2026-07-10 12:13 [PATCH] i2c: qcom-geni: Use devm_pm_runtime_enable() for PM management Mukesh Kumar Savaliya
@ 2026-07-10 12:29 ` Konrad Dybcio
0 siblings, 0 replies; 2+ messages in thread
From: Konrad Dybcio @ 2026-07-10 12:29 UTC (permalink / raw)
To: Mukesh Kumar Savaliya, viken.dadhaniya, andi.shyti, linux-arm-msm,
linux-i2c, linux-kernel
On 7/10/26 2:13 PM, 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.
>
> Changes:
> - Replace pm_runtime_enable() with devm_pm_runtime_enable() in probe()
> - Remove pm_runtime_disable() from remove() function
> - Remove pm_runtime_disable() from probe() error paths after
> geni_i2c_init() and i2c_add_adapter()
> - Use 'dev' pointer consistently instead of 'gi2c->se.dev' for PM APIs
Drop this paragraph, describing changes like is unnecessary since
we can just infer this from the diff
>
> Signed-off-by: Mukesh Kumar Savaliya <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..6d6c2fa287ca 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);
> + ret = devm_pm_runtime_enable(dev);
> + if (ret)
> + return ret;
This shifts the enabling of runpm> +
> + pm_runtime_set_suspended(dev);
> + pm_runtime_set_autosuspend_delay(dev, I2C_AUTO_SUSPEND_DELAY);
> + pm_runtime_use_autosuspend(dev);
..which is wrong since:
/**
* pm_runtime_set_suspended - Set runtime PM status to "suspended".
* @dev: Target device.
*
* Set the runtime PM status of @dev to %RPM_SUSPENDED and ensure that
* dependencies of it will be taken into account.
*
* It is not valid to call this function for devices with runtime PM enabled.
*/
Konrad
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-10 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10 12:13 [PATCH] i2c: qcom-geni: Use devm_pm_runtime_enable() for PM management Mukesh Kumar Savaliya
2026-07-10 12:29 ` Konrad Dybcio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox