[PATCH 08/16] cpufreq/intel_pstate: remove NULL entry + use match_string()

Alexandru Ardelean alexandru.ardelean at analog.com
Wed May 8 21:28:34 AEST 2019


The change is mostly cosmetic.

The `energy_perf_strings` array is static, so match_string() can be used
(which will implicitly do a ARRAY_SIZE(energy_perf_strings)).

The only small benefit here, is the reduction of the array size by 1
element.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean at analog.com>
---
 drivers/cpufreq/intel_pstate.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 6ed1e705bc05..ab9a0b34b900 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -593,8 +593,7 @@ static const char * const energy_perf_strings[] = {
 	"performance",
 	"balance_performance",
 	"balance_power",
-	"power",
-	NULL
+	"power"
 };
 static const unsigned int epp_values[] = {
 	HWP_EPP_PERFORMANCE,
@@ -680,8 +679,8 @@ static ssize_t show_energy_performance_available_preferences(
 	int i = 0;
 	int ret = 0;
 
-	while (energy_perf_strings[i] != NULL)
-		ret += sprintf(&buf[ret], "%s ", energy_perf_strings[i++]);
+	for (; i < ARRAY_SIZE(energy_perf_strings); i++)
+		ret += sprintf(&buf[ret], "%s ", energy_perf_strings[i]);
 
 	ret += sprintf(&buf[ret], "\n");
 
@@ -701,7 +700,7 @@ static ssize_t store_energy_performance_preference(
 	if (ret != 1)
 		return -EINVAL;
 
-	ret = __match_string(energy_perf_strings, -1, str_preference);
+	ret = match_string(energy_perf_strings, str_preference);
 	if (ret < 0)
 		return ret;
 
-- 
2.17.1



More information about the Linuxppc-dev mailing list