Skip to contentSkip to conversation

intel_idle: Replace min_t() with the better alternatives

PATCH Applied Andy Shevchenko 2 participants 2 messages Aug 13 – Sep 4 Intel idle driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel_idle: Replace min_t() with the better alternatives

Almost always use of min_t() is wrong. Replace it with min() and min3() as all types are int and there is no point to use typed variant of it.

---
 drivers/idle/intel_idle.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/idle/intel_idle.c +3 -5
index b12b4f62752a..699665f24ecd 100644
@@ -1792,9 +1792,7 @@ static bool __init intel_idle_cst_usable(void)
 {
 	int cstate, limit;
 
-	limit = min_t(int, min_t(int, CPUIDLE_STATE_MAX, max_cstate + 1),
-		      acpi_state_table.count);
-
+	limit = min3(CPUIDLE_STATE_MAX, max_cstate + 1, acpi_state_table.count);
 	for (cstate = 1; cstate < limit; cstate++) {
 		struct acpi_processor_cx *cx = &acpi_state_table.states[cstate];
 
@@ -1938,7 +1936,7 @@ static void __init intel_idle_init_cstates_acpi_lpi(struct cpuidle_driver *drv)
 
 static void __init intel_idle_init_cstates_acpi_cst(struct cpuidle_driver *drv)
 {
-	int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
+	int cstate, limit = min(CPUIDLE_STATE_MAX, acpi_state_table.count);
 
 	/*
 	 * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
@@ -2018,7 +2016,7 @@ static bool __init intel_idle_off_by_default_lpi(unsigned int flags, u32 mwait_h
 
 static bool __init intel_idle_off_by_default_cst(unsigned int flags, u32 mwait_hint)
 {
-	int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
+	int cstate, limit = min(CPUIDLE_STATE_MAX, acpi_state_table.count);
 
 	/*
 	 * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
Signature · 1 line
2.50.1
maintainer Applied
#1 lore raw
Quoted 34 lines · Andy Shevchenko

Almost always use of min_t() is wrong. Replace it with min() and min3() as all types are int and there is no point to use typed variant of it.

---
 drivers/idle/intel_idle.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/idle/intel_idle.c +2 -4
index b12b4f62752a..699665f24ecd 100644
@@ -1792,9 +1792,7 @@ static bool __init intel_idle_cst_usable(void)
 {
        int cstate, limit;
 
-       limit = min_t(int, min_t(int, CPUIDLE_STATE_MAX, max_cstate + 1),
-                     acpi_state_table.count);
-
+       limit = min3(CPUIDLE_STATE_MAX, max_cstate + 1, acpi_state_table.count);
        for (cstate = 1; cstate < limit; cstate++) {
                struct acpi_processor_cx *cx = &acpi_state_table.states[cstate];
 
@@ -1938,7 +1936,7 @@ static void __init intel_idle_init_cstates_acpi_lpi(struct cpuidle_driver *drv)
 
 static void __init intel_idle_init_cstates_acpi_cst(struct cpuidle_driver *drv)
 {
-       int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
+       int cstate, limit = min(CPUIDLE_STATE_MAX, acpi_state_table.count);
 
        /*
         * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of

drivers/idle/intel_idle.c static bool __init intel_idle_off_by_default_lpi(unsigned int flags, u32 mwait_h

Quoted 9 lines
drivers/idle/intel_idle.c +1 -2
@@ -2018,7 +2016,7 @@ static bool __init intel_idle_off_by_default_lpi(unsigned int flags, u32 mwait_h
 
 static bool __init intel_idle_off_by_default_cst(unsigned int flags, u32 mwait_hint)
 {
-       int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
+       int cstate, limit = min(CPUIDLE_STATE_MAX, acpi_state_table.count);
 
        /*
         * If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
--

Applied as 7.4 material, thanks!