]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpufreq/amd-pstate: Make amd_pstate_get_mode_string() never return NULL
authorMario Limonciello (AMD) <superm1@kernel.org>
Thu, 9 Oct 2025 16:17:53 +0000 (11:17 -0500)
committerMario Limonciello (AMD) <superm1@kernel.org>
Tue, 11 Nov 2025 05:35:20 +0000 (23:35 -0600)
amd_pstate_get_mode_string() is only used by amd-pstate-ut.  Set the
failure path to use AMD_PSTATE_UNDEFINED ("undefined") to avoid showing
"(null)" as a string when running test suite.

Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
drivers/cpufreq/amd-pstate.c

index a5b9e5baf42344cb0c0ea05f1c7b199a1be37a81..5feb9f5e3a49148d784ffd3c2e422ac41a803432 100644 (file)
@@ -70,8 +70,8 @@ static_assert(ARRAY_SIZE(amd_pstate_mode_string) == AMD_PSTATE_MAX);
 
 const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode)
 {
-       if (mode < 0 || mode >= AMD_PSTATE_MAX)
-               return NULL;
+       if (mode < AMD_PSTATE_UNDEFINED || mode >= AMD_PSTATE_MAX)
+               mode = AMD_PSTATE_UNDEFINED;
        return amd_pstate_mode_string[mode];
 }
 EXPORT_SYMBOL_GPL(amd_pstate_get_mode_string);