From patchwork Thu Jun 20 14:47:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 11006845 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 6057676 for ; Thu, 20 Jun 2019 14:49:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E2381FFBD for ; Thu, 20 Jun 2019 14:49:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D6E121327; Thu, 20 Jun 2019 14:49: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 DB0851FFBD for ; Thu, 20 Jun 2019 14:49:22 +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=hUogu3k/ywvT/E73aXDTJ6XVz+5R2dolbJ1BjiXrf3M=; b=mlVaWdSmVoeOjUJyfP8GcLh61M 47H9U/YEJHu3ilM6HTIfkAcOelS89dCraZtMabDexP2VwweA9pfrHrSA8f8leEycV4bdSSB3crOeS 91GFzEqI/gG/YLNmf4HihAUvS79eUFiOZGgZDdtwRTIsQciuXu2RqvYipj1cCpSbUEKempXHIHnhv QFIzt7mjjLRTo9N+2qRVDaObMBotgXhoAdTntkRNUfBOUS+qF901BrNIGnCHkCNnchXhBQYxMD4ft AKckpZl/a7JVCZtpvr5QJHIBXMltPdcAZCrfq4p/vR6qibTn8U2BUGbXauJ+gFNH2KSsjflq7iP4v 9NJ+DoNw==; 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 1hdyNN-0004XE-5z; Thu, 20 Jun 2019 14:49:21 +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 1hdyMF-0003k8-8o for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2019 14:48:12 +0000 Received: by mail-lj1-x241.google.com with SMTP id k18so2943949ljc.11 for ; Thu, 20 Jun 2019 07:48:11 -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=MnAE4r5Gl1VIMZviL9ksOeXJGJoVijEdryliB0x51XQ=; b=esADZiMgQW0phjcMP5wGBWdGf0sjWXZVlUmxjk3spgkE/2OYr3lKq6mqsOhzTXqQTz ukrVC0PnYxysphIT72J+suxXuM+zzaE6PC8qMPXxAuV/4nAYBnfhsD5MoZ4XQ91mFNNJ /zowM5mm9mSgyrnhhUn/AXHgM7i5bdxbxQLSzlHmIG+DOezY6j3Usr+zlDoTIg/Y1DYR bzJ8UvMloxzecGl0ZCInvukHiBubu3yzoJPTjLfQiroCfEZqMq93myXDzXQP1uzt3f0c m/cKWIacS1yy1Ggyfq5cShrzF7N4WF73SPj6z6/NcYru+XuJmRdJNTvWL02kcSitUXjF 6J4w== 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=MnAE4r5Gl1VIMZviL9ksOeXJGJoVijEdryliB0x51XQ=; b=SiHJw28Iu5I9QM0QTlpS/ftFntKGc5tIDMydzAOj2F0MukSOKkeZBIxVYTQYqZoKnQ r+0IcfIfxr8I7S2ZICjXllhGFB1PZh3nHxMA1+w+0APi6GGB8Ve7XEPPUJbMrkQpC9/b o6pIBpIJO4vHnaVKlXrTFvAHDPe4a7iCASyDlznNyStCfnbFsJX82UyZCKhUD6jHo+PK EhwxUmvDF5BKIJno43yqZlbenm8LewRp4uIDS/VbtiS1xWfpdmITql3zWu63UIgPpbcS vx/FY2kqkpUkFdhLbBeXCkxSs4UIwTzY1FHddr9lVGc98jOnsU/ve1E+uYcaJ8fdMFWz NRRg== X-Gm-Message-State: APjAAAVgzEXgulgxLwPY8NovIf/6WsXIH8TSypURkIXisWemcFwSONkZ yGIXQcA9qRiiry/+y1kFjxI= X-Google-Smtp-Source: APXvYqyAnGzVJ/Osqss5wtdaH9tLn+JR7FRReDUCijI7YySbgQBmR2hFw/wCoPHZYc2MS5T3JLwUfw== X-Received: by 2002:a2e:989a:: with SMTP id b26mr9690786ljj.31.1561042089823; Thu, 20 Jun 2019 07:48:09 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id f10sm3577768ljk.95.2019.06.20.07.48.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Jun 2019 07:48:09 -0700 (PDT) From: Sergey Organov To: Sascha Hauer Subject: [PATCH RFC v1 3/7] serial: imx: set_termios(): clarify RTS/CTS bits calculation Date: Thu, 20 Jun 2019 17:47:49 +0300 Message-Id: <1561042073-617-4-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1561042073-617-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1561042073-617-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190620_074811_331589_762E2888 X-CRM114-Status: GOOD ( 12.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: Pengutronix Kernel Team , NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= 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. 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;