linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: linux-usb@vger.kernel.org
Cc: Sheng Long Wang <shenglong.wang.ext@siemens.com>,
	linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH 1/6] USB: serial: cp210x: return early on unchanged termios
Date: Mon, 16 Nov 2020 17:18:21 +0100	[thread overview]
Message-ID: <20201116161826.29417-2-johan@kernel.org> (raw)
In-Reply-To: <20201116161826.29417-1-johan@kernel.org>

Return early from set_termios() in case no relevant terminal settings
have changed.

This avoids testing each parameter in turn and specifically allows the
line-control handling to be cleaned up further.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/serial/cp210x.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index d0c05aa8a0d6..f1fd109d97d5 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1352,6 +1352,15 @@ static void cp210x_disable_event_mode(struct usb_serial_port *port)
 	port_priv->event_mode = false;
 }
 
+static bool cp210x_termios_change(const struct ktermios *a, const struct ktermios *b)
+{
+	bool iflag_change;
+
+	iflag_change = ((a->c_iflag ^ b->c_iflag) & INPCK);
+
+	return tty_termios_hw_change(a, b) || iflag_change;
+}
+
 static void cp210x_set_termios(struct tty_struct *tty,
 		struct usb_serial_port *port, struct ktermios *old_termios)
 {
@@ -1359,6 +1368,9 @@ static void cp210x_set_termios(struct tty_struct *tty,
 	unsigned int cflag, old_cflag;
 	u16 bits;
 
+	if (!cp210x_termios_change(&tty->termios, old_termios))
+		return;
+
 	cflag = tty->termios.c_cflag;
 	old_cflag = old_termios->c_cflag;
 
-- 
2.26.2


  reply	other threads:[~2020-11-16 16:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 16:18 [PATCH 0/6] USB: serial: cp210x: clean up termios handling Johan Hovold
2020-11-16 16:18 ` Johan Hovold [this message]
2020-11-16 16:18 ` [PATCH 2/6] USB: serial: cp210x: clean up line-control handling Johan Hovold
2020-11-16 16:18 ` [PATCH 3/6] USB: serial: cp210x: set terminal settings on open Johan Hovold
2020-11-16 16:18 ` [PATCH 4/6] USB: serial: cp210x: drop flow-control debugging Johan Hovold
2020-11-16 16:18 ` [PATCH 5/6] USB: serial: cp210x: refactor flow-control handling Johan Hovold
2020-11-16 16:18 ` [PATCH 6/6] USB: serial: cp210x: clean up dts_rts Johan Hovold
2020-12-04 13:59 ` [PATCH 0/6] USB: serial: cp210x: clean up termios handling Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201116161826.29417-2-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shenglong.wang.ext@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).