tty: vt: remove CM_* constants
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Mon, 22 Jan 2024 11:03:43 +0000 (12:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jan 2024 02:08:54 +0000 (18:08 -0800)
There is no difference between CM_MOVE and CM_DRAW. Either of them
enables the cursor. CM_ERASE then disables cursor.

So get rid of all of them and use simple "bool enable".

Note that this propagates down to the fbcon code.

And document the hook.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-parisc@vger.kernel.org
Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
Link: https://lore.kernel.org/r/20240122110401.7289-30-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 files changed:
drivers/tty/vt/vt.c
drivers/video/console/dummycon.c
drivers/video/console/mdacon.c
drivers/video/console/newport_con.c
drivers/video/console/sticon.c
drivers/video/console/vgacon.c
drivers/video/fbdev/core/bitblit.c
drivers/video/fbdev/core/fbcon.c
drivers/video/fbdev/core/fbcon.h
drivers/video/fbdev/core/fbcon_ccw.c
drivers/video/fbdev/core/fbcon_cw.c
drivers/video/fbdev/core/fbcon_ud.c
drivers/video/fbdev/core/tileblit.c
include/linux/console.h

index 6091ffcf93d86a63d4d4661590e6b73db5344cea..e4edcaf9d0a365d6e16d706fb173b1ce0f5989e5 100644 (file)
@@ -860,7 +860,7 @@ static void hide_cursor(struct vc_data *vc)
        if (vc_is_sel(vc))
                clear_selection();
 
-       vc->vc_sw->con_cursor(vc, CM_ERASE);
+       vc->vc_sw->con_cursor(vc, false);
        hide_softcursor(vc);
 }
 
@@ -873,7 +873,7 @@ static void set_cursor(struct vc_data *vc)
                        clear_selection();
                add_softcursor(vc);
                if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE)
-                       vc->vc_sw->con_cursor(vc, CM_DRAW);
+                       vc->vc_sw->con_cursor(vc, true);
        } else
                hide_cursor(vc);
 }
index 188d9f3e201c45d91f7c13571ff88bb3640cd0b7..1171e27edef7f11d873579d7f79178dc65648328 100644 (file)
@@ -113,7 +113,7 @@ static void dummycon_init(struct vc_data *vc, bool init)
 static void dummycon_deinit(struct vc_data *vc) { }
 static void dummycon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
                           unsigned int width) { }
-static void dummycon_cursor(struct vc_data *vc, int mode) { }
+static void dummycon_cursor(struct vc_data *vc, bool enable) { }
 
 static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
                            unsigned int bottom, enum con_scroll dir,
index b8822b615b2ff581092a25dc7548ce506c5793db..bc851a1d9f4d17c2bb64e239739e9d1cb55decc2 100644 (file)
@@ -470,9 +470,9 @@ static int mdacon_blank(struct vc_data *c, int blank, int mode_switch)
        }
 }
 
-static void mdacon_cursor(struct vc_data *c, int mode)
+static void mdacon_cursor(struct vc_data *c, bool enable)
 {
-       if (mode == CM_ERASE) {
+       if (!enable) {
                mda_set_cursor(mda_vram_len - 1);
                return;
        }
index f852717b88f0ec9e7ee1934f6fe27c7e074a196f..e35406dea7c7b19fd5a343cff63ce90d856125f5 100644 (file)
@@ -438,14 +438,14 @@ static void newport_putcs(struct vc_data *vc, const u16 *s,
        }
 }
 
-static void newport_cursor(struct vc_data *vc, int mode)
+static void newport_cursor(struct vc_data *vc, bool enable)
 {
        unsigned short treg;
        int xcurs, ycurs;
 
        treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
 
-       if (mode == CM_ERASE) {
+       if (!enable) {
                newport_vc2_set(npregs, VC2_IREG_CONTROL,
                                (treg & ~(VC2_CTRL_ECDISP)));
                return;
index 42480874db001ec61d3a34d109ea56707512cc6b..786e1b3a98eae0b7c4c63635d3297169347f1eef 100644 (file)
@@ -86,7 +86,7 @@ static void sticon_putcs(struct vc_data *conp, const u16 *s, unsigned int count,
     }
 }
 
-static void sticon_cursor(struct vc_data *conp, int mode)
+static void sticon_cursor(struct vc_data *conp, bool enable)
 {
     unsigned short car1;
 
@@ -95,7 +95,7 @@ static void sticon_cursor(struct vc_data *conp, int mode)
        return;
 
     car1 = conp->vc_screenbuf[conp->state.x + conp->state.y * conp->vc_cols];
-    if (mode == CM_ERASE) {
+    if (!enable) {
        sti_putc(sticon_sti, car1, conp->state.y, conp->state.x,
                 font_data[conp->vc_num]);
        return;
@@ -121,7 +121,7 @@ static bool sticon_scroll(struct vc_data *conp, unsigned int t,
     if (vga_is_gfx)
         return false;
 
-    sticon_cursor(conp, CM_ERASE);
+    sticon_cursor(conp, false);
 
     switch (dir) {
     case SM_UP:
index 82d01a9ccd6dd3138d57f8058b3ae8af474af329..d93eb15da4353a8b29038b8cad40b717524c45ec 100644 (file)
@@ -503,7 +503,7 @@ static void vgacon_set_cursor_size(int from, int to)
        raw_spin_unlock_irqrestore(&vga_lock, flags);
 }
 
-static void vgacon_cursor(struct vc_data *c, int mode)
+static void vgacon_cursor(struct vc_data *c, bool enable)
 {
        unsigned int c_height;
 
@@ -516,7 +516,7 @@ static void vgacon_cursor(struct vc_data *c, int mode)
 
        write_vga(14, (c->vc_pos - vga_vram_base) / 2);
 
-       if (mode == CM_ERASE) {
+       if (!enable) {
                if (vga_video_type >= VIDEO_TYPE_VGAC)
                        vgacon_set_cursor_size(31, 30);
                else
@@ -1030,7 +1030,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight)
                                /* void size to cause regs to be rewritten */
                                cursor_size_lastfrom = 0;
                                cursor_size_lastto = 0;
-                               c->vc_sw->con_cursor(c, CM_DRAW);
+                               c->vc_sw->con_cursor(c, true);
                        }
                        c->vc_font.height = c->vc_cell_height = fontheight;
                        vc_resize(c, 0, rows);  /* Adjust console size */
index daff152f4c2247a8f2aa847e59ac7086f82f40e7..3ff1b2a8659e87c746c39a9fd47815eb82ffdb41 100644 (file)
@@ -233,7 +233,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info,
        }
 }
 
-static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
+static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
                       int fg, int bg)
 {
        struct fb_cursor cursor;
@@ -348,7 +348,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
                        mask[i++] = msk;
        }
 
-       ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw;
+       ops->cursor_state.enable = enable && !use_sw;
 
        cursor.image.data = src;
        cursor.image.fg_color = ops->cursor_state.image.fg_color;
index 7a7b2ac0d7a9fabfb1a57626a83a26909b1c7d23..c1765a6ef490e2970d9425c413d6805f6b4d4f34 100644 (file)
@@ -351,7 +351,7 @@ static void fb_flashcursor(struct work_struct *work)
        struct fb_info *info;
        struct vc_data *vc = NULL;
        int c;
-       int mode;
+       bool enable;
        int ret;
 
        /* FIXME: we should sort out the unbind locking instead */
@@ -375,9 +375,8 @@ static void fb_flashcursor(struct work_struct *work)
        }
 
        c = scr_readw((u16 *) vc->vc_pos);
-       mode = (!ops->cursor_flash || ops->cursor_state.enable) ?
-               CM_ERASE : CM_DRAW;
-       ops->cursor(vc, info, mode, get_color(vc, info, c, 1),
+       enable = ops->cursor_flash && !ops->cursor_state.enable;
+       ops->cursor(vc, info, enable, get_color(vc, info, c, 1),
                    get_color(vc, info, c, 0));
        console_unlock();
 
@@ -1301,7 +1300,7 @@ static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
                ops->clear_margins(vc, info, margin_color, bottom_only);
 }
 
-static void fbcon_cursor(struct vc_data *vc, int mode)
+static void fbcon_cursor(struct vc_data *vc, bool enable)
 {
        struct fb_info *info = fbcon_info_from_console(vc->vc_num);
        struct fbcon_ops *ops = info->fbcon_par;
@@ -1317,12 +1316,12 @@ static void fbcon_cursor(struct vc_data *vc, int mode)
        else
                fbcon_add_cursor_work(info);
 
-       ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1;
+       ops->cursor_flash = enable;
 
        if (!ops->cursor)
                return;
 
-       ops->cursor(vc, info, mode, get_color(vc, info, c, 1),
+       ops->cursor(vc, info, enable, get_color(vc, info, c, 1),
                    get_color(vc, info, c, 0));
 }
 
@@ -1742,7 +1741,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
        if (fbcon_is_inactive(vc, info))
                return true;
 
-       fbcon_cursor(vc, CM_ERASE);
+       fbcon_cursor(vc, false);
 
        /*
         * ++Geert: Only use ywrap/ypan if the console is in text mode
@@ -2221,7 +2220,7 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
        if (!fbcon_is_inactive(vc, info)) {
                if (ops->blank_state != blank) {
                        ops->blank_state = blank;
-                       fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
+                       fbcon_cursor(vc, !blank);
                        ops->cursor_flash = (!blank);
 
                        if (fb_blank(info, blank))
@@ -2649,7 +2648,7 @@ void fbcon_suspended(struct fb_info *info)
        vc = vc_cons[ops->currcon].d;
 
        /* Clear cursor, restore saved data */
-       fbcon_cursor(vc, CM_ERASE);
+       fbcon_cursor(vc, false);
 }
 
 void fbcon_resumed(struct fb_info *info)
index 0eaf54a211516786ca2863c865654fb248a045e5..df70ea5ec5b379a95105fc35a067181531cfc217 100644 (file)
@@ -61,8 +61,8 @@ struct fbcon_ops {
                      int fg, int bg);
        void (*clear_margins)(struct vc_data *vc, struct fb_info *info,
                              int color, int bottom_only);
-       void (*cursor)(struct vc_data *vc, struct fb_info *info, int mode,
-                      int fg, int bg);
+       void (*cursor)(struct vc_data *vc, struct fb_info *info,
+                      bool enable, int fg, int bg);
        int  (*update_start)(struct fb_info *info);
        int  (*rotate_font)(struct fb_info *info, struct vc_data *vc);
        struct fb_var_screeninfo var;  /* copy of the current fb_var_screeninfo */
index 889423d580bc8466d1f3e3b5b4aa7ee79e62c045..f9b794ff7d396854ccc2dadbb0f41f1b2606dd23 100644 (file)
@@ -218,7 +218,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info,
        }
 }
 
-static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
+static void ccw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
                       int fg, int bg)
 {
        struct fb_cursor cursor;
@@ -349,7 +349,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
                kfree(tmp);
        }
 
-       ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw;
+       ops->cursor_state.enable = enable && !use_sw;
 
        cursor.image.data = src;
        cursor.image.fg_color = ops->cursor_state.image.fg_color;
index a306ca5802e8cb36ededd3c038dd4816e3fbc7d0..903f6fc174e14623eacc2ef2a23bb54d072e2f8e 100644 (file)
@@ -201,7 +201,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info,
        }
 }
 
-static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
+static void cw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
                      int fg, int bg)
 {
        struct fb_cursor cursor;
@@ -332,7 +332,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
                kfree(tmp);
        }
 
-       ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw;
+       ops->cursor_state.enable = enable && !use_sw;
 
        cursor.image.data = src;
        cursor.image.fg_color = ops->cursor_state.image.fg_color;
index f6fc458b46c7bb7520d1ca9163ac70ebfb9bfa87..594331936fd3cffbd3e75c4ff93dbab8be68cae8 100644 (file)
@@ -248,7 +248,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info,
        }
 }
 
-static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode,
+static void ud_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
                      int fg, int bg)
 {
        struct fb_cursor cursor;
@@ -372,7 +372,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode,
                        mask[i++] = ~msk;
        }
 
-       ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw;
+       ops->cursor_state.enable = enable && !use_sw;
 
        cursor.image.data = src;
        cursor.image.fg_color = ops->cursor_state.image.fg_color;
index 2768eff247ba4623dd0beaa8e2d96926c472f519..eff7ec4da1671f0a13c919ec9aad225c071ae0ff 100644 (file)
@@ -79,7 +79,7 @@ static void tile_clear_margins(struct vc_data *vc, struct fb_info *info,
        return;
 }
 
-static void tile_cursor(struct vc_data *vc, struct fb_info *info, int mode,
+static void tile_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
                        int fg, int bg)
 {
        struct fb_tilecursor cursor;
@@ -87,7 +87,7 @@ static void tile_cursor(struct vc_data *vc, struct fb_info *info, int mode,
 
        cursor.sx = vc->state.x;
        cursor.sy = vc->state.y;
-       cursor.mode = (mode == CM_ERASE || use_sw) ? 0 : 1;
+       cursor.mode = enable && !use_sw;
        cursor.fg = fg;
        cursor.bg = bg;
 
index 82d55764a66f8a100d02bdb8aa9da129e67d2e17..a6a46b5efd661e59ab6275e557eca1ce31d27c26 100644 (file)
@@ -42,6 +42,7 @@ enum vc_intensity;
  * @con_putc:   emit one character with attributes @ca to [@x, @y] on @vc.
  *             (optional -- @con_putcs would be called instead)
  * @con_putcs:  emit @count characters with attributes @s to [@x, @y] on @vc.
+ * @con_cursor: enable/disable cursor depending on @enable
  * @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
  *             Return true if no generic handling should be done.
  *             Invoked by csi_M and printing to the console.
@@ -61,7 +62,7 @@ struct consw {
        void    (*con_putcs)(struct vc_data *vc, const u16 *s,
                             unsigned int count, unsigned int ypos,
                             unsigned int xpos);
-       void    (*con_cursor)(struct vc_data *vc, int mode);
+       void    (*con_cursor)(struct vc_data *vc, bool enable);
        bool    (*con_scroll)(struct vc_data *vc, unsigned int top,
                        unsigned int bottom, enum con_scroll dir,
                        unsigned int lines);
@@ -128,11 +129,6 @@ static inline void con_debug_enter(struct vc_data *vc) { }
 static inline void con_debug_leave(void) { }
 #endif
 
-/* cursor */
-#define CM_DRAW     (1)
-#define CM_ERASE    (2)
-#define CM_MOVE     (3)
-
 /*
  * The interface for a console, or any other device that wants to capture
  * console messages (printer driver?)