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

From: Greg KH
Date: Tue Jan 07 2025 - 07:00:16 EST


On Tue, Jan 07, 2025 at 04:51:35PM +0530, Viresh Kumar wrote:
> Add a function to calculate number of entries in the cpufreq table. This
> will be used by the Rust implementation.

Again, why is Rust unique here? Why wouldn't the C code also need this?

> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---
> include/linux/cpufreq.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> 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++;

No locking is needed? Why does anyone care about the length of this
table?

thanks,

greg k-h