summaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2020-06-15 09:48:40 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-24 17:08:31 +0200
commitde53ce0427cd20886b0d53555dc576702cbb1ff8 (patch)
tree0c127a71647417655bc825e8b9d27a67c32162c4 /drivers/tty/vt
parentvt: remove 25 years stale comment (diff)
downloadlinux-de53ce0427cd20886b0d53555dc576702cbb1ff8.tar.xz
linux-de53ce0427cd20886b0d53555dc576702cbb1ff8.zip
vt: use tty_insert_flip_string in respond_string
Pass the length of a string to respond_string and use tty_insert_flip_string instead of a loop with tty_insert_flip_char. This simplifies the processing on the tty side. The added strlens are optimized during constant folding and propagation and the result are proper constants in assembly. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200615074910.19267-8-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r--drivers/tty/vt/vt.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 3adb7f409524..49c9d1e4067c 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1809,40 +1809,43 @@ static void csi_m(struct vc_data *vc)
update_attr(vc);
}
-static void respond_string(const char *p, struct tty_port *port)
+static void respond_string(const char *p, size_t len, struct tty_port *port)
{
- while (*p) {
- tty_insert_flip_char(port, *p, 0);
- p++;
- }
+ tty_insert_flip_string(port, p, len);
tty_schedule_flip(port);
}
static void cursor_report(struct vc_data *vc, struct tty_struct *tty)
{
char buf[40];
+ int len;
- sprintf(buf, "\033[%d;%dR", vc->state.y + (vc->vc_decom ? vc->vc_top + 1 : 1), vc->state.x + 1);
- respond_string(buf, tty->port);
+ len = sprintf(buf, "\033[%d;%dR", vc->state.y +
+ (vc->vc_decom ? vc->vc_top + 1 : 1),
+ vc->state.x + 1);
+ respond_string(buf, len, tty->port);
}
static inline void status_report(struct tty_struct *tty)
{
- respond_string("\033[0n", tty->port); /* Terminal ok */
+ static const char teminal_ok[] = "\033[0n";
+
+ respond_string(teminal_ok, strlen(teminal_ok), tty->port);
}
static inline void respond_ID(struct tty_struct *tty)
{
- respond_string(VT102ID, tty->port);
+ respond_string(VT102ID, strlen(VT102ID), tty->port);
}
void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry)
{
char buf[8];
+ int len;
- sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx),
- (char)('!' + mry));
- respond_string(buf, tty->port);
+ len = sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt),
+ (char)('!' + mrx), (char)('!' + mry));
+ respond_string(buf, len, tty->port);
}
/* invoked via ioctl(TIOCLINUX) and through set_selection_user */