From: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
To: Simon Horman <horms@verge.net.au>
Cc: Alban Bedel <alban.bedel@avionic-design.de>,
kexec@lists.infradead.org,
Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
Subject: [PATCH v2 3/3] arm: Change setup_dtb_prop to create nodes by offset and node name
Date: Fri, 29 Apr 2016 16:22:23 +0200 [thread overview]
Message-ID: <1461939743-21775-4-git-send-email-nikolaus.schulz@avionic-design.de> (raw)
In-Reply-To: <1461939743-21775-1-git-send-email-nikolaus.schulz@avionic-design.de>
setup_dtb_prop looks like a generic function that can find and add any
nodes, which need not be top-level in the DT. In practice though, the
function is only used for the top-level /chosen node, and it can't add
nodes for which the parent doesn't exist.
So far, so good - but for adding a new node to the DT, the parent offset
need be passed to fdt_add_subnode. Currently in setup_dtb_prop the
parent offset is unknown, and instead a bogus error code is passed to
fdt_add_subnode.
Fix that by adding the parent offset as an extra function argument to
setup_dtb_prop, and change the handling of the /chosen node to operate
on a relative path plus (zero) offset instead of an absolute path. This
aligns setup_dtb_prop to the libfdt API, where functions commonly
operate with a parent offset plus child node name.
Signed-off-by: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
---
kexec/arch/arm/kexec-zImage-arm.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 3222dd3..6b548c3 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -274,8 +274,9 @@ int atag_arm_load(struct kexec_info *info, unsigned long base,
return 0;
}
-static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
- const char *prop_name, const void *val, int len)
+static int setup_dtb_prop(char **bufp, off_t *sizep, int parentoffset,
+ const char *node_name, const char *prop_name,
+ const void *val, int len)
{
char *dtb_buf;
off_t dtb_size;
@@ -290,14 +291,14 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
dtb_size = *sizep;
/* check if the subnode has already exist */
- off = fdt_path_offset(dtb_buf, node_name);
+ off = fdt_subnode_offset(dtb_buf, parentoffset, node_name);
if (off == -FDT_ERR_NOTFOUND) {
dtb_size += fdt_node_len(node_name);
fdt_set_totalsize(dtb_buf, dtb_size);
dtb_buf = xrealloc(dtb_buf, dtb_size);
if (dtb_buf == NULL)
die("xrealloc failed\n");
- off = fdt_add_subnode(dtb_buf, off, node_name);
+ off = fdt_add_subnode(dtb_buf, parentoffset, node_name);
}
if (off < 0) {
@@ -548,7 +549,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
* Error should have been reported so
* directly return -1
*/
- if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+ if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
"bootargs", command_line,
strlen(command_line) + 1))
return -1;
@@ -594,11 +595,11 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
start = cpu_to_be32((unsigned long)(initrd_base));
end = cpu_to_be32((unsigned long)(initrd_base + initrd_size));
- if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+ if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
"linux,initrd-start", &start,
sizeof(start)))
return -1;
- if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+ if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
"linux,initrd-end", &end,
sizeof(end)))
return -1;
--
2.1.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
prev parent reply other threads:[~2016-04-29 14:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 14:22 Nikolaus Schulz
2016-04-29 14:22 ` [PATCH v2 1/3] zImage-arm: Fix a return value check that use the wrong variable Nikolaus Schulz
2016-04-29 14:22 ` [PATCH v2 2/3] zImage-arm: Add support for booting android images Nikolaus Schulz
2016-04-29 14:22 ` Nikolaus Schulz [this message]
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=1461939743-21775-4-git-send-email-nikolaus.schulz@avionic-design.de \
--to=nikolaus.schulz@avionic-design.de \
--cc=alban.bedel@avionic-design.de \
--cc=horms@verge.net.au \
--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