From patchwork Tue May 17 11:07:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 12852298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3390C433F5 for ; Tue, 17 May 2022 11:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vn5pieWYvhYXuc62dxONSyFjCQzxkqZK1gLni07Rky8=; b=Jjnzdusq045751 /gQKEcYe5yL/RFOcjNmdgAQ++vt1KQd0MXUWWzkw8onF17IpVqmLr2b9Tg9yHgEk/4sZOP+fTZAw9 NtfGHIg/lEIHw5gjitcYEc30ju9FOgCZT8nr4qfnW7AHw3uhUVEAYIPf1N3exWnVUEzJFZgr6FAjS pfxyheV+0MGhbBLntcBrS9xLee4sXo3MP4y62RM7VlDakkh3Yw3ac5GPYgtG9Nw0VNsC/p7QdTviU AuCF/i1Juhml8deGMdxgBBzOuonvFJG1IgizQIIK2lefW2tqmGKYoPvp9e23HLthjrt6s5+C4kH1E S0h8k0pQUW3mEk8G71Yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqv45-00DHcx-Nn; Tue, 17 May 2022 11:08:33 +0000 Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqv3q-00DHVG-NT for linux-riscv@lists.infradead.org; Tue, 17 May 2022 11:08:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652785698; x=1684321698; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3RnQRuR6bhTHb3WuNEk9N0DsLlzhv/5aX1wkEj3xq6s=; b=DGmrsPiS7fkJXO49MlbQIamTNA4ChHVj4iEoFbzYRoTQKoAA8h/pG+0a SDj1JAsD06QX5EChO3g50Nloor/loGFtjq4PT0wLxFXq+faxGmVrds6KR 3iiEdxxrEftfti4xmzz0cMDgfzk+VNgUwSjlGZP9NVjS0buB/WddREx8A MGarZdX+b3gK1E0R1Zp/FkHZxWfX6Orvyk9qflkPGJJYHNzeGdrMzb80q zSyuOvXMWUfcYUskBELUp9o0arDzPubobwT1i0HJO6UIexbwTP+XjGgf1 q6JQrk8HXYx+UCxVBSa8rloO5O4DGGyuhoZeLkfyNdkKTOZPv8VNSwlsn g==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="251658937" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="251658937" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:17 -0700 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="568831099" Received: from mtarral-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.52.88]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 04:08:14 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg KH , Jiri Slaby , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 6/9] serial: sifive: Sanitize CSIZE and c_iflag Date: Tue, 17 May 2022 14:07:34 +0300 Message-Id: <20220517110737.37148-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> References: <20220517110737.37148-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220517_040818_829114_6341BFCE X-CRM114-Status: GOOD ( 10.13 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Only CS8 is supported but CSIZE was not sanitized to CS8. Set CSIZE correctly so that userspace knows the effective value. Incorrect CSIZE also results in miscalculation of the frame bits in tty_get_char_size() or in its predecessor where the roughly the same code is directly within uart_update_timeout(). Similarly, INPCK, PARMRK, and BRKINT are reported textually unsupported but were not cleared in termios c_iflag which is the machine-readable format. Cc: Paul Walmsley Fixes: 45c054d0815b (tty: serial: add driver for the SiFive UART) Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/sifive.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c index f5ac14c384c4..c1c0fb9c1822 100644 --- a/drivers/tty/serial/sifive.c +++ b/drivers/tty/serial/sifive.c @@ -666,12 +666,16 @@ static void sifive_serial_set_termios(struct uart_port *port, int rate; char nstop; - if ((termios->c_cflag & CSIZE) != CS8) + if ((termios->c_cflag & CSIZE) != CS8) { dev_err_once(ssp->port.dev, "only 8-bit words supported\n"); + termios->c_cflag &= ~CSIZE; + termios->c_cflag |= CS8; + } if (termios->c_iflag & (INPCK | PARMRK)) dev_err_once(ssp->port.dev, "parity checking not supported\n"); if (termios->c_iflag & BRKINT) dev_err_once(ssp->port.dev, "BREAK detection not supported\n"); + termios->c_iflag &= ~(INPCK|PARMRK|BRKINT); /* Set number of stop bits */ nstop = (termios->c_cflag & CSTOPB) ? 2 : 1;