aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2016-10-03 05:18:35 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-10-27 10:37:44 -0400
commit35cc56f9a30480c8a0cca809cf341614a2144758 (patch)
treef7edce136762932eaad0c7a448c72e3a1df3006d /drivers/tty
parent89765b9424eafb954b1ca167a00c2a10e4f025be (diff)
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>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/vt/vt.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index a0b7576747cd..2eab714aab67 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -4279,6 +4279,44 @@ void vcs_scr_updated(struct vc_data *vc)
4279 notify_update(vc); 4279 notify_update(vc);
4280} 4280}
4281 4281
4282void vc_scrolldelta_helper(struct vc_data *c, int lines,
4283 unsigned int rolled_over, void *base, unsigned int size)
4284{
4285 unsigned long ubase = (unsigned long)base;
4286 int margin = c->vc_size_row * 4;
4287 int ul, we, p, st;
4288
4289 /* Turn scrollback off */
4290 if (!lines) {
4291 c->vc_visible_origin = c->vc_origin;
4292 return;
4293 }
4294
4295 /* Do we have already enough to allow jumping from 0 to the end? */
4296 if (rolled_over > (c->vc_scr_end - ubase) + margin) {
4297 ul = c->vc_scr_end - ubase;
4298 we = rolled_over + c->vc_size_row;
4299 } else {
4300 ul = 0;
4301 we = size;
4302 }
4303
4304 p = (c->vc_visible_origin - ubase - ul + we) % we +
4305 lines * c->vc_size_row;
4306 st = (c->vc_origin - ubase - ul + we) % we;
4307
4308 /* Only a little piece would be left? Show all incl. the piece! */
4309 if (st < 2 * margin)
4310 margin = 0;
4311 if (p < margin)
4312 p = 0;
4313 if (p > st - margin)
4314 p = st;
4315
4316 c->vc_visible_origin = ubase + (p + ul) % we;
4317}
4318EXPORT_SYMBOL_GPL(vc_scrolldelta_helper);
4319
4282/* 4320/*
4283 * Visible symbols for modules 4321 * Visible symbols for modules
4284 */ 4322 */