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>
struct clk_core *new_child;
unsigned long flags;
bool orphan;
struct clk_core *new_child;
unsigned long flags;
bool orphan;
unsigned int enable_count;
unsigned int prepare_count;
unsigned int protect_count;
unsigned int enable_count;
unsigned int prepare_count;
unsigned int protect_count;
/*** runtime pm ***/
static int clk_pm_runtime_get(struct clk_core *core)
{
/*** runtime pm ***/
static int clk_pm_runtime_get(struct clk_core *core)
{
+ if (!core->rpm_enabled)
return 0;
ret = pm_runtime_get_sync(core->dev);
return 0;
ret = pm_runtime_get_sync(core->dev);
static void clk_pm_runtime_put(struct clk_core *core)
{
static void clk_pm_runtime_put(struct clk_core *core)
{
+ if (!core->rpm_enabled)
return;
pm_runtime_put_sync(core->dev);
return;
pm_runtime_put_sync(core->dev);
* taking enable spinlock, but the below check is needed if one tries
* to call it from other places.
*/
* taking enable spinlock, but the below check is needed if one tries
* to call it from other places.
*/
+ if (core->rpm_enabled) {
pm_runtime_get_noresume(core->dev);
if (!pm_runtime_active(core->dev)) {
ret = false;
pm_runtime_get_noresume(core->dev);
if (!pm_runtime_active(core->dev)) {
ret = false;
ret = core->ops->is_enabled(core->hw);
done:
ret = core->ops->is_enabled(core->hw);
done:
pm_runtime_put(core->dev);
return ret;
pm_runtime_put(core->dev);
return ret;
core->ops = hw->init->ops;
if (dev && pm_runtime_enabled(dev))
core->ops = hw->init->ops;
if (dev && pm_runtime_enabled(dev))
+ core->rpm_enabled = true;
+ core->dev = dev;
if (dev && dev->driver)
core->owner = dev->driver->owner;
core->hw = hw;
if (dev && dev->driver)
core->owner = dev->driver->owner;
core->hw = hw;