Skip to content

Commit 10dabdf

Browse files
andy-shevgregkh
authored andcommitted
resource: Unify next_resource() and next_resource_skip_children()
We have the next_resource() is used once and no user for the next_resource_skip_children() outside of the for_each_resource(). Unify them by adding skip_children parameter to the next_resource(). Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 441f0dd commit 10dabdf

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

kernel/resource.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,17 @@ struct resource_constraint {
5656

5757
static DEFINE_RWLOCK(resource_lock);
5858

59-
static struct resource *next_resource(struct resource *p)
59+
static struct resource *next_resource(struct resource *p, bool skip_children)
6060
{
61-
if (p->child)
61+
if (!skip_children && p->child)
6262
return p->child;
6363
while (!p->sibling && p->parent)
6464
p = p->parent;
6565
return p->sibling;
6666
}
6767

68-
static struct resource *next_resource_skip_children(struct resource *p)
69-
{
70-
while (!p->sibling && p->parent)
71-
p = p->parent;
72-
return p->sibling;
73-
}
74-
7568
#define for_each_resource(_root, _p, _skip_children) \
76-
for ((_p) = (_root)->child; (_p); \
77-
(_p) = (_skip_children) ? next_resource_skip_children(_p) : \
78-
next_resource(_p))
69+
for ((_p) = (_root)->child; (_p); (_p) = next_resource(_p, _skip_children))
7970

8071
#ifdef CONFIG_PROC_FS
8172

@@ -100,8 +91,10 @@ static void *r_start(struct seq_file *m, loff_t *pos)
10091
static void *r_next(struct seq_file *m, void *v, loff_t *pos)
10192
{
10293
struct resource *p = v;
94+
10395
(*pos)++;
104-
return (void *)next_resource(p);
96+
97+
return (void *)next_resource(p, false);
10598
}
10699

107100
static void r_stop(struct seq_file *m, void *v)

0 commit comments

Comments
 (0)