diff mbox series

[V6,02/15] cpufreq: Add cpufreq_table_len()

Message ID 867ba9728179ba21ff8f8aca97d416b72ccd63d9.1736248242.git.viresh.kumar@linaro.org
State New
Headers show
Series Rust bindings for cpufreq and OPP core + sample driver | expand

Commit Message

Viresh Kumar Jan. 7, 2025, 11:21 a.m. UTC
Add a function to calculate number of entries in the cpufreq table. This
will be used by the Rust implementation.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 include/linux/cpufreq.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 7fe0981a7e46..6b882ff4dc24 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -783,6 +783,17 @@  bool cpufreq_boost_enabled(void);
 int cpufreq_enable_boost_support(void);
 bool policy_has_boost_freq(struct cpufreq_policy *policy);
 
+static inline unsigned int cpufreq_table_len(struct cpufreq_frequency_table *freq_table)
+{
+	struct cpufreq_frequency_table *pos;
+	unsigned int count = 0;
+
+	cpufreq_for_each_entry(pos, freq_table)
+		count++;
+
+	return count;
+}
+
 /* Find lowest freq at or above target in a table in ascending order */
 static inline int cpufreq_table_find_index_al(struct cpufreq_policy *policy,
 					      unsigned int target_freq,