[PATCH 10/40] expo: Store the console in the expo
Simon Glass
sjg at chromium.org
Thu Jun 1 18:22:34 CEST 2023
Rather than finding this each time, keep a pointer to it. This simplifies
the code a little.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
boot/expo.c | 9 +++++++++
boot/scene.c | 10 ++--------
include/expo.h | 2 ++
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/boot/expo.c b/boot/expo.c
index 05950a176038..cd1b1a3de50c 100644
--- a/boot/expo.c
+++ b/boot/expo.c
@@ -83,7 +83,16 @@ const char *expo_get_str(struct expo *exp, uint id)
int expo_set_display(struct expo *exp, struct udevice *dev)
{
+ struct udevice *cons;
+ int ret;
+
+ ret = device_find_first_child_by_uclass(dev, UCLASS_VIDEO_CONSOLE,
+ &cons);
+ if (ret)
+ return log_msg_ret("con", ret);
+
exp->display = dev;
+ exp->cons = cons;
return 0;
}
diff --git a/boot/scene.c b/boot/scene.c
index d2f77c008cf7..7e9ba047f2d4 100644
--- a/boot/scene.c
+++ b/boot/scene.c
@@ -278,16 +278,10 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode)
{
struct scene *scn = obj->scene;
struct expo *exp = scn->expo;
- struct udevice *cons, *dev = exp->display;
+ struct udevice *dev = exp->display;
+ struct udevice *cons = text_mode ? NULL : exp->cons;
int x, y, ret;
- cons = NULL;
- if (!text_mode) {
- ret = device_find_first_child_by_uclass(dev,
- UCLASS_VIDEO_CONSOLE,
- &cons);
- }
-
x = obj->x;
y = obj->y;
diff --git a/include/expo.h b/include/expo.h
index 8827f4b0b45f..06f5629e03f8 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -50,6 +50,7 @@ struct expo_action {
*
* @name: Name of the expo (allocated)
* @display: Display to use (`UCLASS_VIDEO`), or NULL to use text mode
+ * @cons: Console to use (`UCLASS_VIDEO_CONSOLE`), or NULL to use text mode
* @scene_id: Current scene ID (0 if none)
* @next_id: Next ID number to use, for automatic allocation
* @action: Action selected by user. At present only one is supported, with the
@@ -62,6 +63,7 @@ struct expo_action {
struct expo {
char *name;
struct udevice *display;
+ struct udevice *cons;
uint scene_id;
uint next_id;
struct expo_action action;
--
2.41.0.rc0.172.g3f132b7071-goog
More information about the U-Boot
mailing list