lkml.org 
[lkml]   [2020]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 16/38] vc: move translation out of do_con_write
    Date
    Now that we reordered the code and the label, we can eliminate the
    translation into a separate function. We call it vc_translate here.

    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    ---
    drivers/tty/vt/vt.c | 26 ++++++++++++++++----------
    1 file changed, 16 insertions(+), 10 deletions(-)

    diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
    index 93ad7e004900..0f61dc360067 100644
    --- a/drivers/tty/vt/vt.c
    +++ b/drivers/tty/vt/vt.c
    @@ -2658,6 +2658,19 @@ static int vc_translate_unicode(struct vc_data *vc, int c, bool *rescan)
    return -1;
    }

    +static int vc_translate(struct vc_data *vc, int *c, bool *rescan)
    +{
    + /* Do no translation at all in control states */
    + if (vc->vc_state != ESnormal)
    + return *c;
    +
    + if (vc->vc_utf && !vc->vc_disp_ctrl)
    + return *c = vc_translate_unicode(vc, *c, rescan);
    +
    + /* no utf or alternate charset mode */
    + return vc_translate_ascii(vc, *c);
    +}
    +
    static inline unsigned char vc_invert_attr(const struct vc_data *vc)
    {
    if (!vc->vc_can_do_color)
    @@ -2726,16 +2739,9 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
    inverse = false;
    width = 1;

    - /* Do no translation at all in control states */
    - if (vc->vc_state != ESnormal) {
    - tc = c;
    - } else if (vc->vc_utf && !vc->vc_disp_ctrl) {
    - tc = c = vc_translate_unicode(vc, c, &rescan);
    - if (tc == -1)
    - continue;
    - } else { /* no utf or alternate charset mode */
    - tc = vc_translate_ascii(vc, c);
    - }
    + tc = vc_translate(vc, &c, &rescan);
    + if (tc == -1)
    + continue;

    param.c = tc;
    if (atomic_notifier_call_chain(&vt_notifier_list, VT_PREWRITE,
    --
    2.27.0
    \
     
     \ /
      Last update: 2020-06-15 09:51    [W:4.079 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site