[RFC PATCH 2/4] clk: Add consumers count to core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux