treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / s390 / numa / toptree.h
blob5246371ec713f79ba03562dbac1c3a817ce837e1
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * NUMA support for s390
5 * A tree structure used for machine topology mangling
7 * Copyright IBM Corp. 2015
8 */
9 #ifndef S390_TOPTREE_H
10 #define S390_TOPTREE_H
12 #include <linux/cpumask.h>
13 #include <linux/list.h>
15 struct toptree {
16 int level;
17 int id;
18 cpumask_t mask;
19 struct toptree *parent;
20 struct list_head sibling;
21 struct list_head children;
24 struct toptree *toptree_alloc(int level, int id);
25 void toptree_free(struct toptree *cand);
26 void toptree_update_mask(struct toptree *cand);
27 void toptree_unify(struct toptree *cand);
28 struct toptree *toptree_get_child(struct toptree *cand, int id);
29 void toptree_move(struct toptree *cand, struct toptree *target);
30 int toptree_count(struct toptree *context, int level);
32 struct toptree *toptree_first(struct toptree *context, int level);
33 struct toptree *toptree_next(struct toptree *cur, struct toptree *context,
34 int level);
36 #define toptree_for_each_child(child, ptree) \
37 list_for_each_entry(child, &ptree->children, sibling)
39 #define toptree_for_each_child_safe(child, ptmp, ptree) \
40 list_for_each_entry_safe(child, ptmp, &ptree->children, sibling)
42 #define toptree_is_last(ptree) \
43 ((ptree->parent == NULL) || \
44 (ptree->parent->children.prev == &ptree->sibling))
46 #define toptree_for_each(ptree, cont, ttype) \
47 for (ptree = toptree_first(cont, ttype); \
48 ptree != NULL; \
49 ptree = toptree_next(ptree, cont, ttype))
51 #define toptree_for_each_safe(ptree, tmp, cont, ttype) \
52 for (ptree = toptree_first(cont, ttype), \
53 tmp = toptree_next(ptree, cont, ttype); \
54 ptree != NULL; \
55 ptree = tmp, \
56 tmp = toptree_next(ptree, cont, ttype))
58 #define toptree_for_each_sibling(ptree, start) \
59 toptree_for_each(ptree, start->parent, start->level)
61 #endif /* S390_TOPTREE_H */