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

tty: vt: remove CM_* constants

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>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
a292e3fc 9aefbaeb

+36 -41
+2 -2
drivers/tty/vt/vt.c
··· 860 860 if (vc_is_sel(vc)) 861 861 clear_selection(); 862 862 863 - vc->vc_sw->con_cursor(vc, CM_ERASE); 863 + vc->vc_sw->con_cursor(vc, false); 864 864 hide_softcursor(vc); 865 865 } 866 866 ··· 873 873 clear_selection(); 874 874 add_softcursor(vc); 875 875 if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE) 876 - vc->vc_sw->con_cursor(vc, CM_DRAW); 876 + vc->vc_sw->con_cursor(vc, true); 877 877 } else 878 878 hide_cursor(vc); 879 879 }
+1 -1
drivers/video/console/dummycon.c
··· 113 113 static void dummycon_deinit(struct vc_data *vc) { } 114 114 static void dummycon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, 115 115 unsigned int width) { } 116 - static void dummycon_cursor(struct vc_data *vc, int mode) { } 116 + static void dummycon_cursor(struct vc_data *vc, bool enable) { } 117 117 118 118 static bool dummycon_scroll(struct vc_data *vc, unsigned int top, 119 119 unsigned int bottom, enum con_scroll dir,
+2 -2
drivers/video/console/mdacon.c
··· 470 470 } 471 471 } 472 472 473 - static void mdacon_cursor(struct vc_data *c, int mode) 473 + static void mdacon_cursor(struct vc_data *c, bool enable) 474 474 { 475 - if (mode == CM_ERASE) { 475 + if (!enable) { 476 476 mda_set_cursor(mda_vram_len - 1); 477 477 return; 478 478 }
+2 -2
drivers/video/console/newport_con.c
··· 438 438 } 439 439 } 440 440 441 - static void newport_cursor(struct vc_data *vc, int mode) 441 + static void newport_cursor(struct vc_data *vc, bool enable) 442 442 { 443 443 unsigned short treg; 444 444 int xcurs, ycurs; 445 445 446 446 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); 447 447 448 - if (mode == CM_ERASE) { 448 + if (!enable) { 449 449 newport_vc2_set(npregs, VC2_IREG_CONTROL, 450 450 (treg & ~(VC2_CTRL_ECDISP))); 451 451 return;
+3 -3
drivers/video/console/sticon.c
··· 86 86 } 87 87 } 88 88 89 - static void sticon_cursor(struct vc_data *conp, int mode) 89 + static void sticon_cursor(struct vc_data *conp, bool enable) 90 90 { 91 91 unsigned short car1; 92 92 ··· 95 95 return; 96 96 97 97 car1 = conp->vc_screenbuf[conp->state.x + conp->state.y * conp->vc_cols]; 98 - if (mode == CM_ERASE) { 98 + if (!enable) { 99 99 sti_putc(sticon_sti, car1, conp->state.y, conp->state.x, 100 100 font_data[conp->vc_num]); 101 101 return; ··· 121 121 if (vga_is_gfx) 122 122 return false; 123 123 124 - sticon_cursor(conp, CM_ERASE); 124 + sticon_cursor(conp, false); 125 125 126 126 switch (dir) { 127 127 case SM_UP:
+3 -3
drivers/video/console/vgacon.c
··· 503 503 raw_spin_unlock_irqrestore(&vga_lock, flags); 504 504 } 505 505 506 - static void vgacon_cursor(struct vc_data *c, int mode) 506 + static void vgacon_cursor(struct vc_data *c, bool enable) 507 507 { 508 508 unsigned int c_height; 509 509 ··· 516 516 517 517 write_vga(14, (c->vc_pos - vga_vram_base) / 2); 518 518 519 - if (mode == CM_ERASE) { 519 + if (!enable) { 520 520 if (vga_video_type >= VIDEO_TYPE_VGAC) 521 521 vgacon_set_cursor_size(31, 30); 522 522 else ··· 1030 1030 /* void size to cause regs to be rewritten */ 1031 1031 cursor_size_lastfrom = 0; 1032 1032 cursor_size_lastto = 0; 1033 - c->vc_sw->con_cursor(c, CM_DRAW); 1033 + c->vc_sw->con_cursor(c, true); 1034 1034 } 1035 1035 c->vc_font.height = c->vc_cell_height = fontheight; 1036 1036 vc_resize(c, 0, rows); /* Adjust console size */
+2 -2
drivers/video/fbdev/core/bitblit.c
··· 233 233 } 234 234 } 235 235 236 - static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, 236 + static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable, 237 237 int fg, int bg) 238 238 { 239 239 struct fb_cursor cursor; ··· 348 348 mask[i++] = msk; 349 349 } 350 350 351 - ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; 351 + ops->cursor_state.enable = enable && !use_sw; 352 352 353 353 cursor.image.data = src; 354 354 cursor.image.fg_color = ops->cursor_state.image.fg_color;
+9 -10
drivers/video/fbdev/core/fbcon.c
··· 351 351 struct fb_info *info; 352 352 struct vc_data *vc = NULL; 353 353 int c; 354 - int mode; 354 + bool enable; 355 355 int ret; 356 356 357 357 /* FIXME: we should sort out the unbind locking instead */ ··· 375 375 } 376 376 377 377 c = scr_readw((u16 *) vc->vc_pos); 378 - mode = (!ops->cursor_flash || ops->cursor_state.enable) ? 379 - CM_ERASE : CM_DRAW; 380 - ops->cursor(vc, info, mode, get_color(vc, info, c, 1), 378 + enable = ops->cursor_flash && !ops->cursor_state.enable; 379 + ops->cursor(vc, info, enable, get_color(vc, info, c, 1), 381 380 get_color(vc, info, c, 0)); 382 381 console_unlock(); 383 382 ··· 1300 1301 ops->clear_margins(vc, info, margin_color, bottom_only); 1301 1302 } 1302 1303 1303 - static void fbcon_cursor(struct vc_data *vc, int mode) 1304 + static void fbcon_cursor(struct vc_data *vc, bool enable) 1304 1305 { 1305 1306 struct fb_info *info = fbcon_info_from_console(vc->vc_num); 1306 1307 struct fbcon_ops *ops = info->fbcon_par; ··· 1316 1317 else 1317 1318 fbcon_add_cursor_work(info); 1318 1319 1319 - ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1; 1320 + ops->cursor_flash = enable; 1320 1321 1321 1322 if (!ops->cursor) 1322 1323 return; 1323 1324 1324 - ops->cursor(vc, info, mode, get_color(vc, info, c, 1), 1325 + ops->cursor(vc, info, enable, get_color(vc, info, c, 1), 1325 1326 get_color(vc, info, c, 0)); 1326 1327 } 1327 1328 ··· 1741 1742 if (fbcon_is_inactive(vc, info)) 1742 1743 return true; 1743 1744 1744 - fbcon_cursor(vc, CM_ERASE); 1745 + fbcon_cursor(vc, false); 1745 1746 1746 1747 /* 1747 1748 * ++Geert: Only use ywrap/ypan if the console is in text mode ··· 2220 2221 if (!fbcon_is_inactive(vc, info)) { 2221 2222 if (ops->blank_state != blank) { 2222 2223 ops->blank_state = blank; 2223 - fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); 2224 + fbcon_cursor(vc, !blank); 2224 2225 ops->cursor_flash = (!blank); 2225 2226 2226 2227 if (fb_blank(info, blank)) ··· 2648 2649 vc = vc_cons[ops->currcon].d; 2649 2650 2650 2651 /* Clear cursor, restore saved data */ 2651 - fbcon_cursor(vc, CM_ERASE); 2652 + fbcon_cursor(vc, false); 2652 2653 } 2653 2654 2654 2655 void fbcon_resumed(struct fb_info *info)
+2 -2
drivers/video/fbdev/core/fbcon.h
··· 61 61 int fg, int bg); 62 62 void (*clear_margins)(struct vc_data *vc, struct fb_info *info, 63 63 int color, int bottom_only); 64 - void (*cursor)(struct vc_data *vc, struct fb_info *info, int mode, 65 - int fg, int bg); 64 + void (*cursor)(struct vc_data *vc, struct fb_info *info, 65 + bool enable, int fg, int bg); 66 66 int (*update_start)(struct fb_info *info); 67 67 int (*rotate_font)(struct fb_info *info, struct vc_data *vc); 68 68 struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */
+2 -2
drivers/video/fbdev/core/fbcon_ccw.c
··· 218 218 } 219 219 } 220 220 221 - static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, 221 + static void ccw_cursor(struct vc_data *vc, struct fb_info *info, bool enable, 222 222 int fg, int bg) 223 223 { 224 224 struct fb_cursor cursor; ··· 349 349 kfree(tmp); 350 350 } 351 351 352 - ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; 352 + ops->cursor_state.enable = enable && !use_sw; 353 353 354 354 cursor.image.data = src; 355 355 cursor.image.fg_color = ops->cursor_state.image.fg_color;
+2 -2
drivers/video/fbdev/core/fbcon_cw.c
··· 201 201 } 202 202 } 203 203 204 - static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, 204 + static void cw_cursor(struct vc_data *vc, struct fb_info *info, bool enable, 205 205 int fg, int bg) 206 206 { 207 207 struct fb_cursor cursor; ··· 332 332 kfree(tmp); 333 333 } 334 334 335 - ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; 335 + ops->cursor_state.enable = enable && !use_sw; 336 336 337 337 cursor.image.data = src; 338 338 cursor.image.fg_color = ops->cursor_state.image.fg_color;
+2 -2
drivers/video/fbdev/core/fbcon_ud.c
··· 248 248 } 249 249 } 250 250 251 - static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, 251 + static void ud_cursor(struct vc_data *vc, struct fb_info *info, bool enable, 252 252 int fg, int bg) 253 253 { 254 254 struct fb_cursor cursor; ··· 372 372 mask[i++] = ~msk; 373 373 } 374 374 375 - ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; 375 + ops->cursor_state.enable = enable && !use_sw; 376 376 377 377 cursor.image.data = src; 378 378 cursor.image.fg_color = ops->cursor_state.image.fg_color;
+2 -2
drivers/video/fbdev/core/tileblit.c
··· 79 79 return; 80 80 } 81 81 82 - static void tile_cursor(struct vc_data *vc, struct fb_info *info, int mode, 82 + static void tile_cursor(struct vc_data *vc, struct fb_info *info, bool enable, 83 83 int fg, int bg) 84 84 { 85 85 struct fb_tilecursor cursor; ··· 87 87 88 88 cursor.sx = vc->state.x; 89 89 cursor.sy = vc->state.y; 90 - cursor.mode = (mode == CM_ERASE || use_sw) ? 0 : 1; 90 + cursor.mode = enable && !use_sw; 91 91 cursor.fg = fg; 92 92 cursor.bg = bg; 93 93
+2 -6
include/linux/console.h
··· 42 42 * @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. 43 43 * (optional -- @con_putcs would be called instead) 44 44 * @con_putcs: emit @count characters with attributes @s to [@x, @y] on @vc. 45 + * @con_cursor: enable/disable cursor depending on @enable 45 46 * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. 46 47 * Return true if no generic handling should be done. 47 48 * Invoked by csi_M and printing to the console. ··· 62 61 void (*con_putcs)(struct vc_data *vc, const u16 *s, 63 62 unsigned int count, unsigned int ypos, 64 63 unsigned int xpos); 65 - void (*con_cursor)(struct vc_data *vc, int mode); 64 + void (*con_cursor)(struct vc_data *vc, bool enable); 66 65 bool (*con_scroll)(struct vc_data *vc, unsigned int top, 67 66 unsigned int bottom, enum con_scroll dir, 68 67 unsigned int lines); ··· 128 127 static inline void con_debug_enter(struct vc_data *vc) { } 129 128 static inline void con_debug_leave(void) { } 130 129 #endif 131 - 132 - /* cursor */ 133 - #define CM_DRAW (1) 134 - #define CM_ERASE (2) 135 - #define CM_MOVE (3) 136 130 137 131 /* 138 132 * The interface for a console, or any other device that wants to capture