mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-20 20:04:46 +00:00
binman: Move selection of the binman node into a function
Move this logic out of the main init function so it is available for other purpose. Use a different error when multiple-images is in use but no subnode is available. This makes it easier to determine what is wrong. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
ec5f101a37
commit
76b54d8ca1
1 changed files with 33 additions and 10 deletions
43
lib/binman.c
43
lib/binman.c
|
@ -30,6 +30,34 @@ struct binman_info {
|
||||||
|
|
||||||
static struct binman_info *binman;
|
static struct binman_info *binman;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find_image_node() - Find the top-level binman node
|
||||||
|
*
|
||||||
|
* Finds the binman node which can be used to load entries. The correct node
|
||||||
|
* depends on whether multiple-images is in use.
|
||||||
|
*
|
||||||
|
* @nodep: Returns the node found, on success
|
||||||
|
* @return 0 if OK, , -EINVAL if there is no /binman node, -ECHILD if multiple
|
||||||
|
* images are being used but the first image is not available
|
||||||
|
*/
|
||||||
|
static int find_image_node(ofnode *nodep)
|
||||||
|
{
|
||||||
|
ofnode node;
|
||||||
|
|
||||||
|
node = ofnode_path("/binman");
|
||||||
|
if (!ofnode_valid(node))
|
||||||
|
return log_msg_ret("binman node", -EINVAL);
|
||||||
|
if (ofnode_read_bool(node, "multiple-images")) {
|
||||||
|
node = ofnode_first_subnode(node);
|
||||||
|
|
||||||
|
if (!ofnode_valid(node))
|
||||||
|
return log_msg_ret("first image", -ECHILD);
|
||||||
|
}
|
||||||
|
*nodep = node;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int binman_entry_find_internal(ofnode node, const char *name,
|
static int binman_entry_find_internal(ofnode node, const char *name,
|
||||||
struct binman_entry *entry)
|
struct binman_entry *entry)
|
||||||
{
|
{
|
||||||
|
@ -90,19 +118,14 @@ int binman_get_rom_offset(void)
|
||||||
|
|
||||||
int binman_init(void)
|
int binman_init(void)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
binman = malloc(sizeof(struct binman_info));
|
binman = malloc(sizeof(struct binman_info));
|
||||||
if (!binman)
|
if (!binman)
|
||||||
return log_msg_ret("space for binman", -ENOMEM);
|
return log_msg_ret("space for binman", -ENOMEM);
|
||||||
binman->image = ofnode_path("/binman");
|
ret = find_image_node(&binman->image);
|
||||||
if (!ofnode_valid(binman->image))
|
if (ret)
|
||||||
return log_msg_ret("binman node", -EINVAL);
|
return log_msg_ret("node", -ENOENT);
|
||||||
if (ofnode_read_bool(binman->image, "multiple-images")) {
|
|
||||||
ofnode node = ofnode_first_subnode(binman->image);
|
|
||||||
|
|
||||||
if (!ofnode_valid(node))
|
|
||||||
return log_msg_ret("first image", -ENOENT);
|
|
||||||
binman->image = node;
|
|
||||||
}
|
|
||||||
binman_set_rom_offset(ROM_OFFSET_NONE);
|
binman_set_rom_offset(ROM_OFFSET_NONE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue