Skip to content

Commit ee27368

Browse files
YuryNorovrafaeljw
authored andcommitted
cpuidle: dt: fix opencoded for_each_cpu() in idle_state_valid()
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>
1 parent d7b8f8e commit ee27368

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

drivers/cpuidle/dt_idle_states.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ static bool idle_state_valid(struct device_node *state_node, unsigned int idx,
9898
{
9999
int cpu;
100100
struct device_node *cpu_node, *curr_state_node;
101-
bool valid = true;
102101

103102
/*
104103
* 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,
107106
* retrieved from. If a mismatch is found bail out straight
108107
* away since we certainly hit a firmware misconfiguration.
109108
*/
110-
for (cpu = cpumask_next(cpumask_first(cpumask), cpumask);
111-
cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpumask)) {
109+
cpu = cpumask_first(cpumask) + 1;
110+
for_each_cpu_from(cpu, cpumask) {
112111
cpu_node = of_cpu_device_node_get(cpu);
113112
curr_state_node = of_get_cpu_state_node(cpu_node, idx);
114-
if (state_node != curr_state_node)
115-
valid = false;
116-
117113
of_node_put(curr_state_node);
118114
of_node_put(cpu_node);
119-
if (!valid)
120-
break;
115+
if (state_node != curr_state_node)
116+
return false;
121117
}
122118

123-
return valid;
119+
return true;
124120
}
125121

126122
/**

0 commit comments

Comments
 (0)