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':