From patchwork Tue Jan 20 23:18:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1708 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951273; bh=aviROIrURAAoMJeShQNjlL9+2kQNikABuZ4YCw2i108=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=IHZmMTEmMqENanw5Dc6jUrpL1RsY19xFjzGqxiRf7H0oxrBbA+YleEYnjIuM1y9Ba t+Y13huE2r3uJ7bhwD2zpOAUzepqdT73OIZCUKrkw8tbSE+QYAbbTYEWVc/z5BUUhx XoNGGEb8Css7YJctfJlWQybNM/koKh77l952ZIsTCtwNSbcgzYuOfx+739TukbXOTe nxFm69N1S8bKQk1JZAmJL2AyDF9ijvmGdeU4XDGbiLQfiAW7mD5EGZcv6dDr+9SoYM R+zSthLYZZnj5drdKKAIgDAM6eySAsPmWIv0E1VPCE+YDa+cuuMYhDyl1i9QiWYmEw EacCtWfXE8U5A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A68816959F for ; Tue, 20 Jan 2026 16:21:13 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id lhV6CF-gpypJ for ; Tue, 20 Jan 2026 16:21:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951273; bh=aviROIrURAAoMJeShQNjlL9+2kQNikABuZ4YCw2i108=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=IHZmMTEmMqENanw5Dc6jUrpL1RsY19xFjzGqxiRf7H0oxrBbA+YleEYnjIuM1y9Ba t+Y13huE2r3uJ7bhwD2zpOAUzepqdT73OIZCUKrkw8tbSE+QYAbbTYEWVc/z5BUUhx XoNGGEb8Css7YJctfJlWQybNM/koKh77l952ZIsTCtwNSbcgzYuOfx+739TukbXOTe nxFm69N1S8bKQk1JZAmJL2AyDF9ijvmGdeU4XDGbiLQfiAW7mD5EGZcv6dDr+9SoYM R+zSthLYZZnj5drdKKAIgDAM6eySAsPmWIv0E1VPCE+YDa+cuuMYhDyl1i9QiWYmEw EacCtWfXE8U5A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 967F76959E for ; Tue, 20 Jan 2026 16:21:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951271; bh=zEKdRAEQrEeTW8JPXNKeRkb/oV12pDr4cfiC8/nj+mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuZ9Xn8pQ3Wy9roOigMs4ZRpudauQQl99+NmPTNx2/VcjNssdXDjq0NwYbhMQJOSR BO/bSu/PLP8r/Wzh2MuXw6wwp8OAp7LDqBrUyutWvsVpr8mgHJgztezssiU2v2NQm6 X6+a1HJ/S1LQu0arNEM6KWkIctJ0pdNqRVA3f8ae0+pQ+1b8dsuWi5rLFhANrTJdfV d+tfvKlep1NeWxHuj2gTPxQVudjHWxBm/PiVas+kyHIc79BXRLl8w27mGvGpJYq2eY FGvGWmhBuJ22K2zeNJjhB8P9VglpN7k3UxGIWiMARz4rQpKbGH0QSslgGOIifM2lMs woceY2+NE6sJg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9919369597; Tue, 20 Jan 2026 16:21:11 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id D-CnoWDWdzJU; Tue, 20 Jan 2026 16:21:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951267; bh=UalgBh17F8RuFx2se3Pxyh99mjEAMZlClv4GH4yYlOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KKckPmuwVtF14fPQnN8c72Y2AMmbGKKzEKBLlA7FU2wnzVVhunNQpCJjIesxHxrEL DWVOLiNG11WGstDozNUv5/0Cny7N/bnKFY3exqxvlPdmUc5cwh13gan+AmsHiuN1JQ x9cR4EN4b88LmzLYYYWfNaumcxdWROHFTK+9l5oAkWl3SSlZPRmO6Gd07cj5vS9ujb ST1chtB4HhNIx8Jsy+mZ7LlglsMkeKjCKSB4ZUbtmVAQfIJctYaRGRy+WjRWRRfgtd OXcgbDS78GrlSj8ni1uoOdJblALVdq/3zQkJkHfhWeqc4cEF/ejzOJFfMOCZ3t0dZ0 vWfu51UD1o9gQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id ECCD869463; Tue, 20 Jan 2026 16:21:06 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:18:02 -0700 Message-ID: <20260120231814.2033069-36-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260120231814.2033069-1-sjg@u-boot.org> References: <20260120231814.2033069-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LJYNKEGG75RK4BHDTUE3CQ2WGGFYN5BD X-Message-ID-Hash: LJYNKEGG75RK4BHDTUE3CQ2WGGFYN5BD X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 35/36] video: Move context freeing to uclass List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 Signed-off-by: Simon Glass --- 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(-) diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 5f57b3403f1..c3b7f848b43 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -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), }; diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index ae7e7d0ec58..4cf7ffebef3 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -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, diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index b22408dc2a4..147063c4d38 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -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)