lkml.org 
[lkml]   [2022]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 2/4] clk: Add consumers count to core
Date
Keep a count of all consumers per clock. One usage of could be to make
core decisions (like disabling unused clocks) based on the number of
consumers a clock has.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
drivers/clk/clk.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index e1d8245866b1..9b54afd2fee8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -72,6 +72,7 @@ struct clk_core {
unsigned long flags;
bool orphan;
bool rpm_enabled;
+ unsigned int consumers_count;
unsigned int enable_count;
unsigned int prepare_count;
unsigned int protect_count;
@@ -3682,6 +3683,9 @@ static int __clk_core_init(struct clk_core *core)
core->hw->core = NULL;
}

+ if (!ret)
+ core->consumers_count = 0;
+
clk_prepare_unlock();

if (!ret)
@@ -3699,6 +3703,7 @@ static void clk_core_link_consumer(struct clk_core *core, struct clk *clk)
{
clk_prepare_lock();
hlist_add_head(&clk->clks_node, &core->clks);
+ clk->core->consumers_count++;
clk_prepare_unlock();
}

@@ -3710,6 +3715,7 @@ static void clk_core_unlink_consumer(struct clk *clk)
{
lockdep_assert_held(&prepare_lock);
hlist_del(&clk->clks_node);
+ clk->core->consumers_count--;
}

/**
--
2.34.3
\
 
 \ /
  Last update: 2022-07-07 12:04    [W:0.041 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site