From patchwork Fri Feb 2 06:55:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769443 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEFD317755; Fri, 2 Feb 2024 06:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856973; cv=none; b=lXvyu0cAw/xxDKKwHzf07VmWxNQWTg3qq4gUUNWou13Iw/d9CZVqpJMSVOei2lAC3jHrAONXoZvlXfP0lPuwOiVqCpohYu7zZfiJk6gKtSAwx9fpqdjMis0P8xCgmOK00gTkavIkVU/gMXIsIvghaj1OG6jkGcSO+6mb7F49nFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856973; c=relaxed/simple; bh=zh855z9zkcp82mqscxhofAUAlll2wwDk2/8ndqNudGY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MTKWp91PtU062uDAQloOj43r8LFdxUjzFzi3MzmL6gQcWZ0KqkVq2irigxTshr+K23BMM90DPpBbv90oTHzQ5lH4thbQjGKHcsbg3Rkfa/qgGNuyTeaY7Yd+jX9VGBbYDVRrBE7wVyy35p+OXifXAP9yqrcDnw/RaBYp6RbCUAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JFgEKrM5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JFgEKrM5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7240BC433C7; Fri, 2 Feb 2024 06:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856973; bh=zh855z9zkcp82mqscxhofAUAlll2wwDk2/8ndqNudGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JFgEKrM5wTITV5azZ2L6F8afa5eFIYHYdLzpw31YAcYR868VOQ4TDnFbC4fhj2Jmx RfQZ1Hvihyw6XGtCweIMchTGuv+VATe4pmExZ/TxBAUMC70k61HOAVSYYXY9+hpuX2 3nw+vzq4CDMssgtsWrwNqwnUj8TQouzM+NtS8yJJsMdOPG1FwKtJJsgybizSX35u2F 4F5RPgzaYT4+JKrrCZWxUNgkNUTfRTvrYISst3cJ3VLNoJ6nY/iAH+vTf4EA8Etgqg AV3Zpcw/Z9ux2H0JpmqvmSO4/oSCv0HQtpNkVZQEcfuG+eE9SwbTQmPnPqtrMHrXy9 qetFvHcDPPMeg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 01/22] tty: vt: make rgb_from_256() slighly more comprehensible Date: Fri, 2 Feb 2024 07:55:47 +0100 Message-ID: <20240202065608.14019-2-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 * make the parameter unsigned, as it is expected to be unsigned, * make the computation easier to follow -- step-by-step, and * don't use 85 / 2 which is only a reduced form of 255 / 6 (by a factor 3). Unlike the former, the latter can be understood. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 65cd40cac96b..7d42f148559a 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1588,7 +1588,7 @@ static void default_attr(struct vc_data *vc) struct rgb { u8 r; u8 g; u8 b; }; -static void rgb_from_256(int i, struct rgb *c) +static void rgb_from_256(unsigned int i, struct rgb *c) { if (i < 8) { /* Standard colours. */ c->r = i&1 ? 0xaa : 0x00; @@ -1599,9 +1599,12 @@ static void rgb_from_256(int i, struct rgb *c) c->g = i&2 ? 0xff : 0x55; c->b = i&4 ? 0xff : 0x55; } else if (i < 232) { /* 6x6x6 colour cube. */ - c->r = (i - 16) / 36 * 85 / 2; - c->g = (i - 16) / 6 % 6 * 85 / 2; - c->b = (i - 16) % 6 * 85 / 2; + i -= 16; + c->b = i % 6 * 255 / 6; + i /= 6; + c->g = i % 6 * 255 / 6; + i /= 6; + c->r = i * 255 / 6; } else /* Grayscale ramp. */ c->r = c->g = c->b = i * 10 - 2312; } From patchwork Fri Feb 2 06:55:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770033 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D97617BC2; Fri, 2 Feb 2024 06:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856975; cv=none; b=rQz3W/DLH1cEQ6MM1TSL5ZdLf+z6mMtxkkmzeeGUtf7n1fyMJHc86K+aKFbgIEsADIkyzbdVhngRZhm+kI2mft9eNXQB94iGsmy5/YOFtsO331ENt8ZPUGRCbgmM75yazSrEcj64UNEGNgfXyz1hjyG3q6GAwdL4saYMpG/e/zw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856975; c=relaxed/simple; bh=kxVDTHfZGYZb1zilvgP1SsL8GjUUvmxkdEFoPyB4ugg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PVOkGG9xoq2T2AniGVc2EBvrZngB13JzYhJX0NGE8wh/8m9gBrbtluYj3c/lqVvrlRJbICOGuGKyTT/Jhqt21DAlvP8VYRj7BH0nLdsAI+1iwSepgiEiKJxCc5pU4PNKmfFbZtNkziDCD5dB4vZynqccRI3zTS3g2Yguauu6ZH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aAi+ARWj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aAi+ARWj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED070C43390; Fri, 2 Feb 2024 06:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856975; bh=kxVDTHfZGYZb1zilvgP1SsL8GjUUvmxkdEFoPyB4ugg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aAi+ARWjnWruG7yFiXNTUS1zzRsHbEUEzLZLEhgham7+Hk/8XBDZus9sRBcDUjVso UtTW5nuy1N/hxCu8RVPkH4vp2uMVLoWMgE7gxYv09d1nWI/1l3dPs1ahIETRG/IY5R uQx70vnQ4+Ocz5OgYV8F/D+nnz7tEpB6pAyjFLFYzFj4toEEEB6zcpQZ7ZCs/6zWYI ur5cRCAHt0tPvym0Rl0OLtCffzB54KtIa3No1nnl9oUUQ4ZwwfpUVOHFqQYs8p6ZaK poU87oHLdFuxSte1dHCRUIpj/NbzTRnWMxPO7kr7iETqNGPeqNyHUMXsdEq4hj4hEp rb5mT/DnV3zCg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 02/22] tty: vt: define enums for CSI+h/l codes Date: Fri, 2 Feb 2024 07:55:48 +0100 Message-ID: <20240202065608.14019-3-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Decrypt the constant values by proper enum names. This time in set_mode(). Define two of them as DEC ('CSI ?') is about to be split away in the next patches. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 7d42f148559a..7b55d87248f8 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1862,6 +1862,24 @@ int mouse_reporting(void) return vc_cons[fg_console].d->vc_report_mouse; } +enum { + CSI_DEC_hl_CURSOR_KEYS = 1, /* CKM: cursor keys send ^[Ox/^[[x */ + CSI_DEC_hl_132_COLUMNS = 3, /* COLM: 80/132 mode switch */ + CSI_DEC_hl_REVERSE_VIDEO = 5, /* SCNM */ + CSI_DEC_hl_ORIGIN_MODE = 6, /* OM: origin relative/absolute */ + CSI_DEC_hl_AUTOWRAP = 7, /* AWM */ + CSI_DEC_hl_AUTOREPEAT = 8, /* ARM */ + CSI_DEC_hl_MOUSE_X10 = 9, + CSI_DEC_hl_SHOW_CURSOR = 25, /* TCEM */ + CSI_DEC_hl_MOUSE_VT200 = 1000, +}; + +enum { + CSI_hl_DISPLAY_CTRL = 3, /* handle ansi control chars */ + CSI_hl_INSERT = 4, /* IRM: insert/replace */ + CSI_hl_AUTO_NL = 20, /* LNM: Enter == CrLf/Lf */ +}; + /* console_lock is held */ static void set_mode(struct vc_data *vc, int on_off) { @@ -1870,20 +1888,20 @@ static void set_mode(struct vc_data *vc, int on_off) for (i = 0; i <= vc->vc_npar; i++) if (vc->vc_priv == EPdec) { switch(vc->vc_par[i]) { /* DEC private modes set/reset */ - case 1: /* Cursor keys send ^[Ox/^[[x */ + case CSI_DEC_hl_CURSOR_KEYS: if (on_off) set_kbd(vc, decckm); else clr_kbd(vc, decckm); break; - case 3: /* 80/132 mode switch unimplemented */ + case CSI_DEC_hl_132_COLUMNS: /* unimplemented */ #if 0 vc_resize(deccolm ? 132 : 80, vc->vc_rows); /* this alone does not suffice; some user mode utility has to change the hardware regs */ #endif break; - case 5: /* Inverted screen on/off */ + case CSI_DEC_hl_REVERSE_VIDEO: if (vc->vc_decscnm != on_off) { vc->vc_decscnm = on_off; invert_screen(vc, 0, @@ -1892,38 +1910,38 @@ static void set_mode(struct vc_data *vc, int on_off) update_attr(vc); } break; - case 6: /* Origin relative/absolute */ + case CSI_DEC_hl_ORIGIN_MODE: vc->vc_decom = on_off; gotoxay(vc, 0, 0); break; - case 7: /* Autowrap on/off */ + case CSI_DEC_hl_AUTOWRAP: vc->vc_decawm = on_off; break; - case 8: /* Autorepeat on/off */ + case CSI_DEC_hl_AUTOREPEAT: if (on_off) set_kbd(vc, decarm); else clr_kbd(vc, decarm); break; - case 9: + case CSI_DEC_hl_MOUSE_X10: vc->vc_report_mouse = on_off ? 1 : 0; break; - case 25: /* Cursor on/off */ + case CSI_DEC_hl_SHOW_CURSOR: vc->vc_deccm = on_off; break; - case 1000: + case CSI_DEC_hl_MOUSE_VT200: vc->vc_report_mouse = on_off ? 2 : 0; break; } } else { switch(vc->vc_par[i]) { /* ANSI modes set/reset */ - case 3: /* Monitor (display ctrls) */ + case CSI_hl_DISPLAY_CTRL: vc->vc_disp_ctrl = on_off; break; - case 4: /* Insert Mode on/off */ + case CSI_hl_INSERT: vc->vc_decim = on_off; break; - case 20: /* Lf, Enter == CrLf/Lf */ + case CSI_hl_AUTO_NL: if (on_off) set_kbd(vc, lnm); else From patchwork Fri Feb 2 06:55:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769442 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE92D17C79; Fri, 2 Feb 2024 06:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856977; cv=none; b=kx65CX4dQlO9gc6xvnmitT9tD5K3lQrINvI43ZEnlhKP+kAhv/I6E6vmid+LoAQYLJOWIJDaVAEOVnRyvV7loEncLP92kswrESsBL21N/14XWrm/gtdutqRad6lq8GewwWnffl09YU2kaGGdakLNrEFaFJ6r2BMHPQx17lTG7iU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856977; c=relaxed/simple; bh=1ggf9N68+vMUK1jcvrtDR4Sh3DWkqEikyT9dyj3heQ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bKEF35J9Tr+WZymZZM4eZVNhq/5BkyX1gcQM3z0QBxUfBJhnanpCQyHeTiMvLrQDxf26e33umeLY0DxfBCpTJKml4F8h3lThpzEBTTsRTZnJSDKl7ltZToFvlPcznhNgLY9cDAjzTEreDz3D1ywhP2Pk+LdkyApgBZbnstLTcK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=puyPq7MW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="puyPq7MW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72FD5C43394; Fri, 2 Feb 2024 06:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856976; bh=1ggf9N68+vMUK1jcvrtDR4Sh3DWkqEikyT9dyj3heQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=puyPq7MWSrRarl+OmiFB6rP1PURCFE9fChZXyP29VV50HvdluViBp0absbs22mr8+ +Wg66Mvsn2QD6LeBDPrwKxI2A0bc3Q49W+pdum3o2S7jHgTYcwEe0Zocxx3IMPZ4uo 9lkufuHYBZjnMp18ULpEcVaxREIfCJXYGIGmgab8JCvFmJgktrptZDPSgQPk9Mp5/+ oP4g3NmqhbcF0+RQ/4QG6GuEhD7jyWz0yYzLpqnbXtvjIAnsP3L+0yoyinHHZzjbRD DbimhrdoG0z86nZFOnAZ/LP74NV/SBd8YMnWLMhRglPovbI7HfaP/u+BUBfSxbOUMK AanEK4lgXGe5Q== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 03/22] tty: vt: rename set_mode() to csi_hl() Date: Fri, 2 Feb 2024 07:55:49 +0100 Message-ID: <20240202065608.14019-4-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's how the other CSI handling functions are named, so unify to that. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 7b55d87248f8..ae333f49790a 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1881,7 +1881,7 @@ enum { }; /* console_lock is held */ -static void set_mode(struct vc_data *vc, int on_off) +static void csi_hl(struct vc_data *vc, bool on_off) { int i; @@ -2380,11 +2380,11 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) switch(c) { case 'h': if (vc->vc_priv <= EPdec) - set_mode(vc, 1); + csi_hl(vc, true); return; case 'l': if (vc->vc_priv <= EPdec) - set_mode(vc, 0); + csi_hl(vc, false); return; case 'c': if (vc->vc_priv == EPdec) { From patchwork Fri Feb 2 06:55:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770032 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 905AD18036; Fri, 2 Feb 2024 06:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856978; cv=none; b=FEabLS1bxAPVfC71/S7wGeQAItpBaNyK2JeGRXcsLWtDcQbMUQ+2WXVNBJzfZdvYZzHLGoZTEkU5lb7bNkePXfTWJQp0CyCLXDrvxBK4GI9zUNBaiDkq1wOedc3dqsk+aup46H1KyJOdqGZafoSDqkiAqwerlkHS2C8itOeR/sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856978; c=relaxed/simple; bh=miH8BEvG/hsFaXFdQjVxX6ykS62LQxmbGXrx1onhjCA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p4WxYzeupey9TVm7qIumQB06SfmujKT3I/0PPajS23U6KvHPbWpzx7qdw2W7a9h5jdVPSPm33gOt2eayvU0jtgXTLJGIjfOsUYE/vAajNqbY4gpUh41zoOLy0C7B1WRVwZcMZyDhl7/W+4KhpveRxkd2eWQdiI76ghjeWL1NikA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RASuBlnz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RASuBlnz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE841C433C7; Fri, 2 Feb 2024 06:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856978; bh=miH8BEvG/hsFaXFdQjVxX6ykS62LQxmbGXrx1onhjCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RASuBlnzt4kzH4bqRksl37SOd8Mpr2gElneWbxC6iEeW5Tn7GTLbGe3kS11DD2XWW U/aZ6bCHc/HDD/cpIj2Ji1r1+KLsUigWKqF80hF9Qq2ikc/GE5QF/DJCBu7JCniEFA TBVr9CGOh4/rTR6zyR7DjMypg71e0ZPy/GVe4AfP/K+YJf9+AW6KMmsJw5Jgi5d0JN b1gkZflbUN8N+HlLns9vwALQ7Jo9SNBPAaTe1BjakhbbFp8zYam/ReYR7ygcQfRvkr QQzGBHFxP0j/iYfeCpGd6b22wsAauN2lKAWs5hzKV+OUQ8InoSSUswN3KJgqG+GIIp +cGJYBatY5VaQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 04/22] tty: vt: split DEC CSI+h/l handling into csi_DEC_hl() Date: Fri, 2 Feb 2024 07:55:50 +0100 Message-ID: <20240202065608.14019-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The DEC and ECMA handling of CSI+h/l is needlessly complicated. Split these two, so that DEC is handled when the state is EPdec ('CSI ?' was seen) and ECMA is handled in the EPecma state (no '?'). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 144 +++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 67 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index ae333f49790a..d04dbafc0517 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1874,6 +1874,59 @@ enum { CSI_DEC_hl_MOUSE_VT200 = 1000, }; +/* console_lock is held */ +static void csi_DEC_hl(struct vc_data *vc, bool on_off) +{ + unsigned int i; + + for (i = 0; i <= vc->vc_npar; i++) + switch (vc->vc_par[i]) { + case CSI_DEC_hl_CURSOR_KEYS: + if (on_off) + set_kbd(vc, decckm); + else + clr_kbd(vc, decckm); + break; + case CSI_DEC_hl_132_COLUMNS: /* unimplemented */ +#if 0 + vc_resize(deccolm ? 132 : 80, vc->vc_rows); + /* this alone does not suffice; some user mode + utility has to change the hardware regs */ +#endif + break; + case CSI_DEC_hl_REVERSE_VIDEO: + if (vc->vc_decscnm != on_off) { + vc->vc_decscnm = on_off; + invert_screen(vc, 0, vc->vc_screenbuf_size, + false); + update_attr(vc); + } + break; + case CSI_DEC_hl_ORIGIN_MODE: + vc->vc_decom = on_off; + gotoxay(vc, 0, 0); + break; + case CSI_DEC_hl_AUTOWRAP: + vc->vc_decawm = on_off; + break; + case CSI_DEC_hl_AUTOREPEAT: + if (on_off) + set_kbd(vc, decarm); + else + clr_kbd(vc, decarm); + break; + case CSI_DEC_hl_MOUSE_X10: + vc->vc_report_mouse = on_off ? 1 : 0; + break; + case CSI_DEC_hl_SHOW_CURSOR: + vc->vc_deccm = on_off; + break; + case CSI_DEC_hl_MOUSE_VT200: + vc->vc_report_mouse = on_off ? 2 : 0; + break; + } +} + enum { CSI_hl_DISPLAY_CTRL = 3, /* handle ansi control chars */ CSI_hl_INSERT = 4, /* IRM: insert/replace */ @@ -1883,71 +1936,22 @@ enum { /* console_lock is held */ static void csi_hl(struct vc_data *vc, bool on_off) { - int i; + unsigned int i; for (i = 0; i <= vc->vc_npar; i++) - if (vc->vc_priv == EPdec) { - switch(vc->vc_par[i]) { /* DEC private modes set/reset */ - case CSI_DEC_hl_CURSOR_KEYS: - if (on_off) - set_kbd(vc, decckm); - else - clr_kbd(vc, decckm); - break; - case CSI_DEC_hl_132_COLUMNS: /* unimplemented */ -#if 0 - vc_resize(deccolm ? 132 : 80, vc->vc_rows); - /* this alone does not suffice; some user mode - utility has to change the hardware regs */ -#endif - break; - case CSI_DEC_hl_REVERSE_VIDEO: - if (vc->vc_decscnm != on_off) { - vc->vc_decscnm = on_off; - invert_screen(vc, 0, - vc->vc_screenbuf_size, - false); - update_attr(vc); - } - break; - case CSI_DEC_hl_ORIGIN_MODE: - vc->vc_decom = on_off; - gotoxay(vc, 0, 0); - break; - case CSI_DEC_hl_AUTOWRAP: - vc->vc_decawm = on_off; - break; - case CSI_DEC_hl_AUTOREPEAT: - if (on_off) - set_kbd(vc, decarm); - else - clr_kbd(vc, decarm); - break; - case CSI_DEC_hl_MOUSE_X10: - vc->vc_report_mouse = on_off ? 1 : 0; - break; - case CSI_DEC_hl_SHOW_CURSOR: - vc->vc_deccm = on_off; - break; - case CSI_DEC_hl_MOUSE_VT200: - vc->vc_report_mouse = on_off ? 2 : 0; - break; - } - } else { - switch(vc->vc_par[i]) { /* ANSI modes set/reset */ - case CSI_hl_DISPLAY_CTRL: - vc->vc_disp_ctrl = on_off; - break; - case CSI_hl_INSERT: - vc->vc_decim = on_off; - break; - case CSI_hl_AUTO_NL: - if (on_off) - set_kbd(vc, lnm); - else - clr_kbd(vc, lnm); - break; - } + switch (vc->vc_par[i]) { /* ANSI modes set/reset */ + case CSI_hl_DISPLAY_CTRL: + vc->vc_disp_ctrl = on_off; + break; + case CSI_hl_INSERT: + vc->vc_decim = on_off; + break; + case CSI_hl_AUTO_NL: + if (on_off) + set_kbd(vc, lnm); + else + clr_kbd(vc, lnm); + break; } } @@ -2379,12 +2383,12 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_state = ESnormal; switch(c) { case 'h': - if (vc->vc_priv <= EPdec) - csi_hl(vc, true); + if (vc->vc_priv == EPdec) + csi_DEC_hl(vc, true); return; case 'l': - if (vc->vc_priv <= EPdec) - csi_hl(vc, false); + if (vc->vc_priv == EPdec) + csi_DEC_hl(vc, false); return; case 'c': if (vc->vc_priv == EPdec) { @@ -2494,6 +2498,12 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) else if (vc->vc_par[0] == 3) bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); return; + case 'h': + csi_hl(vc, true); + return; + case 'l': + csi_hl(vc, false); + return; case 'm': csi_m(vc); return; From patchwork Fri Feb 2 06:55:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769441 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F41C2182BD; Fri, 2 Feb 2024 06:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856980; cv=none; b=qP1gvv5kbJDOyW1RBRFOYsHfPtxHw8mtVBB9RQxgxlSnKZI3DvhIpa9CPDqgTwuxO9J5rwTjJ1J1BGdYLF4s6GS7q0VKZjaI1EHkiey+Z+ECkDQ0nS2/7bXFPl6Or6ZtZv7UeK0+kheRM960cWun74vNP4Tz7AF9zCwR3RHEflg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856980; c=relaxed/simple; bh=W9KFsqQrZI8Sz/TN7frGjMUlXkKEz2nE7bsFVKL5CyU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g+QLbkstyzDoORqmuZXG5JDS0cI8BPaxM4m/cGnrqhK5pnWGCQ4+u6qP1LiQoMNLtRgMr+QL7EKb80Oi/1IWYG7N6znulWXlXzGog5n1AiJ4Nn2+LnjL3QaPFEK4O52srViWCIGpDm/sOpVnb/J6iupUAkZbzzaNySbk1vOIeG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RtuHRPU9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RtuHRPU9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 756F3C43399; Fri, 2 Feb 2024 06:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856979; bh=W9KFsqQrZI8Sz/TN7frGjMUlXkKEz2nE7bsFVKL5CyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtuHRPU9FpzT5yDF2vq8XfXgP/0y1diDcLNimncLlu61PbNXz12OwQkqqyGuYZqxN O/JB61ox5ESoiHepTaoOFlYFhnlbcw1OrSn8stQ+cHPVM8P3c7XEzQIVtIbTU9Z7gZ YgEdY6P63TyIcrBjjgkg94/Iesy033j0dFXERwc0dZYLcD5H0H5F0dFNthvCPP5f3l KAarWoO7igBV/Css7i5QxQvTwaC/6cS3aev+yzbWQofvviEEKNDarQvxUA31EoJuUu HeTnnUXvFVrZ7Def5IuChkVqmJYvIk4bW/yKyS/W1N4oJbJ00o6RaQanX1ewpmY9lP rKp9+IvTbhF1A== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 05/22] tty: vt: remove unneeded assignment of EPecma to vc_priv Date: Fri, 2 Feb 2024 07:55:51 +0100 Message-ID: <20240202065608.14019-6-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 vc_data::vc_priv is _always_ assigned before the ESgetpars case is entered (in ESsquare). Therefore, there is no need to reset it when leaving the ESgetpars case. Note the state is set to ESnormal few lines above, so ESgetpars is entered only by the next CSI. Therefore, this obfuscation can be removed. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index d04dbafc0517..69ebce0878f2 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2421,10 +2421,9 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) } return; } - if (vc->vc_priv != EPecma) { - vc->vc_priv = EPecma; + if (vc->vc_priv != EPecma) return; - } + switch(c) { case 'G': case '`': if (vc->vc_par[0]) From patchwork Fri Feb 2 06:55:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770031 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C23B18635; Fri, 2 Feb 2024 06:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856981; cv=none; b=U/Fw38bDADxMiYXRFGPQtSitxVPNUbdRNCM+JnMaCK5Bip7YkBkQklqsjg3u6VSBjkVWXUrQ5F0umq6DkBpb7QiQViK6QrWG12w6VtcEnOEkA9xvLKndM9I+RiRGqnecMlHh7sMNVJViQgR/DnXvNPeWYn1vHjH6xqFuOAcTmzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856981; c=relaxed/simple; bh=JA1mO7mmkQWRWZ2IXS92LNrizm+dnPGK0g9gxxuO5o4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JcOjopFqFo0pFpitRURETXXb3mIIpe2TS7RRtwVrZmxuK4csDZnVHvCjOxBriyaBZxffHumrYyYuGQmgT/cDNHC4ZfInr/OMPoxc/LWd2xjemV25hr8TEP4R5a5a/NI12QKdxnfBVTUi05VKcCkgaBNYnwbcBiriCEre6oFsDPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xbqoliew; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xbqoliew" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2738C433F1; Fri, 2 Feb 2024 06:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856981; bh=JA1mO7mmkQWRWZ2IXS92LNrizm+dnPGK0g9gxxuO5o4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XbqoliewihlJoVWJh4154WINa0cRBw31SKQvFj8IAONpiWGCXclbNYAyEpWhSchl0 +ilOZK2FH4UpqUXAOqJSsXip7pX/gKOV7czDx1XAV/cwMl3fg7NOpd64F7RBSgdZmJ Izf/xRd83CIwBFwnL4y/kShrMds+C7LnBDIPM3ooPkNw30mUEjFlVc6xPANg3tQ0Kz 2SWIvwKNAQJ6wjgqN3RmZAvk3OUnDSWgmRGPmLzEidgCl7fZtkmEQGkY/T4xFfv6s9 RZqyg5Yeb/24tJQwa11gUHmllx5rzoEHE8DqJeri58mv6lQ9edSrT4NCgsp9O76nz2 yiSAfK4GsEGfA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 06/22] tty: vt: move CSI+n handling along to other ECMA CSIs Date: Fri, 2 Feb 2024 07:55:52 +0100 Message-ID: <20240202065608.14019-7-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 CSIs without [<=>?] modifiers (ECMA) are handled in the switch-case below this DEC switch+case handler. So move this ECMA CSI+n there too as it fits there better. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 69ebce0878f2..04d109464994 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2412,14 +2412,6 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) return; } break; - case 'n': - if (vc->vc_priv == EPecma) { - if (vc->vc_par[0] == 5) - status_report(tty); - else if (vc->vc_par[0] == 6) - cursor_report(vc, tty); - } - return; } if (vc->vc_priv != EPecma) return; @@ -2506,6 +2498,12 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) case 'm': csi_m(vc); return; + case 'n': + if (vc->vc_par[0] == 5) + status_report(tty); + else if (vc->vc_par[0] == 6) + cursor_report(vc, tty); + return; case 'q': /* DECLL - but only 3 leds */ /* map 0,1,2,3 to 0,1,2,4 */ if (vc->vc_par[0] < 4) From patchwork Fri Feb 2 06:55:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769440 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 108EE18B1A; Fri, 2 Feb 2024 06:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856983; cv=none; b=Dc2fg2dNjRVT+EWWi04z+wE9AgHMgLo0emsXAQ8PkBz99eS/zlMn10ojKUbc+yG1w/OX/IELWzkAcq5/Dg70DTXQzwnd4TuIgwxXTLO9xzVJOo3BKmKDj/qOZc2IxcwNa93GocflMiOv0VqO1tyNqudjK4UTieHA9cz8Qavttw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856983; c=relaxed/simple; bh=zkznFitIGz2Pjh+DWBKkgJYWUMuKCoX2dndhJadUQuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aPI9/88JNKa7u7vKAUl9rJt2x0XGHXa+GJJf5A30kFMeSwhp0NY4qam+7cblhwDsQuZhhRDxruzrYjzVurQYY8TUqGwSpjXnrRQGx7FqODe9I9YTyqSFRCjYoCIrYXUdNpl00CUsqHYEl+C3jQllKv2kxBoUPiCp/rAfmiBekno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VsC1hGXa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VsC1hGXa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78580C433C7; Fri, 2 Feb 2024 06:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856982; bh=zkznFitIGz2Pjh+DWBKkgJYWUMuKCoX2dndhJadUQuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VsC1hGXai8T/J6kGDOoqZZn+xt85UFy8vY+mX3xA/YfJZ2XfS48vU2OTg5yVRIyB9 AEh21ZTb7aYIXdB5yyg1hu4pXaRv3cXW3F/uR8KZUVpNvUevxaLbsdsi8fsIQ1EkjX aOVWKsXEKicbmZzKOd0x1i/gW4cknOBqCeOTWgSeAEp6dRyXmkpUmmh8+dqQfv/6Xy xj7sRtR4JC3scoWps3WP/mt18u1I7RBeJeYaPCLxqlOw80TgNoXyfGc0OE4/WOnhTj JTjTmOa2aHEPEKqk7Mrn+pSUvbUtQyeYAw7RwmGjeho8WHa/UuMlMSm3O62JeFxGLX EZgDxl1afKvIA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 07/22] tty: vt: define an enum for CSI+] codes Date: Fri, 2 Feb 2024 07:55:53 +0100 Message-ID: <20240202065608.14019-8-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Decrypt the constant values by proper enum names. This time in setterm_command() (to be renamed to csi_RSB() in the next patches). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 04d109464994..9db545f305dc 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1955,62 +1955,76 @@ static void csi_hl(struct vc_data *vc, bool on_off) } } +enum CSI_right_square_bracket { + CSI_RSB_COLOR_FOR_UNDERLINE = 1, + CSI_RSB_COLOR_FOR_HALF_BRIGHT = 2, + CSI_RSB_MAKE_CUR_COLOR_DEFAULT = 8, + CSI_RSB_BLANKING_INTERVAL = 9, + CSI_RSB_BELL_FREQUENCY = 10, + CSI_RSB_BELL_DURATION = 11, + CSI_RSB_BRING_CONSOLE_TO_FRONT = 12, + CSI_RSB_UNBLANK = 13, + CSI_RSB_VESA_OFF_INTERVAL = 14, + CSI_RSB_BRING_PREV_CONSOLE_TO_FRONT = 15, + CSI_RSB_CURSOR_BLINK_INTERVAL = 16, +}; + /* console_lock is held */ static void setterm_command(struct vc_data *vc) { switch (vc->vc_par[0]) { - case 1: /* set color for underline mode */ + case CSI_RSB_COLOR_FOR_UNDERLINE: if (vc->vc_can_do_color && vc->vc_par[1] < 16) { vc->vc_ulcolor = color_table[vc->vc_par[1]]; if (vc->state.underline) update_attr(vc); } break; - case 2: /* set color for half intensity mode */ + case CSI_RSB_COLOR_FOR_HALF_BRIGHT: if (vc->vc_can_do_color && vc->vc_par[1] < 16) { vc->vc_halfcolor = color_table[vc->vc_par[1]]; if (vc->state.intensity == VCI_HALF_BRIGHT) update_attr(vc); } break; - case 8: /* store colors as defaults */ + case CSI_RSB_MAKE_CUR_COLOR_DEFAULT: vc->vc_def_color = vc->vc_attr; if (vc->vc_hi_font_mask == 0x100) vc->vc_def_color >>= 1; default_attr(vc); update_attr(vc); break; - case 9: /* set blanking interval */ + case CSI_RSB_BLANKING_INTERVAL: blankinterval = min(vc->vc_par[1], 60U) * 60; poke_blanked_console(); break; - case 10: /* set bell frequency in Hz */ + case CSI_RSB_BELL_FREQUENCY: if (vc->vc_npar >= 1) vc->vc_bell_pitch = vc->vc_par[1]; else vc->vc_bell_pitch = DEFAULT_BELL_PITCH; break; - case 11: /* set bell duration in msec */ + case CSI_RSB_BELL_DURATION: if (vc->vc_npar >= 1) vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? msecs_to_jiffies(vc->vc_par[1]) : 0; else vc->vc_bell_duration = DEFAULT_BELL_DURATION; break; - case 12: /* bring specified console to the front */ + case CSI_RSB_BRING_CONSOLE_TO_FRONT: if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) set_console(vc->vc_par[1] - 1); break; - case 13: /* unblank the screen */ + case CSI_RSB_UNBLANK: poke_blanked_console(); break; - case 14: /* set vesa powerdown interval */ + case CSI_RSB_VESA_OFF_INTERVAL: vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ; break; - case 15: /* activate the previous console */ + case CSI_RSB_BRING_PREV_CONSOLE_TO_FRONT: set_console(last_console); break; - case 16: /* set cursor blink duration in msec */ + case CSI_RSB_CURSOR_BLINK_INTERVAL: if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && vc->vc_par[1] <= USHRT_MAX) vc->vc_cur_blink_ms = vc->vc_par[1]; From patchwork Fri Feb 2 06:55:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770030 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 354EE18E17; Fri, 2 Feb 2024 06:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856984; cv=none; b=kl1b5gsuaeHqtwnu4x0AO2W7t8tdZvIypDyfr34j0zKnbw+MRP1H8ojEOHF1s8+oIRZ9mRvMr+va9qsDG9A4cRhbhfEr2waw6JAxCgjsDLcQWSelCL/fCIS8nrhaa6o2hkKDoVYra7N9OMb0tCEC2EOqIfobyjSU3SbLUmBdNW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856984; c=relaxed/simple; bh=A/DGpXBJR9ZPWHNz7cYQLXBrUjxv88QCU8EKOJUwuLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DxJG+2rMqj6nJ/oXF8qeF99caOxhe0F8c4y3MeaDzntWxj+b8g5QuGnQ+9wOyr40/oqOcDO1mwl5xsmN+WjEG5ijffavavF2CbzYmmciqIaOgmysRwerg941zNsbWMJfmIkIFONvPWY5Kvrq0wZAZVTvnl+DEZM5po3qA8wkcSY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kuJMc8b5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kuJMc8b5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3B1CC43394; Fri, 2 Feb 2024 06:56:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856984; bh=A/DGpXBJR9ZPWHNz7cYQLXBrUjxv88QCU8EKOJUwuLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kuJMc8b5oWti2uqzIM81eI6MSTQ4nWHHsfkub7U72acPXXmqg5CnmC+rzysD0LEnk MQpYZOJdKlIZVbNMXW1Wu5Ft/L+/JJ2oHFTV31rSKhM1iUDqBWrUgKs6Llyl3oxq4X Ri+I4cmSPZHKbQ2EmCOlXtiv4nxos0J1U+C+5Wfd6+23NixG2qzc24rmK4gCLH2L8Z CIW4AOOp5vSB6lMcR/NdG5xzj/JVHyHqKrozjNeFGZiISNBSCDdvgcXOV/WvYcbrrR PzM0V3OlOSoCIglvksdSrG89Ewz7+2XgIh0AHC9pH3xDzQkRDumTnQemEu61/zdsDk C42a/jjizuwQQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 08/22] tty: vt: rename setterm_command() to csi_RSB() Date: Fri, 2 Feb 2024 07:55:54 +0100 Message-ID: <20240202065608.14019-9-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It follows naming of other similar functions. RSB stands here for Right Square Bracket as (obviously) ']' cannot be in the function name. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 9db545f305dc..c072007807e1 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1969,8 +1969,14 @@ enum CSI_right_square_bracket { CSI_RSB_CURSOR_BLINK_INTERVAL = 16, }; -/* console_lock is held */ -static void setterm_command(struct vc_data *vc) +/* + * csi_RSB - csi+] (Right Square Bracket) handler + * + * These are linux console private sequences. + * + * console_lock is held + */ +static void csi_RSB(struct vc_data *vc) { switch (vc->vc_par[0]) { case CSI_RSB_COLOR_FOR_UNDERLINE: @@ -2549,8 +2555,8 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) case '@': csi_at(vc, vc->vc_par[0]); return; - case ']': /* setterm functions */ - setterm_command(vc); + case ']': + csi_RSB(vc); return; } return; From patchwork Fri Feb 2 06:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769439 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B5081AAD7; Fri, 2 Feb 2024 06:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856986; cv=none; b=U+fexmCs01GQu2CmG4jvNrq76Ch5WQIf3s8vSG0MDmZ3PHAsGA81Q5x9lDyUfWhWbIsKS4udn0TS/zJ05pzd1ZyFnKT9hRjDJj7bB8u9IctU84PejC2+vbII0qOJxuSChPy+wmrX8XxhEVrtcKwost7WEAb08Q0H7ucX/eUe8M0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856986; c=relaxed/simple; bh=k53CFJFMOZQDpOcxwZ7H0r8hlFfuSR0Pgv3cmw8obIM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LTHv36C795uX3gxPV3d+xwnGl9lBvl04RoMBLKX55rnDbtz4tGaOe1qw/UMNexLgBBH7BASZxc6bJAhPprX9umeIKeROnzBvoirS5SmcE3DAMm7mBQRAFkcfRJYktVHOZTkq4fqHcXklh/T1LysLS6dRkTPYyHrrchCUxBjRUOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jo2gf6ep; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jo2gf6ep" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A63EC43601; Fri, 2 Feb 2024 06:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856985; bh=k53CFJFMOZQDpOcxwZ7H0r8hlFfuSR0Pgv3cmw8obIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jo2gf6ep1g1L1uoWylXncKHKTwLanexUMlfY3+AlIwoZqrEz/pN5zORvJJe7ssrn3 2uaVFAbXJSht34Ho3DYxDgciSaPztclqo3+Xfez3pIVHjO6mBXjDY+lQHRoRZ23DoS Y/Bte72KDyBz7lBXDHP3ETGMlNDKxMVH6fhWnhtUa1T0ok6gcQuiBjK1zvgf9dEPrL zG0h/ScHc800hNOZ6DlbLGCUIg5L2U31339PA3MTDecfZJjy1ywIxpgINoGgxEeetY ZUXAlL5pNfD0ZheKPA8W//PCidyHAuPGd6xvVbQ/dqRvCOaYMVHyLskk7gQRDudzix 9PU3qZnvffTew== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 09/22] tty: vt: put cases on separate lines Date: Fri, 2 Feb 2024 07:55:55 +0100 Message-ID: <20240202065608.14019-10-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some cases of the CSI switch are stuffed on one line. Put them all to a separate line as is dictated by the coding style (and for better readability). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index c072007807e1..42bc0957a654 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2437,7 +2437,8 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) return; switch(c) { - case 'G': case '`': + case 'G': + case '`': if (vc->vc_par[0]) vc->vc_par[0]--; gotoxy(vc, vc->vc_par[0], vc->state.y); @@ -2447,12 +2448,14 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_par[0]++; gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); return; - case 'B': case 'e': + case 'B': + case 'e': if (!vc->vc_par[0]) vc->vc_par[0]++; gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); return; - case 'C': case 'a': + case 'C': + case 'a': if (!vc->vc_par[0]) vc->vc_par[0]++; gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); @@ -2477,7 +2480,8 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_par[0]--; gotoxay(vc, vc->state.x ,vc->vc_par[0]); return; - case 'H': case 'f': + case 'H': + case 'f': if (vc->vc_par[0]) vc->vc_par[0]--; if (vc->vc_par[1]) From patchwork Fri Feb 2 06:55:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770029 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94B41282E9; Fri, 2 Feb 2024 06:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856987; cv=none; b=bBkZiune8khOsk22QTEs0vRQJ+2zDbLwBVfb0iy8NASVVgDuuMUR2XWUkUijNSs122vJ94jmPknHwjDwFi1JqNtdqWBov6P0eG1JyxR+eCntOGpI/VK5WuNlTOZ6Aw6SHVFha5XF5OOwKA1rPtN1OZQGkv1AZY2qC5j4whb5Uj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856987; c=relaxed/simple; bh=UbOFvmxMCfDnw/gmoV7JLKUwxcacwjOcrfiF+WJiOpA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qh1Di9RA2MyL3HdpKZnCpRJryFI6HF4yoSvIUWeeiQKBoIvNik0k9aFzQI8RVbEtuRCDcaUNp4ikc1CvkRJOtq2Dqcm2Jcj3f1D9H6TSMR9lhnjFyf2Ee3s9aq6Cl6BA6uAqSz3dd3f4v4oJHCWwsoe6viUruRrUV0XC7JTzXrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u2Gxc7Vw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u2Gxc7Vw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 043D3C433C7; Fri, 2 Feb 2024 06:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856987; bh=UbOFvmxMCfDnw/gmoV7JLKUwxcacwjOcrfiF+WJiOpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u2Gxc7VwSJBG7CcwBfKs9oPAEVwykMwexruSoEhi8oUL0csvCt+2CF0WkHFYMaIWE X3PWCJKXlhMvIS2zvFaENLuA6DQ32HEeAjQr/j44j3egVRA490bidTep3YqB7d0M6d J80MmCN58phB0hL1EoULMno8ykxGoAwHCchWlHF7LnE2dN0qHfqhaYXaCqN34lnn9R Bjtsnw4FHQgoo/WqjqFSg7F8E8R4+4yTVMfUM1Q5MQq6/9rZ+3tsUNiVVPgCgPC0LR /D/kZehfDHaaZhZ7B7uktgYV0OeviVaQoM4ljNCDT0Fg3/tctWP23hdpLKox3eKYzx e4e7SQhG3fnUQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 10/22] tty: vt: accept u8 in do_con_trol() and vc_setGx() Date: Fri, 2 Feb 2024 07:55:56 +0100 Message-ID: <20240202065608.14019-11-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 These functions expect u8 as the control character. Switch the type from 'int' appropriately. The caller passing the value (do_con_write()) is fixed as well. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 42bc0957a654..451a852ed234 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2144,7 +2144,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear) csi_J(vc, CSI_J_VISIBLE); } -static void vc_setGx(struct vc_data *vc, unsigned int which, int c) +static void vc_setGx(struct vc_data *vc, unsigned int which, u8 c) { unsigned char *charset = &vc->state.Gx_charset[which]; @@ -2198,7 +2198,7 @@ enum { }; /* console_lock is held */ -static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) +static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) { /* * Control characters can be used in the _middle_ @@ -2963,7 +2963,7 @@ static int do_con_write(struct tty_struct *tty, const u8 *buf, int count) param.vc = vc; while (!tty->flow.stopped && count) { - int orig = *buf; + u8 orig = *buf; buf++; n++; count--; From patchwork Fri Feb 2 06:55:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769438 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20FC539AD5; Fri, 2 Feb 2024 06:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856989; cv=none; b=IRA3erbRAZX2XSvS+ngaKrdPLsFiwKH/ppiPEGzxWcRVe2AYoWd45+KMfxcgRh3hke1Lrez+rgBtvRBUiUQXENnrR8U5Zb6paIyWuUKkZDRirJUvsCsmegp9qirD/nUhKl2yXY6Lg2Qpo1+ZokF3cHrbCyguId6ulFl7Qmm2epI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856989; c=relaxed/simple; bh=jqH2OL/S99n3SsvoefaaNMtSDFKpEggQ4kdfbyZSD9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W2iZ9RbardKLoS6/npTHk5lkGoDOEwp7MHTXZQe0qoaVOXrA/wH/8w/nMbTG2tTLYCqY/61bi5zvk1ar/mxxmzaJG5/CF8eOykG5APyipTbN4sicOglmZBcIaV0ciLuRLI7vVIPEIAcbqDqpXS9Oj7dU5136IKo42SMfqPPUjW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cIadmm3N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cIadmm3N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EB43C433F1; Fri, 2 Feb 2024 06:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856988; bh=jqH2OL/S99n3SsvoefaaNMtSDFKpEggQ4kdfbyZSD9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cIadmm3N1wg15B4yH/C2pNXeJG3c/5pfwMefBRntw6Noq+gR75j7qUqafLLaBcqxX JmwfTIPPD5rTkCfngAwWDKaR1htYYgvz7QisqbrSPqY7iiWlosySh+SNbzHY3elMbh iWFlBe0m6E7MbuFtWi0wAsEqUYM0J1du3/RNb7w+gJpqeVR+q4KMX+IvvdowEUTGQL /zOQy8Rr/vM5JRJzYzID8iz7PxAhmcfrw1+frEIVB8tfpILGAbirZmawfONAPIjviP C0xTJ16GId0eFnxVfmyX6CsROsdseS9vOmS0kgz+NB/zSe+fQ5JI+1b5sUDA0vZ4D+ gLE69DNNJr4Dg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 11/22] tty: vt: extract ascii handling to handle_ascii() Date: Fri, 2 Feb 2024 07:55:57 +0100 Message-ID: <20240202065608.14019-12-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To make the do_con_trol() a bit more understandable, extract the ASCII handling (the switch-case) to a separate function. Other nested switch-cases will follow in the next patches. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 58 +++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 451a852ed234..7cda1a958c5e 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2197,28 +2197,26 @@ enum { ASCII_EXT_CSI = 128 + ASCII_ESCAPE, }; -/* console_lock is held */ -static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) +/* + * Handle ascii characters in control sequences and change states accordingly. + * E.g. ESC sets the state of vc to ESesc. + * + * Returns: true if @c handled. + */ +static bool handle_ascii(struct tty_struct *tty, struct vc_data *vc, u8 c) { - /* - * Control characters can be used in the _middle_ - * of an escape sequence, aside from ANSI control strings. - */ - if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST && - c <= ASCII_IGNORE_LAST) - return; switch (c) { case ASCII_NULL: - return; + return true; case ASCII_BELL: if (ansi_control_string(vc->vc_state)) vc->vc_state = ESnormal; else if (vc->vc_bell_duration) kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); - return; + return true; case ASCII_BACKSPACE: bs(vc); - return; + return true; case ASCII_HTAB: vc->vc_pos -= (vc->state.x << 1); @@ -2230,41 +2228,59 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) vc->vc_pos += (vc->state.x << 1); notify_write(vc, '\t'); - return; + return true; case ASCII_LINEFEED: case ASCII_VTAB: case ASCII_FORMFEED: lf(vc); if (!is_kbd(vc, lnm)) - return; + return true; fallthrough; case ASCII_CAR_RET: cr(vc); - return; + return true; case ASCII_SHIFTOUT: vc->state.charset = 1; vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc); vc->vc_disp_ctrl = 1; - return; + return true; case ASCII_SHIFTIN: vc->state.charset = 0; vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc); vc->vc_disp_ctrl = 0; - return; + return true; case ASCII_CANCEL: case ASCII_SUBSTITUTE: vc->vc_state = ESnormal; - return; + return true; case ASCII_ESCAPE: vc->vc_state = ESesc; - return; + return true; case ASCII_DEL: del(vc); - return; + return true; case ASCII_EXT_CSI: vc->vc_state = ESsquare; - return; + return true; } + + return false; +} + +/* console_lock is held */ +static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) +{ + /* + * Control characters can be used in the _middle_ + * of an escape sequence, aside from ANSI control strings. + */ + if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST && + c <= ASCII_IGNORE_LAST) + return; + + if (handle_ascii(tty, vc, c)) + return; + switch(vc->vc_state) { case ESesc: vc->vc_state = ESnormal; From patchwork Fri Feb 2 06:55:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770028 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A88353FB14; Fri, 2 Feb 2024 06:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856990; cv=none; b=rFcZ0fem9FpWC85WQjPnrYPY8bCNDTVTCxR9LYbMKpUr6g995lYB0B6jEPl7jJNpiRBcoVF26G7UXOSA81U+zdp/71WO+paKFYBwEhrqlb8aDRvDvnUKQyQvR3iCmrNqPCYiWKKKeJjSCCujqCur3QN1qTEokxULvlVdU6t54n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856990; c=relaxed/simple; bh=dwhJ8tMD7utmbBdUx26kvWGDI4UoU+Gd4+oVhddQzgU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O3O2oojnJ9h89H6YExhM1VSgHJybXxs9QJUbFbTjxTPpLI+nW24Ocb4tOorRDot/Ubyc3B2lAO6YOb3z8rVvAtXMFz9ok9zHsgapU2AtWiLB9LDloPBTvIjUof+3z9Wm1c6IXpJRluXya8kSA0GfSI0XcUtQQtpPD/WhpCUnT3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mmAdHWvh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mmAdHWvh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05814C43394; Fri, 2 Feb 2024 06:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856990; bh=dwhJ8tMD7utmbBdUx26kvWGDI4UoU+Gd4+oVhddQzgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mmAdHWvhdhtg/J5rP85q53ofa/qN9bxxDAO2wfkpsuY2rWfapAMMM7o7mj6bZ8f2l DOtQ7ozjMU7hkPT/nz4H2OpIB6zE8d604cgJIDyL3hVK9KPJXdrCeG+C+OUVWmIxUU t9emzr1wV5Qo+7DezY0b9Jzu2nR5xu0iHIw2Qgmvfkk4FTB10VdmeiDotVF11ZfPPW 5B/GTowEvG22ZXeu0NlWAhqrAlcKIT2OJkbucTXgbmhUp/hUMBbsNBGNMhLwhCasL2 a8ZkM0nCYVWho1EsJarmzx45NtRZLEVNsVaAxXoPxsn1V9FTOdW+1HYwetHuxZnxTG E7XN0m5o5rvzQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 12/22] tty: vt: separate ESesc state handling into handle_esc() Date: Fri, 2 Feb 2024 07:55:58 +0100 Message-ID: <20240202065608.14019-13-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similar to the ASCII handling, the ESC handling can be easily moved away from do_con_trol(). So create a new handle_esc() for that. And add a comment with an example. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 134 ++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 62 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 7cda1a958c5e..3dddb7128234 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2267,6 +2267,77 @@ static bool handle_ascii(struct tty_struct *tty, struct vc_data *vc, u8 c) return false; } +/* + * Handle a character (@c) following an ESC (when @vc is in the ESesc state). + * E.g. previous ESC with @c == '[' here yields the ESsquare state (that is: + * CSI). + */ +static void handle_esc(struct tty_struct *tty, struct vc_data *vc, u8 c) +{ + vc->vc_state = ESnormal; + switch (c) { + case '[': + vc->vc_state = ESsquare; + break; + case ']': + vc->vc_state = ESnonstd; + break; + case '_': + vc->vc_state = ESapc; + break; + case '^': + vc->vc_state = ESpm; + break; + case '%': + vc->vc_state = ESpercent; + break; + case 'E': + cr(vc); + lf(vc); + break; + case 'M': + ri(vc); + break; + case 'D': + lf(vc); + break; + case 'H': + if (vc->state.x < VC_TABSTOPS_COUNT) + set_bit(vc->state.x, vc->vc_tab_stop); + break; + case 'P': + vc->vc_state = ESdcs; + break; + case 'Z': + respond_ID(tty); + break; + case '7': + save_cur(vc); + break; + case '8': + restore_cur(vc); + break; + case '(': + vc->vc_state = ESsetG0; + break; + case ')': + vc->vc_state = ESsetG1; + break; + case '#': + vc->vc_state = EShash; + break; + case 'c': + reset_terminal(vc, 1); + break; + case '>': /* Numeric keypad */ + clr_kbd(vc, kbdapplic); + break; + case '=': /* Appl. keypad */ + set_kbd(vc, kbdapplic); + break; + } +} + /* console_lock is held */ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) { @@ -2283,68 +2354,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) switch(vc->vc_state) { case ESesc: - vc->vc_state = ESnormal; - switch (c) { - case '[': - vc->vc_state = ESsquare; - return; - case ']': - vc->vc_state = ESnonstd; - return; - case '_': - vc->vc_state = ESapc; - return; - case '^': - vc->vc_state = ESpm; - return; - case '%': - vc->vc_state = ESpercent; - return; - case 'E': - cr(vc); - lf(vc); - return; - case 'M': - ri(vc); - return; - case 'D': - lf(vc); - return; - case 'H': - if (vc->state.x < VC_TABSTOPS_COUNT) - set_bit(vc->state.x, vc->vc_tab_stop); - return; - case 'P': - vc->vc_state = ESdcs; - return; - case 'Z': - respond_ID(tty); - return; - case '7': - save_cur(vc); - return; - case '8': - restore_cur(vc); - return; - case '(': - vc->vc_state = ESsetG0; - return; - case ')': - vc->vc_state = ESsetG1; - return; - case '#': - vc->vc_state = EShash; - return; - case 'c': - reset_terminal(vc, 1); - return; - case '>': /* Numeric keypad */ - clr_kbd(vc, kbdapplic); - return; - case '=': /* Appl. keypad */ - set_kbd(vc, kbdapplic); - return; - } + handle_esc(tty, vc, c); return; case ESnonstd: if (c=='P') { /* palette escape sequence */ From patchwork Fri Feb 2 06:55:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769437 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 183463FE4C; Fri, 2 Feb 2024 06:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856992; cv=none; b=oAWns+lroTc0Mgws4sTBkCMFGamD3b3V2lQymG4eeTG/LNWifpD2yjC0WoPGdr6pFOJFCDH+0Ww8leO1R59fynrDHZYUOxc/+L1ENxpvZ9naEHWHHFCp1I3hourIDcL6t5npbJtLElo/gwFbBFDXH4zTJhIQq2iN/WsD7KyuWTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856992; c=relaxed/simple; bh=br4CsOaJKFLkacvMt7qXjCHOiPEn6HigxjiQN83xsF0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=enG7D1Nv64ycobO+lbn5a+IIijzxkmKJylyVoByWtHOaHi0OVW0YtDfih5fXdZDXlDy6fUN/dk5hw0WNMaIkG5LMxHLFPelIcjYM5EQJV2+zFLTVs6PQ5dTue5LJe35MrbbRQanXNOTlh8bZpCRT05YPsJjVTINNtoRkXApbPpY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=urSwzHRf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="urSwzHRf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80BE4C43390; Fri, 2 Feb 2024 06:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856991; bh=br4CsOaJKFLkacvMt7qXjCHOiPEn6HigxjiQN83xsF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=urSwzHRfIEtM0XBZoW/QWahm6rK6Hn3ao+LZHlj/vRBL/U7Q9LB7VwdhqSb67MFKP JlpWZOotYTnkksw5N7Ljn8jtD3NZEPas4l70p1Ez6ws3BzEFgrR72Y2kiyqB57yaRy 4yC8wl2lq22i1QHYWK0u3D5GOJf/k417q+Llsyf4k9gvk4iQnsjB8G22LHjPqSJvM9 nNk29F74unFLIIcBZQd8WYAuComGFr0btphRO2T5lxH7hTY4GLFbZddfPNemT202US 2Y5qOI9poA9ur8Aa10r+JzaQlnwLiz8F0llwfF+lAUekc8XFtb8kTMc9SrFE3Sw7L5 fNNoMabJQ9ofA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 13/22] tty: vt: move CSI DEC handling to a separate function Date: Fri, 2 Feb 2024 07:55:59 +0100 Message-ID: <20240202065608.14019-14-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The handling of "CSI ? ..." (i.e. vc_priv == EPdec) can be easily moved out of do_con_trol() into a separate function. This again increases readability of do_con_trol(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 75 ++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 3dddb7128234..7cdd0eb1e423 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2338,6 +2338,43 @@ static void handle_esc(struct tty_struct *tty, struct vc_data *vc, u8 c) } } +/* + * Handle special DEC control sequences ("ESC [ ? parameters char"). Parameters + * are in @vc->vc_par and the char is in @c here. + */ +static void csi_DEC(struct tty_struct *tty, struct vc_data *vc, u8 c) +{ + switch (c) { + case 'h': + csi_DEC_hl(vc, true); + break; + case 'l': + csi_DEC_hl(vc, false); + break; + case 'c': + if (vc->vc_par[0]) + vc->vc_cursor_type = CUR_MAKE(vc->vc_par[0], + vc->vc_par[1], + vc->vc_par[2]); + else + vc->vc_cursor_type = cur_default; + break; + case 'm': + clear_selection(); + if (vc->vc_par[0]) + vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; + else + vc->vc_complement_mask = vc->vc_s_complement_mask; + break; + case 'n': + if (vc->vc_par[0] == 5) + status_report(tty); + else if (vc->vc_par[0] == 6) + cursor_report(vc, tty); + break; + } +} + /* console_lock is held */ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) { @@ -2427,40 +2464,16 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) return; } vc->vc_state = ESnormal; - switch(c) { - case 'h': - if (vc->vc_priv == EPdec) - csi_DEC_hl(vc, true); - return; - case 'l': - if (vc->vc_priv == EPdec) - csi_DEC_hl(vc, false); + + switch (vc->vc_priv) { + case EPdec: + csi_DEC(tty, vc, c); return; - case 'c': - if (vc->vc_priv == EPdec) { - if (vc->vc_par[0]) - vc->vc_cursor_type = - CUR_MAKE(vc->vc_par[0], - vc->vc_par[1], - vc->vc_par[2]); - else - vc->vc_cursor_type = cur_default; - return; - } + case EPecma: break; - case 'm': - if (vc->vc_priv == EPdec) { - clear_selection(); - if (vc->vc_par[0]) - vc->vc_complement_mask = vc->vc_par[0] << 8 | vc->vc_par[1]; - else - vc->vc_complement_mask = vc->vc_s_complement_mask; - return; - } - break; - } - if (vc->vc_priv != EPecma) + default: return; + } switch(c) { case 'G': From patchwork Fri Feb 2 06:56:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770027 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7769342A8C; Fri, 2 Feb 2024 06:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856993; cv=none; b=EMjy/K6BU+4ySmZL564kcr7nW1gpGZQqTtGWF5OIyn+8mwOoRI9iYOMWhTlMPYJ2u5H79I369WDQdzru+JtflzLQPmaSds95qwCgZGUVNWSW9eE9XhCvQc4cckjVnKxVT3luLz0ohQZhGYQGPp5QJmmgmewnj7DWVISjUSnvyUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856993; c=relaxed/simple; bh=2KcL2ijyRKHlKaD+KC9TeZ0POGrQVYsHbeWSN8pgPQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Am2AyS4mE8KaBdc5SC7FC2AS/ERqv551FZglKxBhWG4CSp/27v11Idik/Au6Pyhu3FWKTu6Z0vGDJNgdFJ2hG+PRmIYQQxGYS5k3ruFwB9e0AWViC0OOPuzKHbsA2FSKp9GetOpZkm/rRO7gbN+GUg69sTvP8LpNBQfiJn3Rq2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tWApjrEh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tWApjrEh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0772CC433F1; Fri, 2 Feb 2024 06:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856993; bh=2KcL2ijyRKHlKaD+KC9TeZ0POGrQVYsHbeWSN8pgPQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tWApjrEhNdAFoMhUQ5jOlLTZ8nZVO9Hnwzqy/IQfCJ+ZJvbHHypYV67Q9q5KS20PL XcmGX1GFlKt7VsJCVjgW5S4lLSZWIGhz+Bn3j9U5WwJMqRU9kNZuJd6PgBzkHU9SiU Gh+FS+BO5iOuP5Oz9tCOa/SBVkIfau2NCLpGi5YNh3KsY5okVcEv0n/dWoLFdh13JU MvT/nDLGUOrm5VjuyE8MZgRvCj3TtFQ5UQOyIVQrHAcZz7letqa2cqG0iss7xZWnL7 sNzMPybXhLrqVrgCQWS2J5pjtsSEsR6rqSETPrmhYhrheE++c4e4FC9SetN1YuR4gj 4K7sksHHxAffg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 14/22] tty: vt: move CSI ECMA handling to a separate function Date: Fri, 2 Feb 2024 07:56:00 +0100 Message-ID: <20240202065608.14019-15-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similar to previous moves, move also "CSI ..." (i.e. vc_priv == EPecma) handling to a separate function. This is the last large move of code out of do_con_trol(). And despite it is still 151 lines of code (down from 407!), it is now quite easy to folllow the transitions of the state machine in there. ESnonstd and ESpalette handling still can be moved away, but it won't improve that much. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 269 +++++++++++++++++++++++--------------------- 1 file changed, 139 insertions(+), 130 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 7cdd0eb1e423..1c832d04c0dc 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2375,6 +2375,143 @@ static void csi_DEC(struct tty_struct *tty, struct vc_data *vc, u8 c) } } +/* + * Handle Control Sequence Introducer control characters. That is + * "ESC [ parameters char". Parameters are in @vc->vc_par and the char is in + * @c here. + */ +static void csi_ECMA(struct tty_struct *tty, struct vc_data *vc, u8 c) +{ + switch (c) { + case 'G': + case '`': + if (vc->vc_par[0]) + vc->vc_par[0]--; + gotoxy(vc, vc->vc_par[0], vc->state.y); + break; + case 'A': + if (!vc->vc_par[0]) + vc->vc_par[0]++; + gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); + break; + case 'B': + case 'e': + if (!vc->vc_par[0]) + vc->vc_par[0]++; + gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); + break; + case 'C': + case 'a': + if (!vc->vc_par[0]) + vc->vc_par[0]++; + gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); + break; + case 'D': + if (!vc->vc_par[0]) + vc->vc_par[0]++; + gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y); + break; + case 'E': + if (!vc->vc_par[0]) + vc->vc_par[0]++; + gotoxy(vc, 0, vc->state.y + vc->vc_par[0]); + break; + case 'F': + if (!vc->vc_par[0]) + vc->vc_par[0]++; + gotoxy(vc, 0, vc->state.y - vc->vc_par[0]); + break; + case 'd': + if (vc->vc_par[0]) + vc->vc_par[0]--; + gotoxay(vc, vc->state.x ,vc->vc_par[0]); + break; + case 'H': + case 'f': + if (vc->vc_par[0]) + vc->vc_par[0]--; + if (vc->vc_par[1]) + vc->vc_par[1]--; + gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); + break; + case 'J': + csi_J(vc, vc->vc_par[0]); + break; + case 'K': + csi_K(vc); + break; + case 'L': + csi_L(vc); + break; + case 'M': + csi_M(vc); + break; + case 'P': + csi_P(vc); + break; + case 'c': + if (!vc->vc_par[0]) + respond_ID(tty); + break; + case 'g': + if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT) + set_bit(vc->state.x, vc->vc_tab_stop); + else if (vc->vc_par[0] == 3) + bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); + break; + case 'h': + csi_hl(vc, true); + break; + case 'l': + csi_hl(vc, false); + break; + case 'm': + csi_m(vc); + break; + case 'n': + if (vc->vc_par[0] == 5) + status_report(tty); + else if (vc->vc_par[0] == 6) + cursor_report(vc, tty); + break; + case 'q': /* DECLL - but only 3 leds */ + /* map 0,1,2,3 to 0,1,2,4 */ + if (vc->vc_par[0] < 4) + vt_set_led_state(vc->vc_num, + (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); + break; + case 'r': + if (!vc->vc_par[0]) + vc->vc_par[0]++; + if (!vc->vc_par[1]) + vc->vc_par[1] = vc->vc_rows; + /* Minimum allowed region is 2 lines */ + if (vc->vc_par[0] < vc->vc_par[1] && + vc->vc_par[1] <= vc->vc_rows) { + vc->vc_top = vc->vc_par[0] - 1; + vc->vc_bottom = vc->vc_par[1]; + gotoxay(vc, 0, 0); + } + break; + case 's': + save_cur(vc); + break; + case 'u': + restore_cur(vc); + break; + case 'X': + csi_X(vc); + break; + case '@': + csi_at(vc, vc->vc_par[0]); + break; + case ']': + csi_RSB(vc); + break; + } + +} + /* console_lock is held */ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) { @@ -2470,139 +2607,11 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) csi_DEC(tty, vc, c); return; case EPecma: - break; - default: - return; - } - - switch(c) { - case 'G': - case '`': - if (vc->vc_par[0]) - vc->vc_par[0]--; - gotoxy(vc, vc->vc_par[0], vc->state.y); - return; - case 'A': - if (!vc->vc_par[0]) - vc->vc_par[0]++; - gotoxy(vc, vc->state.x, vc->state.y - vc->vc_par[0]); - return; - case 'B': - case 'e': - if (!vc->vc_par[0]) - vc->vc_par[0]++; - gotoxy(vc, vc->state.x, vc->state.y + vc->vc_par[0]); - return; - case 'C': - case 'a': - if (!vc->vc_par[0]) - vc->vc_par[0]++; - gotoxy(vc, vc->state.x + vc->vc_par[0], vc->state.y); - return; - case 'D': - if (!vc->vc_par[0]) - vc->vc_par[0]++; - gotoxy(vc, vc->state.x - vc->vc_par[0], vc->state.y); - return; - case 'E': - if (!vc->vc_par[0]) - vc->vc_par[0]++; - gotoxy(vc, 0, vc->state.y + vc->vc_par[0]); + csi_ECMA(tty, vc, c); return; - case 'F': - if (!vc->vc_par[0]) - vc->vc_par[0]++; - gotoxy(vc, 0, vc->state.y - vc->vc_par[0]); - return; - case 'd': - if (vc->vc_par[0]) - vc->vc_par[0]--; - gotoxay(vc, vc->state.x ,vc->vc_par[0]); - return; - case 'H': - case 'f': - if (vc->vc_par[0]) - vc->vc_par[0]--; - if (vc->vc_par[1]) - vc->vc_par[1]--; - gotoxay(vc, vc->vc_par[1], vc->vc_par[0]); - return; - case 'J': - csi_J(vc, vc->vc_par[0]); - return; - case 'K': - csi_K(vc); - return; - case 'L': - csi_L(vc); - return; - case 'M': - csi_M(vc); - return; - case 'P': - csi_P(vc); - return; - case 'c': - if (!vc->vc_par[0]) - respond_ID(tty); - return; - case 'g': - if (!vc->vc_par[0] && vc->state.x < VC_TABSTOPS_COUNT) - set_bit(vc->state.x, vc->vc_tab_stop); - else if (vc->vc_par[0] == 3) - bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); - return; - case 'h': - csi_hl(vc, true); - return; - case 'l': - csi_hl(vc, false); - return; - case 'm': - csi_m(vc); - return; - case 'n': - if (vc->vc_par[0] == 5) - status_report(tty); - else if (vc->vc_par[0] == 6) - cursor_report(vc, tty); - return; - case 'q': /* DECLL - but only 3 leds */ - /* map 0,1,2,3 to 0,1,2,4 */ - if (vc->vc_par[0] < 4) - vt_set_led_state(vc->vc_num, - (vc->vc_par[0] < 3) ? vc->vc_par[0] : 4); - return; - case 'r': - if (!vc->vc_par[0]) - vc->vc_par[0]++; - if (!vc->vc_par[1]) - vc->vc_par[1] = vc->vc_rows; - /* Minimum allowed region is 2 lines */ - if (vc->vc_par[0] < vc->vc_par[1] && - vc->vc_par[1] <= vc->vc_rows) { - vc->vc_top = vc->vc_par[0] - 1; - vc->vc_bottom = vc->vc_par[1]; - gotoxay(vc, 0, 0); - } - return; - case 's': - save_cur(vc); - return; - case 'u': - restore_cur(vc); - return; - case 'X': - csi_X(vc); - return; - case '@': - csi_at(vc, vc->vc_par[0]); - return; - case ']': - csi_RSB(vc); + default: return; } - return; case EScsiignore: if (c >= ASCII_CSI_IGNORE_FIRST && c <= ASCII_CSI_IGNORE_LAST) return; From patchwork Fri Feb 2 06:56:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769436 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B849C47F52; Fri, 2 Feb 2024 06:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856994; cv=none; b=Odlp6DGbVnwIfHRhqrSosQ3fTBdMfNRgpJaEduzt0kUjN6vjIaTtcI8WwlPsxAfh/u6hLMOgdRQyl5ItBb6G4tOVbiZuqQ7vypFqHmEb2kYI45hTs41EW55vqbqUjbyOTgAdQIof6aHDlaxApFkicCsa0l9VrAkZmwRJTJbuWV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856994; c=relaxed/simple; bh=0GUh1LaUgkZ77YCZj6fr2MXPqpNXX+mysOC2Cm9UfMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IP+mJK3JHvVHno7Z10FNNGRBYPklhBPLjQURxs+X009VQszZF831s7GMtcQIPmcqg888oWlvqzgADEVEhuwYotwu02JzgabOMJN9sIJX4tq+H8kXFSwU9RM0A6spBgqKA6xOfdJpoqAPV2plcUO+f5NznI5KJMRlsq2VF0/G5qM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C67wQcD3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C67wQcD3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82468C43390; Fri, 2 Feb 2024 06:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856994; bh=0GUh1LaUgkZ77YCZj6fr2MXPqpNXX+mysOC2Cm9UfMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C67wQcD3tTtHSj1IE0ZwxgJ3G+xAwGt3zmD19kECsceqpUtYDDPTYZDiHJ2hYTJSb 50bgErCPc9aKBxLPuzz4NFcEKjPTkcqdGUFi8lIoePVh65km7SE5hnPS0MLC/q943h 31VctLSPyF5rhEWPFoAu2oAhO1qC6TmD1ADeWDx95QW0epS186MudRCdT7O2h5Ao8q uqdlbfmnQ0vDxhd185jQPSyGbaEUeJ/uw62KekPiviNYTLWFOYMqgTP/S5Wjb+sT4Z 8Bb+9Fyv/CbPNWnDJCPQUEuZIxmBaIousgOWjTyVgMwnGeSSpiyAk4xCsTBJOeLkWU FW7ckznyZq4Sw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 15/22] tty: vt: name, reflow and document enum vc_ctl_state Date: Fri, 2 Feb 2024 07:56:01 +0100 Message-ID: <20240202065608.14019-16-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The enum for states is currently compact and undocumented. Put each definition on a separate line and document them all using kernel-doc. Document the same on the use sites. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 72 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 1c832d04c0dc..6d08290fdfdf 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2091,9 +2091,44 @@ static void restore_cur(struct vc_data *vc) vc->vc_need_wrap = 0; } -enum { ESnormal, ESesc, ESsquare, ESgetpars, ESfunckey, - EShash, ESsetG0, ESsetG1, ESpercent, EScsiignore, ESnonstd, - ESpalette, ESosc, ESapc, ESpm, ESdcs }; +/** + * enum vc_ctl_state - control characters state of a vt + * + * @ESnormal: initial state, no control characters parsed + * @ESesc: ESC parsed + * @ESsquare: CSI parsed -- modifiers/parameters/ctrl chars expected + * @ESgetpars: CSI parsed -- parameters/ctrl chars expected + * @ESfunckey: CSI [ parsed + * @EShash: ESC # parsed + * @ESsetG0: ESC ( parsed + * @ESsetG1: ESC ) parsed + * @ESpercent: ESC % parsed + * @EScsiignore: CSI [0x20-0x3f] parsed + * @ESnonstd: OSC parsed + * @ESpalette: OSC P parsed + * @ESosc: OSC [0-9] parsed + * @ESapc: ESC _ parsed + * @ESpm: ESC ^ parsed + * @ESdcs: ESC P parsed + */ +enum vc_ctl_state { + ESnormal, + ESesc, + ESsquare, + ESgetpars, + ESfunckey, + EShash, + ESsetG0, + ESsetG1, + ESpercent, + EScsiignore, + ESnonstd, + ESpalette, + ESosc, + ESapc, + ESpm, + ESdcs, +}; /* console_lock is held (except via vc_init()) */ static void reset_terminal(struct vc_data *vc, int do_clear) @@ -2527,10 +2562,10 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) return; switch(vc->vc_state) { - case ESesc: + case ESesc: /* ESC */ handle_esc(tty, vc, c); return; - case ESnonstd: + case ESnonstd: /* ESC ] aka OSC */ if (c=='P') { /* palette escape sequence */ for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) vc->vc_par[vc->vc_npar] = 0; @@ -2545,7 +2580,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) else vc->vc_state = ESnormal; return; - case ESpalette: + case ESpalette: /* ESC ] P aka OSC P */ if (isxdigit(c)) { vc->vc_par[vc->vc_npar++] = hex_to_bin(c); if (vc->vc_npar == 7) { @@ -2562,7 +2597,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) } else vc->vc_state = ESnormal; return; - case ESsquare: + case ESsquare: /* ESC [ aka CSI, parameters or modifiers expected */ for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) vc->vc_par[vc->vc_npar] = 0; vc->vc_npar = 0; @@ -2587,7 +2622,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) } vc->vc_priv = EPecma; fallthrough; - case ESgetpars: + case ESgetpars: /* ESC [ aka CSI, parameters expected */ if (c == ';' && vc->vc_npar < NPAR - 1) { vc->vc_npar++; return; @@ -2600,6 +2635,9 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) vc->vc_state = EScsiignore; return; } + + /* parameters done, handle the control char @c */ + vc->vc_state = ESnormal; switch (vc->vc_priv) { @@ -2617,7 +2655,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) return; vc->vc_state = ESnormal; return; - case ESpercent: + case ESpercent: /* ESC % */ vc->vc_state = ESnormal; switch (c) { case '@': /* defined in ISO 2022 */ @@ -2629,10 +2667,10 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) return; } return; - case ESfunckey: + case ESfunckey: /* ESC [ [ aka CSI [ */ vc->vc_state = ESnormal; return; - case EShash: + case EShash: /* ESC # */ vc->vc_state = ESnormal; if (c == '8') { /* DEC screen alignment test. kludge :-) */ @@ -2644,21 +2682,21 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2); } return; - case ESsetG0: + case ESsetG0: /* ESC ( */ vc_setGx(vc, 0, c); vc->vc_state = ESnormal; return; - case ESsetG1: + case ESsetG1: /* ESC ) */ vc_setGx(vc, 1, c); vc->vc_state = ESnormal; return; - case ESapc: + case ESapc: /* ESC _ */ return; - case ESosc: + case ESosc: /* ESC ] [0-9] aka OSC [0-9] */ return; - case ESpm: + case ESpm: /* ESC ^ */ return; - case ESdcs: + case ESdcs: /* ESC P */ return; default: vc->vc_state = ESnormal; From patchwork Fri Feb 2 06:56:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40CD3481A5; Fri, 2 Feb 2024 06:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856996; cv=none; b=KC9G1gLYYyIBzAt371rrHntkzQfkHhXvufHo2Glg4gzOOTg1wbIdQfquTg3dbF688ysdDQ1+ZnMyY9TibCXfLHgnlNOyiAJBfnmt71X+p2Exbmt9t99tCoOo6lR2GJWJml0ccV7qesuN+Qg/Ca6wLX1vgD8LVaJ6tRvWOBUZWxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856996; c=relaxed/simple; bh=jceecDRmdMOBljAQEyGtk+60sTp3SXvkt+2y39jsxjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z+X5f4uwxLneDcvxYHnstEWAnh/L4bI9lqpo7kXWVZuoLf+RG/CCfYJPgePNyozKsJ1RkHQWnYZOaDMLdGoZMB2oDGWbFCohEgkE9H+7Zs1SfL35TuW3RPSP5ijgxbrSyfMw/RNPR5lF4LevoM4nl8avlxWi3tgDrchlhVBO/xg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ajng1D+q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ajng1D+q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 091F4C43394; Fri, 2 Feb 2024 06:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856996; bh=jceecDRmdMOBljAQEyGtk+60sTp3SXvkt+2y39jsxjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajng1D+qyLcEo3NKj2TKAFekEQK4OpTjcATlGAi0UzAzndbu42IXqlyD9TSS/lS/g 5zCrj6DZmV30SnJp2o3z0//gq1U600DsBmfu4uPpdRjXbOJ/D8eAT8WYQkfFYX+lsV eP1KsbWgZ5aOXxQTi/UQhWbnAkam1yVy29rjQqlt2IkuutOLnNlwRA9sWy3TsDvlUa UdlqV4kKirAILgxYbKCSsw9H6aSM+ZcmAAxXHGBrVg0uVRP/nptJPXmneHq95BN33v 1oHUHLWvDekjHvWxgdRGPxpwVriFdzUA79uPCZ/znwPz7hL0GLxBQy05rGwUCfQs45 FQxiNu6/KLH8w== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 16/22] tty: vt: simplify ansi_control_string() Date: Fri, 2 Feb 2024 07:56:02 +0100 Message-ID: <20240202065608.14019-17-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Given all the ANSI control states are sequential in the vc_ctl_state enum, we can define first/last constants and use them in ansi_control_string(). It makes the test simple and allows for removal of the 'if' (which was unnecessary at all -- the 'return' should have returned the 'if' content directly anyway). And remove the useless comment -- it's clear from the function prototype. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 6d08290fdfdf..e1cbe966bc84 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2107,9 +2107,11 @@ static void restore_cur(struct vc_data *vc) * @ESnonstd: OSC parsed * @ESpalette: OSC P parsed * @ESosc: OSC [0-9] parsed + * @ESANSI_first: first state for ignoring ansi control sequences * @ESapc: ESC _ parsed * @ESpm: ESC ^ parsed * @ESdcs: ESC P parsed + * @ESANSI_last: last state for ignoring ansi control sequences */ enum vc_ctl_state { ESnormal, @@ -2125,9 +2127,11 @@ enum vc_ctl_state { ESnonstd, ESpalette, ESosc, + ESANSI_first = ESosc, ESapc, ESpm, ESdcs, + ESANSI_last = ESdcs, }; /* console_lock is held (except via vc_init()) */ @@ -2202,12 +2206,9 @@ static void vc_setGx(struct vc_data *vc, unsigned int which, u8 c) vc->vc_translate = set_translate(*charset, vc); } -/* is this state an ANSI control string? */ -static bool ansi_control_string(unsigned int state) +static bool ansi_control_string(enum vc_ctl_state state) { - if (state == ESosc || state == ESapc || state == ESpm || state == ESdcs) - return true; - return false; + return state >= ESANSI_first && state <= ESANSI_last; } enum { From patchwork Fri Feb 2 06:56:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769435 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D92A482CA; Fri, 2 Feb 2024 06:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856998; cv=none; b=t8CMOHToJNj10I7fLFUHSuhnPsMAp97DLlL31F0Ln3AQmGkyMIgzgFRGlG23/JeqzH50+BFcmyFOD+bSKG53lKSIRE8otsSObQn3AGoJ2aLwq7ZPgmrpSOxWbPQDaqyuxdWD+dn6nBMg6FOsoG+tGbjEjEwTE/IPVj+GENvci+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856998; c=relaxed/simple; bh=6UXhr7Um6o27JtU1FYPkbandRU53JbY5Vx7820lgPtw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Iap8SAcHBlz4+r1pKA4pAMy5n8//SI2moQgttmFAAb2q9XuOQVBO19I7KL72Jb1VXbbpeIEUX53idGQ/OmtXL9QjNoW5pmjHfUjhmtst2AisaAfYcngGHJb1bDEqVYlEfT43bLKep58kEJLPBVRunSa53NgjFL2nuXk5Vx5zihs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VNcB9rBM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VNcB9rBM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84317C433C7; Fri, 2 Feb 2024 06:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856997; bh=6UXhr7Um6o27JtU1FYPkbandRU53JbY5Vx7820lgPtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VNcB9rBMdt2/bzWjEIv48297aN92UMaLGhsgrEldMtKrkB6v9X6dJYFgsKHT1ZQjC H6STC1iuvWrOxp0oc/AGH8j9HXJ4yKl5+5XusRZMwsaWxqs6gAVaQjh0rJx/fWLVo0 g6Nrxe/cFIaXjdpJy7ugxJRu+JFBOYpzp9VHUwl20dR8jYexv3PzFX7BbFGQDMQZFw UmyG2kMQv0myvrVaqLheIQb7T7rhvd0PHZH9k9DI/FqSAy6VBHqmasRlbKEofm6Xxc 2FGyIh3pYQoLqauteqk/HyN+qhkhcPzklQxcaR/0rCwPmV7DOSxamr14a4o6wdBPmj PrVOdWqL++xjw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 17/22] tty: vt: handle CSI+[ inside preexisting switch-case Date: Fri, 2 Feb 2024 07:56:03 +0100 Message-ID: <20240202065608.14019-18-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In do_con_trol()'s ESsquare case, there is already a switch (c). It is preceded by an 'if (c == '[')'. Despite this 'if' handles a state transition and not a modifier, move it as one of the switch cases. This makes all the 'c' decision making more obvious there. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index e1cbe966bc84..4d020a9967a2 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2603,11 +2603,10 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) vc->vc_par[vc->vc_npar] = 0; vc->vc_npar = 0; vc->vc_state = ESgetpars; - if (c == '[') { /* Function key */ - vc->vc_state=ESfunckey; - return; - } switch (c) { + case '[': /* Function key */ + vc->vc_state = ESfunckey; + return; case '?': vc->vc_priv = EPdec; return; From patchwork Fri Feb 2 06:56:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90452482F1; Fri, 2 Feb 2024 06:56:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856999; cv=none; b=CGBZ9vZTznceiWvlFmtsEVy0/523lTTPGWZ03L7+Dg7YySkGqmeiDby7DQdbISRD2zn5b5GHMt8zHBFEi1xmDCqyvfdP1Knjw8C06WvOFXmWV1ceNu0mtX7enjeBm6cMgk70N/l4Mulo+6tjFqKDoBEyU77BWMFUKVK1obn5OW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856999; c=relaxed/simple; bh=f1BOAc650vN/wZSXPoFGQMv1ubutbNRxF0vqxh4BsrY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NwIvAXxzvUKfL+GCv3Jbo5UdllMYHlUb+S5qTaZ0zUV+74RIshmL/05BTMuKJf5XBKlK3vO2r9ry1/o6oIrWTpO4Bimumk45OVKvudU82fMI6aCOwFZUQPHW2j4E5Ptk1Vc3U67F4MhrCAVGNdBOQw3jqBsjgCc++xCqDsxmZEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M7ZxXwSn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M7ZxXwSn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A8FEC433F1; Fri, 2 Feb 2024 06:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856999; bh=f1BOAc650vN/wZSXPoFGQMv1ubutbNRxF0vqxh4BsrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7ZxXwSn6t/o6IcTt2O/lgEkqG7p8eTQGR3uTgShc3uXD8hdci7keg1scFmervl94 YIou5trwftdSLC09lwe7zetKNMl88kCLhSq+P0LHcNlk2UVvo6ijc9FjV5600gGeN+ yPtt0deFW8xHdOnW0rdjRdtNQTx5nAoiaL6hbOAZa0f2cadjhoHyN25dDFOVo2fwRV 5aCb8X+3cQLKm2wBbxcc5nAge1//xdMkWpLCVMN2cL5hQI7J5+b/kdriNV0p9a8NWH pXu/NadI9jdJu2TYFuDRZBx5ARaGqVfU4c2saN1PlO54SLZjvgWGb8hQuEH7pEjtEN A8gtvYRMubGnw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 18/22] tty: vt: add new helper for reseting vc parameters Date: Fri, 2 Feb 2024 07:56:04 +0100 Message-ID: <20240202065608.14019-19-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The code to reset the vc parameter parsing is repeated on two locations. Create a helper vc_reset_params() and use it on both of them. And instead of a 'for' loop to clear the array of parameters, use simpler memset(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 4d020a9967a2..b0f691d79bf2 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2548,6 +2548,12 @@ static void csi_ECMA(struct tty_struct *tty, struct vc_data *vc, u8 c) } +static void vc_reset_params(struct vc_data *vc) +{ + memset(vc->vc_par, 0, sizeof(vc->vc_par)); + vc->vc_npar = 0; +} + /* console_lock is held */ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) { @@ -2568,9 +2574,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) return; case ESnonstd: /* ESC ] aka OSC */ if (c=='P') { /* palette escape sequence */ - for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) - vc->vc_par[vc->vc_npar] = 0; - vc->vc_npar = 0; + vc_reset_params(vc); vc->vc_state = ESpalette; return; } else if (c=='R') { /* reset palette */ @@ -2599,9 +2603,8 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) vc->vc_state = ESnormal; return; case ESsquare: /* ESC [ aka CSI, parameters or modifiers expected */ - for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) - vc->vc_par[vc->vc_npar] = 0; - vc->vc_npar = 0; + vc_reset_params(vc); + vc->vc_state = ESgetpars; switch (c) { case '[': /* Function key */ From patchwork Fri Feb 2 06:56:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769434 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B46648786; Fri, 2 Feb 2024 06:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857001; cv=none; b=h3/t6YrOXdTmKsh0gfeSFo0QSGIUuDCu4crCwE7PhPktZzpaZ5M4HZT7QUIfENS3GT1T5XkcYaRbxleIbN6toh/oX+bJ2HqxX2kcWW+z2T3rZzrcYS3RMBcr3uTxCAlmI/dGfqsjTLUjRbskmz289pr1fw2834iI4qcM4sYshpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857001; c=relaxed/simple; bh=mf+XMWdb5Ui9tDRVo2+XaapMqsHlRKk1tHRmQX2ocSo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YQB4POLZ9RW7FcHmDCT62bl6SKU2eSKg4O0WjZD19OSMw16o0fQdbSepNEH9UkyCFB7Kya6hCaGB5Kl1lW7KxgbB75xDhI0F7p1i8DV6pFXGeDw46yEHzpIMXiMpAhP9aft0QHIjixn01W1LeNHsR6Broypzf9YqMw06HoU07I0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TVOV5o6e; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TVOV5o6e" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8527FC43394; Fri, 2 Feb 2024 06:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706857000; bh=mf+XMWdb5Ui9tDRVo2+XaapMqsHlRKk1tHRmQX2ocSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TVOV5o6eQDLO0488ndhuhsueCU9dSmu6C5xnRf6KoiZ/8LUZliej2Fs40OdDw6D5p sFELmt9JluCw7J80k9UFEMrXceGL5hiT+oYe9CXM+DcwoqUU1UQP/Rls4NFFuYiuEO gh+S+jW5cCV1omOp3nh6CCoiufeLkpy5kUteiaiZ3T4Wqnx/aLcFVupFscE1vF4CUN OkT+9Z6li+wPXrr1RMr/7HZNfaDZdVLOwqHb99hLNgknZ1edOCrp82Wd6rjMuhDPyY dId9iToeILBXPe1UhXgrB5ed3v1ypzMOdjq2Jns1GFtzDIyrhkB1pqXLAU2k+cPY4/ MaNvlbXxXZksA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 19/22] tty: vt: use switch+case in the ESnonstd case Date: Fri, 2 Feb 2024 07:56:05 +0100 Message-ID: <20240202065608.14019-20-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To be uniform in the 'c' handling, use switch-case (with ranges) even in the ESnonstd case in do_con_trol(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index b0f691d79bf2..b5fc3b896e26 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2573,17 +2573,19 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) handle_esc(tty, vc, c); return; case ESnonstd: /* ESC ] aka OSC */ - if (c=='P') { /* palette escape sequence */ + switch (c) { + case 'P': /* palette escape sequence */ vc_reset_params(vc); vc->vc_state = ESpalette; return; - } else if (c=='R') { /* reset palette */ + case 'R': /* reset palette */ reset_palette(vc); - vc->vc_state = ESnormal; - } else if (c>='0' && c<='9') + break; + case '0' ... '9': vc->vc_state = ESosc; - else - vc->vc_state = ESnormal; + return; + } + vc->vc_state = ESnormal; return; case ESpalette: /* ESC ] P aka OSC P */ if (isxdigit(c)) { From patchwork Fri Feb 2 06:56:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 770024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95AEF487A3; Fri, 2 Feb 2024 06:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857002; cv=none; b=KbIZaseLzQQgJCv9/qQXkqvqfnXixjIe+ZOCq9WJhSaRgnJOHiu+UE07cKuiWzm0PwGn/ITcf5DO6hEUCfNbh1rtcLAQs6gIgymxHSMxbIyZXcwXX1wfSKdb4eD8+t0PEPxU3gNmbZDRm7PhhUxBmfmFnaeJFeoljGKqYmoLOSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857002; c=relaxed/simple; bh=nkWkHSb0yfwwGbw4xRVlBM1cIu2gl8Yeewy4ovMPibY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tVt6+wmq0xelnKdi89uzNKmZ7LRy1NU4mUpXqaWok8SB36M9aX3qDG91EJ+j6t/2UlMQ851oy5YXyZMqoKo06rZbPUdaPF5VkVoi1mi9EoNN9Rjl/2KSRhhSXhqKrRtKyJWiiIEjK4jdpMvvb+gm/mu98YAS4FauDSWc2bQ6Jtw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oKsN4Buf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oKsN4Buf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B97EC433F1; Fri, 2 Feb 2024 06:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706857002; bh=nkWkHSb0yfwwGbw4xRVlBM1cIu2gl8Yeewy4ovMPibY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oKsN4Buf4FfaSfj508bocnUZ2FXfe0mjiJMu1gXev4VDSb3zPJ8AQH5LsQX1lgY++ zCzNsYG4x4nA7nfIpp4n7HawBEo/EVAKGi1+htZxXfrYMsLjCk/e9TVxX4J6hzymdE zKR/wjycigLKJS9eougbDQ2HbgHec3zKK76/YmGgY4DX2kO6EJqF5Z2k4+osDutU+v qxLQ176yzHFWvRE9/K0wF8Gd5WvjtJUMpdgOHPLQp8T4x0rrgnMUj0W2I7OtvGsfKd t0EtUQWVu8tZHHjfCKjCpp7nS5NjQ/74UShvnVM3u+6RYsCc1vrPIbpLyZ0pZaGrYH 5BCHfqZFtfwNQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 20/22] tty: vt: use switch+case in the ESgetpars case Date: Fri, 2 Feb 2024 07:56:06 +0100 Message-ID: <20240202065608.14019-21-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To be uniform in the 'c' handling, use switch-case (with ranges) even in the ESgetpars case in do_con_trol(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index b5fc3b896e26..b3c61ec92df9 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2628,10 +2628,14 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) vc->vc_priv = EPecma; fallthrough; case ESgetpars: /* ESC [ aka CSI, parameters expected */ - if (c == ';' && vc->vc_npar < NPAR - 1) { - vc->vc_npar++; - return; - } else if (c>='0' && c<='9') { + switch (c) { + case ';': + if (vc->vc_npar < NPAR - 1) { + vc->vc_npar++; + return; + } + break; + case '0' ... '9': vc->vc_par[vc->vc_npar] *= 10; vc->vc_par[vc->vc_npar] += c - '0'; return; From patchwork Fri Feb 2 06:56:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 769433 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB8FF48CD2; Fri, 2 Feb 2024 06:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857003; cv=none; b=fJnueGg/Xs9gKLOl5mWoAfoBQSwHHU5V0xCIIZxb0eBVVYAlvAgP12xoALfGkTA72pzIR9HegGimcqeTqNmNxDxhaYLr5JJgU3gsN73py98y7q3RCQLbkblgGF/FYe8MTv8RO9gQjAImppfa9bNeZXpoCk14t3o4xHLC6aIPWwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857003; c=relaxed/simple; bh=VOEOzfnSThEWfOBJs6nKpRIEyLceRRUxrYlGmQrTE5g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SB8T/rQ3wj/AEKpX5J75zBrPBFGUggNQi/loWc5NJY8MWwv4MgdlLBetrE829kZZ46iAr6gU+i4S62cLPki0rIWWFZQOnJ8ZffJvKXI/++z+TACLGJZjH2JwqyfnQM8CqWOsfniw8QBEJV8ditq1xWLQI/5KhuKlktv9XIL9ff4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lghqeEoq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lghqeEoq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86348C433C7; Fri, 2 Feb 2024 06:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706857003; bh=VOEOzfnSThEWfOBJs6nKpRIEyLceRRUxrYlGmQrTE5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lghqeEoqNlo0iQxUcgQ+h3jWhF9iNmNOdEM7gxs9NG4VGihXIase6yX9+SkohvOUO SPrmVPygwVB1KzXFVkFLnPWQiqnrC+5ZrXfn/iPfYJAs8MxXK7IVqh7mgvX6s1IOwc EMk3PmDozw1IBfCjtZWsHP+ugyNUxcNRv27jGlnrht1MXtVuuZmhAWthAzn8nkoKvx bjW97dH+bkhYeHksM13x8wbfCx7MW8XjHJAtFTJ12gHYkL1+PHP214DPsVCtanQMlu kRWivQ4F7XWBUXlRKZooHPztyIuYjnjU4idT3UqS+ht+mO6zU5+A5yGsJMSd+gpmO1 23QZ7jjI+7sow== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 21/22] tty: vt: use ASCII enum constants in vt_console_print() Date: Fri, 2 Feb 2024 07:56:07 +0100 Message-ID: <20240202065608.14019-22-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are still numbers used for ASCII characters in vt_console_print(). As we have an ASCII enum now, use the constant names from the enum instead. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index b3c61ec92df9..e35f7a31a7bd 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -3240,22 +3240,23 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) cnt = 0; while (count--) { c = *b++; - if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { + if (c == ASCII_LINEFEED || c == ASCII_CAR_RET || + c == ASCII_BACKSPACE || vc->vc_need_wrap) { if (cnt && con_is_visible(vc)) vc->vc_sw->con_putcs(vc, start, cnt, vc->state.y, start_x); cnt = 0; - if (c == 8) { /* backspace */ + if (c == ASCII_BACKSPACE) { bs(vc); start = (ushort *)vc->vc_pos; start_x = vc->state.x; continue; } - if (c != 13) + if (c != ASCII_CAR_RET) lf(vc); cr(vc); start = (ushort *)vc->vc_pos; start_x = vc->state.x; - if (c == 10 || c == 13) + if (c == ASCII_LINEFEED || c == ASCII_CAR_RET) continue; } vc_uniscr_putc(vc, c);