[Concept,09/18] video: Set ctx_size in console_truetype driver

Message ID 20260117005702.1684841-10-sjg@u-boot.org
State New
Headers
Series Refactor vidconsole context for dynamic allocation |

Commit Message

Simon Glass Jan. 17, 2026, 12:56 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add a bind function to the truetype console driver that sets the
ctx_size to sizeof(struct console_tt_ctx). This tells the uclass to
allocate enough space for the driver's extended context structure,
which includes the base vidconsole_ctx plus driver-specific fields
for cursor position history.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 drivers/video/console_truetype.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Patch

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index a9553cc9a53..faf10f2730b 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -1375,10 +1375,20 @@  struct vidconsole_ops console_truetype_ops = {
 	.mark_start	= truetype_mark_start,
 };
 
+static int console_truetype_bind(struct udevice *dev)
+{
+	struct vidconsole_uc_plat *plat = dev_get_uclass_plat(dev);
+
+	plat->ctx_size = sizeof(struct console_tt_ctx);
+
+	return 0;
+}
+
 U_BOOT_DRIVER(vidconsole_truetype) = {
 	.name	= "vidconsole_tt",
 	.id	= UCLASS_VIDEO_CONSOLE,
 	.ops	= &console_truetype_ops,
+	.bind	= console_truetype_bind,
 	.probe	= console_truetype_probe,
 	.remove	= console_truetype_remove,
 	.priv_auto	= sizeof(struct console_tt_priv),