From: Simon Glass <simon.glass@canonical.com>
The backspace() driver method currently uses the default context. Update
it to accept a context parameter so callers can specify which context to
use for the backspace operation. This is needed for text-input objects
which have their own vidconsole context.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
drivers/video/console_truetype.c | 5 +++--
drivers/video/vidconsole-uclass.c | 10 ++++------
include/video_console.h | 3 ++-
3 files changed, 9 insertions(+), 9 deletions(-)
@@ -660,12 +660,13 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
* not been entered.
*
* @dev: Device to update
+ * @vctx: Vidconsole context to use
* Return: 0 if OK, -ENOSYS if not supported
*/
-static int console_truetype_backspace(struct udevice *dev)
+static int console_truetype_backspace(struct udevice *dev, void *vctx)
{
struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
- struct console_tt_ctx *ctx = vidconsole_ctx(dev);
+ struct console_tt_ctx *ctx = vctx;
struct vidconsole_ctx *com = &ctx->com;
struct pos_info *pos;
int xend;
@@ -61,16 +61,14 @@ int vidconsole_entry_start(struct udevice *dev, void *ctx)
return ops->entry_start(dev, ctx);
}
-/* Move backwards one space */
-static int vidconsole_back(struct udevice *dev)
+/* Move backwards one space, ctx must be non-NULL */
+static int vidconsole_back(struct udevice *dev, struct vidconsole_ctx *ctx)
{
- struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
- struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv);
struct vidconsole_ops *ops = vidconsole_get_ops(dev);
int ret;
if (ops->backspace) {
- ret = ops->backspace(dev);
+ ret = ops->backspace(dev, ctx);
if (ret != -ENOSYS)
return ret;
}
@@ -523,7 +521,7 @@ int vidconsole_put_char(struct udevice *dev, char ch)
vidconsole_newline(dev);
break;
case '\b':
- vidconsole_back(dev);
+ vidconsole_back(dev, ctx);
ctx->last_ch = 0;
break;
default:
@@ -294,6 +294,7 @@ struct vidconsole_ops {
* backspace() - Handle erasing the last character
*
* @dev: Device to adjust
+ * @ctx: Vidconsole context to use
* Returns: 0 on success, -ve on error
*
* With proportional fonts the vidconsole uclass cannot itself erase
@@ -305,7 +306,7 @@ struct vidconsole_ops {
* If not implement, default behaviour will work for fixed-width
* characters.
*/
- int (*backspace)(struct udevice *dev);
+ int (*backspace)(struct udevice *dev, void *ctx);
/**
* get_font() - Obtain information about a font (optional)