mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-19 16:31:27 +01:00
expo: Split bootflow_menu_new() into two pieces
Split the iteration piece of this function into bootflow_menu_add_all() so that it is possible for the caller to be in control of adding items to the menu. Move the expo_destroy() call into the caller. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
b991a0c8bf
commit
da754e20c9
@ -32,14 +32,12 @@ struct menu_priv {
|
|||||||
|
|
||||||
int bootflow_menu_new(struct expo **expp)
|
int bootflow_menu_new(struct expo **expp)
|
||||||
{
|
{
|
||||||
struct udevice *last_bootdev;
|
|
||||||
struct scene_obj_menu *menu;
|
struct scene_obj_menu *menu;
|
||||||
struct menu_priv *priv;
|
struct menu_priv *priv;
|
||||||
struct bootflow *bflow;
|
|
||||||
struct scene *scn;
|
struct scene *scn;
|
||||||
struct expo *exp;
|
struct expo *exp;
|
||||||
void *logo;
|
void *logo;
|
||||||
int ret, i;
|
int ret;
|
||||||
|
|
||||||
priv = calloc(1, sizeof(*priv));
|
priv = calloc(1, sizeof(*priv));
|
||||||
if (!priv)
|
if (!priv)
|
||||||
@ -74,6 +72,26 @@ int bootflow_menu_new(struct expo **expp)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return log_msg_ret("new", -EINVAL);
|
return log_msg_ret("new", -EINVAL);
|
||||||
|
|
||||||
|
*expp = exp;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bootflow_menu_add_all(struct expo *exp)
|
||||||
|
{
|
||||||
|
struct menu_priv *priv = exp->priv;
|
||||||
|
struct udevice *last_bootdev;
|
||||||
|
struct bootflow *bflow;
|
||||||
|
struct scene *scn;
|
||||||
|
uint scene_id;
|
||||||
|
int ret, i;
|
||||||
|
|
||||||
|
ret = expo_first_scene_id(exp);
|
||||||
|
if (ret < 0)
|
||||||
|
return log_msg_ret("scn", ret);
|
||||||
|
scene_id = ret;
|
||||||
|
scn = expo_lookup_scene_id(exp, scene_id);
|
||||||
|
|
||||||
last_bootdev = NULL;
|
last_bootdev = NULL;
|
||||||
for (ret = bootflow_first_glob(&bflow), i = 0; !ret && i < 36;
|
for (ret = bootflow_first_glob(&bflow), i = 0; !ret && i < 36;
|
||||||
ret = bootflow_next_glob(&bflow), i++) {
|
ret = bootflow_next_glob(&bflow), i++) {
|
||||||
@ -133,8 +151,6 @@ int bootflow_menu_new(struct expo **expp)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return log_msg_ret("arr", ret);
|
return log_msg_ret("arr", ret);
|
||||||
|
|
||||||
*expp = exp;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +200,10 @@ int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
|
|||||||
|
|
||||||
ret = bootflow_menu_new(&exp);
|
ret = bootflow_menu_new(&exp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return log_msg_ret("exp", ret);
|
return log_msg_ret("bmn", ret);
|
||||||
|
ret = bootflow_menu_add_all(exp);
|
||||||
|
if (ret)
|
||||||
|
return log_msg_ret("bma", ret);
|
||||||
|
|
||||||
if (ofnode_valid(std->theme)) {
|
if (ofnode_valid(std->theme)) {
|
||||||
ret = bootflow_menu_apply_theme(exp, std->theme);
|
ret = bootflow_menu_apply_theme(exp, std->theme);
|
||||||
|
|||||||
@ -488,11 +488,24 @@ int bootflow_iter_check_system(const struct bootflow_iter *iter);
|
|||||||
/**
|
/**
|
||||||
* bootflow_menu_new() - Create a new bootflow menu
|
* bootflow_menu_new() - Create a new bootflow menu
|
||||||
*
|
*
|
||||||
|
* This is initially empty. Call bootflow_menu_add_all() to add all the
|
||||||
|
* bootflows to it.
|
||||||
|
*
|
||||||
* @expp: Returns the expo created
|
* @expp: Returns the expo created
|
||||||
* Returns 0 on success, -ve on error
|
* Returns 0 on success, -ve on error
|
||||||
*/
|
*/
|
||||||
int bootflow_menu_new(struct expo **expp);
|
int bootflow_menu_new(struct expo **expp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bootflow_menu_add_all() - Add all bootflows to a menu
|
||||||
|
*
|
||||||
|
* Loops through all bootflows and adds them to the menu
|
||||||
|
*
|
||||||
|
* @exp: Menu to update
|
||||||
|
* Return 0 on success, -ve on error
|
||||||
|
*/
|
||||||
|
int bootflow_menu_add_all(struct expo *exp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bootflow_menu_apply_theme() - Apply a theme to a bootmenu
|
* bootflow_menu_apply_theme() - Apply a theme to a bootmenu
|
||||||
*
|
*
|
||||||
|
|||||||
@ -878,6 +878,7 @@ static int bootflow_menu_theme(struct unit_test_state *uts)
|
|||||||
ut_assertok(scan_mmc4_bootdev(uts));
|
ut_assertok(scan_mmc4_bootdev(uts));
|
||||||
|
|
||||||
ut_assertok(bootflow_menu_new(&exp));
|
ut_assertok(bootflow_menu_new(&exp));
|
||||||
|
ut_assertok(bootflow_menu_add_all(exp));
|
||||||
node = ofnode_path("/bootstd/theme");
|
node = ofnode_path("/bootstd/theme");
|
||||||
ut_assert(ofnode_valid(node));
|
ut_assert(ofnode_valid(node));
|
||||||
ut_assertok(bootflow_menu_apply_theme(exp, node));
|
ut_assertok(bootflow_menu_apply_theme(exp, node));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user