From patchwork Tue Jan 20 23:18:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1707 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=1768951269; bh=18ye/pmBNOkXBeibRK8noNNShp3jy5I3jYgs1usaRTo=; 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=OpHuXM0OeMT1dXvFKMBbtdifEq++k1ejP2t1lz7uwiuBsiCzXwkDgfdEm8MyIgRgU WcE9kjWBQFIWUeJGSwTU7NPu2S0hnB/iIpWsw7fi4cgYQfStxbR6FbfXyrpkR+moVo g4wk8+Qi4xv+dRd17jUF7YFIurxjjSBMgLsJHJ1K2BdvA+qr8f8SW4fubDG/y+ZnCn bsn44QsmLgcVJ5/opcpMGaAAjkCpAP197O7uZ2rWikil8px2LtI0tJejRzDwdalx/B GCIWj6AmDfcusT2YwsuBPmQzjvixWDgJphZw/oGe2hy8iDPz2PeX+blendoxN23lbh kq7/tuTjx958A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 36E086959F for ; Tue, 20 Jan 2026 16:21:09 -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 12dOjLU6bvoe for ; Tue, 20 Jan 2026 16:21:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951269; bh=18ye/pmBNOkXBeibRK8noNNShp3jy5I3jYgs1usaRTo=; 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=OpHuXM0OeMT1dXvFKMBbtdifEq++k1ejP2t1lz7uwiuBsiCzXwkDgfdEm8MyIgRgU WcE9kjWBQFIWUeJGSwTU7NPu2S0hnB/iIpWsw7fi4cgYQfStxbR6FbfXyrpkR+moVo g4wk8+Qi4xv+dRd17jUF7YFIurxjjSBMgLsJHJ1K2BdvA+qr8f8SW4fubDG/y+ZnCn bsn44QsmLgcVJ5/opcpMGaAAjkCpAP197O7uZ2rWikil8px2LtI0tJejRzDwdalx/B GCIWj6AmDfcusT2YwsuBPmQzjvixWDgJphZw/oGe2hy8iDPz2PeX+blendoxN23lbh kq7/tuTjx958A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26DFD6959D for ; Tue, 20 Jan 2026 16:21:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951268; bh=HFGMZUyMC66EqekrNDPcDw+7aN9sUSpKCbP7ZVTv23A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9a5Bwq8HtxCdL7cCsn6UZy8QWlgapqlt5vwYarBaKTcLteUlKG3VBZmIedwVzCO9 PR9sXX2QbQdbTGN3hrzm7Th5gmoEmLwgQRfYJwnaZXmn0AYcLhjew/nbbWOEr8pbgv 7OmDq8lc18CC/36v7MOF0v4/AuSkER1TV8f25aGYqYJOaXgAZc/u9UwyYOhWvoSTXO LbbESlwRKaTlO0b+hQXQS5GGMQB0PLM5erjv8RtADvqCoUZuD789D+S7XUAoMiQob0 eA/EVtogFvRlVrX2Uxexsvh1EOp5wm8mf4vN/6rJ5iEDLSi0QqHKmmosQ+8mH/hycg 2W30yXl8y1r9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3040069597; Tue, 20 Jan 2026 16:21:08 -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 2OTAs3jXI0Tr; Tue, 20 Jan 2026 16:21:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951262; bh=iqpiEIjOlDx890TEiZmdfM6Fz80DgIXWBlvGB3DOW/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bF0dOttLIDtCn+gHHJT8TiDPoW9ixVl9VLxm63DXKk/lP/SEs7jpK0bWIpkFLl6ej q07ZcDdZoxvyRcI//3IkacwNJ5pVfYMMOodoOvwIJmr5DQxF4/PlBkUTlYaJIZfq1z Cxchx8brzd7AdrWikre1ZfYl4/gicuyKXl+zAjkeMeI6d3INqFL3boJC4BJRhAB1ks lxum1iiBm/0dhrYjn9bCjcuxmTfIIHouENFhsRzC/Orm1+HUlzjOvOfrIFkol5DhM/ DzXb2ULcFQ80KyMuPsspISvYPOgIG2/smgKaCBQuzvH4KF9twTRTm4d8bMWRpScE+D ABhciOfICpL/A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2CE026959E; Tue, 20 Jan 2026 16:21:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:18:01 -0700 Message-ID: <20260120231814.2033069-35-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: H5GZWU3IV25GXLFEB6UHPL6XVA4QRXYR X-Message-ID-Hash: H5GZWU3IV25GXLFEB6UHPL6XVA4QRXYR 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 34/36] video: Pass a cursor pointer to console_alloc_cursor() 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 Change console_alloc_cursor() to take a struct vidconsole_cursor pointer directly instead of the full context, since that is not needed. This allows the function to be used a cursor embedded in a larger struct. Add a matching console_free_cursor() function to free the cursor's save_data buffer. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_core.c | 9 ++++++--- drivers/video/vidconsole-uclass.c | 4 ++-- drivers/video/vidconsole_internal.h | 13 +++++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index 0580e2661de..6bd7dc263e6 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -280,9 +280,8 @@ int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv, return 0; } -int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx) +int console_alloc_cursor(struct udevice *dev, struct vidconsole_cursor *curs) { - struct vidconsole_cursor *curs; struct video_priv *vid_priv; struct udevice *vid; int save_count; @@ -291,7 +290,6 @@ int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx) return 0; vid = dev_get_parent(dev); vid_priv = dev_get_uclass_priv(vid); - curs = &ctx->curs; /* Allocate cursor save buffer for maximum possible cursor height */ save_count = vid_priv->ysize * VIDCONSOLE_CURSOR_WIDTH; @@ -302,6 +300,11 @@ int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx) return 0; } +void console_free_cursor(struct vidconsole_cursor *curs) +{ + free(curs->save_data); +} + int console_probe(struct udevice *dev) { int ret; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 83cd1651205..b22408dc2a4 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -749,7 +749,7 @@ 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); + console_free_cursor(&ctx->curs); if (ops->ctx_dispose) ops->ctx_dispose(dev, ctx); } @@ -951,7 +951,7 @@ static int vidconsole_post_probe(struct udevice *dev) int ret; if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { - ret = console_alloc_cursor(dev, ctx); + ret = console_alloc_cursor(dev, &ctx->curs); if (ret) return ret; } diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 23d29fea081..b5ffdfad4da 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -152,10 +152,19 @@ int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv, * Allocates memory for saving pixels under the cursor * * @dev: vidconsole device - * @ctx: vidconsole context + * @curs: cursor to set up * Return: 0 if success, -ENOMEM if allocation fails */ -int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx); +int console_alloc_cursor(struct udevice *dev, struct vidconsole_cursor *curs); + +/** + * console_free_cursor() - Free cursor memory + * + * Free the memory used by a cursor + * + * @curs: cursor to set up + */ +void console_free_cursor(struct vidconsole_cursor *curs); /** * console probe function.