From patchwork Tue Jan 20 23:18:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1706 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=1768951265; bh=kPP/HT3IWyyFacFZ7H9rlNDSY/RwOhE8Rlr41kKzg10=; 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=cAbX51XHbHccwQXRXVv1qjLN69oK1lS/L7nmGAOUiRFaklPREhduWcu4EY/4DNXqp d7pFLhQu4XEeGVQnw+tagIVpSVKDaGT84JfcMvhfPut4u6n/KgUSChnzX2RzGOzcFz fGwTqBoxC7oXdxnBWFRWlrsNo5TcK3Cbfq+VOeZu33ZRJ3tQG8FAnAjXl3Wr/nLuVU 3nPgWb037ctZsEbC/UOyA6AgcNL6jzKZBshZ2MdPC/+ouyCKrsbwkFeFjt8vckhT+n +qd0KbFS8UgcgcBCqF8QLJCDec9k3oMlvj9VQY4XtkRDUpoEcXj5UCKw03yBWs2rsx Vx7XBcN/9i4lQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 79DED69463 for ; Tue, 20 Jan 2026 16:21:05 -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 LMGj_3Kzf_bP for ; Tue, 20 Jan 2026 16:21:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951265; bh=kPP/HT3IWyyFacFZ7H9rlNDSY/RwOhE8Rlr41kKzg10=; 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=cAbX51XHbHccwQXRXVv1qjLN69oK1lS/L7nmGAOUiRFaklPREhduWcu4EY/4DNXqp d7pFLhQu4XEeGVQnw+tagIVpSVKDaGT84JfcMvhfPut4u6n/KgUSChnzX2RzGOzcFz fGwTqBoxC7oXdxnBWFRWlrsNo5TcK3Cbfq+VOeZu33ZRJ3tQG8FAnAjXl3Wr/nLuVU 3nPgWb037ctZsEbC/UOyA6AgcNL6jzKZBshZ2MdPC/+ouyCKrsbwkFeFjt8vckhT+n +qd0KbFS8UgcgcBCqF8QLJCDec9k3oMlvj9VQY4XtkRDUpoEcXj5UCKw03yBWs2rsx Vx7XBcN/9i4lQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 69A1469597 for ; Tue, 20 Jan 2026 16:21:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951264; bh=gOePhU8eU3HZUsUZejsbH4p1WPBJcWP+dxJoIT+g2wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mlcFj+6FU0uH+J2K/+llsSTaPOUC3q1WyUp3FOvtwAjuXpPQya1Kx8XSRRa7yiHiF aTB91eJU9p4aebgVHQVisQOHFnFlIemMx2SGZnBjpORP84Xwy2kkuyP7KhBeAP19e3 WVXQ4SUfxkOoSEVGcorEh/YqdTOGzPPtWXc4JP1IZtUWKn7QiakbHT+XBdV02lKStX I/DUBZIbgLGebeTqZgTjXH4gC0nsb3Akc8lQfEMzYwxQUVixC2MhAN4wQDoplYN2UB RZPrYLijoxEfe46Y1AGnOpYw6T1cpuxjdXfv5MSYn4wouIAtZXSaKXldHJCUAOmKe/ IVzwFbvUaUBCw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 587D56959D; Tue, 20 Jan 2026 16:21:04 -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 1PfZVRq1Isgz; Tue, 20 Jan 2026 16:21:04 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951257; bh=h0KPhNvn2yyHJ4jNiCnumo4g3lWd0rZ1JZ+gnfnQ+Xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YlKJYDF6LsH8vm+GUyWbuX3f7fl/dT37IGOwzMFLw8Sg9LG5kj8UbJoGxf6dm61aT oSKFk/uZIXMGCWSRHKUsfFUIVOe3+r63+T9Og0sq+8EQ6aj6APRAufrXlDvsTT6N3J ug2vjjZ2J5knvCKbG2EXkwUQlrnsVWQashq4AJngC8milsjgoKEUzVHvbgJIrGcIss qkWJe2NfpSNXLOdqArmmci6gLrxLql7Zb2mUi+JJNYAE3s71j8SAm9R9zDNPiMhHYv BgRLaj1eMaUqBJocq+beW1q2XgKG1vlkReZtW/KODk2neEt7Xk+rjDFCntAyFvu+NJ 8PHVP3IVbhpnA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 626EF69463; Tue, 20 Jan 2026 16:20:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:18:00 -0700 Message-ID: <20260120231814.2033069-34-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: XPFAXX5LCZEOAJWCYCZUX5VYUXYO3TN5 X-Message-ID-Hash: XPFAXX5LCZEOAJWCYCZUX5VYUXYO3TN5 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 33/36] video: Allocate the cursor in the 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 Both console_core.c and console_truetype.c call console_alloc_cursor() to set up the cursor-save buffer. This duplication can be avoided by moving the call into vidconsole_post_probe() where it benefits all drivers. Move cursor allocation into the uclass and remove the calls from the individual drivers. Also reorder vidconsole_free_ctx() to free the cursor save_data before calling ctx_dispose(), since the cursor is now owned by the uclass rather than the driver. Signed-off-by: Simon Glass --- drivers/video/console_core.c | 6 ------ drivers/video/console_truetype.c | 4 ---- drivers/video/vidconsole-uclass.c | 12 ++++++++++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index c26a35e435d..0580e2661de 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -310,12 +310,6 @@ int console_probe(struct udevice *dev) if (ret) return ret; - if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { - ret = console_alloc_cursor(dev, vidconsole_ctx(dev)); - if (ret) - return ret; - } - return 0; } diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index f797dbe16f9..ae7e7d0ec58 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1302,10 +1302,6 @@ static int console_truetype_probe(struct udevice *dev) debug("%s: ready\n", __func__); - ret = console_alloc_cursor(dev, &ctx->com); - if (ret) - return ret; - return 0; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 4433920ecb6..83cd1651205 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -13,9 +13,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include "vidconsole_internal.h" @@ -748,9 +749,9 @@ static void vidconsole_free_ctx(struct udevice *dev, struct vidconsole_ctx *ctx) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); + free(ctx->curs.save_data); if (ops->ctx_dispose) ops->ctx_dispose(dev, ctx); - free(ctx->curs.save_data); } int vidconsole_ctx_dispose(struct udevice *dev, void *vctx) @@ -947,6 +948,13 @@ static int vidconsole_post_probe(struct udevice *dev) struct vidconsole_priv *priv = dev_get_uclass_priv(dev); struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); struct stdio_dev *sdev = &priv->sdev; + int ret; + + if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { + ret = console_alloc_cursor(dev, ctx); + if (ret) + return ret; + } if (!ctx->tab_width_frac) ctx->tab_width_frac = VID_TO_POS(ctx->x_charsize) * 8;