Skip to contentSkip to conversation

cpufreq: schedutil: Simplify sugov_fast_switch()

PATCH In review Rafael J. Wysocki 2 participants 2 messages Oct 6, 2020 – Oct 7, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: schedutil: Simplify sugov_fast_switch()

From: Rafael J. Wysocki <[email protected]>

Drop a redundant local variable definition from sugov_fast_switch() and rearrange the code in there to avoid the redundant logical negation.

---

The code reads a bit easier after this change IMV.

linux-next material.

---
 kernel/sched/cpufreq_schedutil.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/sched/cpufreq_schedutil.c +2 -6
Index: linux-pm/kernel/sched/cpufreq_schedutil.c
===================================================================
@@ -114,12 +114,8 @@ static bool sugov_update_next_freq(struc
 static void sugov_fast_switch(struct sugov_policy *sg_policy, u64 time,
 			      unsigned int next_freq)
 {
-	struct cpufreq_policy *policy = sg_policy->policy;
-
-	if (!sugov_update_next_freq(sg_policy, time, next_freq))
-		return;
-
-	cpufreq_driver_fast_switch(policy, next_freq);
+	if (sugov_update_next_freq(sg_policy, time, next_freq))
+		cpufreq_driver_fast_switch(sg_policy->policy, next_freq);
 }
 
 static void sugov_deferred_update(struct sugov_policy *sg_policy, u64 time,
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 26 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Drop a redundant local variable definition from sugov_fast_switch() and rearrange the code in there to avoid the redundant logical negation.

---

The code reads a bit easier after this change IMV.

linux-next material.

---
 kernel/sched/cpufreq_schedutil.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Index: linux-pm/kernel/sched/cpufreq_schedutil.c
===================================================================

kernel/sched/cpufreq_schedutil.c +0 -1
@@ -114,12 +114,8 @@ static bool sugov_update_next_freq(struc
 static void sugov_fast_switch(struct sugov_policy *sg_policy, u64 time,
 			      unsigned int next_freq)
 {
-	struct cpufreq_policy *policy = sg_policy->policy;

kernel/sched/cpufreq_schedutil.c static bool sugov_update_next_freq(struc · line 121

Quoted 10 lines
kernel/sched/cpufreq_schedutil.c +2 -5
-
-	if (!sugov_update_next_freq(sg_policy, time, next_freq))
-		return;
-
-	cpufreq_driver_fast_switch(policy, next_freq);
+	if (sugov_update_next_freq(sg_policy, time, next_freq))
+		cpufreq_driver_fast_switch(sg_policy->policy, next_freq);
 }
 
 static void sugov_deferred_update(struct sugov_policy *sg_policy, u64 time,
Signature · 1 line
viresh