expo: Add a function to poll for input
Both bootflow_menu and cedit use similar logic to poll an expo. Move
this into the expo library so the code can be shared.
Update bootflow_menu_run() to return -EPIPE when the user quits without
choosing anything, since -EAGAIN is ambiguous and elsewhere means that
there is no input yet.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/include/bootflow.h b/include/bootflow.h
index d408b8c..fe090d3 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -508,7 +508,7 @@
* @std: Bootstd information
* @text_mode: Uses a text-based menu suitable for a serial port
* @bflowp: Returns chosen bootflow (set to NULL if nothing is chosen)
- * @return 0 if an option was chosen, -EAGAIN if nothing was chosen, -ve on
+ * @return 0 if an option was chosen, -EPIPE if nothing was chosen, -ve on
* error
*/
int bootflow_menu_run(struct bootstd_priv *std, bool text_mode,
diff --git a/include/expo.h b/include/expo.h
index b3b9c0b..63452bb 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -772,4 +772,17 @@
*/
int cb_expo_build(struct expo **expp);
+/**
+ * expo_poll() - render an expo and see if the user takes an action
+ *
+ * Thsi calls expo_render() and then checks for a keypress. If there is one, it
+ * is processed and the resulting action returned, if any
+ *
+ * @exp: Expo to poll
+ * @act: Returns action on success
+ * Return: 0 if an action was obtained, -EAGAIN if not, other error if something
+ * went wrong
+ */
+int expo_poll(struct expo *exp, struct expo_action *act);
+
#endif /*__EXPO_H */