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

Configure Feed

Select the types of activity you want to include in your feed.

consoles: use if instead of switch-case in consw::con_cursor()

This is only a preparation for the following cleanup patch to make it
easier. Provided CM_ERASE is the only different, use 'if' instead of
'switch+case' in all those.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
Link: https://lore.kernel.org/r/20240122110401.7289-28-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
7c5337c9 bfd7de49

+53 -66
+11 -15
drivers/video/console/newport_con.c
··· 443 443 unsigned short treg; 444 444 int xcurs, ycurs; 445 445 446 - switch (mode) { 447 - case CM_ERASE: 448 - treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); 446 + treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); 447 + 448 + if (mode == CM_ERASE) { 449 449 newport_vc2_set(npregs, VC2_IREG_CONTROL, 450 450 (treg & ~(VC2_CTRL_ECDISP))); 451 - break; 452 - 453 - case CM_MOVE: 454 - case CM_DRAW: 455 - treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); 456 - newport_vc2_set(npregs, VC2_IREG_CONTROL, 457 - (treg | VC2_CTRL_ECDISP)); 458 - xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2; 459 - ycurs = ((xcurs / vc->vc_cols) << 4) + 31; 460 - xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction; 461 - newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs); 462 - newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs); 451 + return; 463 452 } 453 + 454 + newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg | VC2_CTRL_ECDISP)); 455 + xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2; 456 + ycurs = ((xcurs / vc->vc_cols) << 4) + 31; 457 + xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction; 458 + newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs); 459 + newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs); 464 460 } 465 461 466 462 static int newport_switch(struct vc_data *vc)
+12 -15
drivers/video/console/sticon.c
··· 95 95 return; 96 96 97 97 car1 = conp->vc_screenbuf[conp->state.x + conp->state.y * conp->vc_cols]; 98 - switch (mode) { 99 - case CM_ERASE: 98 + if (mode == CM_ERASE) { 100 99 sti_putc(sticon_sti, car1, conp->state.y, conp->state.x, 101 100 font_data[conp->vc_num]); 102 - break; 103 - case CM_MOVE: 104 - case CM_DRAW: 105 - switch (CUR_SIZE(conp->vc_cursor_type)) { 106 - case CUR_UNDERLINE: 107 - case CUR_LOWER_THIRD: 108 - case CUR_LOWER_HALF: 109 - case CUR_TWO_THIRDS: 110 - case CUR_BLOCK: 111 - sti_putc(sticon_sti, (car1 & 255) + (0 << 8) + (7 << 11), 112 - conp->state.y, conp->state.x, font_data[conp->vc_num]); 113 - break; 114 - } 101 + return; 102 + } 103 + 104 + switch (CUR_SIZE(conp->vc_cursor_type)) { 105 + case CUR_UNDERLINE: 106 + case CUR_LOWER_THIRD: 107 + case CUR_LOWER_HALF: 108 + case CUR_TWO_THIRDS: 109 + case CUR_BLOCK: 110 + sti_putc(sticon_sti, (car1 & 255) + (0 << 8) + (7 << 11), 111 + conp->state.y, conp->state.x, font_data[conp->vc_num]); 115 112 break; 116 113 } 117 114 }
+30 -36
drivers/video/console/vgacon.c
··· 514 514 515 515 c_height = c->vc_cell_height; 516 516 517 - switch (mode) { 518 - case CM_ERASE: 519 - write_vga(14, (c->vc_pos - vga_vram_base) / 2); 517 + write_vga(14, (c->vc_pos - vga_vram_base) / 2); 518 + 519 + if (mode == CM_ERASE) { 520 520 if (vga_video_type >= VIDEO_TYPE_VGAC) 521 521 vgacon_set_cursor_size(31, 30); 522 522 else 523 523 vgacon_set_cursor_size(31, 31); 524 - break; 524 + return; 525 + } 525 526 526 - case CM_MOVE: 527 - case CM_DRAW: 528 - write_vga(14, (c->vc_pos - vga_vram_base) / 2); 529 - switch (CUR_SIZE(c->vc_cursor_type)) { 530 - case CUR_UNDERLINE: 531 - vgacon_set_cursor_size(c_height - 532 - (c_height < 10 ? 2 : 3), 533 - c_height - 534 - (c_height < 10 ? 1 : 2)); 535 - break; 536 - case CUR_TWO_THIRDS: 537 - vgacon_set_cursor_size(c_height / 3, c_height - 538 - (c_height < 10 ? 1 : 2)); 539 - break; 540 - case CUR_LOWER_THIRD: 541 - vgacon_set_cursor_size(c_height * 2 / 3, c_height - 542 - (c_height < 10 ? 1 : 2)); 543 - break; 544 - case CUR_LOWER_HALF: 545 - vgacon_set_cursor_size(c_height / 2, c_height - 546 - (c_height < 10 ? 1 : 2)); 547 - break; 548 - case CUR_NONE: 549 - if (vga_video_type >= VIDEO_TYPE_VGAC) 550 - vgacon_set_cursor_size(31, 30); 551 - else 552 - vgacon_set_cursor_size(31, 31); 553 - break; 554 - default: 555 - vgacon_set_cursor_size(1, c_height); 556 - break; 557 - } 527 + switch (CUR_SIZE(c->vc_cursor_type)) { 528 + case CUR_UNDERLINE: 529 + vgacon_set_cursor_size(c_height - (c_height < 10 ? 2 : 3), 530 + c_height - (c_height < 10 ? 1 : 2)); 531 + break; 532 + case CUR_TWO_THIRDS: 533 + vgacon_set_cursor_size(c_height / 3, 534 + c_height - (c_height < 10 ? 1 : 2)); 535 + break; 536 + case CUR_LOWER_THIRD: 537 + vgacon_set_cursor_size(c_height * 2 / 3, 538 + c_height - (c_height < 10 ? 1 : 2)); 539 + break; 540 + case CUR_LOWER_HALF: 541 + vgacon_set_cursor_size(c_height / 2, 542 + c_height - (c_height < 10 ? 1 : 2)); 543 + break; 544 + case CUR_NONE: 545 + if (vga_video_type >= VIDEO_TYPE_VGAC) 546 + vgacon_set_cursor_size(31, 30); 547 + else 548 + vgacon_set_cursor_size(31, 31); 549 + break; 550 + default: 551 + vgacon_set_cursor_size(1, c_height); 558 552 break; 559 553 } 560 554 }