summaryrefslogtreecommitdiff
path: root/drivers/tty/vt
diff options
context:
space:
mode:
authorJiri Slaby (SUSE) <jirislaby@kernel.org>2023-01-12 11:01:36 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-19 17:06:42 +0300
commitbf8baa00668dbc4fcfca5ac49ae8a3059c795e4e (patch)
tree5ee3dd968d223c90d6cdfa9ccc0a52c223e21609 /drivers/tty/vt
parent424c82af26b1b8ca6c0be06987a4e6d18c9a92dd (diff)
downloadlinux-bf8baa00668dbc4fcfca5ac49ae8a3059c795e4e.tar.xz
tty: vt: cache row count in con_scroll()
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>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r--drivers/tty/vt/vt.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index e3f62fffbdd5..71f182416835 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -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;
@@ -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);
}