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

tty: vt: make consw::con_switch() return a bool

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>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
8d5cc8ee a292e3fc

+17 -15
+1 -1
drivers/tty/vt/vt.c
··· 970 970 } 971 971 972 972 if (redraw) { 973 - int update; 973 + bool update; 974 974 int old_was_color = vc->vc_can_do_color; 975 975 976 976 set_origin(vc);
+2 -2
drivers/video/console/dummycon.c
··· 122 122 return false; 123 123 } 124 124 125 - static int dummycon_switch(struct vc_data *vc) 125 + static bool dummycon_switch(struct vc_data *vc) 126 126 { 127 - return 0; 127 + return false; 128 128 } 129 129 130 130 /*
+2 -2
drivers/video/console/mdacon.c
··· 446 446 scr_memsetw(dest, eattr, width * 2); 447 447 } 448 448 449 - static int mdacon_switch(struct vc_data *c) 449 + static bool mdacon_switch(struct vc_data *c) 450 450 { 451 - return 1; /* redrawing needed */ 451 + return true; /* redrawing needed */ 452 452 } 453 453 454 454 static int mdacon_blank(struct vc_data *c, int blank, int mode_switch)
+2 -2
drivers/video/console/newport_con.c
··· 459 459 newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs); 460 460 } 461 461 462 - static int newport_switch(struct vc_data *vc) 462 + static bool newport_switch(struct vc_data *vc) 463 463 { 464 464 static int logo_drawn = 0; 465 465 ··· 473 473 } 474 474 } 475 475 476 - return 1; 476 + return true; 477 477 } 478 478 479 479 static int newport_blank(struct vc_data *c, int blank, int mode_switch)
+2 -2
drivers/video/console/sticon.c
··· 293 293 conp->vc_video_erase_char, font_data[conp->vc_num]); 294 294 } 295 295 296 - static int sticon_switch(struct vc_data *conp) 296 + static bool sticon_switch(struct vc_data *conp) 297 297 { 298 - return 1; /* needs refreshing */ 298 + return true; /* needs refreshing */ 299 299 } 300 300 301 301 static int sticon_blank(struct vc_data *c, int blank, int mode_switch)
+2 -2
drivers/video/console/vgacon.c
··· 614 614 raw_spin_unlock_irqrestore(&vga_lock, flags); 615 615 } 616 616 617 - static int vgacon_switch(struct vc_data *c) 617 + static bool vgacon_switch(struct vc_data *c) 618 618 { 619 619 int x = c->vc_cols * VGA_FONTWIDTH; 620 620 int y = c->vc_rows * c->vc_cell_height; ··· 643 643 vgacon_doresize(c, c->vc_cols, c->vc_rows); 644 644 } 645 645 646 - return 0; /* Redrawing not needed */ 646 + return false; /* Redrawing not needed */ 647 647 } 648 648 649 649 static void vga_set_palette(struct vc_data *vc, const unsigned char *table)
+3 -3
drivers/video/fbdev/core/fbcon.c
··· 2056 2056 return 0; 2057 2057 } 2058 2058 2059 - static int fbcon_switch(struct vc_data *vc) 2059 + static bool fbcon_switch(struct vc_data *vc) 2060 2060 { 2061 2061 struct fb_info *info, *old_info = NULL; 2062 2062 struct fbcon_ops *ops; ··· 2178 2178 vc->vc_origin + vc->vc_size_row * vc->vc_top, 2179 2179 vc->vc_size_row * (vc->vc_bottom - 2180 2180 vc->vc_top) / 2); 2181 - return 0; 2181 + return false; 2182 2182 } 2183 - return 1; 2183 + return true; 2184 2184 } 2185 2185 2186 2186 static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
+3 -1
include/linux/console.h
··· 46 46 * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. 47 47 * Return true if no generic handling should be done. 48 48 * Invoked by csi_M and printing to the console. 49 + * @con_switch: notifier about the console switch; it is supposed to return 50 + * true if a redraw is needed. 49 51 * @con_set_palette: sets the palette of the console to @table (optional) 50 52 * @con_scrolldelta: the contents of the console should be scrolled by @lines. 51 53 * Invoked by user. (optional) ··· 68 66 bool (*con_scroll)(struct vc_data *vc, unsigned int top, 69 67 unsigned int bottom, enum con_scroll dir, 70 68 unsigned int lines); 71 - int (*con_switch)(struct vc_data *vc); 69 + bool (*con_switch)(struct vc_data *vc); 72 70 int (*con_blank)(struct vc_data *vc, int blank, int mode_switch); 73 71 int (*con_font_set)(struct vc_data *vc, struct console_font *font, 74 72 unsigned int vpitch, unsigned int flags);