xref: /openbmc/linux/arch/alpha/kernel/gct.c (revision 293d5b43)
1 /*
2  *	linux/arch/alpha/kernel/gct.c
3  */
4 
5 #include <linux/kernel.h>
6 #include <linux/types.h>
7 #include <linux/errno.h>
8 
9 #include <asm/hwrpb.h>
10 #include <asm/gct.h>
11 
12 int
13 gct6_find_nodes(gct6_node *node, gct6_search_struct *search)
14 {
15 	gct6_search_struct *wanted;
16 	int status = 0;
17 
18 	/* First check the magic number.  */
19 	if (node->magic != GCT_NODE_MAGIC) {
20 		printk(KERN_ERR "GCT Node MAGIC incorrect - GCT invalid\n");
21 		return -EINVAL;
22 	}
23 
24 	/* Check against the search struct.  */
25 	for (wanted = search;
26 	     wanted && (wanted->type | wanted->subtype);
27 	     wanted++) {
28 		if (node->type != wanted->type)
29 			continue;
30 		if (node->subtype != wanted->subtype)
31 			continue;
32 
33 		/* Found it -- call out.  */
34 		if (wanted->callout)
35 			wanted->callout(node);
36 	}
37 
38 	/* Now walk the tree, siblings first.  */
39 	if (node->next)
40 		status |= gct6_find_nodes(GCT_NODE_PTR(node->next), search);
41 
42 	/* Then the children.  */
43 	if (node->child)
44 		status |= gct6_find_nodes(GCT_NODE_PTR(node->child), search);
45 
46 	return status;
47 }
48