From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C80861E25FE; Tue, 7 Jan 2025 11:59:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736251188; cv=none; b=fSnnHdrIgdLtuH+Ntp7U4R1vPkfeHasq0nCvxDUD6XlvopD8KYA55eLgPg7zbLCcPARd75DiSzoexvAWn/o0JaMN8FLoc6loo2O2+WLKpZh+VWZldelKooeQT9IS8luN3ut2ccIlnD0pSvY/cELQcgTlVQKWkzvOMjILps1marc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736251188; c=relaxed/simple; bh=6Z2U0iw0kI6m8i6PtIB4z7wSp1MCMGFgNcIgiGGe19Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nyCh7B5W0VuPE9Gli+zeiuKmAxVEVLvFBpPWRkO8XM49vebnJLLQy3CLoyMOHbw6NKJfezWf6utIqHG+2X5keiGxgBkFPA1rw+8LWWS3JE79fSY9Z3TQLUE07ag+XBkHxufgUztZN10geAW534HtkfHWcArblEspDEaHt8zalJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uJQZtSEN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uJQZtSEN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB9F8C4CED6; Tue, 7 Jan 2025 11:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1736251187; bh=6Z2U0iw0kI6m8i6PtIB4z7wSp1MCMGFgNcIgiGGe19Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uJQZtSEN1lXNaFluGnk+w50lM1xdTi6tdk+S4TmqVJcFNS9fJbHlGZa+GeVKOwZ+8 4v3h2MN8EzIOVjg0U+ujlkQ0jD/1p0Mi5AtUQg4BjwUuCeSA7kch9ea6uaZNFekicg iQx/T9OSdGeRFLhhWAvZtDcfgxyNtc+LkMtKbs0k= Date: Tue, 7 Jan 2025 12:59:44 +0100 From: Greg KH To: Viresh Kumar Cc: "Rafael J. Wysocki" , Miguel Ojeda , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , rust-for-linux@vger.kernel.org, Manos Pitsidianakis , Erik Schilling , Alex =?iso-8859-1?Q?Benn=E9e?= , Joakim Bech , Rob Herring , linux-kernel@vger.kernel.org Subject: Re: [PATCH V6 02/15] cpufreq: Add cpufreq_table_len() Message-ID: <2025010727-banner-monday-1941@gregkh> References: <867ba9728179ba21ff8f8aca97d416b72ccd63d9.1736248242.git.viresh.kumar@linaro.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <867ba9728179ba21ff8f8aca97d416b72ccd63d9.1736248242.git.viresh.kumar@linaro.org> 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 > --- > 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