i2c: designware-platdrv: fix unbalanced clk enable and prepare
Subsystems (3)
PATCH v2 1/1 i2c: designware-platdrv: fix unbalanced clk enable and prepare
If i2c_dw_probe() fail, we should disable and unprepare the clk, otherwise the clk enable and prepare is left unbalanced.
In dw_i2c_plat_remove(), we'd better to not rely on rpm to disable and unprepare the clk since CONFIG_PM may be disabled when configuring the kernel. So we explicitly disable and unprepare the clk in dw_i2c_plat_remove().
---
Since v1:
- fix commit msg: "not rely on rpm" rather than "rely on rpm"
- call i2c_dw_plat_prepare_clk after pm_rumtime_disable()
drivers/i2c/busses/i2c-designware-platdrv.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +10 -6
@@ -253,8 +253,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) } r =i2c_dw_probe (dev); -if (r && !dev->pm_runtime_disabled) -pm_runtime_disable (&pdev->dev); +if (r) { +if (!dev->pm_runtime_disabled) +pm_runtime_disable (&pdev->dev); +i2c_dw_plat_prepare_clk (dev, false); + }return r; }
@@ -264,15 +267,16 @@ static int dw_i2c_plat_remove(struct platform_device *pdev)struct dw_i2c_dev *dev =platform_get_drvdata (pdev);pm_runtime_get_sync (&pdev->dev); +pm_runtime_dont_use_autosuspend (&pdev->dev); +if (!dev->pm_runtime_disabled) +pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev);i2c_del_adapter (&dev->adapter);i2c_dw_disable (dev); -pm_runtime_dont_use_autosuspend (&pdev->dev); -pm_runtime_put_sync (&pdev->dev); -if (!dev->pm_runtime_disabled) -pm_runtime_disable (&pdev->dev); +i2c_dw_plat_prepare_clk (dev, false);return 0 ; }
Signature · 1 line
2.8.1
Andy Shevchenko
reviewerQuoted 1 line · Jisheng Zhang
If
i2c_dw_probe()fail, we should disable and unprepare the clk,
clk -> clock, or use function name explicitly.
Quoted 2 lines
otherwise the clk enable and prepare is left unbalanced.
Ditto.
Quoted 2 lines
In
dw_i2c_plat_remove(), we'd better to not rely on rpm to disable and unprepare the clk sinceCONFIG_PMmay be disabled when configuring
Ditto.
Quoted 1 line
the kernel. So we explicitly disable and unprepare the clk in
Ditto.
drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_plat_remove(struct platform_device *pdev) · line 273
Quoted 7 lines
dw_i2c_plat_remove().drivers/i2c/busses/i2c-designware-platdrv.c +1
-0+pm_runtime_put_noidle (&pdev->dev);drivers/i2c/busses/i2c-designware-platdrv.c +0
-1-pm_runtime_put_sync (&pdev->dev);
This change also needs to be described in the commit message.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy