Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp940709pxb; Wed, 3 Mar 2021 21:53:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXRSFRw35bdOIkVbAyiJ3sLtws5TzIbBtI2WPWpU6PsuZk/EkPCPvZPW76ywokMaCgxbC4 X-Received: by 2002:a05:6402:17e9:: with SMTP id t9mr2524269edy.211.1614837209570; Wed, 03 Mar 2021 21:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614837209; cv=none; d=google.com; s=arc-20160816; b=cfYscWG2nh0yxAH8eWj5+DWiNnS6DiF5Gn87q6B6nW2lgA7TyObCNBVwUoGC7Ym8xZ xQm8p3JsFIAZmUqidIbOelQzFP3b6QiutuD+O+DrI1Qu7SKosBCw5edn83prcCbR878n EK6vWeQyTou/Z9e9+c+Xtf2Um0gcVCkRMu77MwqVNGsCZ5PoApmc+dzPJP/XYSAc0YP+ qLI5JIZ7GZGs2PnpkhnPosuW3kxHgPELEnbpdDv20KEzOSHbs5EIFuB+Riu7gf6syxg0 xslOJn7+lcFRbjA20KPkDsIoesVanJ/2bLQfxQcBONGPWVSGY81HsoqAJ1S3CLCewAvO yIAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=T/nfZGhY1qF6rdLEQi36WAMb6T7cKD8zhTlyF4KDSfE=; b=F3CMzsPpNwncu74y8whk3gokvx10yhXqluYKPfixVwz3YmqQ65UiyK6yXLCQdL9ANP HOqXPMK5tt27cCBU9VisnvAbEeq0eLdWxWFCcNFDBWZ7d5IJ2jWdGiyJExTfhGVker3i rEVgxiXGN9gf4taDh1MomZ1xqi0Ek5e2qozcPS0jRzkAJXht+pT0MgPKSd9LC6HtX1Wf 2YFCY/3hc615NF+ro7bYE9YVKfzi/90hMUZryXikl+2WPAmt4cCwj3niottE3XfLWAHA Dohne0Q6O9JmRKhNQlHFw64zDg8QpLqNZTlt3BgpqIH26NLwYnOUPZxy5paeA4+QV80Z aTUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n13si970322ejs.39.2021.03.03.21.53.07; Wed, 03 Mar 2021 21:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349411AbhCBHQZ (ORCPT + 99 others); Tue, 2 Mar 2021 02:16:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:39600 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1835873AbhCBGYS (ORCPT ); Tue, 2 Mar 2021 01:24:18 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3113FAC24; Tue, 2 Mar 2021 06:22:19 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 21/44] tty: jsm_tty, make char+error handling readable Date: Tue, 2 Mar 2021 07:21:51 +0100 Message-Id: <20210302062214.29627-21-jslaby@suse.cz> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210302062214.29627-1-jslaby@suse.cz> References: <20210302062214.29627-1-jslaby@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code for char+error handling in jsm_input was complete mess of letters. Introduce 3 new local variables and use them with care. Signed-off-by: Jiri Slaby --- drivers/tty/serial/jsm/jsm_tty.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index 512b77195e9f..8e42a7682c63 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c @@ -603,18 +603,22 @@ void jsm_input(struct jsm_channel *ch) if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { for (i = 0; i < s; i++) { + u8 chr = ch->ch_rqueue[tail + i]; + u8 error = ch->ch_equeue[tail + i]; + char flag = TTY_NORMAL; + /* - * Give the Linux ld the flags in the - * format it likes. + * Give the Linux ld the flags in the format it + * likes. */ - if (*(ch->ch_equeue + tail + i) & UART_LSR_BI) - tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_BREAK); - else if (*(ch->ch_equeue +tail +i) & UART_LSR_PE) - tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_PARITY); - else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE) - tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_FRAME); - else - tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_NORMAL); + if (error & UART_LSR_BI) + flag = TTY_BREAK; + else if (error & UART_LSR_PE) + flag = TTY_PARITY; + else if (error & UART_LSR_FE) + flag = TTY_FRAME; + + tty_insert_flip_char(port, chr, flag); } } else { tty_insert_flip_string(port, ch->ch_rqueue + tail, s); -- 2.30.1