diff options
author | Scott Wood <scottwood@freescale.com> | 2007-03-16 13:27:54 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-03-21 07:35:21 -0400 |
commit | a07940ba00218267493798e89e3f4a86fea53125 (patch) | |
tree | 99baf6139b5f9ae214dde6c629fbe986b83786b4 /arch/powerpc/boot/ops.h | |
parent | e85f008d016d2de59ee5b01dba18ea3dea41545b (diff) |
[POWERPC] bootwrapper: Add dt_ops methods.
Add get_parent, create_node, and find_node_by_prop_value to dt_ops.
Currently only implemented by flatdevtree_misc.
Also, add a _str convenience wrapper for setprop.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot/ops.h')
-rw-r--r-- | arch/powerpc/boot/ops.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h index 2b569ad984bd..dae0e3b23cf5 100644 --- a/arch/powerpc/boot/ops.h +++ b/arch/powerpc/boot/ops.h | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <stddef.h> | 14 | #include <stddef.h> |
15 | #include "types.h" | 15 | #include "types.h" |
16 | #include "string.h" | ||
16 | 17 | ||
17 | #define COMMAND_LINE_SIZE 512 | 18 | #define COMMAND_LINE_SIZE 512 |
18 | #define MAX_PATH_LEN 256 | 19 | #define MAX_PATH_LEN 256 |
@@ -37,6 +38,12 @@ struct dt_ops { | |||
37 | const int buflen); | 38 | const int buflen); |
38 | int (*setprop)(const void *phandle, const char *name, | 39 | int (*setprop)(const void *phandle, const char *name, |
39 | const void *buf, const int buflen); | 40 | const void *buf, const int buflen); |
41 | void *(*get_parent)(const void *phandle); | ||
42 | /* The node must not already exist. */ | ||
43 | void *(*create_node)(const void *parent, const char *name); | ||
44 | void *(*find_node_by_prop_value)(const void *prev, | ||
45 | const char *propname, | ||
46 | const char *propval, int proplen); | ||
40 | unsigned long (*finalize)(void); | 47 | unsigned long (*finalize)(void); |
41 | }; | 48 | }; |
42 | extern struct dt_ops dt_ops; | 49 | extern struct dt_ops dt_ops; |
@@ -89,6 +96,50 @@ static inline int setprop(void *devp, const char *name, void *buf, int buflen) | |||
89 | return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1; | 96 | return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1; |
90 | } | 97 | } |
91 | 98 | ||
99 | static inline int setprop_str(void *devp, const char *name, const char *buf) | ||
100 | { | ||
101 | if (dt_ops.setprop) | ||
102 | return dt_ops.setprop(devp, name, buf, strlen(buf) + 1); | ||
103 | |||
104 | return -1; | ||
105 | } | ||
106 | |||
107 | static inline void *get_parent(const char *devp) | ||
108 | { | ||
109 | return dt_ops.get_parent ? dt_ops.get_parent(devp) : NULL; | ||
110 | } | ||
111 | |||
112 | static inline void *create_node(const void *parent, const char *name) | ||
113 | { | ||
114 | return dt_ops.create_node ? dt_ops.create_node(parent, name) : NULL; | ||
115 | } | ||
116 | |||
117 | |||
118 | static inline void *find_node_by_prop_value(const void *prev, | ||
119 | const char *propname, | ||
120 | const char *propval, int proplen) | ||
121 | { | ||
122 | if (dt_ops.find_node_by_prop_value) | ||
123 | return dt_ops.find_node_by_prop_value(prev, propname, | ||
124 | propval, proplen); | ||
125 | |||
126 | return NULL; | ||
127 | } | ||
128 | |||
129 | static inline void *find_node_by_prop_value_str(const void *prev, | ||
130 | const char *propname, | ||
131 | const char *propval) | ||
132 | { | ||
133 | return find_node_by_prop_value(prev, propname, propval, | ||
134 | strlen(propval) + 1); | ||
135 | } | ||
136 | |||
137 | static inline void *find_node_by_devtype(const void *prev, | ||
138 | const char *type) | ||
139 | { | ||
140 | return find_node_by_prop_value_str(prev, "device_type", type); | ||
141 | } | ||
142 | |||
92 | static inline void *malloc(u32 size) | 143 | static inline void *malloc(u32 size) |
93 | { | 144 | { |
94 | return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL; | 145 | return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL; |