Skip to content

Commit

Permalink
tty: vt: cache row count in con_scroll()
Browse files Browse the repository at this point in the history
It's used on few places, so make the code easier to follow by caching
the subtraction result.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230112080136.4929-11-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jiri Slaby (SUSE) authored and gregkh committed Jan 19, 2023
1 parent 424c82a commit bf8baa0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/tty/vt/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,11 @@ static void con_scroll(struct vc_data *vc, unsigned int top,
unsigned int bottom, enum con_scroll dir,
unsigned int nr)
{
unsigned int rows = bottom - top;
u16 *clear, *dst, *src;

if (top + nr >= bottom)
nr = bottom - top - 1;
nr = rows - 1;
if (bottom > vc->vc_rows || top >= bottom || nr < 1)
return;

Expand All @@ -577,10 +578,10 @@ static void con_scroll(struct vc_data *vc, unsigned int top,
dst = (u16 *)(vc->vc_origin + vc->vc_size_row * (top + nr));

if (dir == SM_UP) {
clear = src + (bottom - top - nr) * vc->vc_cols;
clear = src + (rows - nr) * vc->vc_cols;
swap(src, dst);
}
scr_memmovew(dst, src, (bottom - top - nr) * vc->vc_size_row);
scr_memmovew(dst, src, (rows - nr) * vc->vc_size_row);
scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr);
}

Expand Down

0 comments on commit bf8baa0

Please sign in to comment.