mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 15:22:21 -04:00
timers/migration: Convert "while" loops to use "for"
Both the "do while" and "while" loops in tmigr_setup_groups() eventually mimic the behaviour of "for" loops. Simplify accordingly. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://patch.msgid.link/20251024132536.39841-2-frederic@kernel.org
This commit is contained in:
committed by
Thomas Gleixner
parent
4138787408
commit
6c181b5667
@@ -1642,22 +1642,23 @@ static void tmigr_connect_child_parent(struct tmigr_group *child,
|
|||||||
static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
|
static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
|
||||||
{
|
{
|
||||||
struct tmigr_group *group, *child, **stack;
|
struct tmigr_group *group, *child, **stack;
|
||||||
int top = 0, err = 0, i = 0;
|
int i, top = 0, err = 0;
|
||||||
struct list_head *lvllist;
|
struct list_head *lvllist;
|
||||||
|
|
||||||
stack = kcalloc(tmigr_hierarchy_levels, sizeof(*stack), GFP_KERNEL);
|
stack = kcalloc(tmigr_hierarchy_levels, sizeof(*stack), GFP_KERNEL);
|
||||||
if (!stack)
|
if (!stack)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
do {
|
for (i = 0; i < tmigr_hierarchy_levels; i++) {
|
||||||
group = tmigr_get_group(cpu, node, i);
|
group = tmigr_get_group(cpu, node, i);
|
||||||
if (IS_ERR(group)) {
|
if (IS_ERR(group)) {
|
||||||
err = PTR_ERR(group);
|
err = PTR_ERR(group);
|
||||||
|
i--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
top = i;
|
top = i;
|
||||||
stack[i++] = group;
|
stack[i] = group;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When booting only less CPUs of a system than CPUs are
|
* When booting only less CPUs of a system than CPUs are
|
||||||
@@ -1667,16 +1668,18 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
|
|||||||
* be different from tmigr_hierarchy_levels, contains only a
|
* be different from tmigr_hierarchy_levels, contains only a
|
||||||
* single group.
|
* single group.
|
||||||
*/
|
*/
|
||||||
if (group->parent || list_is_singular(&tmigr_level_list[i - 1]))
|
if (group->parent || list_is_singular(&tmigr_level_list[i]))
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
} while (i < tmigr_hierarchy_levels);
|
/* Assert single root without parent */
|
||||||
|
if (WARN_ON_ONCE(i >= tmigr_hierarchy_levels))
|
||||||
|
return -EINVAL;
|
||||||
|
if (WARN_ON_ONCE(!err && !group->parent && !list_is_singular(&tmigr_level_list[top])))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
/* Assert single root */
|
for (; i >= 0; i--) {
|
||||||
WARN_ON_ONCE(!err && !group->parent && !list_is_singular(&tmigr_level_list[top]));
|
group = stack[i];
|
||||||
|
|
||||||
while (i > 0) {
|
|
||||||
group = stack[--i];
|
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
list_del(&group->list);
|
list_del(&group->list);
|
||||||
|
|||||||
Reference in New Issue
Block a user