mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
BACKPORT: clk: core: clarify the check for runtime PM
Currently, the core->dev entry is populated only if runtime PM is
enabled. Doing so prevents accessing the device structure in any
case.
Keep the same logic but instead of using the presence of core->dev as
the only condition, also check the status of
pm_runtime_enabled(). Then, we can set the core->dev pointer at any
time as long as a device structure is available.
This change will help supporting device links in the clock subsystem.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Jeffrey Hugo <jhugo@codeaurora.org>
Cc: Chen-Yu Tsai <wens@csie.org>
[sboyd@kernel.org: Change to a boolean flag]
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
(cherry picked from commit 2447883934)
[Resolved minor struct field conflict in driver/clk/clk.c]
Bug: 144066914
Signed-off-by: Saravana Kannan <saravanak@google.com>
Change-Id: Ifcb8c6afdcada7046feec4f570258befbfe98eeb
This commit is contained in:
committed by
Saravana Kannan
parent
1b44c9bd91
commit
5833206170
@@ -60,6 +60,7 @@ struct clk_core {
|
||||
struct clk_core *new_child;
|
||||
unsigned long flags;
|
||||
bool orphan;
|
||||
bool rpm_enabled;
|
||||
bool need_sync;
|
||||
bool boot_enabled;
|
||||
unsigned int enable_count;
|
||||
@@ -97,9 +98,9 @@ struct clk {
|
||||
/*** runtime pm ***/
|
||||
static int clk_pm_runtime_get(struct clk_core *core)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
if (!core->dev)
|
||||
if (!core->rpm_enabled)
|
||||
return 0;
|
||||
|
||||
ret = pm_runtime_get_sync(core->dev);
|
||||
@@ -108,7 +109,7 @@ static int clk_pm_runtime_get(struct clk_core *core)
|
||||
|
||||
static void clk_pm_runtime_put(struct clk_core *core)
|
||||
{
|
||||
if (!core->dev)
|
||||
if (!core->rpm_enabled)
|
||||
return;
|
||||
|
||||
pm_runtime_put_sync(core->dev);
|
||||
@@ -228,7 +229,7 @@ static bool clk_core_is_enabled(struct clk_core *core)
|
||||
* taking enable spinlock, but the below check is needed if one tries
|
||||
* to call it from other places.
|
||||
*/
|
||||
if (core->dev) {
|
||||
if (core->rpm_enabled) {
|
||||
pm_runtime_get_noresume(core->dev);
|
||||
if (!pm_runtime_active(core->dev)) {
|
||||
ret = false;
|
||||
@@ -238,7 +239,7 @@ static bool clk_core_is_enabled(struct clk_core *core)
|
||||
|
||||
ret = core->ops->is_enabled(core->hw);
|
||||
done:
|
||||
if (core->dev)
|
||||
if (core->rpm_enabled)
|
||||
pm_runtime_put(core->dev);
|
||||
|
||||
return ret;
|
||||
@@ -3258,7 +3259,8 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
|
||||
core->ops = hw->init->ops;
|
||||
|
||||
if (dev && pm_runtime_enabled(dev))
|
||||
core->dev = dev;
|
||||
core->rpm_enabled = true;
|
||||
core->dev = dev;
|
||||
if (dev && dev->driver)
|
||||
core->owner = dev->driver->owner;
|
||||
core->hw = hw;
|
||||
|
||||
Reference in New Issue
Block a user