diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2008-01-24 23:41:05 -0500 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2008-01-27 15:07:37 -0500 |
commit | b3bea15d29799797d1486aeddf883404a2e05c81 (patch) | |
tree | d8ddcaa66e27a0b367d50c9d32e389c41d580322 /arch/powerpc/boot | |
parent | 03a16b27bd30f22d88f570585551925248469f84 (diff) |
[POWERPC] bootwrapper: Add find_node_by_compatible
Add the ability to find a device node by just what its compatible with.
This is useful in cases that we don't have a prop to find the node with.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/boot')
-rw-r--r-- | arch/powerpc/boot/libfdt-wrapper.c | 9 | ||||
-rw-r--r-- | arch/powerpc/boot/ops.h | 11 |
2 files changed, 20 insertions, 0 deletions
diff --git a/arch/powerpc/boot/libfdt-wrapper.c b/arch/powerpc/boot/libfdt-wrapper.c index 97af36c224bd..59016bef1391 100644 --- a/arch/powerpc/boot/libfdt-wrapper.c +++ b/arch/powerpc/boot/libfdt-wrapper.c | |||
@@ -133,6 +133,14 @@ static void *fdt_wrapper_find_node_by_prop_value(const void *prev, | |||
133 | return offset_devp(offset); | 133 | return offset_devp(offset); |
134 | } | 134 | } |
135 | 135 | ||
136 | static void *fdt_wrapper_find_node_by_compatible(const void *prev, | ||
137 | const char *val) | ||
138 | { | ||
139 | int offset = fdt_node_offset_by_compatible(fdt, devp_offset_find(prev), | ||
140 | val); | ||
141 | return offset_devp(offset); | ||
142 | } | ||
143 | |||
136 | static char *fdt_wrapper_get_path(const void *devp, char *buf, int len) | 144 | static char *fdt_wrapper_get_path(const void *devp, char *buf, int len) |
137 | { | 145 | { |
138 | int rc; | 146 | int rc; |
@@ -164,6 +172,7 @@ void fdt_init(void *blob) | |||
164 | dt_ops.get_parent = fdt_wrapper_get_parent; | 172 | dt_ops.get_parent = fdt_wrapper_get_parent; |
165 | dt_ops.create_node = fdt_wrapper_create_node; | 173 | dt_ops.create_node = fdt_wrapper_create_node; |
166 | dt_ops.find_node_by_prop_value = fdt_wrapper_find_node_by_prop_value; | 174 | dt_ops.find_node_by_prop_value = fdt_wrapper_find_node_by_prop_value; |
175 | dt_ops.find_node_by_compatible = fdt_wrapper_find_node_by_compatible; | ||
167 | dt_ops.get_path = fdt_wrapper_get_path; | 176 | dt_ops.get_path = fdt_wrapper_get_path; |
168 | dt_ops.finalize = fdt_wrapper_finalize; | 177 | dt_ops.finalize = fdt_wrapper_finalize; |
169 | 178 | ||
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h index 5872ef1779ae..4b0544b03c64 100644 --- a/arch/powerpc/boot/ops.h +++ b/arch/powerpc/boot/ops.h | |||
@@ -46,6 +46,8 @@ struct dt_ops { | |||
46 | void *(*find_node_by_prop_value)(const void *prev, | 46 | void *(*find_node_by_prop_value)(const void *prev, |
47 | const char *propname, | 47 | const char *propname, |
48 | const char *propval, int proplen); | 48 | const char *propval, int proplen); |
49 | void *(*find_node_by_compatible)(const void *prev, | ||
50 | const char *compat); | ||
49 | unsigned long (*finalize)(void); | 51 | unsigned long (*finalize)(void); |
50 | char *(*get_path)(const void *phandle, char *buf, int len); | 52 | char *(*get_path)(const void *phandle, char *buf, int len); |
51 | }; | 53 | }; |
@@ -172,6 +174,15 @@ static inline void *find_node_by_alias(const char *alias) | |||
172 | return NULL; | 174 | return NULL; |
173 | } | 175 | } |
174 | 176 | ||
177 | static inline void *find_node_by_compatible(const void *prev, | ||
178 | const char *compat) | ||
179 | { | ||
180 | if (dt_ops.find_node_by_compatible) | ||
181 | return dt_ops.find_node_by_compatible(prev, compat); | ||
182 | |||
183 | return NULL; | ||
184 | } | ||
185 | |||
175 | void dt_fixup_memory(u64 start, u64 size); | 186 | void dt_fixup_memory(u64 start, u64 size); |
176 | void dt_fixup_cpu_clocks(u32 cpufreq, u32 tbfreq, u32 busfreq); | 187 | void dt_fixup_cpu_clocks(u32 cpufreq, u32 tbfreq, u32 busfreq); |
177 | void dt_fixup_clock(const char *path, u32 freq); | 188 | void dt_fixup_clock(const char *path, u32 freq); |