tty: vt: add con_putc() helper
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Mon, 22 Jan 2024 11:03:37 +0000 (12:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jan 2024 02:08:53 +0000 (18:08 -0800)
And let it call consw::con_putc() if it exists, otherwise
consw::con_putcs(). This is similar to tty_put_char().

It supports dropping unneeded duplication of code like sticon_putc() is
(see the next patch).

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
Link: https://lore.kernel.org/r/20240122110401.7289-24-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt.c

index b6f1449421bc34c916949261a23774fce4ab03bf..6091ffcf93d86a63d4d4661590e6b73db5344cea 100644 (file)
@@ -300,6 +300,14 @@ static inline unsigned short *screenpos(const struct vc_data *vc, int offset,
        return p;
 }
 
+static void con_putc(struct vc_data *vc, u16 ca, unsigned int y, unsigned int x)
+{
+       if (vc->vc_sw->con_putc)
+               vc->vc_sw->con_putc(vc, ca, y, x);
+       else
+               vc->vc_sw->con_putcs(vc, &ca, 1, y, x);
+}
+
 /* Called  from the keyboard irq path.. */
 static inline void scrolldelta(int lines)
 {
@@ -762,7 +770,7 @@ void complement_pos(struct vc_data *vc, int offset)
            old_offset < vc->vc_screenbuf_size) {
                scr_writew(old, screenpos(vc, old_offset, true));
                if (con_should_update(vc))
-                       vc->vc_sw->con_putc(vc, old, oldy, oldx);
+                       con_putc(vc, old, oldy, oldx);
                notify_update(vc);
        }
 
@@ -779,7 +787,7 @@ void complement_pos(struct vc_data *vc, int offset)
                if (con_should_update(vc)) {
                        oldx = (offset >> 1) % vc->vc_cols;
                        oldy = (offset >> 1) / vc->vc_cols;
-                       vc->vc_sw->con_putc(vc, new, oldy, oldx);
+                       con_putc(vc, new, oldy, oldx);
                }
                notify_update(vc);
        }
@@ -833,7 +841,7 @@ static void add_softcursor(struct vc_data *vc)
                i ^= CUR_FG;
        scr_writew(i, (u16 *)vc->vc_pos);
        if (con_should_update(vc))
-               vc->vc_sw->con_putc(vc, i, vc->state.y, vc->state.x);
+               con_putc(vc, i, vc->state.y, vc->state.x);
 }
 
 static void hide_softcursor(struct vc_data *vc)
@@ -841,8 +849,8 @@ static void hide_softcursor(struct vc_data *vc)
        if (softcursor_original != -1) {
                scr_writew(softcursor_original, (u16 *)vc->vc_pos);
                if (con_should_update(vc))
-                       vc->vc_sw->con_putc(vc, softcursor_original,
-                                       vc->state.y, vc->state.x);
+                       con_putc(vc, softcursor_original, vc->state.y,
+                                vc->state.x);
                softcursor_original = -1;
        }
 }