[Patch 9/9]: vt: Misc changes, e.g. to #include directives

From: Alan Mackenzie

Date: Thu Aug 27 2026 - 15:03:01 EST


vt: 32b glyph: 9. Misc changes, e.g. to #include directives

Rearrange some #include directives, add some clarifying
comments, and some code changes which didn't fit elsewhere.

Signed-off-by: Alan Mackenzie <acm@xxxxxx>

diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index dfdea0842149..35da5e127a49 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -25,7 +25,6 @@

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

-#include <linux/consolemap.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/jiffies.h>
@@ -46,6 +45,7 @@
#include <linux/tty.h>
#include <linux/uaccess.h>
#include <linux/vt_kern.h>
+#include <linux/consolemap.h>

#include <asm/irq_regs.h>

diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index 13f4e48b4142..18affdb3c7c5 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -48,6 +48,8 @@ static struct vc_selection {
.start = -1,
};

+static unsigned int size_row;
+
/* clear_selection, highlight and highlight_pointer can be called
from interrupt (via scrollback/front) */

@@ -340,6 +342,7 @@ static int vc_selection(struct vc_data *vc, struct tiocl_selection *v,
{
int ps, pe;

+ size_row = vc->vc_size_row;
poke_blanked_console();

if (v->sel_mode == TIOCL_SELCLEAR) {
diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index 7d40eacc21b3..f23d61fe10c1 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -201,6 +201,8 @@ static struct vc_data *vcs_vc(struct inode *inode, bool *viewed)

/**
* vcs_size - return size for a VC in @vc
+ * The size is the number of bytes required by a buffer reading to/writing from
+ * the entire device.
* @vc: which VC
* @attr: does it use attributes?
* @unicode: is it unicode?
@@ -307,7 +314,9 @@ static unsigned int vcs_read_buf(const struct vc_data *vc, char *con_buf,
getconsxy(vc, con_buf + 2);

*skip += pos;
- count += pos;
+ count += pos; /* COUNT is now the byte offset of the end
+ * position from the start of the header.
+ */
if (count > CON_BUF_SIZE) {
count = CON_BUF_SIZE;
filled = count - pos;
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 8f467b22b799..0c389a564357 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -89,6 +89,7 @@
#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/vt_kern.h>
+#include <linux/vt_buffer.h>
#include <linux/selection.h>
#include <linux/tiocl.h>
#include <linux/kbd_kern.h>
@@ -4910,15 +4967,17 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
static int con_font_get(struct vc_data *vc, struct console_font_op *op)
{
struct console_font font;
int c;
- unsigned int vpitch = op->op == KD_FONT_OP_GET_TALL ? op->height : 32;
+ unsigned int vpitch =
+ op->op == KD_FONT_OP_GET_TALL ? vc->vc_font.height : 32;

if (vpitch > max_font_height)
return -EINVAL;

void *font_data __free(kvfree) = NULL;
+ c = DIV_ROUND_UP(vc->vc_font.width, 8) * vpitch * vc->vc_font.charcount;
if (op->data) {
- font.data = font_data = kvzalloc(max_font_size, GFP_KERNEL);
+ font.data = font_data = kvzalloc(c, GFP_KERNEL);
if (!font.data)
return -ENOMEM;
} else
@@ -4935,8 +4994,6 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
return ret;
}

- c = DIV_ROUND_UP(font.width, 8) * vpitch * font.charcount;
-
if (op->data && font.charcount > op->charcount)
return -ENOSPC;
if (font.width > op->width || font.height > op->height)
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
index fe915afdece5..5afce52057ca 100644
--- a/include/linux/console_struct.h
+++ b/include/linux/console_struct.h
@@ -13,6 +13,7 @@
#ifndef _LINUX_CONSOLE_STRUCT_H
#define _LINUX_CONSOLE_STRUCT_H

+#include <linux/consolemap.h>
#include <linux/vt.h>
#include <linux/wait.h>
#include <linux/workqueue.h>


--
Alan Mackenzie (Nuremberg, Germany).