From patchwork Fri Jun 14 12:11:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 10995159 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 CCB1576 for ; Fri, 14 Jun 2019 12:12:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB0EC28684 for ; Fri, 14 Jun 2019 12:12:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEE672867C; Fri, 14 Jun 2019 12:12:56 +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 58A4A28658 for ; Fri, 14 Jun 2019 12:12:56 +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=adSE2FkV9nr3yEXFFdb2E1uxCy Kg4hbyZUO/Yn0k1tg3EqRGZLZYUuKKfoluQQCr8Fep8npTPCnFRTElpV+V/45oDFxE8jC1G5TbZf7 yYHoyjYiAeN6SclVsIuy/Lj+/OnotEbg3dJMU0HjlRYmnPyhXojeH4/XExRa7cuztQIsK5CKebei+ np+tSbUYcTviRIBCA5mL8sMW1SAu76WlM7JIrZYUcuWIdxyUBUxPhkzvdBUnjxNAWcayqLIbCoS5M Gc4V8z1k0e6lJvt1DyrOvSkziPPv8cg5L9oWYfik/x47cC7hbkFREoYIL3huFmj9OWHlCzYS6txLl 1aXhGbKQ==; 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 1hbl4Z-0003Uh-Em; Fri, 14 Jun 2019 12:12:47 +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 1hbl3j-0002mj-QM for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2019 12:11:57 +0000 Received: by mail-lj1-x243.google.com with SMTP id s21so2143060lji.8 for ; Fri, 14 Jun 2019 05:11:55 -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=WU87SO0rFdKL0jGGN3E6Yp4DQcPvigBLGDldakRZfF9oHXptATGbb3eOe65YT23hUd dkf7UPpuSeYpi6DzYDXNoxAv/mWc8BepQwQVRO5NR6Xc+CaKDd6L/Sq6oCweq6YLldxE A29Df0QutRTjnn1BG6/cz2jJovdwQGI3+JxTV0sLtr2CS8gr6sfFthAaaUuJnBQT07an P+tJX6Lj5Lr4NDPk9RgIWe8h1nMMR2kqTT+xMnrfTeoRBEGZkF/kFczWQFQ2/lRPXbJL rLCHCfKS9qmAouwI9qDFy5XqlHg8tj7DD0g6RGnJ3U2Z3oOJZ2vPNkZ0M9hBm3S8Jwih MPyw== 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=tNzechaWJ1pJnFHYCOF5n+XEUQvirsNWaNbVddqOAQvSmwCFPcq2GsMna3CeVIbRJ7 hfGwW4XBJliFvI98nycTiQN9fjuploGeXfwU65sayoDLqODcQZahxqah8zHUCBUUnjKK kWfUKTyQ/Wr7SbujyIwoFyFgKHeOzjEC/pg9P7aNCQ0uz8whFrGItNhPLQRJxAeGmWGp Gd+1I71TRi31UoSs3vnOIREec4t3yoms95AEoLinTFGY1qQ6KSYCf/A6YBrR8SGtPaHZ VUmjxDCexhH8BzDuKnHMUlikF57swRuLK8wQD2OuhoXM9q2bZe017q5Ye0YwPL9dPn3w 85DQ== X-Gm-Message-State: APjAAAX8YuadMTVvpZsN+yO9CLLkNuozr6Nr9axmAsDqBjtPz3jBZbub 5J4hfBl4P/PenZIhMqlkzW4= X-Google-Smtp-Source: APXvYqxW2PF12BhUCKAQN98WEsRpNhDJrFTYunpAY6YNMydMQgm5z9W1FQbZS6qhN/xSK/JDxqUcHw== X-Received: by 2002:a2e:4a1a:: with SMTP id x26mr35479854lja.207.1560514314037; Fri, 14 Jun 2019 05:11:54 -0700 (PDT) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id p27sm459683lfh.8.2019.06.14.05.11.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Jun 2019 05:11:53 -0700 (PDT) From: Sergey Organov To: Sascha Hauer Subject: [PATCH RFC 3/7] serial: imx: set_termios(): clarify RTS/CTS bits calculation Date: Fri, 14 Jun 2019 15:11:30 +0300 Message-Id: <1560514294-29111-4-git-send-email-sorganov@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1560514294-29111-1-git-send-email-sorganov@gmail.com> References: <20190614072801.3187-1-s.hauer@pengutronix.de> <1560514294-29111-1-git-send-email-sorganov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190614_051155_880672_83FF3E7E X-CRM114-Status: GOOD ( 11.96 ) 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;