When the user presses 'up' when on the top menu item, it is a waste of
time to refresh since nothing has changed.

Add a new return code from this function to indicate that the UI must be
refreshed.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 boot/bootflow_menu.c | 2 ++
 cmd/bootflow.c       | 2 +-
 include/bootflow.h   | 4 +++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c
index 1966e38a6d6..2f08fa54081 100644
--- a/boot/bootflow_menu.c
+++ b/boot/bootflow_menu.c
@@ -310,6 +310,8 @@ int bootflow_menu_poll(struct expo *exp, int *seqp)
                ret = scene_menu_select_item(scn, OBJ_MENU, act.select.id);
                if (ret)
                        return log_msg_ret("bmp", ret);
+               if (act.select.changed)
+                       return -EREMCHG;
                return -ERESTART;
        }
        case EXPOACT_QUIT:
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 9d449f430c9..3bdebd96bda 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -126,7 +126,7 @@ __maybe_unused static int bootflow_handle_menu(struct 
bootstd_priv *std,
                                return log_msg_ret("bhr", ret);
                }
                ret = bootflow_menu_poll(exp, &seq);
-       } while (ret == -EAGAIN || ret == -ERESTART);
+       } while (ret == -EAGAIN || ret == -ERESTART || ret == -EREMCHG);
 
        if (ret == -EPIPE) {
                printf("Nothing chosen\n");
diff --git a/include/bootflow.h b/include/bootflow.h
index c0e19feb9cc..18bfa1fe8b1 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -688,7 +688,9 @@ int bootflow_menu_start(struct bootstd_priv *std, bool 
text_mode,
  * @exp: Expo to poll
  * @seqp: Returns the bootflow chosen or currently pointed to (numbered from 0)
  * Return: 0 if a bootflow was chosen, -EAGAIN if nothing is chosen yet, -EPIPE
- *     if the user quit, -ERESTART if the expo needs refreshing
+ *     if the user quit, -EREMCHG if the expo needs refreshing, -ERESTART if
+ *     the user tried to move to a new selection but was unable (e.g. already
+ *     at the top and tried to move up)
  */
 int bootflow_menu_poll(struct expo *exp, int *seqp);
 
-- 
2.43.0

base-commit: e3ced530e543c9f24cbc66430abc6109ce8df015
branch: expa

Reply via email to