All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gautham R. Shenoy" <gautham.shenoy@amd.com>
To: "Mario Limonciello (AMD)" <superm1@kernel.org>
Cc: Perry Yuan <perry.yuan@amd.com>,
	"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<linux-kernel@vger.kernel.org>,
	"open list:CPU FREQUENCY SCALING FRAMEWORK"
	<linux-pm@vger.kernel.org>
Subject: Re: [PATCH v2 1/6] cpufreq/amd-pstate: Use sysfs_match_string() for epp
Date: Wed, 15 Oct 2025 14:16:41 +0530	[thread overview]
Message-ID: <aO9fcenyZ5SgReMK@BLRRASHENOY1.amd.com> (raw)
In-Reply-To: <20251009161756.2728199-2-superm1@kernel.org>

On Thu, Oct 09, 2025 at 11:17:51AM -0500, Mario Limonciello (AMD) wrote:
> Rather than scanning the buffer and manually matching the string
> use the sysfs macros.
> 
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>

The patch looks good to me.
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>

> ---
> v2:
>  * Drop NULL from energy_perf_strings too (Gautham)
> ---
>  drivers/cpufreq/amd-pstate.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index b44f0f7a5ba1c..0bc5013448873 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -118,7 +118,6 @@ static const char * const energy_perf_strings[] = {
>  	[EPP_INDEX_BALANCE_PERFORMANCE] = "balance_performance",
>  	[EPP_INDEX_BALANCE_POWERSAVE] = "balance_power",
>  	[EPP_INDEX_POWERSAVE] = "power",
> -	NULL
>  };
>  
>  static unsigned int epp_values[] = {
> @@ -1137,16 +1136,15 @@ static ssize_t show_amd_pstate_hw_prefcore(struct cpufreq_policy *policy,
>  static ssize_t show_energy_performance_available_preferences(
>  				struct cpufreq_policy *policy, char *buf)
>  {
> -	int i = 0;
> -	int offset = 0;
> +	int offset = 0, i;
>  	struct amd_cpudata *cpudata = policy->driver_data;
>  
>  	if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
>  		return sysfs_emit_at(buf, offset, "%s\n",
>  				energy_perf_strings[EPP_INDEX_PERFORMANCE]);
>  
> -	while (energy_perf_strings[i] != NULL)
> -		offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i++]);
> +	for (i = 0; i < ARRAY_SIZE(energy_perf_strings); i++)
> +		offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i]);
>  
>  	offset += sysfs_emit_at(buf, offset, "\n");
>  
> @@ -1157,15 +1155,10 @@ static ssize_t store_energy_performance_preference(
>  		struct cpufreq_policy *policy, const char *buf, size_t count)
>  {
>  	struct amd_cpudata *cpudata = policy->driver_data;
> -	char str_preference[21];
>  	ssize_t ret;
>  	u8 epp;
>  
> -	ret = sscanf(buf, "%20s", str_preference);
> -	if (ret != 1)
> -		return -EINVAL;
> -
> -	ret = match_string(energy_perf_strings, -1, str_preference);
> +	ret = sysfs_match_string(energy_perf_strings, buf);
>  	if (ret < 0)
>  		return -EINVAL;
>  
> -- 
> 2.43.0
> 

-- 
Thanks and Regards
gautham.

  reply	other threads:[~2025-10-15  8:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 16:17 [PATCH v2 0/6] amd-pstate optimizations Mario Limonciello (AMD)
2025-10-09 16:17 ` [PATCH v2 1/6] cpufreq/amd-pstate: Use sysfs_match_string() for epp Mario Limonciello (AMD)
2025-10-15  8:46   ` Gautham R. Shenoy [this message]
2025-10-09 16:17 ` [PATCH v2 2/6] cpufreq/amd-pstate: Drop NULL value from amd_pstate_mode_string Mario Limonciello (AMD)
2025-10-15  8:47   ` Gautham R. Shenoy
2025-10-09 16:17 ` [PATCH v2 3/6] cpufreq/amd-pstate: Make amd_pstate_get_mode_string() never return NULL Mario Limonciello (AMD)
2025-10-15  8:51   ` Gautham R. Shenoy
2025-10-09 16:17 ` [PATCH v2 4/6] cpufreq/amd-pstate: Adjust return values in amd_pstate_update_status() Mario Limonciello (AMD)
2025-10-15  9:02   ` Gautham R. Shenoy
2025-10-09 16:17 ` [PATCH v2 5/6] cpufreq/amd-pstate: Fix some whitespace issues Mario Limonciello (AMD)
2025-10-15  9:04   ` Gautham R. Shenoy
2025-10-09 16:17 ` [PATCH v2 6/6] cpufreq/amd-pstate: Add static asserts for EPP indices Mario Limonciello (AMD)
2025-10-15  9:11   ` Gautham R. Shenoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aO9fcenyZ5SgReMK@BLRRASHENOY1.amd.com \
    --to=gautham.shenoy@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=perry.yuan@amd.com \
    --cc=superm1@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.