]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[POWERPC] bootwrapper: Add find_node_by_compatible
authorKumar Gala <galak@kernel.crashing.org>
Fri, 25 Jan 2008 04:41:05 +0000 (22:41 -0600)
committerKumar Gala <galak@kernel.crashing.org>
Sun, 27 Jan 2008 20:07:37 +0000 (14:07 -0600)
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>
arch/powerpc/boot/libfdt-wrapper.c
arch/powerpc/boot/ops.h

index 97af36c224bd2679f12d1a02e7535fb6498c68fa..59016bef1391bf6078024d3be2207dc1d531dedc 100644 (file)
@@ -133,6 +133,14 @@ static void *fdt_wrapper_find_node_by_prop_value(const void *prev,
        return offset_devp(offset);
 }
 
+static void *fdt_wrapper_find_node_by_compatible(const void *prev,
+                                                const char *val)
+{
+       int offset = fdt_node_offset_by_compatible(fdt, devp_offset_find(prev),
+                                                  val);
+       return offset_devp(offset);
+}
+
 static char *fdt_wrapper_get_path(const void *devp, char *buf, int len)
 {
        int rc;
@@ -164,6 +172,7 @@ void fdt_init(void *blob)
        dt_ops.get_parent = fdt_wrapper_get_parent;
        dt_ops.create_node = fdt_wrapper_create_node;
        dt_ops.find_node_by_prop_value = fdt_wrapper_find_node_by_prop_value;
+       dt_ops.find_node_by_compatible = fdt_wrapper_find_node_by_compatible;
        dt_ops.get_path = fdt_wrapper_get_path;
        dt_ops.finalize = fdt_wrapper_finalize;
 
index 5872ef1779ae5d93c94e7a2b367931f2ec48ed3b..4b0544b03c640fb45d8f4aef229c7a019dc7a6ee 100644 (file)
@@ -46,6 +46,8 @@ struct dt_ops {
        void *(*find_node_by_prop_value)(const void *prev,
                                         const char *propname,
                                         const char *propval, int proplen);
+       void *(*find_node_by_compatible)(const void *prev,
+                                        const char *compat);
        unsigned long (*finalize)(void);
        char *(*get_path)(const void *phandle, char *buf, int len);
 };
@@ -172,6 +174,15 @@ static inline void *find_node_by_alias(const char *alias)
        return NULL;
 }
 
+static inline void *find_node_by_compatible(const void *prev,
+                                            const char *compat)
+{
+       if (dt_ops.find_node_by_compatible)
+               return dt_ops.find_node_by_compatible(prev, compat);
+
+       return NULL;
+}
+
 void dt_fixup_memory(u64 start, u64 size);
 void dt_fixup_cpu_clocks(u32 cpufreq, u32 tbfreq, u32 busfreq);
 void dt_fixup_clock(const char *path, u32 freq);