linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: paulus@samba.org
Cc: linuxppc-dev@ozlabs.org, david@gibson.dropbear.id.au
Subject: [PATCH 2/2] wrapper: Treat NULL as root node in devp_offset; add devp_offset_find().
Date: Tue, 11 Dec 2007 15:23:05 -0600	[thread overview]
Message-ID: <20071211212305.GB3661@loki.buserror.net> (raw)

Many operations, as currently used in the wrapper, assume they can
pass NULL and have it be treated as the root node.  However, libfdt-wrapper
converts NULL to -1, which is only appropriate when searching for nodes,
and will cause an error otherwise.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/libfdt-wrapper.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/boot/libfdt-wrapper.c b/arch/powerpc/boot/libfdt-wrapper.c
index 868c504..97af36c 100644
--- a/arch/powerpc/boot/libfdt-wrapper.c
+++ b/arch/powerpc/boot/libfdt-wrapper.c
@@ -48,7 +48,8 @@
 		check_err(_offset) ? NULL : (void *)(_offset+1); \
 	})
 
-#define devp_offset(devp)	(((int)(devp))-1)
+#define devp_offset_find(devp)	(((int)(devp))-1)
+#define devp_offset(devp)	(devp ? ((int)(devp))-1 : 0)
 
 static void *fdt;
 static void *buf; /* = NULL */
@@ -127,8 +128,9 @@ static void *fdt_wrapper_find_node_by_prop_value(const void *prev,
 						 const char *val,
 						 int len)
 {
-	return offset_devp(fdt_node_offset_by_prop_value(fdt, devp_offset(prev),
-							 name, val, len));
+	int offset = fdt_node_offset_by_prop_value(fdt, devp_offset_find(prev),
+	                                           name, val, len);
+	return offset_devp(offset);
 }
 
 static char *fdt_wrapper_get_path(const void *devp, char *buf, int len)
-- 
1.5.3.7

             reply	other threads:[~2007-12-11 21:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-11 21:23 Scott Wood [this message]
2007-12-17  5:43 ` [PATCH 2/2] wrapper: Treat NULL as root node in devp_offset; add devp_offset_find() David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071211212305.GB3661@loki.buserror.net \
    --to=scottwood@freescale.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).