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: 195636 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp250661dyc; Thu, 1 Feb 2024 22:56:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IENTCAvSU5NDl48E+Fn6GbuCOt3u7wrlDNoEIfWFzATEaEAWrj6mQUvWuv3ayPoVdtTpRQP X-Received: by 2002:a05:620a:22d4:b0:785:478c:ece4 with SMTP id o20-20020a05620a22d400b00785478cece4mr3544386qki.12.1706857009528; Thu, 01 Feb 2024 22:56:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857009; cv=pass; d=google.com; s=arc-20160816; b=vFoapHj1F5smfQoc8FP6Sy/TdqkKKU8zU6BIT5KLYtWE+uvazzgKkuyhuzZAHLz7AS rbxNxJ0NvkpxO5OjAMBOP/XAV2odUWODBmFJdrBM5g3xKpcrPGoztPrcT/pFLcLwv1+Z 1/MI9i94B0JNvA+ZUM+q9SVClS9QsxjKLYeLaGgWMvkQ3meo83EaEGARzzccI8hSLH7S CrOUSaw2ARQ10JDToRCYuXv7fYt3spp7ckqnsIWC53Sc6xOSTFri4tYTl08y/zlqPekt zTU2b0OvtggDVHq2KyWeE1r4vZvUG++1F6YZcJgpI2sbKlT7LKrRhoh/59GVsCHBWQrk cKGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MtjDizjvjNbFzs5T5EQjvevt0au3cLaYl/EYLWd/EN8=; fh=rU71d9K/uvEk3hGJybyKWTu1IJodyo7AcL1MG7Yz7MA=; b=kssL91rDR8YGEKtvmP7LJhknbPyHPrD+wW6XSDS+8iRcU7VosnBkT+W4NmtiOQEyqe ctUaySJ6YhyCm5x/2j2rnFqoSgIX/vAKAQ7taRyDWYM8qVDUx6y4+hiHVcj7TyhfLoJw NqNY8i1UrvRLGpvyZc18xtHyPMjn3lYVSM3QI5MvjZWMCvkJNKa2KMErfBl5rScPOQrm jJevjqiPPrbQvyECKCptFbkDVV1mXQRE0HYpiVli/C0vFwJUe+F9Xf1makPmVp8KpM6w ByXNYcOrmO3UxDuERLl5alVoigkhQDD5iHWbygc3vDUXzEhrxQrEUm7eKGUnpNpqEWyr DHpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JFgEKrM5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49316-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49316-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUPtgb46ndRdnSG4aMp6H9hdWMVDTgT8/0XM1054u2AYePpduOh1CFzwXJtutbcTyKKLRowEt9pdo9Ly0XV04fdNBFZiw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id po2-20020a05620a384200b007854e0786d0si1332543qkn.648.2024.02.01.22.56.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:56:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49316-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JFgEKrM5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49316-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49316-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 414471C21FBA for ; Fri, 2 Feb 2024 06:56:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 609AE17C60; Fri, 2 Feb 2024 06:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JFgEKrM5" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769295462505559 X-GMAIL-MSGID: 1789769295462505559 * 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: 195637 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp250756dyc; Thu, 1 Feb 2024 22:57:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFd2YraBwJTX4RdPA6TKgZQ5sKsWjjDXOUWrmA9+bzDmnkQksaMGH+irth/0zTufYkFKwS X-Received: by 2002:a05:622a:552:b0:42b:e033:f6e6 with SMTP id m18-20020a05622a055200b0042be033f6e6mr7674046qtx.39.1706857026691; Thu, 01 Feb 2024 22:57:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857026; cv=pass; d=google.com; s=arc-20160816; b=ga4qRZlasY4naQRqQtMQVRXqlNFxGEYn1MRVl7PNgu6tXUlvqPQCDmpKLZKvWy30gf oEPJICg9EUzzG+w7J5kvdh8UqxzjzmH9DrZF26HYsQVPOgnZzOqtc9h7e0ZvuifrSOVO buWeHFGMewaedMyU+dPbS+8zznouPKoQiTCUkUs9Hv0UW13aTbxZSLpchxagxc0Xm7oE i4aYEXeayId/mDJRQLIOaC5PaeqtP7oOYLFhk4mNo0P9X58r+2prJ2aNcj37USpMTESr 0yh9UAUV3FyFGInGUh7pOk4xUooBvpXl4xYK+LhUjDOfQagQfpmZqpwnJI32fYls2YLh nmLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4Tu11sL3RzCltrBBeV2plxqPs13YIey5PaOhIGPwlk4=; fh=XQdcV0EUUJtMfmHe4W0fupun3XN1TmIYMU1BNKcN9Gs=; b=NYH/A9BA09nzhHFltbStyPSk2wOol6X1GWyqyJickgAFl3PCa5dHIhX0c9eGSzJ44T 1vI38QhPmGDvrqqE31n72dn9vALcNJVY1xFDr0nYEERkf5fpDxqW2l8iMW9M3Vpr2Kor 1Gwju66QYrN99onbHIpJgv/yXHvV5whTqwxaKacwg4k0XF2Wms9d6wff/+8PWX9wwkum ELero+NgIYIcjKDrrMnuRqSZ1MXhPEryY9YhMMfbqUnCnAp4Pk5NYu/FOqctIdCfhAs6 aqohikUllALsS8NrKR3TcpvIz49N+RRJ8rHR8Tj/FmbYfTu1rxVwcWM6RCtvy4u6uT3Q VZHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aAi+ARWj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49317-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXa3LODlOQhT+4iUScQJfiD8mF4/2MDMMVOiEGqJ8KnuB8l8HDWWURg+O8bmO2KCZZTcubbx3soqcx6LomPa4Puey8qHA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g4-20020ac85804000000b0042a99009af6si1395812qtg.222.2024.02.01.22.57.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:57:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aAi+ARWj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49317-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49317-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7BAF11C21784 for ; Fri, 2 Feb 2024 06:57:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D16218029; Fri, 2 Feb 2024 06:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aAi+ARWj" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769313499837446 X-GMAIL-MSGID: 1789769313499837446 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: 195638 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp250805dyc; Thu, 1 Feb 2024 22:57:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcgJ/fF72pFIoUOtLCR6gMw+w+T2vzZewSFpjbzbI31KWXo/7RtesobW+iG2KsB1sR4UtZ X-Received: by 2002:a05:6214:2a4d:b0:68c:67aa:c17e with SMTP id jf13-20020a0562142a4d00b0068c67aac17emr8271525qvb.5.1706857040819; Thu, 01 Feb 2024 22:57:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857040; cv=pass; d=google.com; s=arc-20160816; b=Vf1ce3CS0lJCnnxF7tgWa3lYV8syyrAIsrfSEnUvlb85lmcHf2cRJ1+XDfZb1V8JfF AeJ8sCf9+y6Mvv2Yx8kJhYDKjV1qa9axKckAknLX8ZK2jpDfLC9JkhpGrpl3gTJ6GPxo yWPb5Uep3VQdzu7v0XYf8zUfNyHIhkAbNfmVYcEUHqHMwib71vyOcXjK6rj+VMxi+P4X UZhsTM8LW1WIUY2TEAsoIwRAVIN+dvfm19atUTVZ3xXWSHRlqLoKaMd2cVhxpk1Oxm7j G+7++2son6zA1m4PDwBSc+4tdsyAAgxgSu9s7Cbq+/0XPZ+4FbDe2TOWqy78zaYnuwjt 1PSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=m1bCBJyrL82oediiZkEQtgAMIVyOdcNA9RT5qLRK1rg=; fh=79aNT8SHcDa5PnrH8vQraPKj0WY7RIgSt4IemtXx5TA=; b=MzG7mzMH9QiVEoIyn37Y5pP7i+ciKReIh1zEL6Gf+DXLv1HdRTJoopKROhPam3X2rR /89/0Cy3HvXbBv7ZoakEhM34MPe8hWV6tO/OoYlxQFAJBiMuauFJ2ujYgyLS1XR05H55 QSfdjQQTEg19ddBVoauzfY2AyPTMaqyzzyzm/CLlQTrdFLG3Wo7zs7CTVBi/n39c34ey 5NgSE/RpKYGzjv+XJQlsEbGpGCRq3JVIYYk0uR00J+J/n11FbAIRb+cJEy3zpOER0Jf0 oWh13TzGl0252BXaXiPN6YU2F2s2VOkc01kpvLzoHEgSp159k8dtYYNs9EfN2fO2rMoA DBDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=puyPq7MW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49318-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49318-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXUnQaONnIhDxcp/ogr5q6OKwYLaRBVv/jfEgLlG21V/tiPYDqiPW55naZNp0TOM5T5tdru/27FUaH72gdeFoeMLBEg7g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dr9-20020a05621408e900b006869c9dde0asi1339938qvb.497.2024.02.01.22.57.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:57:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49318-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=puyPq7MW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49318-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49318-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 968D41C23328 for ; Fri, 2 Feb 2024 06:57:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD031182AF; Fri, 2 Feb 2024 06:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="puyPq7MW" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769328511056598 X-GMAIL-MSGID: 1789769328511056598 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: 195656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp254375dyc; Thu, 1 Feb 2024 23:05:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtpi15S3AHCZmCSSRGKUyYhosrmT5UC8p+ZRfkD2tYYTfIXboNjRvCUQxMdmzc8cYUN09P X-Received: by 2002:a05:6a00:1acf:b0:6db:957:d241 with SMTP id f15-20020a056a001acf00b006db0957d241mr1936689pfv.1.1706857532879; Thu, 01 Feb 2024 23:05:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857532; cv=pass; d=google.com; s=arc-20160816; b=nI0wKnvl6T80wCXbwH+5oGHqvMJlz5YaTd7n2zVdzNo9CDby7y77Bhn/dsMsTd4D9N h1ygZFUfAz5lnVe/90gXgAKQcuwq5yHwpl3G8wTSBjib9mrFIOmzFOM21WL6qdGGRcEq IZhlJCgkY6EJhQO+pFIelgtCCYWeMUI5qVk+GTz3WW30QNSoaPwDlLb2bYTsEd0vQKav PJfTf9PgASShkQL5+sCPfzeOpnSazBxvLnv+C6MPnWAqfV3E/Jvs2vVcsNWVhCn/c5jP IcKYwID9rKsZ6tsW5BsgNhEeWm3/IWx4hZU5hLCDuqHKYR9YQExv4V6Thy12N0kkYffe S6Uw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QBq6GzAJ1JLQJrsjBzliG6IglMPgLVO2bz4edX9hsMc=; fh=i8o2xpWcl9tFLSkocHfih1UrNWFoX2FGgITBOb9IXnM=; b=ycuqgzjKd74woicyGmrmnQeYy16XgAJXCVnB92KGS8Ly0IgdIKKAjhEAkiZDQRASkX LDmqBsendiArnXb50xzhBkFefMsO47E3chA5B/5xsx3G+ee9RNp+hXCy7EESM30YWmxB NWsP8QJCIbXHMKeg2MrMC4MzeYD0qXbWf+O+2TkFxAn/pkDgWZZfeIo3eVYcKtjVduW4 D6VeQv65qausJlbOetfFARfRT4hVrtiBr3Fvt7Wc0HaGYXYASMtU645PPseemOtFZQzd yBMRc3lNqWkt23bZiKsH+EiX8dJwh6LWmwrViHuhRspk2zNuflt4+Pfsi+0KzLnEgpxK exKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RASuBlnz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWsqRYyW0oUywhHqLrRQ1RPg3B3nAvq+QpwX2N/IddAhoyxkxlBC4p+6T4CtFULS5KQwnv7xEnOOgSNvb83Ms1UfBZGCA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u29-20020a62d45d000000b006de39f137ecsi1064371pfl.92.2024.02.01.23.05.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:05:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RASuBlnz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 17692B260BE for ; Fri, 2 Feb 2024 06:57:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D64418636; Fri, 2 Feb 2024 06:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RASuBlnz" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769844310443276 X-GMAIL-MSGID: 1789769844310443276 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: 195639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp250989dyc; Thu, 1 Feb 2024 22:57:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGl/nJfN4ejdCfGddz99i48VCHEcvMSQje7ZMhVJrZXsGY3sMOxVKw8oZBuez0VgdEz1GDk X-Received: by 2002:a0c:e3c9:0:b0:68c:5145:af08 with SMTP id e9-20020a0ce3c9000000b0068c5145af08mr882550qvl.63.1706857072428; Thu, 01 Feb 2024 22:57:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857072; cv=pass; d=google.com; s=arc-20160816; b=zbdRD9UfpW2I6Cs8eTlNxyMFzauFc6esTbLQuSea9GmRyWExtk3q9hwKQtprqaErDr Q9p2ByAF2XJR/Y5Jp3MxdOEzgG90HPF5MJIUudUtUWK9ArJkvztfOizwki7bGOo2NQuW 6nZIYsl6YVFxX2x27DIrer/bWtKmZCACP9eAWYVUOaYujLT1zthl3KnUdOvY2UuLaWwZ /Lx+jmpbcz4X+eaygJnnA19lnw+5WK5pSFNwcHkEI34CS07dQJKxA9zIK+aZggpz1Iuo m8LDqlIIEnR5VrhbADNfAsX+6tvf1XA/ts8T+MMZHRFm45wZ4InD09BXSBuk3Xg1kPQL VMDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=KRez3QNtR6hTbw2CIzDtNmzj+CaHtDM2eYX/7H9xukI=; fh=GlCDwkW/zqMT0bBJjvTbYJQ78XWhTLJa2gHwPvi1Zf4=; b=kIXBbp4S6apLWScfDGsow6mPKyluz991Qg7qn9n8E2uCJHYvpovLVSzDhPmiqxB1NL LF/L5oqAjCVUMfc2L9mqTefUB9vpDvGshtpgamzzik8OS9eGPmzDAJxJynoZfKAQWO9Z 0mFMnMuj+lNRCZm6DObYdOmPb4yNHdv18t9Wn14EG6vkpq0xp9Yjqf8BveuUNwovZhjd JMq+uz0TNTCb/bBSCWvJAPxatKa+9ugqvnYcYUHmSbVawWBzJKy7gY1/mam60MA/0la3 fYfFRlXlilHRCjGUcgHF1BaNT/z2YHNMEBI6CfAO9kLHh6kLHmZSejccWU7AkrXdL8WK uBsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RtuHRPU9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49320-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVXCireionWDbBgUaH4L2Ap83+9YXgWiEmygtbBgHkbvNl8o/xI85rPTq9ASfIIwAZcy2NXh39aFKCmov0GJsI6Wyj0KQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u13-20020a05620a454d00b00783f800eb25si1499008qkp.712.2024.02.01.22.57.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:57:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RtuHRPU9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49320-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3A76E1C23352 for ; Fri, 2 Feb 2024 06:57:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAAA218AF8; Fri, 2 Feb 2024 06:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RtuHRPU9" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769361699398763 X-GMAIL-MSGID: 1789769361699398763 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: 195640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp251085dyc; Thu, 1 Feb 2024 22:58:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9F7GJnH2LMTogGm29hOhVt48h1qJIUNfgMi4nm5pXimX00VEkn1hjeXPycaYzOA4fzLOe X-Received: by 2002:a05:620a:673:b0:783:bd16:e46a with SMTP id a19-20020a05620a067300b00783bd16e46amr4665797qkh.58.1706857091920; Thu, 01 Feb 2024 22:58:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857091; cv=pass; d=google.com; s=arc-20160816; b=Rj+G2Uy86HuROSDi8YCOZFeYFDfaTXeItD3xlXxskX37FkVcQXPwlENQeSv9EbjpsH TAmVOflOEeKzkBU2YP0cTp3sShNHd6iZlMbkeauEqZRmS5sz0AREom5kYhlHtPAIrvis exlUyFQZoFCVhYoPKI2wGLaloPnV6Wpg+AENSDnq+le0N1vCRXQw2AvsM4Y+rV5BGOVd zDLcnE1AdZqLFi9BhhQCFTRhB5XSPuDdRxbENwsuSoPqs2FrKMxKUwxvRZ9e4Jdj93Aa wby4WYno7O4cRZt32OVKwuoVZBfFgq2yic5FaDEEMDAUQWFMcyxl5OwGAVcENY0shFZ3 71RA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=L6Gz9pa25UAuusC3IJg0a85Rvo2yETDvNMD+itEiiKg=; fh=ReA7TK6SyyINoXpmXLBaQiYh4OVqXlrExlttGO1S6xg=; b=NCfNce19aTfcT+i7e/nmLKaUuPIu5+i4YEymF6+3Kl0ZZI8xjAuzK1pENbUE/oxFG/ yDuHuKSlIILAFe9ALXplqbSeSA6h8DKD99CARL8orMxmV76iMnPO6sBasz+rNkpR4zDG T+9Vfq9AGxB8kCMZQLLIcEzNH5Hx24WDIEjY1S4e/DbfvFmIqEJ/dacuPjwItGXZlAX1 YM6LRWXWdRncAP4eQ3aL+KAT8+xblT7H4X69psAyXuiUenOGibWLq63yqtVUhWRZmD+s KjXDHIo+yw5pl62gi2ePyI/HEZI5q/DY3zON4/HQfLVCgpJ2AkTq58sk5bX62lcCoELR cTOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xbqoliew; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49321-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49321-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWA3cbnf0zyvQ7wJqQt0i56Hyj2TiFeMXHW6vshsh6yG2tzEoDoUKx6rJvVlFuktfk2XumArlm72OC2ohe0RAVBwmis6Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d2-20020a05620a166200b0078349f5b7c7si1387467qko.559.2024.02.01.22.58.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:58:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49321-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xbqoliew; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49321-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49321-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B28DE1C243B2 for ; Fri, 2 Feb 2024 06:58:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6233518E28; Fri, 2 Feb 2024 06:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xbqoliew" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769382040413963 X-GMAIL-MSGID: 1789769382040413963 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: 195641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp251193dyc; Thu, 1 Feb 2024 22:58:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFagV8tNTuwJLyXnij1Xl5dTUNpuhEQ+v60g0jCVlM4aazLT3boxvTZH+va5SvRdBIiwugG X-Received: by 2002:a05:620a:24c6:b0:783:9999:85 with SMTP id m6-20020a05620a24c600b0078399990085mr6382652qkn.42.1706857112730; Thu, 01 Feb 2024 22:58:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857112; cv=pass; d=google.com; s=arc-20160816; b=IhmJPql9QStdPPh9q644nDfMWpkSfWT/JpT9sZeF5/6AKKQz8GprwEavvtG9QuQFpr 0GWPLUAB7OfPa3g72GPlFKQFMAV7htWKkJ/sx7kJK6gyK7ve7hTzCcZ0WuibFIlVnprh vwxwFIJMfAYWkrKvbJhXrm1v32zYgk4cA2sF24aabM5jDTeOjyWu6NPrGBEdfRhtyW/e bpAD+YilqC3duYtUaExKWG8xDoJSsrUHXJ4Xt2kkV20DQHUVf+uqjpdPHaBcMg/P3YIh qBMX4dVZO9yaeFBWKR4Ce67ibCD5AFYwxHXX75lUQNhQZRPuW6HnzV1XYMOuPE95jRyh FQ1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=aoo4vYxIONPZv3PPU7zQCkhkNDI8qgQyf2FpG8t+nA8=; fh=dr5sXeIbOv0fn3/o/SALjbOG+WSDHbde81K6JzVjBGE=; b=zPn4RrF7CcvXuTjWEWxdikwhkV0/IB7yzXBvi1gCXxc/UBPpN6QR1hNI4r8hIzrdUS zbIpZfprdNvv9E2W6rlsfCHwh45BWz22xCMUAlkAAWiH1TrFbzdBsCCgUj4pzeqWb2NL quXZNsXS/XVmYGgUq4hfAve6n67F+O3t/hHM15O04YyPX8uIS3NZcuT7Big7FGksZ+CV fDfl+04WH4XKdiEzTzJlhLeU8N6gGbnimuQm2JGPp8SvU/owipMiHSck3k6C2MxnlRc7 GKMiXoCN5qxBZ6yqgXIx1lU+fl8/rckJcbybcE0daYYGCEMYU/WSDc07Uj8BhOdfkdXl ePsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VsC1hGXa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXDhxZBJMF8E3sPWqm0fNf+W+2n1eJIax2bCetBbb37HulptMyruamb8l0YsJdm0I2YWdl5VpX7td3tcvSfRtPeKrdDxg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u13-20020a05620a454d00b00783f800eb25si1499008qkp.712.2024.02.01.22.58.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:58:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VsC1hGXa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6F4B71C234B8 for ; Fri, 2 Feb 2024 06:58:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFA0B1AACF; Fri, 2 Feb 2024 06:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VsC1hGXa" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769403925862983 X-GMAIL-MSGID: 1789769403925862983 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: 195642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp251279dyc; Thu, 1 Feb 2024 22:58:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBcnxD++KGiaTkmvLrds1HVocrohcCP+UFrW0JM87hO9BmisYiQuE0c4dwrelJS4yXcE0O X-Received: by 2002:a05:6102:518:b0:46a:faf9:9bd3 with SMTP id l24-20020a056102051800b0046afaf99bd3mr1264170vsa.29.1706857128886; Thu, 01 Feb 2024 22:58:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857128; cv=pass; d=google.com; s=arc-20160816; b=llsqVNXtoUrxIg4jqpi8iEp9XEC8zfUFDxRyx7KQJL5hg/Vl+q/DiANvU4YriTkEr+ J4fX7aA5EFJmlgVsqC17nNy6I5t3Cb8mI/28x5mW47ZKtmkuxup/FgonT61Rzd1XUAxg uvVlBltRZLspeeJXUUNs6dIOxJFddTy1/TJ3OtBeBomMD+/cz9SV1Z4Jjw8CHbHUoEHS oRGWUuzEjU1LZbgeZNFx/0A2n0Z8FUQtyvB+PKayJmDwpSUGqE4p9sd0sFKdJm7NdwU0 GDQZRaoBNAf4naoOBt8dYxS5n3i2h9gnqF62eFONq/DqgD9hOKnFCG3V05iJw6rEWESm 72JQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4vQunUjNguXPTVsbSQihZ0VH1NHiw8ykt1M8Q0/Lnb4=; fh=azCQ7Yc3urS7rSftHFE356Mg+sk2smNFnnuk/+6m0fE=; b=IPv7ZPLlcaPSRF1V0hstzHuASdw7bGVN2YLauE2IZcBZ1XHfv3Cq3e6j8S5f12/wH3 kN0aGgtLrXGzeSwQt9QzdW/ef1X1yxEBj1V3ySPwvI6R5hpGM9BShP1Hg+Xfh2JiQrZm LRDwSNxfKMuyxYlFuJwR9dSt55T5WeAnqetkEi1SqY3Rtslaf2rYhdL2USY38mPTcBsf R43l9+8D5PKTe8/arnQzhbO4Yvc5xjonu6z7A90g/d2wbCKm3TJRftrErXTVZM2Rqdoa c/BKrg2kMft2uU5EiZuQ/zVqE4ikIgeOx0awKiYQ1UzckVF0ZluIIg4U6L6s7B0FS3Fz k54g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kuJMc8b5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49324-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49324-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUMw60rtSyYhR66IpTBvEhRIaxdOKLmCYcxC2OiBqvWjI1PX79Bw+BoCAbqfXGktbdPWUXT0+p4gdUS1uK1HkQ1twCXNw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cn14-20020ad44a6e000000b00686af113368si1321784qvb.381.2024.02.01.22.58.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:58:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49324-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kuJMc8b5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49324-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49324-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A96081C253AB for ; Fri, 2 Feb 2024 06:58:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E7601B5A4; Fri, 2 Feb 2024 06:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kuJMc8b5" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769420359315995 X-GMAIL-MSGID: 1789769420359315995 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: 195657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp254855dyc; Thu, 1 Feb 2024 23:06:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOHMFpX7NbPoc9jmMXtyINODOHhl+ZFOr6ApFMbB9pI1Fx9h50W6U6rH34Q/o8YUG/O71S X-Received: by 2002:a17:902:6803:b0:1d9:4ede:66c0 with SMTP id h3-20020a170902680300b001d94ede66c0mr1245543plk.40.1706857607395; Thu, 01 Feb 2024 23:06:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857607; cv=pass; d=google.com; s=arc-20160816; b=ytNRJO2b8X6cX/LW4ETzf0q2bsDS+2J0Xf1KFIbDoFR++KI9cLamvt514mPIxMsudq ORsNtxcIEIRuSGN5ERq6aEiyzxeQS+RRMJUxmxLIYGlGCFY/ox/K3/pCA6GyacYuH3UJ m9UafRENvhWOFfj/FM4bS+se/ZC6wxtPat8IUJ6gBPX4H0dr5i68Op0ZKZoGZ0b/iqE5 Az1S2q7I1C+PQPNd+BF9yNm96/SsdPmPBDsHWGkiJLj8+YfeOW9QVFrbfcF3UPc2Ttka jjZAaGvGcaj7ADLzYpJauFi4fdLxiO0QmRZbdvToL60ll9NAzO12Fh5SGxZhQgPbZxnl 2Fcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+wm7txhPMUeGVXMnvt4NP2/5uzD6cPZl2D0h+CYwbEM=; fh=+zY/X9uDTWnrKHRUecqNZvH2Bpr4Pn0HTN470HgvRrg=; b=PMFa8vgEKOkTk2kc8vorRl/Pes9LFUJhQ76hfbpb6XDVKZ92uB1kic74X8NpevZhx2 iMc+hXT3sIqwPaixzmSIQfcGRWX3Pcn+U2B95jvic2DqUsWc8dcSPt1mN1KgEFnWTOlc smScM0ywpzWrt1YuGmPwKXI9CAMRDYhpCObXzVRNUWm/MAwhAIMIiGtsCnhxpiXVQ49k osmoSajhfFPHz0/mDN+x8vMjrLt1SIXjl735znNg3Ik8Je0htIy2VrWUAnkPsBSGzzBY RPqepgajEkG7ADpPLkdSqi4yQm7v6mtkeAdPCAX6k90F6dIsKISmmdTke72ctP13G2Gs zPzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jo2gf6ep; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49325-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49325-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWbZMFgwlq8wA6kGW9OUH9nMazXzmdI2uK9/OrrI41qm9ZO5dIOQJLx74NOk38V9reFyzRvhmUNYl/X2aZ9orWCu5tUug== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id g2-20020a170902c38200b001d927157e84si1151847plg.481.2024.02.01.23.06.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:06:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49325-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jo2gf6ep; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49325-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49325-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EB5B3B25928 for ; Fri, 2 Feb 2024 06:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE0DD33CCA; Fri, 2 Feb 2024 06:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jo2gf6ep" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769922741814381 X-GMAIL-MSGID: 1789769922741814381 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: 195644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp251447dyc; Thu, 1 Feb 2024 22:59:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IELsjYSu0YTlTfSM1/FogJD9qitkrnyjvH5jkbxRvk8QDRbzUTWooXrqH9muVygGv6sULwJ X-Received: by 2002:aa7:d58b:0:b0:55f:4799:cbbb with SMTP id r11-20020aa7d58b000000b0055f4799cbbbmr2735410edq.41.1706857166292; Thu, 01 Feb 2024 22:59:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857166; cv=pass; d=google.com; s=arc-20160816; b=eznkupbSNJri1CivgdT7mHLnORR16ii+eXLDw1n4L5lQPK4uDeuEAABQ0bmm4MGC0Y pFmxoIq893gqBhRX8dLjnGxvgTQgvLGazFS21/J17IL+WM0wyP0W0uJRsPSzf/qMKYQR iV93YISswDZSiocZBQSLeWVatYzZkn8tb13F0sdsg8XlgOSgj3F7nKZI8OwZhwVeHpQS fyo6BZDr3dvM7cfOMiJVvA4KQ6hGdb0z02I0siAgQjscicgY5iEJA8u+DV+nCipd4Qrg m1SeD5goRUiJ/7I1T/w+7zicmA3pjFNrV4acFkSqjp8kKdTb8XuEgsKfQLV+soGUbZzG f7aw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xLWuCiz71nrFcofnKFk6KegVSb2S3GdsptB+HP0vce8=; fh=7jcDpAFks/girfqiRin3O0B6a9jwSUMYP/4UCsoKwHM=; b=hEKGBhA+8YUpnCW4bJjf/LFo4+QbB6nGi9tbucBZ+mZ/bxa9VxrQMKkLpKNwfs9Xtp S23hjdG5Q5dp/rfkjDwPc69DO4w/5ywqe6Qkg147+2gWElZljqS8UYv6Q1HKujtSxYBt PXhP6XAXn3M38rQnYoq466xH80Va7hz+FLLDQcjwTM+9DpH3uCQY4ZJiG/BgwYbOagb0 enH+RjqSe31JZzYaEyiRVJ/KP/u+ThREq/J0BmdZ74Xwbjd7O4Ero32Db2nkBRPmia3f TlKQL/LI8s07xD4F/hYOPF6+OrWKnRzfqDTaUYT4WfYl7/b//lO5HgkZmrZ7rs/uXLCO lpXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u2Gxc7Vw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49326-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49326-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUN/WV2ZHilydzlv8d/IIiIB+3KQDKLx4y6qswQJd/7ubEs0E7l77nPHUUvkKZtIO62kYp7A3NbcuYQBcFp1q2VXt94KQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m7-20020aa7c2c7000000b0055f78d2b432si541621edp.609.2024.02.01.22.59.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:59:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49326-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u2Gxc7Vw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49326-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49326-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E099C1F26705 for ; Fri, 2 Feb 2024 06:59:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EC413D3A7; Fri, 2 Feb 2024 06:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u2Gxc7Vw" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769459901616674 X-GMAIL-MSGID: 1789769459901616674 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: 195645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp251516dyc; Thu, 1 Feb 2024 22:59:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6rhEc5QkMGLC669q+hu3OQkgWSk62z0mP43Ub8Ccr+TqOWiFvZkRYvItfGNJxiATQ9E/3 X-Received: by 2002:a67:f959:0:b0:46c:f63f:3801 with SMTP id u25-20020a67f959000000b0046cf63f3801mr3493466vsq.9.1706857180168; Thu, 01 Feb 2024 22:59:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857180; cv=pass; d=google.com; s=arc-20160816; b=JUreMhame398cCggB9sCa2Jeej7L8FEdOgRpnwH/hRUqIvlVe/W5t6DpDvX0QlvlOA PRuvkVNoICpuW4KoQIzodhHfshqUtxrciHNShhL380aeqzzmB5r7XY7CKGFZOg7ADQ9Y Zv74Y0CpJi1t/SuKLapvsgoJ1QLpijorHSB9GuCz7/sOHdP5ON0VirRz6HKhwYQjgog6 tCcrrEa8vCpMDs0MDbbKhcomnuBqKCtij1SOn83IwqCKd+PfaeaSL7eCs2YF+jaSjzLX BtDY9qugaG1izUZMDlpcZ64kN7G9fqaQQwC2FrE2B8Yy4iGdjBVWCbZLq7lSbbaCwww5 8HYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MM2//6++2K+GxeAWx5v5TL63yBmup9eJfNE/ydbuuRg=; fh=FCGMDNIK9xJk70XvC/wF8PNa4pIcxXZmd/iUslFrp5Q=; b=VEaBhjWF+UKVrRayRTV+IBjhhWtj+ii8PsePUAllL9upczWn0A9IoXGbu8EBMn2yNf 89uGqu2hv/n5Px/gyWUnSOEiUoNC6e5efjykrt4p2sU7VrMGSyzPrHYdcnSQmxZAXhlJ 5yoTsue/CTV45y5I3OU/9QEu7IyyNar0Ze6X3LBEjD1R74/KaniuIeC4JQeXS8LsU4wl UzwO5UPM3j6P4Bntz6HjEZZfEN3IWCcUCphpXC9OZZGInpBeEuCCAa74n6BIrOB/j9HL sZzF+4/VYGee0QAsNTM0aA2CpMFzOsO1TBFDvbjvGiz1gJrkJR6npJcP/IRn2WaOwhoN Ei8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cIadmm3N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49327-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49327-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUyGuZy1dnfWgRwlKA2FMsUkWo4b7JHWc3WgI82YdoQKyQ1gYWje7eLp8wOsf9t0DzNEW4SDsSZmpYIWtGcHx2JQwa5CQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cn14-20020ad44a6e000000b00686af113368si1321784qvb.381.2024.02.01.22.59.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:59:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49327-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cIadmm3N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49327-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49327-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DFE111C25391 for ; Fri, 2 Feb 2024 06:59:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CADE13FE5F; Fri, 2 Feb 2024 06:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cIadmm3N" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769474140867346 X-GMAIL-MSGID: 1789769474140867346 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: 195658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp256738dyc; Thu, 1 Feb 2024 23:11:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEulg5KNt/n6N6xAGJ2POX6qZCkLB6Ac4hUnx7V5SrOZAEa5Gi4Eazn9JeiwjQu39FEWfR X-Received: by 2002:a17:90b:391:b0:295:f96c:e75a with SMTP id ga17-20020a17090b039100b00295f96ce75amr5809650pjb.14.1706857882520; Thu, 01 Feb 2024 23:11:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857882; cv=pass; d=google.com; s=arc-20160816; b=RjU+rKAQ1GgNrfekJudqwswpgMXWjbLgX8+cYBwbvz59BrFfekPVz5uwrGdLYHHc8o alI2cXLB/Bkuf6SILzCiaLT6sPshvuEwllQvBQ7wLVP8aNwPK+n749nTIm9RNZIrsckW /JPKNNz6bQCNWAcWIBcKM1I0+jNg12TcZ6wtIBVALXRb98v+9bmG+SX+RrCWAc7oV+mI yS0mfUr0F1UDIU5KZ6kl0A8KaXSra5NK2kCTkqx0mMEbAGc2TOf9WvUN87sOh3CsDAnG +0p2vstxF8/e/9hQBRM0fdJwJqCjxft5e/nCi4kTQp+caubb75xFfZVqcIV2aTdR+hvA 41wQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LdQdMx8J86oWD8e5WvQuJF65re5wEZzL9DxS2VXXpow=; fh=MOT8GDHdkQgaV86HZSghw4n+TTxQ58/1qiYt05HKUtA=; b=i8fIR2MI96WNbhlT/jxZqCIv/OdIxAk1ByKMDqdc7Tgkw2ICxvUc+zzbUCii6AvqYs BE3tWy2Y1uo8Qq7bjjO8LMjTJzfTFap0W5mtsw0O7InCTzfq9KekKp//jyUzIR29030a pnfz8cThGiMboHVAzxymJrJiuaJaKFSPipgs18epfR3UvCG4gUGQZKatcOhZ/jIfrFBQ /lVTA1sV14ckz89qSVVNdyGbtiComuAXcN0y1tP4Lp8CFDrgjLHTbY1FEZB2AYNIYZrJ xj386haQckHLVrEBoLhUXbSEfxdulxjpH3LvIVlDww/XLRV95ZMC6XwKAYJypYJ+RKJq KXGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mmAdHWvh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49328-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49328-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUqjFoSeQbXKB1Bi5vRh2gBu7vyj5MxlQkbENOc/U+h5o/HgtKZv4subT7PSDr7GNiawOp/35AaJfHvkFTn8q9XBuvtgA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q65-20020a17090a754700b0029612f11aa1si3040166pjk.99.2024.02.01.23.11.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:11:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49328-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mmAdHWvh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49328-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49328-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AE62EB23AF9 for ; Fri, 2 Feb 2024 06:59:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BB104207B; Fri, 2 Feb 2024 06:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mmAdHWvh" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789770210697540255 X-GMAIL-MSGID: 1789770210697540255 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: 195646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp251728dyc; Thu, 1 Feb 2024 23:00:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGaBt2YoLa9M2FosgXs6AJAOG/OVMVSNoJvPcwJigIx8MPvtSrDa4bzg3VXGfN1SSrEYwqG X-Received: by 2002:aa7:d359:0:b0:55e:fd3c:66e8 with SMTP id m25-20020aa7d359000000b0055efd3c66e8mr3137984edr.11.1706857211929; Thu, 01 Feb 2024 23:00:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857211; cv=pass; d=google.com; s=arc-20160816; b=H9AHB55hadP1ErPdi/lwJy4i6GRCCDPnH87kPPtQpj8jJHTUmZKIctclfPZYHqIYNu tw6JO0sntakPiNomQ8HyZXBOOri7l21wYJCK+r4IVUjX7rhJqg/I+DFX+DqYqsxUHeFb FtMKSX7js/55fJVXFdGWsEqGo+VzxMKUekERsnTkuLQ99kLQ6NB1l4467RIBKEptgVy5 w1s8I5c8Sa4JOl4I8QLYejOBWzUoRxp/5en122NL4oHOoNdT/CRQt6bRQ0DI3QaM5ahS wR1rRmbjNcUhKL53O5TOazCDiVckBhZfT1LSANHJd3swi//hI/lzn5u/PYAdMki3TbUY KmkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PX9uCJ+qzFKKrP8VK9T9hPy72cODmu3jiyqjnU4wzfg=; fh=CL5AUdd690JN4XvmmY6y1Fh0JfRm6IEK2j1dgL/ns2M=; b=EyAQKtpqcgMrk7NU+IX6N3w3atba1gAz3f2YLzv53FZcX+98JHkWt9Y2bOivE2mdq8 XPREfXUJSAOHRWBN2wS3OlKU6DA8LiL6EXKXaehayyxqpmVEEjDdNXbQhYM7vCpfJIH8 5rUglsk3W4eeoO2Prjm8R4arcvUiFU3o3l5kWYgrGHG85N4RvoqayC1Y7I8k5A753/zH 6KzTINnNxbYDRZUCs4zToFKIq+MGK7FE0457O4QM5u79G6s1OBZEL0gL2tk7n2OrKvyP EdSMEbPvB8WUkrE6jsUOuxqxYlrsbqanME6FRXXxYsQLybs3zWUYDp5yExJyCOY/akhv 7ZZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=urSwzHRf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49329-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49329-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCW7fUHfz860obNysWH4IqeJkoLT1Zuf+g8FCGUwuT85v124TDx+J7HIZiLQ4P9qMfOxeMN8b4raJ/bYgcY+WySiq0hNqA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f24-20020a056402161800b0055f0531733fsi537026edv.372.2024.02.01.23.00.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:00:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49329-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=urSwzHRf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49329-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49329-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 76DB31F26D99 for ; Fri, 2 Feb 2024 07:00:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C649C47F55; Fri, 2 Feb 2024 06:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="urSwzHRf" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769508171968428 X-GMAIL-MSGID: 1789769508171968428 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: 195647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp251938dyc; Thu, 1 Feb 2024 23:00:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzqrRvhut/nCM2jONRTXJpJgPvvJgBKyuUoeaddePcSKQcmgjOW0pH1bMeSADSFgriX8B/ X-Received: by 2002:a05:6808:1289:b0:3bd:36fc:1c1e with SMTP id a9-20020a056808128900b003bd36fc1c1emr1485253oiw.44.1706857233800; Thu, 01 Feb 2024 23:00:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857233; cv=pass; d=google.com; s=arc-20160816; b=gP9mbEzc1pEP13o7t7g2bo1FXhXjw7Qj4lw5fjYyjEaBhoB3VaZ7Ixn6uGxS1ship2 mX2xdhw2A9ZsGvNtX1D/HoxLl8AjhmjeYZj+bU40PDTvWVi4sf33AW2NIAEu1rgCVC7G 3FkoRiGS6ddhYcXatfDzFbBeXLB//Dh+3FJdGs8/AqEFRMEelaA/tbC5xkN1qqLPLNsd rAFEIanY8TxwaDZdY7uRjbTk/+cFiyevYLEApiIsXqQ4k0yBy2OKr2FkNWAbIL0vSNSF 51MQJX8k64zRllfIeqLu6FSfmTj7FQGGDAmRRgJOWv9dYqddAJsbAhXkfR4Wr2QAStzB Gf8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=A3FN0v+b1+yprubsR5ZF0UFk06RD9LjcpeoCz5/Nl5A=; fh=5wL9Jnx2aYTorMXAe9zEx9HWRZ40x0vl7LAFVm0Punk=; b=xF2g4jrSaLU/LHI28C9oE/KTQi2Uf0+3fGRlCBjJ/xUmHc/yyj38jc+vYNGrRi4EL/ fHIklVtgSb6UTdPcOVMMOnvRuzMIzIzXEpV++xQYlICdpIQxinFTRKaKguzZWVOj8WpP LSUh09XB3e79T5kTUH2tesvN7YxoR0qOibAdOBlvjeIJap0OMLSGzfxYDA0dwI3tWqvm hlulD3EE+Ci/yVe/pb150qlpq8rQ9N8ruvX8tedVYsdx6Arls8738V3ZceMLv0hBSu69 EJr1A/q+WUX4YusBMqhe+uDYhr/2vnnxY/D1SaRs1EKV0l6QOnGBz6cAoW5zwWrCrTBM T5XQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tWApjrEh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49330-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49330-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWPnBkywp3UaYwsBWwvKt/c88XUebjKXX17WK7zKapOM/E5lPQblFVuG2xTN8/Bjw6OoiZQ4MFCjrlex+Dirpq30OD8Tg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p16-20020a05622a00d000b0042bff035730si1371834qtw.162.2024.02.01.23.00.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:00:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49330-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tWApjrEh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49330-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49330-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 84B2A1C21E9F for ; Fri, 2 Feb 2024 07:00:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1240481BD; Fri, 2 Feb 2024 06:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tWApjrEh" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769530783796649 X-GMAIL-MSGID: 1789769530783796649 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: 195648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp252032dyc; Thu, 1 Feb 2024 23:00:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHz/AYvhyVqz3MU3b7DyFk8BDC4yIBFrx1M//63KMGMRIgYW1sNGN8zPO7wbz7FZwujf3Du X-Received: by 2002:a05:6a20:d90b:b0:199:96a4:b6b9 with SMTP id jd11-20020a056a20d90b00b0019996a4b6b9mr1645867pzb.38.1706857243615; Thu, 01 Feb 2024 23:00:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857243; cv=pass; d=google.com; s=arc-20160816; b=MSu/6yer2qPF1+lKteojWL8oMF1rgaCgFjQ3DJ0RUbC/Qmxqzn+DriKHdHQbddVbVe UEzeYMGHOOpYi8yVoQZdKIG5JqaAW5nfVz2g+kqorHljkyAiJS3h8o42rVhVfY4soqce VtEGdZNPiS58lRqnDeytmVdEO+t2lZ6P8jS0EerY2IRjzXwmWrH1rvNFBJLaBHswjTef OHvdvsg4U9cj6shFBxqMpOvBxby9FKZdW27LZIQmbEA77zfcbTUHfegzfrygwQe2ocoN 4JGyLWyV0aS3GjNtbUCTIySc90mYiqhV0+empxpkdaDSvdCPTcZr0PJIBTvsnXfEqUby jDFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bF9Ce5IGIdLInRmJO2LVwFcQ5KMk5NXaa4fRd/2HN/M=; fh=/MJJ9AV6+X38WDxn9Om2CKDFxzAs2EiyFpGDSc7UDBg=; b=lp0i2rUHjZ/U3fWoMHS56xmswRwUaJfzhSyzv5ObaCMrCjC7z90+7+QGhZmI9TASjK Srg8aw8EVoasAVIXBrr551WuS17qYMbE3M/p4RBmEm1K2LOmZ8DNWGvBHsoQMdxiYSoo 6K6wJ0mPsQdtbx1MxJJNM2rfgcAYalR3mJEwaBYcjZY741YliA9VpEELqZfZu9fIvcdD y7aJ/mHqoFh+eBRj0Ij9otge3ZPYdnp/XqplXs5175wre6Syh+6EuQhFFNZUhgLNOV05 cfGmvJb9Qp0sWE5qis/9wmDo6RUrxb5BXaYOAX7EyUZwf917gpkMj8yFSER/xca4yu24 8CMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C67wQcD3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49331-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49331-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXnC1MHgFtyDfWBT9JlBsMhL7qRsAPe6L4ykSXoL+XOrLDqNzRNw9gIQyqYl48sVA6479XoO3CdKtazVe0khpiPqtq1Pg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x2-20020a17090a8a8200b00295dddafbc9si1196828pjn.116.2024.02.01.23.00.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:00:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49331-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C67wQcD3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49331-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49331-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6362C292D78 for ; Fri, 2 Feb 2024 07:00:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA78E482C0; Fri, 2 Feb 2024 06:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C67wQcD3" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769540895609684 X-GMAIL-MSGID: 1789769540895609684 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: 195649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp252146dyc; Thu, 1 Feb 2024 23:00:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmOUaPayAP1UubCHAaE6Yc45gbUw92lzJ2p19V7EN3r6AtGm6C8FKkpFSmw4c+phhb/HdE X-Received: by 2002:a05:6870:ce49:b0:215:22fc:a1f2 with SMTP id xd9-20020a056870ce4900b0021522fca1f2mr9397368oab.3.1706857255391; Thu, 01 Feb 2024 23:00:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857255; cv=pass; d=google.com; s=arc-20160816; b=hYoAlmSH/d85b7qVrFhihYRnB+nyUQBWI2hhHch/O0KBgskmqZQPh3YwFGUbmLClx8 AkUTOWZSYIxn9miqjGHMcIr2RoYl/VM3leckRQnDVvz3ATuFTCSam9QLTo2CR1DGRxOe XbpMMlvpTX4+Qd6FAeUZMXKFFDMga3h5IUFB36TlROOkxDjuCKwXkIUFUH+QAj0RApTA 4yN88QEuaB1dtUGrWQ41NFlS59XuThWO45T9IXbV0wSFOIEstUA/0tweX15wuqwe3wvN mB8qT9SQCahHELqa2n0XopEEATa3OHQRTmscCwD8vq3y3G+fGFfefPrYJ3QSYNr3vgm5 jLNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=v/9CC7zKBiR4CeF7miMokhp8H66NmBbYssUSBbo5mks=; fh=Bu9IjWclO49eGkEQN0EVq110Etbf9i2ju4H/PPKpUQw=; b=LmkiSUPI/uHRqu6HgPKtNeJwbXdqPS1H1IN2pTcgbBZZ4Qq9neQ3gOCOAq8bep8dtO Md1OnSWeBYUxZR0AGegtwnW0uem8CXEQZrJlYe/daJx3McPOHepttq7rVNM83RDVNqiD Q5+3ol4Zya85mUnaVJr/hI+XPvyJoFfaIC4L3jvJmuw9OWbiQhSKjH8LMJuBPmmjLsU3 t7gP3lZckTJgrsHDA1gSDWVtKvoeVDczebU2YTR3d+yI32+h8l7I6XRKTC/uaCMpu9Tz IF2fVnEtp3q+i5IpKz3FRQH2ZjWljPKpHbM7RGr91HSelZTMrR8jQmrgcKdpGm/E8y+Q Qiqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ajng1D+q; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWDPQl7S3wVZkryC0OMiYrr6L8UBL4FbvQA49Pn3tdTcqJbN6o8tOMynBVI83fqQwuDkymOOFfCdMOZB6Tyeo0o/R/r4g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e18-20020a635012000000b005d8bdc6258fsi1071637pgb.679.2024.02.01.23.00.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:00:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ajng1D+q; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2716C292BCB for ; Fri, 2 Feb 2024 07:00:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFDA0482E4; Fri, 2 Feb 2024 06:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ajng1D+q" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769553072893457 X-GMAIL-MSGID: 1789769553072893457 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: 195650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp252386dyc; Thu, 1 Feb 2024 23:01:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUtuVSWprQYRcK/CBX0DK3vZvsttSSsWJJWgykF/EboEpuJp+C8bHjKfRIzDBXKtfkJbs3 X-Received: by 2002:a17:906:7853:b0:a31:4e96:f40a with SMTP id p19-20020a170906785300b00a314e96f40amr829081ejm.26.1706857277769; Thu, 01 Feb 2024 23:01:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857277; cv=pass; d=google.com; s=arc-20160816; b=kxm6L2Drvs7jVJK7jHqGEtlj9y7gxw8eJ6RXWsXW7EcZS0xC5Acgx2/SwoDteFtMae aXAyz60Aa/0ut5CUUK/2lbut823J1vFxsZyZsbxnvhBGiSTgthh0ns9rxQ7gmvJlkDjj fQBgPzwsCa5xC3gG89+Z4LukX/jgtM+ue8E8S7LXEJBeNB5l8YlHRH85S+xWjx84qtP3 dqTWEwWfVCVKqJOna2SgzoKKs68PhCt8WVdAZOs6kcat6CfkEEAF9e3WU5+8UEVF8lWY fLq7lbCRgoZd4GZJPGZJsC5ZWE3YmgGFQiZ50agZ8lu+UJfuE7tcdcQVECk5tPsSa73E 1YeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iDtcs5UkS+sxdBXd45EDg8inKGPPjVFp2G0PuhQnM+I=; fh=NsVhVHBy7ADYAlAtfvwmKKDY3WHjSd89UYsZv8YEtAM=; b=WfK+xuUpEeSKywPhE1pKQQb1Hvvwvbk3dEjCRsA5sIDZiP8egpTORmCZaHKWGfIrOE 9qaNVsBimqBKNJn3akHF//ndB6cTZuQICiuPUx4XncBTb1sSijc3DtxYRvHks/BkOy/J rjDDk47LTfB9uv6rnZS5agN+EkVFHLFIv1j1ylxhQC/VLdgc0wsPT6mxwpHTpRpmNq9a 6CRNvuBTfg4VqSnf0shz2SVA9C+Ne49cBwtGyq6nODxICv+02TumwgKnqa4clRqpP79T LBV17YlSHI+nzAgkiRJ1Gt3ZAoMyI2QudFYLYyxDspJOqp+Xqk98kMkVTHGaUf3KWbbC VwcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VNcB9rBM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49333-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49333-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWOKLPGLyGCKFHqlTplYORJdXCNLIxRKQei//VR5R2xw1Z4rDJ1U8AxadOn9iYdgdyyO4s8aHjP/myMnW50u2ZP3WZbIA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qx9-20020a170906fcc900b00a317a8cd7c5si543924ejb.967.2024.02.01.23.01.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:01:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49333-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VNcB9rBM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49333-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49333-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 468441F21A89 for ; Fri, 2 Feb 2024 07:01:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA98548782; Fri, 2 Feb 2024 06:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VNcB9rBM" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769575547586062 X-GMAIL-MSGID: 1789769575547586062 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: 195659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp257155dyc; Thu, 1 Feb 2024 23:12:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9CPuwv9+ZUvMzOC7dou9JNvuwKapQKRNsB0NLw/hyttYIB9iZOVOXePfXH+Nkh+SgWhuZ X-Received: by 2002:a92:c0cf:0:b0:360:d904:4419 with SMTP id t15-20020a92c0cf000000b00360d9044419mr8323049ilf.28.1706857952454; Thu, 01 Feb 2024 23:12:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857952; cv=pass; d=google.com; s=arc-20160816; b=dySCYtM4FeCpERm9IZ6vxBuh5xDtp5/BQYUkMUtAoxe04Ul0hN2npTYNgqU7Q6xlLz g+1PLwh4/laeugXYCAuCo/Wb2Sd0W0m6OAJVhpKCelqBAGeAq2pEJcNOr1bEz6EHdxhp KOm4D9VDSPn4uLim0myPCX1J038XgTDD+nZkeeZRBf1muwG9q/561TvXDvvcTkdv+FbX 0/9j1fHaB+osb9BwC9Wm7aFPJYpeeHk1TwS9LuPWetqzASsZdySbHkKaIzH963sBiKEU 1ysEbzNefZRvy29qlAYq9j9koqZcNNj74O2R+rwn/+7ld9jNKA5h70TmTipj9rD+Ux/P PXRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=a/k2tWcXRTpE89oU0NJSF3ba0JXt1bpeVDvH7jPLV8Q=; fh=UtQRvcDEm6iLb6HKmASmBofcezGd1Ugh08Ple12iNzk=; b=fqxtipj2hvRwI+6F0E9jlo+Z486ckUE/a18DZf+8FEuin1ACTNEHTAkl0U3mDRVew3 vNAXPWGhDe+tekNpn0mCpkUTgKdhdONoctrvdy8faWdjyye01zxHZnk4UZj+EcLW2Qj7 0gVxNToIIe6mJv9RM707JMVeULGH8z9UiMGxj5Iob5qrKKcOs3emzFm9R798bPp0YEKq kxwUh+V/CY6tByuxkIhmGVv9OB89ihTCu8JNRLCaADH9qyi2n3wlBjigXhULneHzIGdp F/0/YMG4amUfZny+uuqA3nPFmY+x7AcykmLHYPj7ADjOTQcRoD/58wH3lepMO6zqgMOg Ztcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7ZxXwSn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUfAFYNv9TbU/vMqGHB7tKavHT+ECLltuYLaMcYYDrnrf84eB9MRzYsYp9pEUSAGc+XmKqiOWkqkbrVm9g9M1K+YFhAww== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v21-20020a63d555000000b005d18fd425f6si1176102pgi.68.2024.02.01.23.12.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:12:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7ZxXwSn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 69302B26C67 for ; Fri, 2 Feb 2024 07:01:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47529487A7; Fri, 2 Feb 2024 06:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M7ZxXwSn" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789770284325749511 X-GMAIL-MSGID: 1789770284325749511 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: 195651 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp252580dyc; Thu, 1 Feb 2024 23:01:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRt4i0lZ1gRRxgHci34wy69WAVs2p/oZlOEyX31yG6MaTCwxd7d5URDV4M8hpKz7CFgsF3 X-Received: by 2002:a05:620a:387:b0:783:e164:8176 with SMTP id q7-20020a05620a038700b00783e1648176mr5068111qkm.39.1706857297771; Thu, 01 Feb 2024 23:01:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857297; cv=pass; d=google.com; s=arc-20160816; b=kVokTL7rHEJoMGVhJuU/IPqFnxTvh0C4+mybqPsToR6XLFp64+TNjuKFCqYiMMPNY6 7DJHWhsIiyxjnccPY/dp0zF5VQe1U5DnOMGeklgLPWOwpY0HwHSoXGY2aI43B9RP2u3V O6YyxViyvo4echPGbefzwrGVfL8SonlYkNoVI5YPcg1mWpfLB0fkzqMA5JxHIvrAIm32 +ptGXgVxUPbUxoisqrG8loMFzgJvU1IK4aLeXtnaX6zNgxb7r4vZtwOU+p1tOQHK51Tt i1G+a6KTascQEqBR3XRTLSMgFhI9OsBy03SBj5JVNzutLOa5ZvCYZXkyeEa2Lnlg4rD/ dXNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=94JIcgIYTHpQNQWSHiSAMm9Ou6JfC/7+3WYuAryyK7g=; fh=I91m2iqfGofKjU5IJmTwqQ5AQYKWsOB7uXMPU0ml1w8=; b=DRpGIIjjIYD9bfOVdzPUpVzZAfLsZ0KKzm+xv9hJiY7CxZcnpHUFXuDVuE8nlnr1zR ZHNuj75xCUHi9/IQNMn/gaJwRxwri7VzWAoX6IITI+u79SHpulxxMCvBM1T64T7n28NF 1N0s7hQvC3ljluV3vGjW/4eLoZ99Bl/h4ktERdhslfkIR1aqA15wbMRiDE8NlicQpZ7B WnpshZQjREI13NS/e3ac2BKQbcnKxTdPCgUZtyKwU0gDOqtCQ1Kdc2r+8e853l1sAZQh o+xttipyLF0Ud5XantT0BeifUWutwAncp1J9I4n8mbkKEMylHObvNHMSOfVPSMAdDFy6 Sf1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TVOV5o6e; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49335-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49335-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXNby8sABMRx9EVSBqG3nQ34MaiY4gL5O20cnYWWnDEFr6hzTxD3iErt5lKKYpJl2wGLmmkWF91LV7zlpB/CsbW3JhTjg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s17-20020a05620a031100b00783dfe9f7e4si1365003qkm.464.2024.02.01.23.01.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:01:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49335-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TVOV5o6e; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49335-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49335-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8E4971C245C9 for ; Fri, 2 Feb 2024 07:01:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E765648CE0; Fri, 2 Feb 2024 06:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TVOV5o6e" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769597492886412 X-GMAIL-MSGID: 1789769597492886412 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: 195660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp257328dyc; Thu, 1 Feb 2024 23:12:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFECbB/YlI5CJ1QAvnFYfUWBntyaUJCWC56eGwPC8/4PFVtlzIpL2tbvRwD7Bt4jPM+/nJG X-Received: by 2002:a05:6a00:998:b0:6de:5e6:8ade with SMTP id u24-20020a056a00099800b006de05e68ademr6005789pfg.24.1706857976967; Thu, 01 Feb 2024 23:12:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857976; cv=pass; d=google.com; s=arc-20160816; b=EWRQGECXykfRKvLBnrPHP5GvUwbmtPDZ1CPe9p7BFiJCkh0ei8T+I6Ap6W7lTD9hSJ KiYb0uo8h+XszF0L/X9T/StNN/7k81m2eaaKosfQh6mhXayfYc5C3dAx0hoL/x+s5ri3 /YMlnL2/tSoPLk96LMXR44a0zI2evr77bspXW51xNt+9BfoFfAYh4HMJtiDq+scJvemz X6IUMHYN/nV8FP/Nn8EGm1DG+r/F9Kj6y2MvMQnLPB7wLUvfiYkNPJovHwUn0Wm6wl2/ 11PGWBjfKuPnmJjqPHGwVn8zpNy9+unQ4d3oEtpTNApWYzC4E45ZSg28/hULL8nf9LWX zY3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZWaD/TyHqTp4VyBTGdVfNeD+T9ZNAlHguThnM0xdAaQ=; fh=bTsEjx7RqhSxBtiNlZNvdzsG0d3YKFYZ+QrQ2uVQ8d8=; b=bhlCQMSt/ETZptv0gYkzCyF9gKO4aOrX8m4APtbthmwOMA3a/U6Uzt2yGyWcSGx+S+ 4kpY6HyY7idmnVNry1eD1hvVpBRWit843K3f7P0gRmZAKZCmj3bMMcAXXd14VLbWnMcl XLPFp8TXhUx4TIXNWJ4qilcCwBPla32wQmbSz1MtsGl4pQ1D9ryMVcHEZsTu4q4by21S jAD0yQXLBbGrQPWp+WI9clARjhP6Vft0DWvQ2VjKIsDKNVyY1zTDfzM924KVhredy9yI sUGBnV9r2WHmYCa2In4PfpB8Ss16OFG0v4EUweBGAztGu+ZtWpSMhR8BFY6TKqpUBcF+ EYfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oKsN4Buf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49336-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49336-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCW6timBq/BuyIkzGcn5F5Cpbx3LtLCCpbqKNXK48nnk5xe5b+2z4y3z3bmm4EG0kkBupoPyPxq6d9pqkv4Lfob3BMT0EA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q7-20020a63e207000000b005d8b6af16b4si1119754pgh.577.2024.02.01.23.12.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:12:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49336-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oKsN4Buf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49336-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49336-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BBF5CB27095 for ; Fri, 2 Feb 2024 07:01:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58CB24A9A5; Fri, 2 Feb 2024 06:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oKsN4Buf" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789770310431921180 X-GMAIL-MSGID: 1789770310431921180 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: 195652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp252807dyc; Thu, 1 Feb 2024 23:02:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWGq+ckil6vImlZWUc/QcisuDYs/X7BNZxjt3BtzCADK5v0rUNVtRwnR2pGURvoAinOwQo X-Received: by 2002:aa7:c45a:0:b0:55f:e8b4:4f7c with SMTP id n26-20020aa7c45a000000b0055fe8b44f7cmr648113edr.5.1706857326121; Thu, 01 Feb 2024 23:02:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857326; cv=pass; d=google.com; s=arc-20160816; b=d3f9jUEB6Z6fXdvHMloz0C3oExmvoL1XDSSQGpK4FUF+NZWpqEZ19iLAcI0rwm/lJ7 wnTtzeby41jA1LCkKUJAZkmwkMasuXVfk73FrVpii9A+/oeOl0kr0KvBKG59iciDJ9j+ xxtyBjrt3tpQIxCCsyeyWg0AadXlYWfPM8h+Aa9CNL4wmjaTiwOHYqFgxF3vvyrA1BwX 2ELZSb8PYjfCsKjzgQSTBz+7IYDIqnNlg7f4pT8jKDBfcZza3RrEQa59y/O5/xY5LXfG y5R+qschzEc6vbCa1p1hT97EN783bdDQTKCxpj9CJ69aFyzl6Zms98Qke8KhEztSyx2h Llvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mbspxjfCNfqG09aFBHiQjPC51Si3kPWftNnuNdV5oP8=; fh=H1sUvTr4jRePQa7FbR+hFUIg9DpoaYKZhK3j33saWfs=; b=udztBVcT74FL8ufI5hcCwVbiQajyaSesdMq4IVaRsBSCOT1lcoCm83JtsZWjCoyc3g 0ZMo3Nz6pFKEoDDPAc6rlKJ3ZEUgiLPHAJ1fUk4XLmy7mbbjLa9wy1wyepld9T0MmUbj 8yqOAtoLk1Ppq1u7+5GufBqSNCj6m4nBJTGqk0LdRpAA/zPh+0vjwMakljrSvhi+oEbD vqR10gtKm53FeMFtenGV1HlE6y99nhdcj2K04c/DzpJci4WOm8aCDm8Z7905/zpsneCo L/oAvXYpX37wuOyqg+Xae1PHoo86qCmbp9dJaYKscR1xrbXdMfQmQbftKVWEkbCJS3eh bPQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lghqeEoq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49337-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49337-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCU+dFJ8NRxpQXtVKk/ZbD8IRQwwExzb4Mi6KP4Zelpg2qLCwsfVNoeU9tZlFvCHtK10WZEhpL+5yzng2W/5mM24CTWh6Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o17-20020a056402039100b0055f2033af19si539243edv.607.2024.02.01.23.02.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:02:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49337-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lghqeEoq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49337-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49337-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B4C1C1F248FE for ; Fri, 2 Feb 2024 07:02:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D8DE17996; Fri, 2 Feb 2024 06:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lghqeEoq" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769627958590490 X-GMAIL-MSGID: 1789769627958590490 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); From patchwork Fri Feb 2 06:56:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 195653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp252875dyc; Thu, 1 Feb 2024 23:02:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IExewogbvwTEINJ3Wt8npj+4tHu3W9ssvmSzKsJnYfrcFqRdRwOuFZwx9O8E5g3o+flTjgx X-Received: by 2002:a6b:d910:0:b0:7c0:3441:a7cd with SMTP id r16-20020a6bd910000000b007c03441a7cdmr1405099ioc.0.1706857332926; Thu, 01 Feb 2024 23:02:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857332; cv=pass; d=google.com; s=arc-20160816; b=l15Mz0Nggmy3YDY6XTgWgJfv6wDMzhOCX9Vl8wh5+F4Zl7sM3hoOliU9evdySV6kdN uc2Oi9XtilN5mkRiky4ohS63iLCH0lQHfUfgZ0EESk4U8eLGbHzAXIXBhIQTxFNY85hU KQ3Mm9oBoTsYYR4lwAkVfC59JjKNZxhr4Vc2B1H/3hkKrUfCIVZmCvMhILmio5perhmI 9I0uJJRul5V6h8t9/ByMitOkGBtSTRM+WF66qa3ydrGsfKn+EnDcAhk9yULyCAc19xva nLr2FkuYmw6hwPSA/Hc7NCqm6GcziNdNRMKH/5ojbi+U5SBGEXzpZBG6OclBzvZPqwks htfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ci6Q85DG+4I/5ZY4IFhwMXUeIWUvTs7tkOWuok6FjaU=; fh=Os4RYsKyMNFlnOEZ7UIhGsSEuf0OVXcHQSO2hAkOfBY=; b=zVt9Dnn3MTxT8iwqY0aZzl+3BeUAN0DhlBRrwBJvuJ7MCoS1cuRB6QQuO+nnh+dZW9 mJfMal0ZaTBDXjDYu7BAxFcDthRQ/vzWDMR5w/mssIM4He6XJWCbBHzDu4F0B+hz/VxR Gft+m8jCrt9cv4Q2KIZygS+tH4RNjt5cK+gFwa3XxsvI7sSdZlDLWvsQdeO6WXKc3ME/ d3MoR3jtrfXJW3Q4IvlXFk1NTuVihfldr1igGcAtgJh+ucNoyD5uGJ1jTCO54IQpBO5T kT1u5qslF66ZP95i486zyIjRp6HW0W0vyUlga22EZLGv3wrXblD7MqIDxoyTSmxG/C+y atXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VVU03+NQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49338-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49338-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWVRsxSciY/MRMhaRgNmEPkmIeiXrZd2iYtntOR5kKTgpW/dUTpc6JsEL5IFMMdeU/jusVNFjPql+lLRKWmXvhIuouamg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l32-20020a635b60000000b005d67007b43dsi1105936pgm.571.2024.02.01.23.02.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:02:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49338-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VVU03+NQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49338-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49338-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9F57C292D26 for ; Fri, 2 Feb 2024 07:02:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A28E4C62E; Fri, 2 Feb 2024 06:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VVU03+NQ" 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 42F404A99C; Fri, 2 Feb 2024 06:56:45 +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=1706857005; cv=none; b=XEwTG77xSOmKXNIClABx8AqQytHy53JvUP2v2YcolD/q3DEGFWZBHTdwKNrcKWtxFo/SCiTROgsQ04Edr/cEY1vVtyZISvudcseYlMdCovw5LdL06TgHOKGtn/VTmWWem1zvQrlQ055HjRquhc16Z7YhZjwNtkcL05zmtoGhZ9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857005; c=relaxed/simple; bh=iv8M0VVwLR+J8qViltmqr1VCLaV0asCVn17nf33N41A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sMDTyKUQ0RT1lyfsdCnwYQdmItEpqTjNCT11ScuzEmCKIBDxcM0WGMzwS26tGcpGB5tLdo9KkEsJS7OVnBdzVWwuJMvt+CfzhqSeZgRforlv1UrPl9skF4NkpGmC0xzHCe0NdzWOWLqQbq/psqxjen976CnVPiCki10LZ8sm9I0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VVU03+NQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CE8EC43394; Fri, 2 Feb 2024 06:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706857005; bh=iv8M0VVwLR+J8qViltmqr1VCLaV0asCVn17nf33N41A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VVU03+NQ/chDLzbyR5IiLeEN4h/MMNrH/Xg9npNv6ZyjaMiifhgyZfHCPrdeTo9JE S0EYRGPIfAer8r4tnag5qldCgCAQUoYzKsywp3yVYSUUC4G1y+h5bEiLil9xJKH0Yj oKkQRqeJM5fTKsH/nHXQzi8P26yduZ+F8kVYPW4U4nPTMIQ5s1+UEohndlKpl8UGSa 0Qy2MsSxSAOolhGpoKmTQNMTZimrcXSsTTA4XVvZeYV37QZKBCbXpbiBOmEO+KKNE2 ls0QwF+w9d4k5wvHbaQVW9dNh7CP31mZQ4NohYCBXdes1gHXm3lhOFGgV12mXgnojm plKK+hLt8f1kw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 22/22] tty: vt: decrypt magic constants in vc_is_control() Date: Fri, 2 Feb 2024 07:56:08 +0100 Message-ID: <20240202065608.14019-23-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769634556340706 X-GMAIL-MSGID: 1789769634556340706 0x0d00ff81 and 0x0800f501 are bitmasks of ASCII characters. Spell them explicitly using BIT() + ASCII constants. GENMASK() is used for the 9-bit range in CTRL_ACTION. This also modifies the 'if' checking if the masks should be applied. From a "random" ' ' to the actual size of the bitmasks' type. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index e35f7a31a7bd..463be4e48dc8 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2893,9 +2893,13 @@ static bool vc_is_control(struct vc_data *vc, int tc, int c) * as cursor movement) and should not be displayed as a glyph unless * the disp_ctrl mode is explicitly enabled. */ - static const u32 CTRL_ACTION = 0x0d00ff81; + static const u32 CTRL_ACTION = BIT(ASCII_NULL) | + GENMASK(ASCII_SHIFTIN, ASCII_BELL) | BIT(ASCII_CANCEL) | + BIT(ASCII_SUBSTITUTE) | BIT(ASCII_ESCAPE); /* Cannot be overridden by disp_ctrl */ - static const u32 CTRL_ALWAYS = 0x0800f501; + static const u32 CTRL_ALWAYS = BIT(ASCII_NULL) | BIT(ASCII_BACKSPACE) | + BIT(ASCII_LINEFEED) | BIT(ASCII_SHIFTIN) | BIT(ASCII_SHIFTOUT) | + BIT(ASCII_CAR_RET) | BIT(ASCII_FORMFEED) | BIT(ASCII_ESCAPE); if (vc->vc_state != ESnormal) return true; @@ -2912,7 +2916,7 @@ static bool vc_is_control(struct vc_data *vc, int tc, int c) * useless without them; to display an arbitrary font position use the * direct-to-font zone in UTF-8 mode. */ - if (c < ' ') { + if (c < BITS_PER_TYPE(CTRL_ALWAYS)) { if (vc->vc_disp_ctrl) return CTRL_ALWAYS & BIT(c); else