]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cpuidle: dt: fix opencoded for_each_cpu() in idle_state_valid()
authorYury Norov [NVIDIA] <yury.norov@gmail.com>
Wed, 4 Jun 2025 21:39:06 +0000 (17:39 -0400)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 10 Jul 2025 12:53:28 +0000 (14:53 +0200)
The function opencodes the for_each_cpu_from() by using an open for-loop.
Fix that in sake of readability.

While there, drop the 'valid' variable as it's pretty useless here.

Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
Link: https://patch.msgid.link/20250604213908.27819-1-yury.norov@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpuidle/dt_idle_states.c

index 97feb7d8fb2329fa4e0f20a858e0a9c1680ff49a..558d49838990f6ea3f324b35b0bb8f113391a342 100644 (file)
@@ -98,7 +98,6 @@ static bool idle_state_valid(struct device_node *state_node, unsigned int idx,
 {
        int cpu;
        struct device_node *cpu_node, *curr_state_node;
-       bool valid = true;
 
        /*
         * Compare idle state phandles for index idx on all CPUs in the
@@ -107,20 +106,17 @@ static bool idle_state_valid(struct device_node *state_node, unsigned int idx,
         * retrieved from. If a mismatch is found bail out straight
         * away since we certainly hit a firmware misconfiguration.
         */
-       for (cpu = cpumask_next(cpumask_first(cpumask), cpumask);
-            cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpumask)) {
+       cpu = cpumask_first(cpumask) + 1;
+       for_each_cpu_from(cpu, cpumask) {
                cpu_node = of_cpu_device_node_get(cpu);
                curr_state_node = of_get_cpu_state_node(cpu_node, idx);
-               if (state_node != curr_state_node)
-                       valid = false;
-
                of_node_put(curr_state_node);
                of_node_put(cpu_node);
-               if (!valid)
-                       break;
+               if (state_node != curr_state_node)
+                       return false;
        }
 
-       return valid;
+       return true;
 }
 
 /**