diff options
Diffstat (limited to 'arch/sparc64/kernel/prom.c')
-rw-r--r-- | arch/sparc64/kernel/prom.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index 7809100034b0..e9d703eea806 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c | |||
@@ -27,6 +27,26 @@ | |||
27 | 27 | ||
28 | static struct device_node *allnodes; | 28 | static struct device_node *allnodes; |
29 | 29 | ||
30 | int of_device_is_compatible(struct device_node *device, const char *compat) | ||
31 | { | ||
32 | const char* cp; | ||
33 | int cplen, l; | ||
34 | |||
35 | cp = (char *) of_get_property(device, "compatible", &cplen); | ||
36 | if (cp == NULL) | ||
37 | return 0; | ||
38 | while (cplen > 0) { | ||
39 | if (strncmp(cp, compat, strlen(compat)) == 0) | ||
40 | return 1; | ||
41 | l = strlen(cp) + 1; | ||
42 | cp += l; | ||
43 | cplen -= l; | ||
44 | } | ||
45 | |||
46 | return 0; | ||
47 | } | ||
48 | EXPORT_SYMBOL(of_device_is_compatible); | ||
49 | |||
30 | struct device_node *of_get_parent(const struct device_node *node) | 50 | struct device_node *of_get_parent(const struct device_node *node) |
31 | { | 51 | { |
32 | struct device_node *np; | 52 | struct device_node *np; |
@@ -38,6 +58,7 @@ struct device_node *of_get_parent(const struct device_node *node) | |||
38 | 58 | ||
39 | return np; | 59 | return np; |
40 | } | 60 | } |
61 | EXPORT_SYMBOL(of_get_parent); | ||
41 | 62 | ||
42 | struct device_node *of_get_next_child(const struct device_node *node, | 63 | struct device_node *of_get_next_child(const struct device_node *node, |
43 | struct device_node *prev) | 64 | struct device_node *prev) |
@@ -51,6 +72,7 @@ struct device_node *of_get_next_child(const struct device_node *node, | |||
51 | 72 | ||
52 | return next; | 73 | return next; |
53 | } | 74 | } |
75 | EXPORT_SYMBOL(of_get_next_child); | ||
54 | 76 | ||
55 | struct device_node *of_find_node_by_path(const char *path) | 77 | struct device_node *of_find_node_by_path(const char *path) |
56 | { | 78 | { |
@@ -75,6 +97,7 @@ struct device_node *of_find_node_by_phandle(phandle handle) | |||
75 | 97 | ||
76 | return np; | 98 | return np; |
77 | } | 99 | } |
100 | EXPORT_SYMBOL(of_find_node_by_phandle); | ||
78 | 101 | ||
79 | struct device_node *of_find_node_by_name(struct device_node *from, | 102 | struct device_node *of_find_node_by_name(struct device_node *from, |
80 | const char *name) | 103 | const char *name) |
@@ -88,6 +111,7 @@ struct device_node *of_find_node_by_name(struct device_node *from, | |||
88 | 111 | ||
89 | return np; | 112 | return np; |
90 | } | 113 | } |
114 | EXPORT_SYMBOL(of_find_node_by_name); | ||
91 | 115 | ||
92 | struct device_node *of_find_node_by_type(struct device_node *from, | 116 | struct device_node *of_find_node_by_type(struct device_node *from, |
93 | const char *type) | 117 | const char *type) |
@@ -101,6 +125,25 @@ struct device_node *of_find_node_by_type(struct device_node *from, | |||
101 | 125 | ||
102 | return np; | 126 | return np; |
103 | } | 127 | } |
128 | EXPORT_SYMBOL(of_find_node_by_type); | ||
129 | |||
130 | struct device_node *of_find_compatible_node(struct device_node *from, | ||
131 | const char *type, const char *compatible) | ||
132 | { | ||
133 | struct device_node *np; | ||
134 | |||
135 | np = from ? from->allnext : allnodes; | ||
136 | for (; np != 0; np = np->allnext) { | ||
137 | if (type != NULL | ||
138 | && !(np->type != 0 && strcmp(np->type, type) == 0)) | ||
139 | continue; | ||
140 | if (of_device_is_compatible(np, compatible)) | ||
141 | break; | ||
142 | } | ||
143 | |||
144 | return np; | ||
145 | } | ||
146 | EXPORT_SYMBOL(of_find_compatible_node); | ||
104 | 147 | ||
105 | struct property *of_find_property(struct device_node *np, const char *name, | 148 | struct property *of_find_property(struct device_node *np, const char *name, |
106 | int *lenp) | 149 | int *lenp) |