i2c: img-scb: disable the clocks when probe fails after init
PATCH 1/1 i2c: img-scb: disable the clocks when probe fails after init
img_i2c_init() resumes the device and drops its reference with pm_runtime_put_autosuspend(), so the device stays active with both clocks on until the autosuspend timer fires.
If i2c_add_numbered_adapter() fails after that, the rpm_disable label only suspends the device when runtime PM is not enabled, and pm_runtime_disable() cancels the timer. The clocks stay enabled after probe has failed.
Disable runtime PM first, then suspend the device if it is not already suspended, as img_i2c_remove() does.
Fixes 93222bd9b966 ("i2c: img-scb: Add runtime PM")
Signed-off-by Cong Nguyen <[email protected]>
--- drivers/i2c/busses/i2c-img-scb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-img-scb.c +4 -2
@@ -1324,6 +1324,7 @@ static int img_i2c_probe(struct platform_device *pdev) {struct device_node *node = pdev->dev.of_node;struct img_i2c *i2c; +bool rpm_enabled;int irq, ret;u32 val;
@@ -1400,9 +1401,10 @@ static int img_i2c_probe(struct platform_device *pdev)return 0 ; rpm_disable: -if (!pm_runtime_enabled (&pdev->dev)) -img_i2c_runtime_suspend (&pdev->dev); + rpm_enabled =pm_runtime_enabled (&pdev->dev);pm_runtime_disable (&pdev->dev); +if (!rpm_enabled || !pm_runtime_status_suspended (&pdev->dev)) +img_i2c_runtime_suspend (&pdev->dev);pm_runtime_dont_use_autosuspend (&pdev->dev);return ret; }
Signature · 1 line
2.25.1