Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8941c0c495e8765206ec1017b1e069ce41bf6e8f
Commit:     8941c0c495e8765206ec1017b1e069ce41bf6e8f
Parent:     a9ec7669fc07f80f6e39807f1ac319764a304319
Author:     Scott Wood <[EMAIL PROTECTED]>
AuthorDate: Mon Mar 12 14:41:58 2007 -0600
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Fri Mar 16 15:49:14 2007 +1100

    [POWERPC] bootwrapper: Add ft_find_node_by_prop_value().
    
    ft_find_node_by_prop_value() finds nodes with the specified
    property/value pair.
    
    Signed-off-by: Scott Wood <[EMAIL PROTECTED]>
    Acked-by: Mark A. Greer <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
 arch/powerpc/boot/flatdevtree.c |   65 +++++++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/flatdevtree.h |    3 ++
 2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 88b178a..f6e37c2 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -820,6 +820,71 @@ int ft_get_prop(struct ft_cxt *cxt, const void *phandle, 
const char *propname,
        return -1;
 }
 
+void *__ft_find_node_by_prop_value(struct ft_cxt *cxt, void *prev,
+                                   const char *propname, const char *propval,
+                                   unsigned int proplen)
+{
+       struct ft_atom atom;
+       char *p = ft_root_node(cxt);
+       char *next;
+       int past_prev = prev ? 0 : 1;
+       int depth = -1;
+
+       while ((next = ft_next(cxt, p, &atom)) != NULL) {
+               const void *data;
+               unsigned int size;
+
+               switch (atom.tag) {
+               case OF_DT_BEGIN_NODE:
+                       depth++;
+
+                       if (prev == p) {
+                               past_prev = 1;
+                               break;
+                       }
+
+                       if (!past_prev || depth < 1)
+                               break;
+
+                       data = __ft_get_prop(cxt, p, propname, &size);
+                       if (!data || size != proplen)
+                               break;
+                       if (memcmp(data, propval, size))
+                               break;
+
+                       return p;
+
+               case OF_DT_END_NODE:
+                       if (depth-- == 0)
+                               return NULL;
+
+                       break;
+               }
+
+               p = next;
+       }
+
+       return NULL;
+}
+
+void *ft_find_node_by_prop_value(struct ft_cxt *cxt, const void *prev,
+                                 const char *propname, const char *propval,
+                                 int proplen)
+{
+       void *node = NULL;
+
+       if (prev) {
+               node = ft_node_ph2node(cxt, prev);
+
+               if (!node)
+                       return NULL;
+       }
+
+       node = __ft_find_node_by_prop_value(cxt, node, propname,
+                                           propval, proplen);
+       return ft_get_phandle(cxt, node);
+}
+
 int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
                const void *buf, const unsigned int buflen)
 {
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index 9500424..e3e3e79 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -105,5 +105,8 @@ int ft_get_prop(struct ft_cxt *cxt, const void *phandle, 
const char *propname,
 int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
                const void *buf, const unsigned int buflen);
 void *ft_get_parent(struct ft_cxt *cxt, const void *phandle);
+void *ft_find_node_by_prop_value(struct ft_cxt *cxt, const void *prev,
+                                 const char *propname, const char *propval,
+                                 int proplen);
 
 #endif /* FLATDEVTREE_H */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to