From patchwork Thu Jul 4 13:00:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11031461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1903B14F6 for ; Thu, 4 Jul 2019 13:01:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0564128751 for ; Thu, 4 Jul 2019 13:01:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8AAB28992; Thu, 4 Jul 2019 13:01:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C68828751 for ; Thu, 4 Jul 2019 13:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e4F20iVqNw1g4Qo7xiiqPyH7pwa1LPvq0hl32V/qHeA=; b=DI8EaW5PZ5G4nI DAL2VIUfFbU6bjNM+f1L9G6UeYqj7QI/jOQh1QsGA6T4IKXhZtsmdo1FSisf+xcXKuI/D4BCzgqQs iKPEbkPJHt7GTZUy5U1CJn101snSmo/i0cJGx57aNWKR2wfnlMnZDh6coPwvQ7M6HhEGPhtvug2/J KY2PRhE+p3tm8C4E/k17kXnTasl/L/8VldkugBfO0SQKj6TBdT88KOVeWVcngw+Opy8s85IRUIdUv Ycf4XHf7f1oPV43zFnaU3pnn6Jn9jC9BWIIklowolLYThARDa+QsgjFVdJUlyuRwr4Kw1sdGnok4c vWeWdge1z3OjN+OFM0OA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hj1Ma-0000GI-0z; Thu, 04 Jul 2019 13:01:24 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hj1ME-0008R1-NH for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2019 13:01:04 +0000 Received: by mail-lj1-x243.google.com with SMTP id 131so6103831ljf.4 for ; Thu, 04 Jul 2019 06:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bILvk7zww/MHzS0Ry8ydW5zQpvSdBYxtDr+zE8tM+sU=; b=jMNp8dC0A+sar0j+Ndv2aZcg+m3SjKWN/qql2KbBPlRWm3MHYJ8akksCCNPYMD8J4l 4OPaCADR1zli5dsaAtbhCQFInApBlhTWZVZWUyGWgByqiH5/WIkVE/E/r65y9UlAYyCp cEGYQ2Fz27/v/Y6QegXtdZFNfg6XEyTzebOIe0OO/2xKABH9tD1UQJbDPwXD3wQ71wqY 2/nhBLK5ntmjo2Ubnf5i6xQi7ZglF7sIHR5IArXx4eeCG4OwmhYKnMn+k8hVtdhn0eWi M5DQ9Z0ET1yMFygcSBJ73IKC2JVjIatVm8U60D9Bvzx8GDItnOPCJtwcfmo4H+vlQI36 NInQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bILvk7zww/MHzS0Ry8ydW5zQpvSdBYxtDr+zE8tM+sU=; b=KwtZxOjAYGTXB8YRx1Vfy/x2kzbPtWBNhCfJp8XGkTJfBE6Q2Ucu1Cb1rjoMvXf/mv RrdxwC/Oy8WrYFffFYw8fQrcF++OdlaUGn2laGnAP6AjDa8sMGtiqK5f9uetpTNORlix d7gnrquOBJ8zZbAIPd8FFGuzDgx4jiRRImjMvR66jk4K+dDJ0sbNOd7liN4XoC5BsUQh IjkAno8eogqXNDpR2seQbo/m90bDxBCJgqE0JAlPKLxKIp5OhuSAKKQ4kBH6ajXtBQQK NRroQUdlONKc3aFQxwaixcb844KpJMCyt+5SPjRIU6pJsFdi00E8pg1J4PU7Nk0zkciL oSSQ== X-Gm-Message-State: APjAAAXuikkrRhbActm/gszFurb2x1vr9IRM7yUP5gDoT6C0nVuaK0aS RMge8N53AJTh4IuBFXeS5RKDJ8M1 X-Google-Smtp-Source: APXvYqwqe6vwvjs4G2dhy4KMCh3DxCD4S1TAcq7FkC6YdKvcUHqEmzDueEOmUFZoOHStbQl7zawztg== X-Received: by 2002:a2e:88d3:: with SMTP id a19mr11892513ljk.32.1562245260861; Thu, 04 Jul 2019 06:01:00 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id h1sm485914lfj.21.2019.07.04.06.00.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 06:01:00 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v3 1/7] serial: imx: fix locking in set_termios() Date: Thu, 4 Jul 2019 16:00:23 +0300 Message-Id: <1562245229-709-2-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1562245229-709-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1562245229-709-1-git-send-email-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190704_060102_757255_4713756A X-CRM114-Status: GOOD ( 13.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Sergey Organov , NXP Linux Team , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP imx_uart_set_termios() called imx_uart_rts_active(), or imx_uart_rts_inactive() before taking port->port.lock. As a consequence, sport->port.mctrl that these functions modify could have been changed without holding port->port.lock. Moved locking of port->port.lock above the calls to fix the issue. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Uwe Kleine-König Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index dff75dc..1055124 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -383,6 +383,7 @@ static void imx_uart_ucrs_restore(struct imx_port *sport, } #endif +/* called with port.lock taken and irqs caller dependent */ static void imx_uart_rts_active(struct imx_port *sport, u32 *ucr2) { *ucr2 &= ~(UCR2_CTSC | UCR2_CTS); @@ -391,6 +392,7 @@ static void imx_uart_rts_active(struct imx_port *sport, u32 *ucr2) mctrl_gpio_set(sport->gpios, sport->port.mctrl); } +/* called with port.lock taken and irqs caller dependent */ static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2) { *ucr2 &= ~UCR2_CTSC; @@ -400,6 +402,7 @@ static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2) mctrl_gpio_set(sport->gpios, sport->port.mctrl); } +/* called with port.lock taken and irqs caller dependent */ static void imx_uart_rts_auto(struct imx_port *sport, u32 *ucr2) { *ucr2 |= UCR2_CTSC; @@ -1550,6 +1553,16 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, old_csize = CS8; } + del_timer_sync(&sport->timer); + + /* + * Ask the core to calculate the divisor for us. + */ + baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 16); + quot = uart_get_divisor(port, baud); + + spin_lock_irqsave(&sport->port.lock, flags); + if ((termios->c_cflag & CSIZE) == CS8) ucr2 = UCR2_WS | UCR2_SRST | UCR2_IRTS; else @@ -1593,16 +1606,6 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, ucr2 |= UCR2_PROE; } - del_timer_sync(&sport->timer); - - /* - * Ask the core to calculate the divisor for us. - */ - baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 16); - quot = uart_get_divisor(port, baud); - - spin_lock_irqsave(&sport->port.lock, flags); - sport->port.read_status_mask = 0; if (termios->c_iflag & INPCK) sport->port.read_status_mask |= (URXD_FRMERR | URXD_PRERR); From patchwork Thu Jul 4 13:00:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11031463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B8F014C0 for ; Thu, 4 Jul 2019 13:01:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AC9328751 for ; Thu, 4 Jul 2019 13:01:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E62D28985; Thu, 4 Jul 2019 13:01:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AD56228751 for ; Thu, 4 Jul 2019 13:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YA30sIiNvmSWGtRqBa/PSujN7iYxEIV43ugThvZYHAI=; b=TAJnVXGAum6PTM Iqxfmu0rLLv1/iycAwYt9anHX1/Jdstk55msm9iP8IF0V/+Hm52JJqRcE9JktrHA4Ye79NTqBpccg DZ6XaTaG4DylqTNb4jOQ58FkMGH1ff/GgDQZcfW5QpGhhwrxCa/CDfsGTNNG2PEnJ2lDBwOxsfkAc 2P0ySk2jma8Kd6vgPTsaXJq1vlBenj+M6mabS8w+tnoEID1fibH8BmMYHAxTWmTOhP4uITC47wljb r31ftY4nUP8V0G8oYaI2/Ln0vXpqokB6XmKAnepXt+gqJI0T8uPJw4/ZL1Wp8UwB5Wo/fXgAy0c7W y0akhiaHShFf5Nh/xFVg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hj1Mr-0000bJ-A3; Thu, 04 Jul 2019 13:01:41 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hj1MF-0008RV-Rt for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2019 13:01:05 +0000 Received: by mail-lj1-x243.google.com with SMTP id a21so6102449ljh.7 for ; Thu, 04 Jul 2019 06:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GovB0KsV809AJW6tOWDxmHhyRG51oTvazg+HECC24X8=; b=vEPEzke0valyfsuQGRkaINfMgvEaL34LSMeazDtcXBSYIsCUjHGDkIqdV4AqVexD0i F/fHwh6MgjNiSgtDccaDE+5JLSt9ln98xz4GiS83kd3KE0njPccfsRa7fEUM2jJLkvFt p96cFAXbhspaBGyfBp8mKKOLQHx4uyo5AdFw3WwheZGg3LFIeXfH2zdactpZ0v6r4WNN 8CsLtStxKemadRcE4jf8tBU4pnVXBb8VYSXRWtvtCYMB8RpnyQ4WpN28rNZqn8Bsd+AS Q+KWDdp6uiKbsmPTnEBBcvlkhi6bJKtLyVJ7GYMtsLTSwObZefpsnCsUsIpXUqHJxJdT GvGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GovB0KsV809AJW6tOWDxmHhyRG51oTvazg+HECC24X8=; b=RXEH9ebgQysyRRu0iLZa+IewGCs0dZhmNilQftkWP50KLNcwA9MQ6iJNuyzqpUXL6l YdX0TsPkWa+GR7ORph6JB74B1h1cNMWuD4eZkxYv/sakNelQpDEooO6PTdFrlyZBeAKJ 5I5h8etGRWMeO9PKf5q96/6cEfyLmRRHjd76UdnGwO6cWrgNcbWxGSUx8fHuJbFyBD2A TslKmrsLR2unbgfLGNSyODmsV998QsQIoNqHpFau41Ob/Ecv6hw91FNQwlEZ7dD+OYdM SGzCR/7gW9mQkAmml7rHeYQSHq5tLqDzr4jF0oKr1uDrMpxEZ5n5q0H4KVrseSfOzJhh KV6w== X-Gm-Message-State: APjAAAU5isHz6p2RN5gvLaVq+55nrrbgCZ5gyxYdET+hN/4Pn8jM2PZN SrqcOkxKNDRU+DrYxUirfRw= X-Google-Smtp-Source: APXvYqwJ2WjaNtVJPAJY+EIZRKqqbDSgCqxD35lCya0AJ5Yf6vXOpOTzZ3tP361M9YOHNH7dyQnfgQ== X-Received: by 2002:a2e:5d46:: with SMTP id r67mr23597540ljb.187.1562245262585; Thu, 04 Jul 2019 06:01:02 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id h1sm485914lfj.21.2019.07.04.06.01.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 06:01:01 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v3 2/7] serial: imx: set_termios(): factor-out 'ucr2' initial value Date: Thu, 4 Jul 2019 16:00:24 +0300 Message-Id: <1562245229-709-3-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1562245229-709-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1562245229-709-1-git-send-email-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190704_060103_902113_184D2FB8 X-CRM114-Status: GOOD ( 11.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Sergey Organov , NXP Linux Team , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Set common bits in a separate statement to make initialization explicit and not repeat the common part. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Uwe Kleine-König Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 1055124..87802fd 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1563,10 +1563,9 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, spin_lock_irqsave(&sport->port.lock, flags); + ucr2 = UCR2_SRST | UCR2_IRTS; if ((termios->c_cflag & CSIZE) == CS8) - ucr2 = UCR2_WS | UCR2_SRST | UCR2_IRTS; - else - ucr2 = UCR2_SRST | UCR2_IRTS; + ucr2 |= UCR2_WS; if (termios->c_cflag & CRTSCTS) { if (sport->have_rtscts) { From patchwork Thu Jul 4 13:00:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11031465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22403112C for ; Thu, 4 Jul 2019 13:02:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F0CE28751 for ; Thu, 4 Jul 2019 13:02:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0035228985; Thu, 4 Jul 2019 13:02:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 88D7D28751 for ; Thu, 4 Jul 2019 13:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SxLG6zqW/wKPPMG1+pRHS0PzUUnu21pIZg6NkOjRmZs=; b=cRjmuUfQ9kKCg/gvWbv3C4rkNi /kBqVXtHxtbVn97GP10gLd+B2uss4Yh5yjH+QMCcMtk0o3738knGw6Poh8+154d0GVNqTuIcXovd4 TMM0TyB4joCW8fCKMQ+JKlOaYXbUJTxZ90siP1Mk1z7A7bI83D3jBlZQfu64m3yEOWO7dYvDUa9Bl JUbsiWUOoEn8LAKXWWl8dmYnaAkETmNWhLojyDIubFvOY3xBchwMjOrnXC2ZlSL1PXLl5aLaL0kKS 9KnFDsW4H2LVzOGwFKZC4SznKQjzBuDQ7aQ8jVynZQerkvWeUhHy4f+f3ED3qOHA5X1ziHmjlrv/i PbCoA5EQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hj1NC-0000qk-Pf; Thu, 04 Jul 2019 13:02:02 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hj1MH-0008Ry-BP for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2019 13:01:06 +0000 Received: by mail-lj1-x244.google.com with SMTP id i21so6104517ljj.3 for ; Thu, 04 Jul 2019 06:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mRhyyilptEVPd04WdgykTEukksr9XwSZnIYd4NBzYsQ=; b=J7KeLt9OoRCHRueMSXq55bYbYpg435r4HjpO3mod8gVs264oODuzbDV2uOxjOUjZrX vq+AYm1ZD1zH8BGE/uslpHdEclofsB+OkC6tEFNZUOdPrJ4kNElarw2AJdQLgRAeczH2 bdxKW4XG6LwXaluA2MB+kzUfBvP24rWAqPO9ztViv88Pjq+URYQhQFnbEt3YZ3pJbSlr SPZki8PWWeU6Oyt7SR30UXsZF/A4CKPi85oij/tpM0M0Qf27ajXUGzc1cCozt9sBo5Yz 0X3Vz7IryZllZj6wzhLW3GbltoEWlYTMb81J+gE42XbMuUwQopDEx5nhmLcUH0PNMPVS Tgaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mRhyyilptEVPd04WdgykTEukksr9XwSZnIYd4NBzYsQ=; b=GW/uNK4F5j3vjzcOSki23k46/FygLul58VQfmq/9ffpjhBuKy2DeDpKp8oGmf5Rohc OaQNO7M+LkgBqkeaKuBZcXtHQqUsSbbBk6QLgWGxSSbc1ClAtuLL2L7LDbYrwx+UAjiX dHDqCvqkExHOgsSzdlfTZ/kwbzX5ccRuykccIXF0WC1kpRzGPX92wttEHnsWbz4SGDBf 4KNYIFp2N87HSgG7QPdp4IIb7YH3vXuZQKgiAjEKWepgPcIFovl1vq9QCUyzRko/8+NZ obQVfW5WVOpjcf/eCTOlWh0zdxUVGnlf90nA70CfzonX/niLuG9DZXgnBn4/5vXOZwdr aMhA== X-Gm-Message-State: APjAAAX0yTuY4gKFu7ozYUmZGHYtyw6UpKlYmxoe3uIeMXS0HQVihF/Z ZdvjTcE+T5xwFnlb3SokYT0= X-Google-Smtp-Source: APXvYqwn0RtHcAtS1iKLqSBCZklPg4z5nGhe97iJgNmJX3SuE/EIAWq8RKtGJIfGjyD1ED/O6ptXsQ== X-Received: by 2002:a2e:864d:: with SMTP id i13mr23876453ljj.92.1562245264059; Thu, 04 Jul 2019 06:01:04 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id h1sm485914lfj.21.2019.07.04.06.01.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 06:01:03 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v3 3/7] serial: imx: set_termios(): clarify RTS/CTS bits calculation Date: Thu, 4 Jul 2019 16:00:25 +0300 Message-Id: <1562245229-709-4-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1562245229-709-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1562245229-709-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190704_060105_416650_648E718E X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Sergey Organov , NXP Linux Team , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid repeating the same code for rs485 twice. Make it obvious we clear CRTSCTS bit in termios->c_cflag whenever sport->have_rtscts is false. Make it obvious we clear UCR2_IRTS whenever CRTSCTS is set. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 87802fd..17e2322 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1567,35 +1567,25 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, if ((termios->c_cflag & CSIZE) == CS8) ucr2 |= UCR2_WS; - if (termios->c_cflag & CRTSCTS) { - if (sport->have_rtscts) { - ucr2 &= ~UCR2_IRTS; + if (!sport->have_rtscts) + termios->c_cflag &= ~CRTSCTS; - if (port->rs485.flags & SER_RS485_ENABLED) { - /* - * RTS is mandatory for rs485 operation, so keep - * it under manual control and keep transmitter - * disabled. - */ - if (port->rs485.flags & - SER_RS485_RTS_AFTER_SEND) - imx_uart_rts_active(sport, &ucr2); - else - imx_uart_rts_inactive(sport, &ucr2); - } else { - imx_uart_rts_auto(sport, &ucr2); - } - } else { - termios->c_cflag &= ~CRTSCTS; - } - } else if (port->rs485.flags & SER_RS485_ENABLED) { - /* disable transmitter */ + if (port->rs485.flags & SER_RS485_ENABLED) { + /* + * RTS is mandatory for rs485 operation, so keep + * it under manual control and keep transmitter + * disabled. + */ if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) imx_uart_rts_active(sport, &ucr2); else imx_uart_rts_inactive(sport, &ucr2); - } + } else if (termios->c_cflag & CRTSCTS) + imx_uart_rts_auto(sport, &ucr2); + + if (termios->c_cflag & CRTSCTS) + ucr2 &= ~UCR2_IRTS; if (termios->c_cflag & CSTOPB) ucr2 |= UCR2_STPB; From patchwork Thu Jul 4 13:00:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11031467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 961A4112C for ; Thu, 4 Jul 2019 13:02:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83DEF28751 for ; Thu, 4 Jul 2019 13:02:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 777BF28985; Thu, 4 Jul 2019 13:02:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2134B28751 for ; Thu, 4 Jul 2019 13:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=w47jJeNj2MXEs/AwY0ZIftgwEXKiPHkXxyL5QsXA9rI=; b=tC9vgNhxzLRPY0cyN4StMtUpwy Ac7KK/HZ2e4BhZ7/lfBfUSjh1zrKhyBe8YzkAj+GJI5Uklp4oWsHxDG/hQ+27aharzqJfgfh8ZsYA qsrm7IE+sPUeV2eLkVofNeqYwlibQMdDUn6MIVS0VN5PbA9Z6fE2AVwgvNRZ1HsSmnVihTr8pYkm6 G5w+YacaMgI2cPcB5HTESvhcavEKiU0m14o0alLre0Y06mOQSWJmZzdGGFRQ3ck2dY6NJFEht3jR8 11Bh2giaBQLDi8ptQ9UxQO/UKtCcKZqnOJLGyXEnyGK2AVYqR382or0oa5DIMaUg8uUnazi7IDO1c MK/fIDNA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hj1NQ-00014o-DY; Thu, 04 Jul 2019 13:02:16 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hj1MI-0008T0-T7 for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2019 13:01:08 +0000 Received: by mail-lj1-x244.google.com with SMTP id 16so6055224ljv.10 for ; Thu, 04 Jul 2019 06:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=942xX7/V43Ir1tZd4dDu7UDtPNxQiTaRZHtBvgqzC20=; b=imkrJQTXeoCo8VKvKTQH1Zi9kdVDhH/6Fx3fbqCpkyMPM0wgU0Pl92amh1sgyMbmMy hYHMzXqjcincO+2Q5AVz6uvhjs3/y+qY2NxNAffVMbGBFPUiGZy7P9dN/upb2tFYsj1T fa8/81F5TuP0VILsBxjglJv9M+BbbXeW1LgKBTMODnZM+C5U4Kfivf8O8tu+VZcf3b3E i1HgLGdovYDFlYijCUh/pEHKJwTlKsJjyz24T25r4lnPiuJBxAc3SXPm0IwY2MgFFevG BeiBMvPVXZtIXN3YRRGX//T5nGdetdZ25iKgkWilaI9nokBzN3XIQaZBzrpy2pyLcLWs /uEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=942xX7/V43Ir1tZd4dDu7UDtPNxQiTaRZHtBvgqzC20=; b=n06DFUmMfPrLg32pEzRGdWK9n6rHEwspxA/jPyrLso6JpHDcFi0/r/e4pIfCy9W41S 5mwDGWxKIUnDleeXvoaSNBUqOwk9H5BB9507t+fIXrzJIgjyroTpUxhQTozzs3rV2eTZ vuGWmk9ZOEXWUX9YhphkUWIuAJsnGJ5cEMztk3JwjgMaxbqdsCfrzdsITYz1hVDf0gpH IvLQ1Gip+xfJYknDezEzUCDQb3mQSIlPwdIR2A2ub0BElCu2q46HxdntAgCNX9saFmC8 7aYKBWttfF5kCMR5y4A2WfpQbyvw0F4EEEE6z6nVVwFWJIhHOYr0op+/VzXTVJ06cSyk Dabg== X-Gm-Message-State: APjAAAWbXVx4RJkB9l0MWJcA9R5Ku+KJZkb6SAhLWlDGQUoy/q3E9gNX HHoruOtuur7ftZ5nyPb0eI4= X-Google-Smtp-Source: APXvYqwWzSpI+jWTSs7/U42qZ07CYj0qsddqPziA/5CTyO80U0gZgQNLmTFWC7Wd20kSqsdhSFw4gw== X-Received: by 2002:a2e:981:: with SMTP id 123mr25025470ljj.66.1562245265485; Thu, 04 Jul 2019 06:01:05 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id h1sm485914lfj.21.2019.07.04.06.01.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 06:01:04 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v3 4/7] serial: imx: set_termios(): preserve RTS state Date: Thu, 4 Jul 2019 16:00:26 +0300 Message-Id: <1562245229-709-5-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1562245229-709-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1562245229-709-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190704_060107_001935_E5EE4F66 X-CRM114-Status: GOOD ( 12.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Sergey Organov , NXP Linux Team , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP imx_set_termios() cleared RTS on every call, now fixed. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 17e2322..e0f5365 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1563,7 +1563,14 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, spin_lock_irqsave(&sport->port.lock, flags); - ucr2 = UCR2_SRST | UCR2_IRTS; + /* + * Read current UCR2 and save it for future use, then clear all the bits + * except those we will or may need to preserve. + */ + old_ucr2 = imx_uart_readl(sport, UCR2); + ucr2 = old_ucr2 & (UCR2_TXEN | UCR2_RXEN | UCR2_ATEN | UCR2_CTS); + + ucr2 |= UCR2_SRST | UCR2_IRTS; if ((termios->c_cflag & CSIZE) == CS8) ucr2 |= UCR2_WS; @@ -1632,7 +1639,6 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, imx_uart_writel(sport, old_ucr1 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN), UCR1); - old_ucr2 = imx_uart_readl(sport, UCR2); imx_uart_writel(sport, old_ucr2 & ~UCR2_ATEN, UCR2); while (!(imx_uart_readl(sport, USR2) & USR2_TXDC)) @@ -1640,7 +1646,6 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, /* then, disable everything */ imx_uart_writel(sport, old_ucr2 & ~(UCR2_TXEN | UCR2_RXEN | UCR2_ATEN), UCR2); - old_ucr2 &= (UCR2_TXEN | UCR2_RXEN | UCR2_ATEN); /* custom-baudrate handling */ div = sport->port.uartclk / (baud * 16); @@ -1678,8 +1683,7 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, imx_uart_writel(sport, old_ucr1, UCR1); - /* set the parity, stop bits and data size */ - imx_uart_writel(sport, ucr2 | old_ucr2, UCR2); + imx_uart_writel(sport, ucr2, UCR2); if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) imx_uart_enable_ms(&sport->port); From patchwork Thu Jul 4 13:00:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11031469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 854BD112C for ; Thu, 4 Jul 2019 13:02:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7319628751 for ; Thu, 4 Jul 2019 13:02:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66A7228985; Thu, 4 Jul 2019 13:02:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F61528751 for ; Thu, 4 Jul 2019 13:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ahdMQP6lEV4tGgnZAaOIIIgU0tFTlg1l0fAywLKsNMU=; b=PyZCi9QgNjHut8F0mCluQVFxbl cM8fKcRhSZAOU6W2F7MlhEsKsNgrIh9VNaKn4vFBVt+jzL92tDpTeJtKem4zXF1UbWFGCWhxmhR1Q VVeJKZgp2xmQRIVRdtGpO3k/YOS2M0COHbUR1ru+SzQo6SR10BAy6dHnCVO8wJjs1F1a79qPIo05f Te5EwnjpEqZ9R7OI1l5J54QeG2ajOsKgkRblRJQ5eKtV1lSXWpcGBtN1HbGkRRQtbDG6s3qNYKD5J RVSE5LwII6xhX7pWzvTmdawWNcH2uFEi/5qLW3sO31KtDmJbmGHWIj71qeiIeLC5XkLOsV+nSLRqy Jm+3Q8lg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hj1Ni-0001JT-Rv; Thu, 04 Jul 2019 13:02:34 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hj1MJ-0008U8-WE for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2019 13:01:09 +0000 Received: by mail-lj1-x244.google.com with SMTP id 131so6104173ljf.4 for ; Thu, 04 Jul 2019 06:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SyDWki8L8NcXuBPDzCdM3r3fpSMLCvKmwBmXWEoRaTo=; b=JgjQ4YYJtuKFcxmWKZHgny5RPwXpt+nC4RcNKN7GHS/mwiaf7JL4ZM9yhTjk6TrdQK 2jlHi6886KivLreGvz9b32HD9aCkjZaLaibFhdk8rWXYYLZAv3t072HcN8z9DejLdDab kuZVMyH+JwwypPNeoh+TrQZiuxyQQt/EbJf/inlcRbXv1u+3xFl/zS5LvV0VNcnSC3TN srRhdLgoComXjILvfwCdtQIPOSaVAaIwU5NoIxjzNC2k4L2gETTfLApcsMA7TCpJ0RFj 12pmiJ6khJ4biLW9Ui8OMZJYaWyoDNjDMEBIxmiSF4mzaDbgYOWPbU8il1Rc5lHZr9jv e/vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SyDWki8L8NcXuBPDzCdM3r3fpSMLCvKmwBmXWEoRaTo=; b=f+dq6o9SovxxDpQY1YwbCgHiCuJDo9jI4QqkEd4G6TlfEmk5K0fAcRJxZsD6IjlIh2 P9UPJARdG5lEPsyLSktSMICa2jvAgHQngMVTZJM4kcwLJ5F4DzWZ+bvd8JxVsBcmGi7g ZsXuDqW2w7dbfDMd8FZ8Ur87+uPZl8bd9arB/E60tXQaf0ffH0bFH5at9A19K62AaxuW E46rX+iqcjsvvqjoU9jIvpbGoHmIDGTYRSo/maOD5qUsfhlRSblMLTl1w2F5beOc8D+8 Lz0sysu1hwZSNFGYoEdaQPHeUjip0ldoQIaT8rBvfYymHx7dvqsYmpt7rh4szQ2WHL0e 7x6Q== X-Gm-Message-State: APjAAAUxxUxpv1LPY1Fsb/z+1YW+i3yQFYrGQEY6pPOCTNrQqniZ1PP1 pSUcBNnvxlCWeYs9659I9CM= X-Google-Smtp-Source: APXvYqyqK8GICe53xP/lgQ6CIujxjkUSwEwiwZV5tINqS+mXysxT97isy6FNRj8B4IC9m+Ngqp6cEg== X-Received: by 2002:a2e:9858:: with SMTP id e24mr24094920ljj.91.1562245266664; Thu, 04 Jul 2019 06:01:06 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id h1sm485914lfj.21.2019.07.04.06.01.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 06:01:06 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v3 5/7] serial: imx: set_termios(): do not enable autoRTS if RTS is unset Date: Thu, 4 Jul 2019 16:00:27 +0300 Message-Id: <1562245229-709-6-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1562245229-709-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1562245229-709-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190704_060108_109339_B6ACD49E X-CRM114-Status: GOOD ( 12.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Sergey Organov , NXP Linux Team , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP set_termios() shouldn't set UCR2_CTSC bit if UCR2_CTS (=TIOCM_RTS) is cleared. Added corresponding check in imx_uart_rts_auto() to fix this. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index e0f5365..5532887 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -405,7 +405,8 @@ static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2) /* called with port.lock taken and irqs caller dependent */ static void imx_uart_rts_auto(struct imx_port *sport, u32 *ucr2) { - *ucr2 |= UCR2_CTSC; + if (*ucr2 & UCR2_CTS) + *ucr2 |= UCR2_CTSC; } /* called with port.lock taken and irqs off */ @@ -1588,8 +1589,9 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, else imx_uart_rts_inactive(sport, &ucr2); - } else if (termios->c_cflag & CRTSCTS) + } else if (termios->c_cflag & CRTSCTS) { imx_uart_rts_auto(sport, &ucr2); + } if (termios->c_cflag & CRTSCTS) ucr2 &= ~UCR2_IRTS; From patchwork Thu Jul 4 13:00:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11031471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3124A14C0 for ; Thu, 4 Jul 2019 13:02:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ED1E28751 for ; Thu, 4 Jul 2019 13:02:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1002F28985; Thu, 4 Jul 2019 13:02:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B25D728751 for ; Thu, 4 Jul 2019 13:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jPLzpknnuc4tvUlnIVKonzGfntCep0z89Q7+WliPvN4=; b=hlpVYaOFZdMpXXxuUScI6HOBRS lKV9EsO3FCohqm2mVK6UO8dC36bpIbP/w8OS5MovWN0ia6GOt4trsyc9bB4Cgtbpv+DumTbQzlvMl cN0Gp1oliUVkEsJqUnYwLWmon/kictOY3cHZmZUxn72yyCYG1oDLxTEp51zUJC1YDxVR3twLwk7s3 gMQLqEu25yYR0QceYhPpmeJnSkKEVWzJjt1/nh7eacVn5rgQCdMGrXaOlA+SYFnTYa57cMM+8oWC6 t3v8+cFzEMen1bEMEewDDWow7AujM/Dcc3dl0clgEwABeThWyfwS3pTw+nsve3AFAF7gsFd/erk6p sbWio71w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hj1O0-0001Y1-RX; Thu, 04 Jul 2019 13:02:53 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hj1MM-0008VS-Q5 for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2019 13:01:12 +0000 Received: by mail-lj1-x241.google.com with SMTP id v24so6072455ljg.13 for ; Thu, 04 Jul 2019 06:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vjqg27zo8GSuJgU6iVxhR1yNRE/ZU22ne3V7jvRsp28=; b=QS9k6FW9w4E7lJVl91rKZEbJwQCPFf4dXHEnx92561O9pq8FV57Bu8VQzOZ+tF3acv HDzFIeV2nfNItPM1raEZQIs/7jmltHT3/csXL89AmcdXvreOTEUFHhhQnnqiP/bVv15N 22h/KyIhu8lHKV8Cf0Qq9A/G3avCLY1DOKN7tDHVmuVTAZdUcpemBdo6hJqt5T8oHiPX tOBCkYMYXDYXW3Kz5NR4VuRhTR7BkcupkchrFvRKaMcKH31jlQGdchMyyhN9e3NzlzrT 810EPE02SA7TXnkVI0WJGJ/93KkoCgVyyuP8dppfZ1DkD8cEQfSXpBT3QT20GrAs8tH8 cQ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vjqg27zo8GSuJgU6iVxhR1yNRE/ZU22ne3V7jvRsp28=; b=gG2IfCMsHinOlEJnidnWdJ/JjiKZsDfLPaqaC13HRYvNJ9ieoas7iVjqySqWIEZaDL kbGnD180qIEsEIWs4wniiRYkEngUvzVJyof/X4UFyQ9qbXkvQXfaDVq8uctURGIpUcvq zUfl4pbUZmdWiM4bmyijgk2DUsuRnjalkUMcdjNFtKkrbzXSGknfh5PPO6M9kIvhmRc9 A1WjbcvU8r2jHLmNOJmJrHFFn6qkiopKCpDLjti/BctDRoyzxD95gL4fOVe73+sHSLzT EaxGcjo3n+1eoXEpfXlujV5ZOc9Yl/ACad3tzjGKblr2Sfd6gNSZOyx2XbYdqd9ar71Q qUHg== X-Gm-Message-State: APjAAAX6tRSraULN4x7iK248tYr1ORFjlgq9YVyIeqSPfLoRAFkEHjDf TnSA4AyXxRB8Z/UUM9ytK/I= X-Google-Smtp-Source: APXvYqy0O6Yaej+AxploccL21axdxsQ4p5RQt1Xg5aioHDDia+DQANIaVf69pxKtMsc+zBt44esfiw== X-Received: by 2002:a05:651c:150:: with SMTP id c16mr8505844ljd.193.1562245268095; Thu, 04 Jul 2019 06:01:08 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id h1sm485914lfj.21.2019.07.04.06.01.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 06:01:07 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v3 6/7] serial: imx: set_mctrl(): correctly restore autoRTS state Date: Thu, 4 Jul 2019 16:00:28 +0300 Message-Id: <1562245229-709-7-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1562245229-709-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1562245229-709-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190704_060111_036950_86D8A3F0 X-CRM114-Status: GOOD ( 14.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Sergey Organov , NXP Linux Team , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP imx_uart_set_mctrl() happened to set UCR2_CTSC bit whenever TIOCM_RTS was set, no matter if RTS/CTS handshake is enabled or not. Now fixed by turning handshake on only when CRTSCTS bit for the port is set. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 5532887..582a3fd 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -970,10 +970,22 @@ static void imx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) if (!(port->rs485.flags & SER_RS485_ENABLED)) { u32 ucr2; + /* + * Turn off autoRTS if RTS is lowered and restore autoRTS + * setting if RTS is raised. + */ ucr2 = imx_uart_readl(sport, UCR2); ucr2 &= ~(UCR2_CTS | UCR2_CTSC); - if (mctrl & TIOCM_RTS) - ucr2 |= UCR2_CTS | UCR2_CTSC; + if (mctrl & TIOCM_RTS) { + ucr2 |= UCR2_CTS; + /* + * UCR2_IRTS is unset if and only if the port is + * configured for CRTSCTS, so we use inverted UCR2_IRTS + * to get the state to restore to. + */ + if (!(ucr2 & UCR2_IRTS)) + ucr2 |= UCR2_CTSC; + } imx_uart_writel(sport, ucr2, UCR2); } From patchwork Thu Jul 4 13:00:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11031473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1257B112C for ; Thu, 4 Jul 2019 13:03:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F40E928751 for ; Thu, 4 Jul 2019 13:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E788728985; Thu, 4 Jul 2019 13:03:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 819B828751 for ; Thu, 4 Jul 2019 13:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=laLkmzvZ8MuZKFUwqSjXip8rEW0md6BM7yZQes3DpZU=; b=R9uxh8U44NSMtj46RYmRNQfiIo rv6tHwEM5KNuFLJyjhP+VOHD9YUe5k+nv7PQcI2+4lSm4UNWxeIuU2IqtwZUZHpcMNHUUhi5kydAy djm59RVAhjn0KVo0hLr7KlQ00jDvfXrq2ZGwrvkj6qvghQetR7g42X9llqeaQ4jncK6duOMXbRffr teVCEzNLiLn2QxQdxlk6qjOwdOWUfBvJTaNSidrpYiJQFH3+rwRHizoMAmtNsCMnPHBeqG80HsKKI s8d2RUFXv8VcjNKUBtgeKWlS+OdCFZfVkiaX2MzjtoGi193DrV82SASnogNUrLwGuBx145ZLIZPBz gZtRyZDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hj1OG-0001ms-57; Thu, 04 Jul 2019 13:03:08 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hj1MN-00005C-0T for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2019 13:01:12 +0000 Received: by mail-lj1-x241.google.com with SMTP id 205so6091105ljj.8 for ; Thu, 04 Jul 2019 06:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iFkawdZ5Qbd64aBfLB7G/2IByrJZ52xv8EKcLUHUKyg=; b=gZwrSvC6Ql2DUkwL/tYLzFq7GY821LeLxgRRNN082KZr7oErJNkbsU5t2Yqo9mCTBW X6tX/94+bNZHkEwZawbARckZhMteoiYs8DfsqNOt6OG5ITHEW7Jft5T2rNtYrlVX6ih0 pLhDzflHHAWeItnEsYZqEJrWR9olupRNXzUEbme8n2ry5CBpxFwV26USLYQS183kyuJG dRLI2RGDNTOjl7kX0+ovRbjmo7GyAev8h2RESl939EyHe7cJXO2o4aysrekgw/HvlMSK 54rtLrnjUdGKSquoeWinuVDVtgK108jXTT5kLEZ/1zPpIZ68SRXIEZoGU1J/sOkBq+lt TVCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iFkawdZ5Qbd64aBfLB7G/2IByrJZ52xv8EKcLUHUKyg=; b=nBs7zJbbKHazWcWjJIpQhZ8ylZbLrwWluQWCk9SXQw1eYzI2GP+KSZpxgHTRKbVc6w PEY0AZHYYONhoLTkXTxsWFN2cFBatxqyVugFyvS0O8kAcug1v3LvElaKaR4f7qcSFG24 p0qdLac0Ip1+Rpm01wSoBnbgtjUtCBWw8HLSK5DulYx1rqrOD7A0ipWXczPWtyuh9Zc9 kotkcISvMYllDZ+xqtt8FrDPLNdzPqgaMT2eiCmHnL88REabmj9osy6sXwkrPsAp0MzA jR5v5oeQibwQ5qFpNeMGwRm5JSc/7wzJkKjaRh9Yf2ZxoPBIegRgdc4RNwdsL1KhH9nT vd/A== X-Gm-Message-State: APjAAAW+IazP+V6NiUcV7/67BBoKdSmCoF1cBKPpXus4Ojl51f+otm1J y3svAfe8Dp5IZc1fR31djww= X-Google-Smtp-Source: APXvYqzi+zB+DMQHWPOrhTYHDsuybi9IxDE3XFE0vNOu//S6piBaknj6RbeenK5U7P/fYa9NUJABLw== X-Received: by 2002:a2e:8846:: with SMTP id z6mr23896366ljj.20.1562245269472; Thu, 04 Jul 2019 06:01:09 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id h1sm485914lfj.21.2019.07.04.06.01.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jul 2019 06:01:08 -0700 (PDT) From: Sergey Organov To: linux-serial@vger.kernel.org Subject: [PATCH v3 7/7] serial: imx: get rid of imx_uart_rts_auto() Date: Thu, 4 Jul 2019 16:00:29 +0300 Message-Id: <1562245229-709-8-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1562245229-709-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1562245229-709-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190704_060111_407727_456DC93D X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Sascha Hauer , Sergey Organov , NXP Linux Team , Pengutronix Kernel Team , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Called in only one place, for RS232, it only obscures things, as it doesn't go well with 2 similar named functions, imx_uart_rts_inactive() and imx_uart_rts_active(), that both are RS485-specific. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 582a3fd..f4e9d1a 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -402,13 +402,6 @@ static void imx_uart_rts_inactive(struct imx_port *sport, u32 *ucr2) mctrl_gpio_set(sport->gpios, sport->port.mctrl); } -/* called with port.lock taken and irqs caller dependent */ -static void imx_uart_rts_auto(struct imx_port *sport, u32 *ucr2) -{ - if (*ucr2 & UCR2_CTS) - *ucr2 |= UCR2_CTSC; -} - /* called with port.lock taken and irqs off */ static void imx_uart_start_rx(struct uart_port *port) { @@ -1602,7 +1595,8 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, imx_uart_rts_inactive(sport, &ucr2); } else if (termios->c_cflag & CRTSCTS) { - imx_uart_rts_auto(sport, &ucr2); + if (ucr2 & UCR2_CTS) + ucr2 |= UCR2_CTSC; } if (termios->c_cflag & CRTSCTS)