summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 21:32:03 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commit956a9082d325fae2b8c840d6974b6d090a8a21a7 (patch)
tree271bd07cb3e5c33b810b2c6c505e515c0e5aad14 /lib
parentdb6fb7d152bf39d2781b61d89458900660544b91 (diff)
binman: Refactor binman_entry_find() to allow other nodes
At present we can only read from a top-level binman node entry. Refactor this function to produce a second local function which supports reading from any node. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/binman.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/binman.c b/lib/binman.c
index dc3a880882..9098a1dffa 100644
--- a/lib/binman.c
+++ b/lib/binman.c
@@ -29,25 +29,32 @@ struct binman_info {
static struct binman_info *binman;
-int binman_entry_find(const char *name, struct binman_entry *entry)
+static int binman_entry_find_internal(ofnode node, const char *name,
+ struct binman_entry *entry)
{
- ofnode node;
int ret;
- node = ofnode_find_subnode(binman->image, name);
if (!ofnode_valid(node))
- return log_msg_ret("no binman node", -ENOENT);
+ node = binman->image;
+ node = ofnode_find_subnode(node, name);
+ if (!ofnode_valid(node))
+ return log_msg_ret("node", -ENOENT);
ret = ofnode_read_u32(node, "image-pos", &entry->image_pos);
if (ret)
- return log_msg_ret("bad binman node1", ret);
+ return log_msg_ret("import-pos", ret);
ret = ofnode_read_u32(node, "size", &entry->size);
if (ret)
- return log_msg_ret("bad binman node2", ret);
+ return log_msg_ret("size", ret);
return 0;
}
+int binman_entry_find(const char *name, struct binman_entry *entry)
+{
+ return binman_entry_find_internal(binman->image, name, entry);
+}
+
void binman_set_rom_offset(int rom_offset)
{
binman->rom_offset = rom_offset;