diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2006-06-23 01:08:58 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-06-24 02:15:41 -0400 |
commit | 8cd24ed4f8031636fb5dacb04adee9e02556ecd5 (patch) | |
tree | 8a58e54a4181adf91d0ee2c4af6a92be7427f7cb | |
parent | 92c4e22593c22eb0943b232c61c98b517081637d (diff) |
[SPARC64]: Expand of_*() interfaces some more.
Import some more stuff from powerpc.
Add of_device_is_compatible(), and of_find_compatible_node().
Export some more of the other routines to modules.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | arch/sparc64/kernel/prom.c | 43 | ||||
-rw-r--r-- | include/asm-sparc64/prom.h | 3 |
2 files changed, 46 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) |
diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h index 062ae6e1212e..6d1556c0c263 100644 --- a/include/asm-sparc64/prom.h +++ b/include/asm-sparc64/prom.h | |||
@@ -75,6 +75,8 @@ extern struct device_node *of_find_node_by_type(struct device_node *from, | |||
75 | #define for_each_node_by_type(dn, type) \ | 75 | #define for_each_node_by_type(dn, type) \ |
76 | for (dn = of_find_node_by_type(NULL, type); dn; \ | 76 | for (dn = of_find_node_by_type(NULL, type); dn; \ |
77 | dn = of_find_node_by_type(dn, type)) | 77 | dn = of_find_node_by_type(dn, type)) |
78 | extern struct device_node *of_find_compatible_node(struct device_node *from, | ||
79 | const char *type, const char *compat); | ||
78 | extern struct device_node *of_find_node_by_path(const char *path); | 80 | extern struct device_node *of_find_node_by_path(const char *path); |
79 | extern struct device_node *of_find_node_by_phandle(phandle handle); | 81 | extern struct device_node *of_find_node_by_phandle(phandle handle); |
80 | extern struct device_node *of_get_parent(const struct device_node *node); | 82 | extern struct device_node *of_get_parent(const struct device_node *node); |
@@ -83,6 +85,7 @@ extern struct device_node *of_get_next_child(const struct device_node *node, | |||
83 | extern struct property *of_find_property(struct device_node *np, | 85 | extern struct property *of_find_property(struct device_node *np, |
84 | const char *name, | 86 | const char *name, |
85 | int *lenp); | 87 | int *lenp); |
88 | extern int of_device_is_compatible(struct device_node *device, const char *); | ||
86 | extern void *of_get_property(struct device_node *node, const char *name, | 89 | extern void *of_get_property(struct device_node *node, const char *name, |
87 | int *lenp); | 90 | int *lenp); |
88 | extern int of_getintprop_default(struct device_node *np, | 91 | extern int of_getintprop_default(struct device_node *np, |