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

    [POWERPC] bootwrapper: Refactor ft_get_prop() into internal and external 
functions.
    
    The property searching part of ft_get_prop is factored out into an
    internal __ft_get_prop() which does not deal with phandles and does not
    copy the property data.  ft_get_prop() is then a wrapper that does the
    phandle translation and copying.
    
    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 |   53 +++++++++++++++++++++++++--------------
 1 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index bd006f7..9de267d 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -765,38 +765,53 @@ void *ft_get_parent(struct ft_cxt *cxt, const void 
*phandle)
        return NULL;
 }
 
-int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
-               void *buf, const unsigned int buflen)
+static const void *__ft_get_prop(struct ft_cxt *cxt, void *node,
+                                 const char *propname, unsigned int *len)
 {
        struct ft_atom atom;
-       void *node;
-       char *p;
-       int depth;
-       unsigned int size;
-
-       node = ft_node_ph2node(cxt, phandle);
-       if (node == NULL)
-               return -1;
-
-       depth = 0;
-       p = (char *)node;
+       int depth = 0;
 
-       while ((p = ft_next(cxt, p, &atom)) != NULL) {
+       while ((node = ft_next(cxt, node, &atom)) != NULL) {
                switch (atom.tag) {
                case OF_DT_BEGIN_NODE:
                        ++depth;
                        break;
+
                case OF_DT_PROP:
-                       if ((depth != 1) || strcmp(atom.name, propname))
+                       if (depth != 1 || strcmp(atom.name, propname))
                                break;
-                       size = min(atom.size, buflen);
-                       memcpy(buf, atom.data, size);
-                       return atom.size;
+
+                       if (len)
+                               *len = atom.size;
+
+                       return atom.data;
+
                case OF_DT_END_NODE:
                        if (--depth <= 0)
-                               return -1;
+                               return NULL;
                }
        }
+
+       return NULL;
+}
+
+int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
+               void *buf, const unsigned int buflen)
+{
+       const void *data;
+       unsigned int size;
+
+       void *node = ft_node_ph2node(cxt, phandle);
+       if (!node)
+               return -1;
+
+       data = __ft_get_prop(cxt, node, propname, &size);
+       if (data) {
+               unsigned int clipped_size = min(size, buflen);
+               memcpy(buf, data, clipped_size);
+               return size;
+       }
+
        return -1;
 }
 
-
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