Skip to content

Commit 1023ca1

Browse files
Jiri Slaby (SUSE)hdeller
authored andcommitted
vgacon: cache vc_cell_height in vgacon_cursor()
There are many places c->vc_cell_height is used in the code of vgacon_cursor(). Caching the value to a local variable makes the code much easier to follow. Signed-off-by: "Jiri Slaby (SUSE)" <[email protected]> Cc: Helge Deller <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Helge Deller <[email protected]>
1 parent 93686f6 commit 1023ca1

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

drivers/video/console/vgacon.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,15 @@ static void vgacon_set_cursor_size(int from, int to)
470470

471471
static void vgacon_cursor(struct vc_data *c, int mode)
472472
{
473+
unsigned int c_height;
474+
473475
if (c->vc_mode != KD_TEXT)
474476
return;
475477

476478
vgacon_restore_screen(c);
477479

480+
c_height = c->vc_cell_height;
481+
478482
switch (mode) {
479483
case CM_ERASE:
480484
write_vga(14, (c->vc_pos - vga_vram_base) / 2);
@@ -489,30 +493,22 @@ static void vgacon_cursor(struct vc_data *c, int mode)
489493
write_vga(14, (c->vc_pos - vga_vram_base) / 2);
490494
switch (CUR_SIZE(c->vc_cursor_type)) {
491495
case CUR_UNDERLINE:
492-
vgacon_set_cursor_size(c->vc_cell_height -
493-
(c->vc_cell_height <
494-
10 ? 2 : 3),
495-
c->vc_cell_height -
496-
(c->vc_cell_height <
497-
10 ? 1 : 2));
496+
vgacon_set_cursor_size(c_height -
497+
(c_height < 10 ? 2 : 3),
498+
c_height -
499+
(c_height < 10 ? 1 : 2));
498500
break;
499501
case CUR_TWO_THIRDS:
500-
vgacon_set_cursor_size(c->vc_cell_height / 3,
501-
c->vc_cell_height -
502-
(c->vc_cell_height <
503-
10 ? 1 : 2));
502+
vgacon_set_cursor_size(c_height / 3, c_height -
503+
(c_height < 10 ? 1 : 2));
504504
break;
505505
case CUR_LOWER_THIRD:
506-
vgacon_set_cursor_size((c->vc_cell_height * 2) / 3,
507-
c->vc_cell_height -
508-
(c->vc_cell_height <
509-
10 ? 1 : 2));
506+
vgacon_set_cursor_size(c_height * 2 / 3, c_height -
507+
(c_height < 10 ? 1 : 2));
510508
break;
511509
case CUR_LOWER_HALF:
512-
vgacon_set_cursor_size(c->vc_cell_height / 2,
513-
c->vc_cell_height -
514-
(c->vc_cell_height <
515-
10 ? 1 : 2));
510+
vgacon_set_cursor_size(c_height / 2, c_height -
511+
(c_height < 10 ? 1 : 2));
516512
break;
517513
case CUR_NONE:
518514
if (vga_video_type >= VIDEO_TYPE_VGAC)
@@ -521,7 +517,7 @@ static void vgacon_cursor(struct vc_data *c, int mode)
521517
vgacon_set_cursor_size(31, 31);
522518
break;
523519
default:
524-
vgacon_set_cursor_size(1, c->vc_cell_height);
520+
vgacon_set_cursor_size(1, c_height);
525521
break;
526522
}
527523
break;

0 commit comments

Comments
 (0)