From patchwork Thu May 19 08:18:05 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: 12854651 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 6FC51C433EF for ; Thu, 19 May 2022 08:21:02 +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=iZ/Wj4XkSghI+c vw/Q5cnjhY/rUvutXwxpOtAtO6bG3vpXgdC8f2gfeam3sI5cAy7wx/FvTJUAmb5WrDLda8nX835Gp mPcHEJ9b4Xc65MMSDXoBRc43FG2xrhapQUQJ1FPgkJjxsPYjY9buMPvnbTlxA7u/TUoQR7HgFhiAU TvliEI4cTWHGeHqLYOEtDBn8g6iaz8FaTXgSrvofZDOKL+3CYGXftEIOMKZXOBpdTvMfwWKNAkTfM Evr9nHTiGy17WvRQ0BcuF+F+sSX4PA0eHw5CJBse2ep09F0ea6qvEhbzM/JuRfD9TUuBIVys/aPOu VzTmGMu8Eys7lw5Y5jaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrbOu-005mE0-RE; Thu, 19 May 2022 08:20:52 +0000 Received: from mga07.intel.com ([134.134.136.100]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrbMs-005krz-EK for linux-riscv@lists.infradead.org; Thu, 19 May 2022 08:18:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652948326; x=1684484326; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3RnQRuR6bhTHb3WuNEk9N0DsLlzhv/5aX1wkEj3xq6s=; b=Pe38nKUvqUGa9O8Grqny5xBwz4UWALdJa40640aobUI9YIvoKIHgPKVq t+yWxdFQwUmZHDt0sOLvrbYkbCTbT9jQqKtitOLKqI8zk/QTU24RpN4/j LOEehbPL3rGqTu3Zy07lhswmXjNKjEBDQCrAzQxnl01OhBSpkn5NZ1fXS 49T2Y64+sjCmyMZSJS3U58A4mQlpMdp7gFjRLX7tUj4r2jN40vR+qu9bH fOpAtX6XcdNhXQt8US/1MJpHuImdGZ3jLeAOQdHSUbUeetuPmZvfDgqUK OvhUIR3oOkfZheGE9yWCDrLfx08Akd3kjxLg0k0bpOIGgkYwPF2SCNFGT Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10351"; a="335135288" X-IronPort-AV: E=Sophos;i="5.91,237,1647327600"; d="scan'208";a="335135288" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2022 01:18:42 -0700 X-IronPort-AV: E=Sophos;i="5.91,237,1647327600"; d="scan'208";a="598431479" Received: from ivanovbx-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.249.33.234]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2022 01:18:39 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg KH , Jiri Slaby , Shubhrajyoti Datta , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 6/9] serial: sifive: Sanitize CSIZE and c_iflag Date: Thu, 19 May 2022 11:18:05 +0300 Message-Id: <20220519081808.3776-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220519081808.3776-1-ilpo.jarvinen@linux.intel.com> References: <20220519081808.3776-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-20220519_011846_611752_423074AC X-CRM114-Status: GOOD ( 10.55 ) 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;