mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
menu: Update bootmenu_loop() to return the code
Use the return value to save having to pass around a pointer. This also resolves any ambiguity about what *key contains when the function is called. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
5712976b26
commit
d0ca98dbd9
4 changed files with 24 additions and 23 deletions
|
@ -96,7 +96,7 @@ static char *bootmenu_choice_entry(void *data)
|
||||||
key = bootmenu_autoboot_loop(menu, &esc);
|
key = bootmenu_autoboot_loop(menu, &esc);
|
||||||
} else {
|
} else {
|
||||||
/* Some key was pressed, so autoboot was stopped */
|
/* Some key was pressed, so autoboot was stopped */
|
||||||
bootmenu_loop(menu, &key, &esc);
|
key = bootmenu_loop(menu, &esc);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
|
|
@ -191,7 +191,7 @@ static char *eficonfig_choice_entry(void *data)
|
||||||
struct efimenu *efi_menu = data;
|
struct efimenu *efi_menu = data;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bootmenu_loop((struct bootmenu_data *)efi_menu, &key, &esc);
|
key = bootmenu_loop((struct bootmenu_data *)efi_menu, &esc);
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case BKEY_UP:
|
case BKEY_UP:
|
||||||
|
@ -1868,7 +1868,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
|
||||||
struct eficonfig_entry *entry, *tmp;
|
struct eficonfig_entry *entry, *tmp;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bootmenu_loop(NULL, &key, &esc);
|
key = bootmenu_loop(NULL, &esc);
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case BKEY_PLUS:
|
case BKEY_PLUS:
|
||||||
|
|
|
@ -476,9 +476,9 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc)
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bootmenu_loop(struct bootmenu_data *menu,
|
enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc)
|
||||||
enum bootmenu_key *key, int *esc)
|
|
||||||
{
|
{
|
||||||
|
enum bootmenu_key key = BKEY_NONE;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
if (*esc == 1) {
|
if (*esc == 1) {
|
||||||
|
@ -505,17 +505,17 @@ void bootmenu_loop(struct bootmenu_data *menu,
|
||||||
/* First char of ANSI escape sequence '\e' */
|
/* First char of ANSI escape sequence '\e' */
|
||||||
if (c == '\e') {
|
if (c == '\e') {
|
||||||
*esc = 1;
|
*esc = 1;
|
||||||
*key = BKEY_NONE;
|
key = BKEY_NONE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* Second char of ANSI '[' */
|
/* Second char of ANSI '[' */
|
||||||
if (c == '[') {
|
if (c == '[') {
|
||||||
*esc = 2;
|
*esc = 2;
|
||||||
*key = BKEY_NONE;
|
key = BKEY_NONE;
|
||||||
} else {
|
} else {
|
||||||
/* Alone ESC key was pressed */
|
/* Alone ESC key was pressed */
|
||||||
*key = BKEY_QUIT;
|
key = BKEY_QUIT;
|
||||||
*esc = (c == '\e') ? 1 : 0;
|
*esc = (c == '\e') ? 1 : 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -524,7 +524,7 @@ void bootmenu_loop(struct bootmenu_data *menu,
|
||||||
/* Third char of ANSI (number '1') - optional */
|
/* Third char of ANSI (number '1') - optional */
|
||||||
if (*esc == 2 && c == '1') {
|
if (*esc == 2 && c == '1') {
|
||||||
*esc = 3;
|
*esc = 3;
|
||||||
*key = BKEY_NONE;
|
key = BKEY_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,31 +532,33 @@ void bootmenu_loop(struct bootmenu_data *menu,
|
||||||
|
|
||||||
/* ANSI 'A' - key up was pressed */
|
/* ANSI 'A' - key up was pressed */
|
||||||
if (c == 'A')
|
if (c == 'A')
|
||||||
*key = BKEY_UP;
|
key = BKEY_UP;
|
||||||
/* ANSI 'B' - key down was pressed */
|
/* ANSI 'B' - key down was pressed */
|
||||||
else if (c == 'B')
|
else if (c == 'B')
|
||||||
*key = BKEY_DOWN;
|
key = BKEY_DOWN;
|
||||||
/* other key was pressed */
|
/* other key was pressed */
|
||||||
else
|
else
|
||||||
*key = BKEY_NONE;
|
key = BKEY_NONE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enter key was pressed */
|
/* enter key was pressed */
|
||||||
if (c == '\r')
|
if (c == '\r')
|
||||||
*key = BKEY_SELECT;
|
key = BKEY_SELECT;
|
||||||
|
|
||||||
/* ^C was pressed */
|
/* ^C was pressed */
|
||||||
if (c == 0x3)
|
if (c == 0x3)
|
||||||
*key = BKEY_QUIT;
|
key = BKEY_QUIT;
|
||||||
|
|
||||||
if (c == '+')
|
if (c == '+')
|
||||||
*key = BKEY_PLUS;
|
key = BKEY_PLUS;
|
||||||
|
|
||||||
if (c == '-')
|
if (c == '-')
|
||||||
*key = BKEY_MINUS;
|
key = BKEY_MINUS;
|
||||||
|
|
||||||
if (c == ' ')
|
if (c == ' ')
|
||||||
*key = BKEY_SPACE;
|
key = BKEY_SPACE;
|
||||||
|
|
||||||
|
return key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,10 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc);
|
||||||
* character is recognised
|
* character is recognised
|
||||||
*
|
*
|
||||||
* @menu: Menu being processed
|
* @menu: Menu being processed
|
||||||
* @key: Returns the code for the key the user pressed:
|
* @esc: On input, a non-zero value indicates that an escape sequence has
|
||||||
|
* resulted in that many characters so far. On exit this is updated to the
|
||||||
|
* new number of characters
|
||||||
|
* Returns: code for the key the user pressed:
|
||||||
* enter: BKEY_SELECT
|
* enter: BKEY_SELECT
|
||||||
* Ctrl-C: BKEY_QUIT
|
* Ctrl-C: BKEY_QUIT
|
||||||
* Up arrow: BKEY_UP
|
* Up arrow: BKEY_UP
|
||||||
|
@ -92,11 +95,7 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc);
|
||||||
* Plus: BKEY_PLUS
|
* Plus: BKEY_PLUS
|
||||||
* Minus: BKEY_MINUS
|
* Minus: BKEY_MINUS
|
||||||
* Space: BKEY_SPACE
|
* Space: BKEY_SPACE
|
||||||
* @esc: On input, a non-zero value indicates that an escape sequence has
|
|
||||||
* resulted in that many characters so far. On exit this is updated to the
|
|
||||||
* new number of characters
|
|
||||||
*/
|
*/
|
||||||
void bootmenu_loop(struct bootmenu_data *menu,
|
enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc);
|
||||||
enum bootmenu_key *key, int *esc);
|
|
||||||
|
|
||||||
#endif /* __MENU_H__ */
|
#endif /* __MENU_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue