cpufreq/amd-pstate: Add static asserts for EPP indices

In case a new index is introduced add a static assert to make sure
that strings and values are updated.

Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
This commit is contained in:
Mario Limonciello (AMD) 2025-10-09 11:17:56 -05:00
parent e9d62ca86a
commit 077f23573d
1 changed files with 3 additions and 0 deletions

View File

@ -110,6 +110,7 @@ enum energy_perf_value_index {
EPP_INDEX_BALANCE_PERFORMANCE, EPP_INDEX_BALANCE_PERFORMANCE,
EPP_INDEX_BALANCE_POWERSAVE, EPP_INDEX_BALANCE_POWERSAVE,
EPP_INDEX_POWERSAVE, EPP_INDEX_POWERSAVE,
EPP_INDEX_MAX,
}; };
static const char * const energy_perf_strings[] = { static const char * const energy_perf_strings[] = {
@ -119,6 +120,7 @@ static const char * const energy_perf_strings[] = {
[EPP_INDEX_BALANCE_POWERSAVE] = "balance_power", [EPP_INDEX_BALANCE_POWERSAVE] = "balance_power",
[EPP_INDEX_POWERSAVE] = "power", [EPP_INDEX_POWERSAVE] = "power",
}; };
static_assert(ARRAY_SIZE(energy_perf_strings) == EPP_INDEX_MAX);
static unsigned int epp_values[] = { static unsigned int epp_values[] = {
[EPP_INDEX_DEFAULT] = 0, [EPP_INDEX_DEFAULT] = 0,
@ -127,6 +129,7 @@ static unsigned int epp_values[] = {
[EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_BALANCE_POWERSAVE, [EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_BALANCE_POWERSAVE,
[EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE, [EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE,
}; };
static_assert(ARRAY_SIZE(epp_values) == EPP_INDEX_MAX);
typedef int (*cppc_mode_transition_fn)(int); typedef int (*cppc_mode_transition_fn)(int);