tty: vt: make consw::con_switch() return a bool
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Mon, 22 Jan 2024 11:03:44 +0000 (12:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jan 2024 02:08:54 +0000 (18:08 -0800)
The non-zero (true) return value from consw::con_switch() means a redraw
is needed. So make this return type a bool explicitly instead of int.
The latter might imply that -Eerrors are expected. They are not.

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-31-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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/fbcon.c
include/linux/console.h

index e4edcaf9d0a365d6e16d706fb173b1ce0f5989e5..fd868046f586fe8aad18d3da1056eacf14369f18 100644 (file)
@@ -970,7 +970,7 @@ void redraw_screen(struct vc_data *vc, int is_switch)
        }
 
        if (redraw) {
-               int update;
+               bool update;
                int old_was_color = vc->vc_can_do_color;
 
                set_origin(vc);
index 1171e27edef7f11d873579d7f79178dc65648328..c8d5aa0e3ed0aa87e7173f92c6d32de320d200ed 100644 (file)
@@ -122,9 +122,9 @@ static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
        return false;
 }
 
-static int dummycon_switch(struct vc_data *vc)
+static bool dummycon_switch(struct vc_data *vc)
 {
-       return 0;
+       return false;
 }
 
 /*
index bc851a1d9f4d17c2bb64e239739e9d1cb55decc2..4485ef923bb338c108c43ad602fd6c243948edc0 100644 (file)
@@ -446,9 +446,9 @@ static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x,
        scr_memsetw(dest, eattr, width * 2);
 }
 
-static int mdacon_switch(struct vc_data *c)
+static bool mdacon_switch(struct vc_data *c)
 {
-       return 1;       /* redrawing needed */
+       return true;    /* redrawing needed */
 }
 
 static int mdacon_blank(struct vc_data *c, int blank, int mode_switch)
index e35406dea7c7b19fd5a343cff63ce90d856125f5..039d1c9937d22616d3df7deae9698177fcd0c3ac 100644 (file)
@@ -459,7 +459,7 @@ static void newport_cursor(struct vc_data *vc, bool enable)
        newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs);
 }
 
-static int newport_switch(struct vc_data *vc)
+static bool newport_switch(struct vc_data *vc)
 {
        static int logo_drawn = 0;
 
@@ -473,7 +473,7 @@ static int newport_switch(struct vc_data *vc)
                }
        }
 
-       return 1;
+       return true;
 }
 
 static int newport_blank(struct vc_data *c, int blank, int mode_switch)
index 786e1b3a98eae0b7c4c63635d3297169347f1eef..f3bb48a0e9801d6c25a47e3bd50d25d37ebe91ba 100644 (file)
@@ -293,9 +293,9 @@ static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx,
              conp->vc_video_erase_char, font_data[conp->vc_num]);
 }
 
-static int sticon_switch(struct vc_data *conp)
+static bool sticon_switch(struct vc_data *conp)
 {
-    return 1;  /* needs refreshing */
+    return true;       /* needs refreshing */
 }
 
 static int sticon_blank(struct vc_data *c, int blank, int mode_switch)
index d93eb15da4353a8b29038b8cad40b717524c45ec..f89eb53c0b79e186a294ca3f7d2276f397a1d809 100644 (file)
@@ -614,7 +614,7 @@ static void vgacon_doresize(struct vc_data *c,
        raw_spin_unlock_irqrestore(&vga_lock, flags);
 }
 
-static int vgacon_switch(struct vc_data *c)
+static bool vgacon_switch(struct vc_data *c)
 {
        int x = c->vc_cols * VGA_FONTWIDTH;
        int y = c->vc_rows * c->vc_cell_height;
@@ -643,7 +643,7 @@ static int vgacon_switch(struct vc_data *c)
                        vgacon_doresize(c, c->vc_cols, c->vc_rows);
        }
 
-       return 0;               /* Redrawing not needed */
+       return false;           /* Redrawing not needed */
 }
 
 static void vga_set_palette(struct vc_data *vc, const unsigned char *table)
index c1765a6ef490e2970d9425c413d6805f6b4d4f34..d5d924225209aad15386f99359f4bbfab0838b83 100644 (file)
@@ -2056,7 +2056,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
        return 0;
 }
 
-static int fbcon_switch(struct vc_data *vc)
+static bool fbcon_switch(struct vc_data *vc)
 {
        struct fb_info *info, *old_info = NULL;
        struct fbcon_ops *ops;
@@ -2178,9 +2178,9 @@ static int fbcon_switch(struct vc_data *vc)
                              vc->vc_origin + vc->vc_size_row * vc->vc_top,
                              vc->vc_size_row * (vc->vc_bottom -
                                                 vc->vc_top) / 2);
-               return 0;
+               return false;
        }
-       return 1;
+       return true;
 }
 
 static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
index a6a46b5efd661e59ab6275e557eca1ce31d27c26..f7c6b5fc3a368644e1adcd1371e96dafabcbb514 100644 (file)
@@ -46,6 +46,8 @@ enum vc_intensity;
  * @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.
+ * @con_switch: notifier about the console switch; it is supposed to return
+ *             true if a redraw is needed.
  * @con_set_palette: sets the palette of the console to @table (optional)
  * @con_scrolldelta: the contents of the console should be scrolled by @lines.
  *                  Invoked by user. (optional)
@@ -66,7 +68,7 @@ struct consw {
        bool    (*con_scroll)(struct vc_data *vc, unsigned int top,
                        unsigned int bottom, enum con_scroll dir,
                        unsigned int lines);
-       int     (*con_switch)(struct vc_data *vc);
+       bool    (*con_switch)(struct vc_data *vc);
        int     (*con_blank)(struct vc_data *vc, int blank, int mode_switch);
        int     (*con_font_set)(struct vc_data *vc, struct console_font *font,
                        unsigned int vpitch, unsigned int flags);