tty: vgacon+sisusb, move scrolldelta to a common helper

The code is mirrorred in scrolldelta implementations of both vgacon
and sisusb. Let's move the code to a separate helper where we will
perform a common cleanup and further changes.

While we are moving the code, make it linear and save one indentation
level. This is done by returning from the "!lines" then-branch
immediatelly. This allows flushing the else-branch 1 level to the
left, obviously.

Few more new lines and comments were added too.

And do not forget to export the helper function given sisusb can be
built as module.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Winischhofer <thomas@winischhofer.net>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: <linux-fbdev@vger.kernel.org>
Cc: <linux-usb@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jiri Slaby
2016-10-03 11:18:35 +02:00
committed by Greg Kroah-Hartman
parent 89765b9424
commit 35cc56f9a3
4 changed files with 44 additions and 60 deletions

View File

@@ -686,8 +686,6 @@ static void
sisusbcon_scrolldelta(struct vc_data *c, int lines)
{
struct sisusb_usb_data *sisusb;
int margin = c->vc_size_row * 4;
int ul, we, p, st;
sisusb = sisusb_get_sisusb_lock_and_check(c->vc_num);
if (!sisusb)
@@ -700,39 +698,8 @@ sisusbcon_scrolldelta(struct vc_data *c, int lines)
return;
}
if (!lines) /* Turn scrollback off */
c->vc_visible_origin = c->vc_origin;
else {
if (sisusb->con_rolled_over >
(c->vc_scr_end - sisusb->scrbuf) + margin) {
ul = c->vc_scr_end - sisusb->scrbuf;
we = sisusb->con_rolled_over + c->vc_size_row;
} else {
ul = 0;
we = sisusb->scrbuf_size;
}
p = (c->vc_visible_origin - sisusb->scrbuf - ul + we) % we +
lines * c->vc_size_row;
st = (c->vc_origin - sisusb->scrbuf - ul + we) % we;
if (st < 2 * margin)
margin = 0;
if (p < margin)
p = 0;
if (p > st - margin)
p = st;
c->vc_visible_origin = sisusb->scrbuf + (p + ul) % we;
}
vc_scrolldelta_helper(c, lines, sisusb->con_rolled_over,
(void *)sisusb->scrbuf, sisusb->scrbuf_size);
sisusbcon_set_start_address(sisusb, c);