From: Simon Glass <simon.glass@canonical.com>
Move the responsibility for freeing context memory from the driver's
ctx_dispose() method to the uclass's vidconsole_free_ctx(). This
simplifies the drivers since they no longer need to implement
ctx_dispose() just to call free().
The ctx_dispose() method is still called if present, but only needs to
handle driver-specific cleanup. The uclass handles freeing the cursor
and the context memory.
Also remove the console_probe() reference from console_normal since the
uclass handles all probe setup.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
drivers/video/console_normal.c | 9 ---------
drivers/video/console_truetype.c | 8 --------
drivers/video/vidconsole-uclass.c | 3 ++-
3 files changed, 2 insertions(+), 18 deletions(-)
@@ -191,13 +191,6 @@ static int console_simple_ctx_new(struct udevice *dev, void **ctxp)
return 0;
}
-static int console_simple_ctx_dispose(struct udevice *dev, void *ctx)
-{
- free(ctx);
-
- return 0;
-}
-
struct vidconsole_ops console_ops = {
.putc_xy = console_putc_xy,
.move_rows = console_move_rows,
@@ -206,7 +199,6 @@ struct vidconsole_ops console_ops = {
.get_font = console_simple_get_font,
.select_font = console_simple_select_font,
.ctx_new = console_simple_ctx_new,
- .ctx_dispose = console_simple_ctx_dispose,
#ifdef CONFIG_CURSOR
.get_cursor_info = console_get_cursor_info,
.entry_save = normal_entry_save,
@@ -218,6 +210,5 @@ U_BOOT_DRIVER(vidconsole_normal) = {
.name = "vidconsole0",
.id = UCLASS_VIDEO_CONSOLE,
.ops = &console_ops,
- .probe = console_probe,
.priv_auto = sizeof(struct console_simple_priv),
};
@@ -1157,13 +1157,6 @@ static int truetype_ctx_new(struct udevice *dev, void **ctxp)
return 0;
}
-static int truetype_ctx_dispose(struct udevice *dev, void *ctx)
-{
- free(ctx);
-
- return 0;
-}
-
static int truetype_entry_save(struct udevice *dev, struct abuf *buf)
{
struct console_tt_ctx *ctx = vidconsole_ctx(dev);
@@ -1327,7 +1320,6 @@ struct vidconsole_ops console_truetype_ops = {
.measure = truetype_measure,
.nominal = truetype_nominal,
.ctx_new = truetype_ctx_new,
- .ctx_dispose = truetype_ctx_dispose,
.entry_save = truetype_entry_save,
.entry_restore = truetype_entry_restore,
.get_cursor_info = truetype_get_cursor_info,
@@ -749,9 +749,10 @@ static void vidconsole_free_ctx(struct udevice *dev, struct vidconsole_ctx *ctx)
{
struct vidconsole_ops *ops = vidconsole_get_ops(dev);
- console_free_cursor(&ctx->curs);
if (ops->ctx_dispose)
ops->ctx_dispose(dev, ctx);
+ console_free_cursor(&ctx->curs);
+ free(ctx);
}
int vidconsole_ctx_dispose(struct udevice *dev, void *vctx)