All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/8] USB: serial: belkin_sa: clean up tiocmset()
Date: Wed, 22 Oct 2025 17:26:35 +0200	[thread overview]
Message-ID: <20251022152640.24212-4-johan@kernel.org> (raw)
In-Reply-To: <20251022152640.24212-1-johan@kernel.org>

Clean up the tiocmset() implementation by dropping the dtr and rts flags
to make the logic a little easier to follow.

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

diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index aa6b4c4ad5ec..5c41c1c82c3f 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -436,33 +436,23 @@ static int belkin_sa_tiocmset(struct tty_struct *tty,
 	unsigned long control_state;
 	unsigned long flags;
 	int retval = 0;
-	int rts = 0;
-	int dtr = 0;
 
 	spin_lock_irqsave(&priv->lock, flags);
 	control_state = priv->control_state;
 
-	if (set & TIOCM_RTS) {
+	if (set & TIOCM_RTS)
 		control_state |= TIOCM_RTS;
-		rts = 1;
-	}
-	if (set & TIOCM_DTR) {
+	if (set & TIOCM_DTR)
 		control_state |= TIOCM_DTR;
-		dtr = 1;
-	}
-	if (clear & TIOCM_RTS) {
+	if (clear & TIOCM_RTS)
 		control_state &= ~TIOCM_RTS;
-		rts = 1;
-	}
-	if (clear & TIOCM_DTR) {
+	if (clear & TIOCM_DTR)
 		control_state &= ~TIOCM_DTR;
-		dtr = 1;
-	}
 
 	priv->control_state = control_state;
 	spin_unlock_irqrestore(&priv->lock, flags);
 
-	if (rts) {
+	if ((set | clear) & TIOCM_RTS) {
 		retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST,
 					!!(control_state & TIOCM_RTS));
 		if (retval < 0) {
@@ -471,7 +461,7 @@ static int belkin_sa_tiocmset(struct tty_struct *tty,
 		}
 	}
 
-	if (dtr) {
+	if ((set | clear) & TIOCM_DTR) {
 		retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST,
 					!!(control_state & TIOCM_DTR));
 		if (retval < 0) {
-- 
2.49.1


  parent reply	other threads:[~2025-10-22 15:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 15:26 [PATCH 0/8] USB: serial: fix TIOCMBIS and TIOCMBIC Johan Hovold
2025-10-22 15:26 ` [PATCH 1/8] USB: serial: belkin_sa: " Johan Hovold
2025-10-22 15:26 ` [PATCH 2/8] USB: serial: kobil_sct: " Johan Hovold
2025-10-22 15:26 ` Johan Hovold [this message]
2025-10-22 15:26 ` [PATCH 4/8] USB: serial: kobil_sct: clean up tiocmset() Johan Hovold
2025-10-22 15:26 ` [PATCH 5/8] USB: serial: kobil_sct: clean up device type checks Johan Hovold
2025-10-22 15:26 ` [PATCH 6/8] USB: serial: kobil_sct: add control request helpers Johan Hovold
2025-10-22 15:26 ` [PATCH 7/8] USB: serial: kobil_sct: clean up set_termios() Johan Hovold
2025-10-22 15:26 ` [PATCH 8/8] USB: serial: kobil_sct: drop unnecessary initialisations Johan Hovold
2025-10-22 17:14 ` [PATCH 0/8] USB: serial: fix TIOCMBIS and TIOCMBIC Greg KH
2025-10-27  8:24   ` 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=20251022152640.24212-4-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.