aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/tty/vt
diff options
context:
space:
mode:
authorAlexey Gladkov <legion@kernel.org>2025-02-21 13:43:53 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-25 16:28:44 +0200
commitf92217683a44f79759d805194d6d36af1bde6e10 (patch)
tree1e40b410d0b569983f2ad81b749ebec1c95bbff6 /drivers/tty/vt
parenttty/vt: Use KVAL instead of use bit operation (diff)
downloadwireguard-linux-f92217683a44f79759d805194d6d36af1bde6e10.tar.xz
wireguard-linux-f92217683a44f79759d805194d6d36af1bde6e10.zip
tty/vt: Gather the code that outputs char with utf8 in mind
When we putting character to the tty, we take into account the keyboard mode to properly handle utf8. This code is duplicated few times. Signed-off-by: Alexey Gladkov <legion@kernel.org> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> Link: https://lore.kernel.org/r/c0d10193e61f977b518862d8f216bbaf234138fd.1740141518.git.legion@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r--drivers/tty/vt/keyboard.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index ce2dcf3c824a..dc585079c2fb 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -376,6 +376,17 @@ static void to_utf8(struct vc_data *vc, uint c)
}
}
+static void put_queue_utf8(struct vc_data *vc, u32 value)
+{
+ if (kbd->kbdmode == VC_UNICODE)
+ to_utf8(vc, value);
+ else {
+ int c = conv_uni_to_8bit(value);
+ if (c != -1)
+ put_queue(vc, c);
+ }
+}
+
/* FIXME: review locking for vt.c callers */
static void set_leds(void)
{
@@ -454,13 +465,7 @@ static unsigned int handle_diacr(struct vc_data *vc, unsigned int ch)
if (ch == ' ' || ch == (BRL_UC_ROW|0) || ch == d)
return d;
- if (kbd->kbdmode == VC_UNICODE)
- to_utf8(vc, d);
- else {
- int c = conv_uni_to_8bit(d);
- if (c != -1)
- put_queue(vc, c);
- }
+ put_queue_utf8(vc, d);
return ch;
}
@@ -471,13 +476,7 @@ static unsigned int handle_diacr(struct vc_data *vc, unsigned int ch)
static void fn_enter(struct vc_data *vc)
{
if (diacr) {
- if (kbd->kbdmode == VC_UNICODE)
- to_utf8(vc, diacr);
- else {
- int c = conv_uni_to_8bit(diacr);
- if (c != -1)
- put_queue(vc, c);
- }
+ put_queue_utf8(vc, diacr);
diacr = 0;
}
@@ -685,13 +684,7 @@ static void k_unicode(struct vc_data *vc, unsigned int value, char up_flag)
diacr = value;
return;
}
- if (kbd->kbdmode == VC_UNICODE)
- to_utf8(vc, value);
- else {
- int c = conv_uni_to_8bit(value);
- if (c != -1)
- put_queue(vc, c);
- }
+ put_queue_utf8(vc, value);
}
/*