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

tty: vt, cleanup and document con_scroll

Scrolling helpers scrup and scrdown both accept 'top' and 'bottom' as
unsigned int. Number of lines 'nr' is accepted as int, but all callers
pass down unsigned too. So change the type of 'nr' to unsigned too.
Now, promote unsigned int from the helpers up to the con_scroll
hook which actually accepted all those as signed int.

Next, the 'dir' parameter can have only two values and we define
constants for that: SM_UP and SM_DOWN. Switch them to enum and do
proper type checking on 'dir' too.

Finally, document the behaviour of the hook.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Winischhofer <thomas@winischhofer.net>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Cc: <linux-fbdev@vger.kernel.org>
Cc: <linux-usb@vger.kernel.org>
Cc: <linux-parisc@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
d705ff38 de48b099

+50 -42
+4 -2
drivers/tty/vt/vt.c
··· 315 315 schedule_work(&console_work); 316 316 } 317 317 318 - static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr) 318 + static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, 319 + unsigned int nr) 319 320 { 320 321 unsigned short *d, *s; 321 322 ··· 333 332 vc->vc_size_row * nr); 334 333 } 335 334 336 - static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr) 335 + static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, 336 + unsigned int nr) 337 337 { 338 338 unsigned short *s; 339 339 unsigned int step;
+10 -8
drivers/usb/misc/sisusbvga/sisusb_con.c
··· 808 808 mutex_unlock(&sisusb->lock); 809 809 } 810 810 811 - static int 811 + static bool 812 812 sisusbcon_scroll_area(struct vc_data *c, struct sisusb_usb_data *sisusb, 813 - int t, int b, int dir, int lines) 813 + unsigned int t, unsigned int b, enum con_scroll dir, 814 + unsigned int lines) 814 815 { 815 816 int cols = sisusb->sisusb_num_columns; 816 817 int length = ((b - t) * cols) * 2; ··· 853 852 } 854 853 855 854 /* Interface routine */ 856 - static int 857 - sisusbcon_scroll(struct vc_data *c, int t, int b, int dir, int lines) 855 + static bool 856 + sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, 857 + enum con_scroll dir, unsigned int lines) 858 858 { 859 859 struct sisusb_usb_data *sisusb; 860 860 u16 eattr = c->vc_video_erase_char; ··· 872 870 */ 873 871 874 872 if (!lines) 875 - return 1; 873 + return true; 876 874 877 875 sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num); 878 876 if (!sisusb) 879 - return 0; 877 + return false; 880 878 881 879 /* sisusb->lock is down */ 882 880 883 881 if (sisusb_is_inactive(c, sisusb)) { 884 882 mutex_unlock(&sisusb->lock); 885 - return 0; 883 + return false; 886 884 } 887 885 888 886 /* Special case */ ··· 973 971 974 972 mutex_unlock(&sisusb->lock); 975 973 976 - return 1; 974 + return true; 977 975 } 978 976 979 977 /* Interface routine */
+8 -10
drivers/video/console/fbcon.c
··· 164 164 int count, int ypos, int xpos); 165 165 static void fbcon_clear_margins(struct vc_data *vc, int bottom_only); 166 166 static void fbcon_cursor(struct vc_data *vc, int mode); 167 - static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, 168 - int count); 169 167 static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, 170 168 int height, int width); 171 169 static int fbcon_switch(struct vc_data *vc); ··· 1793 1795 softback_curr = softback_in; 1794 1796 } 1795 1797 1796 - static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, 1797 - int count) 1798 + static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, 1799 + enum con_scroll dir, unsigned int count) 1798 1800 { 1799 1801 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; 1800 1802 struct display *p = &fb_display[vc->vc_num]; 1801 1803 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK; 1802 1804 1803 1805 if (fbcon_is_inactive(vc, info)) 1804 - return -EINVAL; 1806 + return true; 1805 1807 1806 1808 fbcon_cursor(vc, CM_ERASE); 1807 1809 ··· 1829 1831 (b - count)), 1830 1832 vc->vc_video_erase_char, 1831 1833 vc->vc_size_row * count); 1832 - return 1; 1834 + return true; 1833 1835 break; 1834 1836 1835 1837 case SCROLL_WRAP_MOVE: ··· 1901 1903 (b - count)), 1902 1904 vc->vc_video_erase_char, 1903 1905 vc->vc_size_row * count); 1904 - return 1; 1906 + return true; 1905 1907 } 1906 1908 break; 1907 1909 ··· 1920 1922 t), 1921 1923 vc->vc_video_erase_char, 1922 1924 vc->vc_size_row * count); 1923 - return 1; 1925 + return true; 1924 1926 break; 1925 1927 1926 1928 case SCROLL_WRAP_MOVE: ··· 1990 1992 t), 1991 1993 vc->vc_video_erase_char, 1992 1994 vc->vc_size_row * count); 1993 - return 1; 1995 + return true; 1994 1996 } 1995 1997 } 1996 - return 0; 1998 + return false; 1997 1999 } 1998 2000 1999 2001
+4 -3
drivers/video/console/mdacon.c
··· 488 488 } 489 489 } 490 490 491 - static int mdacon_scroll(struct vc_data *c, int t, int b, int dir, int lines) 491 + static bool mdacon_scroll(struct vc_data *c, unsigned int t, unsigned int b, 492 + enum con_scroll dir, unsigned int lines) 492 493 { 493 494 u16 eattr = mda_convert_attr(c->vc_video_erase_char); 494 495 495 496 if (!lines) 496 - return 0; 497 + return false; 497 498 498 499 if (lines > c->vc_rows) /* maximum realistic size */ 499 500 lines = c->vc_rows; ··· 515 514 break; 516 515 } 517 516 518 - return 0; 517 + return false; 519 518 } 520 519 521 520
+4 -4
drivers/video/console/newport_con.c
··· 574 574 return newport_set_font(vc->vc_num, font); 575 575 } 576 576 577 - static int newport_scroll(struct vc_data *vc, int t, int b, int dir, 578 - int lines) 577 + static bool newport_scroll(struct vc_data *vc, unsigned int t, unsigned int b, 578 + enum con_scroll dir, unsigned int lines) 579 579 { 580 580 int count, x, y; 581 581 unsigned short *s, *d; ··· 595 595 (vc->vc_color & 0xf0) >> 4); 596 596 } 597 597 npregs->cset.topscan = (topscan - 1) & 0x3ff; 598 - return 0; 598 + return false; 599 599 } 600 600 601 601 count = (b - t - lines) * vc->vc_cols; ··· 670 670 } 671 671 } 672 672 } 673 - return 1; 673 + return true; 674 674 } 675 675 676 676 static int newport_dummy(struct vc_data *c)
+4 -3
drivers/video/console/sticon.c
··· 153 153 } 154 154 } 155 155 156 - static int sticon_scroll(struct vc_data *conp, int t, int b, int dir, int count) 156 + static bool sticon_scroll(struct vc_data *conp, unsigned int t, 157 + unsigned int b, enum con_scroll dir, unsigned int count) 157 158 { 158 159 struct sti_struct *sti = sticon_sti; 159 160 160 161 if (vga_is_gfx) 161 - return 0; 162 + return false; 162 163 163 164 sticon_cursor(conp, CM_ERASE); 164 165 ··· 175 174 break; 176 175 } 177 176 178 - return 0; 177 + return false; 179 178 } 180 179 181 180 static void sticon_init(struct vc_data *c, int init)
+5 -7
drivers/video/console/vgacon.c
··· 83 83 static void vgacon_scrolldelta(struct vc_data *c, int lines); 84 84 static int vgacon_set_origin(struct vc_data *c); 85 85 static void vgacon_save_screen(struct vc_data *c); 86 - static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, 87 - int lines); 88 86 static void vgacon_invert_region(struct vc_data *c, u16 * p, int count); 89 87 static struct uni_pagedir *vgacon_uni_pagedir; 90 88 static int vgacon_refcount; ··· 1348 1350 c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size); 1349 1351 } 1350 1352 1351 - static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, 1352 - int lines) 1353 + static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b, 1354 + enum con_scroll dir, unsigned int lines) 1353 1355 { 1354 1356 unsigned long oldo; 1355 1357 unsigned int delta; 1356 1358 1357 1359 if (t || b != c->vc_rows || vga_is_gfx || c->vc_mode != KD_TEXT) 1358 - return 0; 1360 + return false; 1359 1361 1360 1362 if (!vga_hardscroll_enabled || lines >= c->vc_rows / 2) 1361 - return 0; 1363 + return false; 1362 1364 1363 1365 vgacon_restore_screen(c); 1364 1366 oldo = c->vc_origin; ··· 1394 1396 c->vc_visible_origin = c->vc_origin; 1395 1397 vga_set_mem_top(c); 1396 1398 c->vc_pos = (c->vc_pos - oldo) + c->vc_origin; 1397 - return 1; 1399 + return true; 1398 1400 } 1399 1401 1400 1402
+11 -5
include/linux/console.h
··· 28 28 #define VT100ID "\033[?1;2c" 29 29 #define VT102ID "\033[?6c" 30 30 31 + enum con_scroll { 32 + SM_UP, 33 + SM_DOWN, 34 + }; 35 + 31 36 /** 32 37 * struct consw - callbacks for consoles 33 38 * 39 + * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. 40 + * Return true if no generic handling should be done. 41 + * Invoked by csi_M and printing to the console. 34 42 * @con_set_palette: sets the palette of the console to @table (optional) 35 43 * @con_scrolldelta: the contents of the console should be scrolled by @lines. 36 44 * Invoked by user. (optional) ··· 52 44 void (*con_putc)(struct vc_data *, int, int, int); 53 45 void (*con_putcs)(struct vc_data *, const unsigned short *, int, int, int); 54 46 void (*con_cursor)(struct vc_data *, int); 55 - int (*con_scroll)(struct vc_data *, int, int, int, int); 47 + bool (*con_scroll)(struct vc_data *, unsigned int top, 48 + unsigned int bottom, enum con_scroll dir, 49 + unsigned int lines); 56 50 int (*con_switch)(struct vc_data *); 57 51 int (*con_blank)(struct vc_data *, int, int); 58 52 int (*con_font_set)(struct vc_data *, struct console_font *, unsigned); ··· 108 98 return 0; 109 99 } 110 100 #endif 111 - 112 - /* scroll */ 113 - #define SM_UP (1) 114 - #define SM_DOWN (2) 115 101 116 102 /* cursor */ 117 103 #define CM_DRAW (1)