vt: move vc_translate to vt.c and rename it
authorJiri Slaby <jslaby@suse.cz>
Mon, 15 Jun 2020 07:48:42 +0000 (09:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:08:31 +0000 (17:08 +0200)
vc_translate is used only in vt.c, so move the definition from a header
there. Also, it used to be a macro, so be modern and make a static
inline from it. This makes the code actually readable.

And as a preparation for next patches, rename it to vc_translate_ascii.
vc_translate will be a wrapper for both unicode and this one.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20200615074910.19267-10-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt.c
include/linux/vt_kern.h

index 8d9e532..b866393 100644 (file)
@@ -2560,6 +2560,18 @@ static void con_flush(struct vc_data *vc, unsigned long draw_from,
        *draw_x = -1;
 }
 
+static inline int vc_translate_ascii(const struct vc_data *vc, int c)
+{
+       if (IS_ENABLED(CONFIG_CONSOLE_TRANSLATIONS)) {
+               if (vc->vc_toggle_meta)
+                       c |= 0x80;
+
+               return vc->vc_translate[c];
+       }
+
+       return c;
+}
+
 /* acquires console_lock */
 static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count)
 {
@@ -2687,7 +2699,7 @@ rescan_last_byte:
                        c = 0xfffd;
                    tc = c;
                } else {        /* no utf or alternate charset mode */
-                   tc = vc_translate(vc, c);
+                       tc = vc_translate_ascii(vc, c);
                }
 
                param.c = tc;
index abf5bcc..349e39c 100644 (file)
@@ -74,8 +74,6 @@ int con_set_default_unimap(struct vc_data *vc);
 void con_free_unimap(struct vc_data *vc);
 int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
 
-#define vc_translate(vc, c) ((vc)->vc_translate[(c) |                  \
-                                       ((vc)->vc_toggle_meta ? 0x80 : 0)])
 #else
 static inline int con_set_trans_old(unsigned char __user *table)
 {
@@ -124,7 +122,6 @@ int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc)
        return 0;
 }
 
-#define vc_translate(vc, c) (c)
 #endif
 
 /* vt.c */