Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vt: move vc_translate to vt.c and rename it

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>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
a018180c 9a6f72d9

+13 -4
+13 -1
drivers/tty/vt/vt.c
··· 2560 2560 *draw_x = -1; 2561 2561 } 2562 2562 2563 + static inline int vc_translate_ascii(const struct vc_data *vc, int c) 2564 + { 2565 + if (IS_ENABLED(CONFIG_CONSOLE_TRANSLATIONS)) { 2566 + if (vc->vc_toggle_meta) 2567 + c |= 0x80; 2568 + 2569 + return vc->vc_translate[c]; 2570 + } 2571 + 2572 + return c; 2573 + } 2574 + 2563 2575 /* acquires console_lock */ 2564 2576 static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) 2565 2577 { ··· 2699 2687 c = 0xfffd; 2700 2688 tc = c; 2701 2689 } else { /* no utf or alternate charset mode */ 2702 - tc = vc_translate(vc, c); 2690 + tc = vc_translate_ascii(vc, c); 2703 2691 } 2704 2692 2705 2693 param.c = tc;
-3
include/linux/vt_kern.h
··· 74 74 void con_free_unimap(struct vc_data *vc); 75 75 int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc); 76 76 77 - #define vc_translate(vc, c) ((vc)->vc_translate[(c) | \ 78 - ((vc)->vc_toggle_meta ? 0x80 : 0)]) 79 77 #else 80 78 static inline int con_set_trans_old(unsigned char __user *table) 81 79 { ··· 122 124 return 0; 123 125 } 124 126 125 - #define vc_translate(vc, c) (c) 126 127 #endif 127 128 128 129 /* vt.c */