* [PATCH v2] i2c: designware-platdrv: fix unbalanced clk enable and prepare
@ 2016-04-21 9:26 Jisheng Zhang
2016-04-21 11:03 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Jisheng Zhang @ 2016-04-21 9:26 UTC (permalink / raw)
To: jarkko.nikula, andriy.shevchenko, mika.westerberg, wsa
Cc: linux-i2c, linux-kernel, linux-arm-kernel, Jisheng Zhang
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().
Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
---
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(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index d656657..a771781 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -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;
}
--
2.8.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] i2c: designware-platdrv: fix unbalanced clk enable and prepare
2016-04-21 9:26 [PATCH v2] i2c: designware-platdrv: fix unbalanced clk enable and prepare Jisheng Zhang
@ 2016-04-21 11:03 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2016-04-21 11:03 UTC (permalink / raw)
To: Jisheng Zhang, jarkko.nikula, mika.westerberg, wsa
Cc: linux-i2c, linux-kernel, linux-arm-kernel
On Thu, 2016-04-21 at 17:26 +0800, Jisheng Zhang wrote:
> If i2c_dw_probe() fail, we should disable and unprepare the clk,
clk -> clock, or use function name explicitly.
> otherwise the clk enable and prepare is left unbalanced.
>
Ditto.
> 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
Ditto.
> the kernel. So we explicitly disable and unprepare the clk in
Ditto.
> dw_i2c_plat_remove().
> + pm_runtime_put_noidle(&pdev->dev);
>
> - pm_runtime_put_sync(&pdev->dev);
>
This change also needs to be described in the commit message.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-21 11:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-21 9:26 [PATCH v2] i2c: designware-platdrv: fix unbalanced clk enable and prepare Jisheng Zhang
2016-04-21 11:03 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).