Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+3
+3
drivers/cpufreq/amd-pstate.c
··· 110 110 EPP_INDEX_BALANCE_PERFORMANCE, 111 111 EPP_INDEX_BALANCE_POWERSAVE, 112 112 EPP_INDEX_POWERSAVE, 113 + EPP_INDEX_MAX, 113 114 }; 114 115 115 116 static const char * const energy_perf_strings[] = { ··· 120 119 [EPP_INDEX_BALANCE_POWERSAVE] = "balance_power", 121 120 [EPP_INDEX_POWERSAVE] = "power", 122 121 }; 122 + static_assert(ARRAY_SIZE(energy_perf_strings) == EPP_INDEX_MAX); 123 123 124 124 static unsigned int epp_values[] = { 125 125 [EPP_INDEX_DEFAULT] = 0, ··· 129 127 [EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_BALANCE_POWERSAVE, 130 128 [EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE, 131 129 }; 130 + static_assert(ARRAY_SIZE(epp_values) == EPP_INDEX_MAX); 132 131 133 132 typedef int (*cppc_mode_transition_fn)(int); 134 133