Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Nan <wangnan0@huawei.com>
To: Dave Young <dyoung@redhat.com>
Cc: Wang Nan <wangnan0@huawei.com>, Simon Horman <horms@verge.net.au>,
	kexec@lists.infradead.org, Geng Hui <hui.geng@huawei.com>
Subject: [PATCH 1/3] kexec: introduce helpers for computing dtb size
Date: Tue, 25 Mar 2014 12:09:43 +0800	[thread overview]
Message-ID: <1395720585-76135-2-git-send-email-wangnan0@huawei.com> (raw)
In-Reply-To: <1395720585-76135-1-git-send-email-wangnan0@huawei.com>

This patch introduce fdt_node_len and fdt_prop_len to help for computing
memory requirement when operating dtb.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Dave Young <dyoung@redhat.com>
Cc: Geng Hui <hui.geng@huawei.com>
---
 kexec/libfdt/libfdt.h          | 24 ++++++++++++++++++++++++
 kexec/libfdt/libfdt_internal.h |  3 ---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/kexec/libfdt/libfdt.h b/kexec/libfdt/libfdt.h
index ce80e4f..87a24ab 100644
--- a/kexec/libfdt/libfdt.h
+++ b/kexec/libfdt/libfdt.h
@@ -1073,4 +1073,28 @@ int fdt_del_node(void *fdt, int nodeoffset);
 
 const char *fdt_strerror(int errval);
 
+#define FDT_ALIGN(x, a)		(((x) + (a) - 1) & ~((a) - 1))
+#define FDT_TAGALIGN(x)		(FDT_ALIGN((x), FDT_TAGSIZE))
+
+/*
+ * if add a new subnode:
+ * see: fdt_add_subnode -> fdt_add_subnode_namelen
+ */
+static inline int fdt_node_len(const char* node_name)
+{
+	return sizeof(struct fdt_node_header) +
+		FDT_TAGALIGN(strlen(node_name) + 1) + FDT_TAGSIZE;
+}
+
+/*
+ * if add a new prop: (assume prop_name not exist in strtab)
+ * see: fdt_setprop -> _fdt_add_property
+ */
+static inline int fdt_prop_len(const char* prop_name, int len)
+{
+	return (strlen(prop_name) + 1) +
+		sizeof(struct fdt_property) +
+		FDT_TAGALIGN(len);
+}
+
 #endif /* _LIBFDT_H */
diff --git a/kexec/libfdt/libfdt_internal.h b/kexec/libfdt/libfdt_internal.h
index 46eb93e..7e6c4c8 100644
--- a/kexec/libfdt/libfdt_internal.h
+++ b/kexec/libfdt/libfdt_internal.h
@@ -52,9 +52,6 @@
  */
 #include <fdt.h>
 
-#define FDT_ALIGN(x, a)		(((x) + (a) - 1) & ~((a) - 1))
-#define FDT_TAGALIGN(x)		(FDT_ALIGN((x), FDT_TAGSIZE))
-
 #define FDT_CHECK_HEADER(fdt) \
 	{ \
 		int err; \
-- 
1.8.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2014-03-25  4:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25  4:09 [PATCH 0/3] kexec: pass initrd position in dtb Wang Nan
2014-03-25  4:09 ` Wang Nan [this message]
2014-03-25  4:09 ` [PATCH 2/3] kexec: introduce setup_dtb_prop to make code clear Wang Nan
2014-03-25  4:09 ` [PATCH 3/3] kexec: pass initrd position by dtb Wang Nan
2014-03-27  1:14 ` [PATCH 0/3] kexec: pass initrd position in dtb Dave Young
2014-03-28 16:49   ` Simon Horman

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=1395720585-76135-2-git-send-email-wangnan0@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=dyoung@redhat.com \
    --cc=horms@verge.net.au \
    --cc=hui.geng@huawei.com \
    --cc=kexec@lists.infradead.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