Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: serial: replacing mutex_lock to guard(mutex)
@ 2026-06-14 19:23 Leonid Konontsov
  0 siblings, 0 replies; only message in thread
From: Leonid Konontsov @ 2026-06-14 19:23 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Leonid Konontsov

Moving from manual mutex_lock's and mutex_unlock's to guard(mutex) in
ark3116.c file.

Signed-off-by: Leonid Konontsov <lkonontsov@gmail.com>
---
 drivers/usb/serial/ark3116.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index d974da43fba3..9cd8179de583 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -237,7 +237,7 @@ static void ark3116_set_termios(struct tty_struct *tty,
 	}
 
 	/* Update state: synchronize */
-	mutex_lock(&priv->hw_lock);
+	guard(mutex)(&priv->hw_lock);
 
 	/* keep old LCR_SBC bit */
 	lcr |= (priv->lcr & UART_LCR_SBC);
@@ -280,8 +280,6 @@ static void ark3116_set_termios(struct tty_struct *tty,
 		ark3116_write_reg(serial, UART_LCR, lcr);
 	}
 
-	mutex_unlock(&priv->hw_lock);
-
 	/* check for software flow control */
 	if (I_IXOFF(tty) || I_IXON(tty)) {
 		dev_warn(&port->dev,
@@ -379,9 +377,8 @@ static int ark3116_tiocmget(struct tty_struct *tty)
 	__u32 ctrl;
 	unsigned long flags;
 
-	mutex_lock(&priv->hw_lock);
+	guard(mutex)(&priv->hw_lock);
 	ctrl = priv->mcr;
-	mutex_unlock(&priv->hw_lock);
 
 	spin_lock_irqsave(&priv->status_lock, flags);
 	status = priv->msr;
@@ -407,7 +404,7 @@ static int ark3116_tiocmset(struct tty_struct *tty,
 	 * in priv->mcr is actually the one that is in the hardware
 	 */
 
-	mutex_lock(&priv->hw_lock);
+	guard(mutex)(&priv->hw_lock);
 
 	if (set & TIOCM_RTS)
 		priv->mcr |= UART_MCR_RTS;
@@ -428,8 +425,6 @@ static int ark3116_tiocmset(struct tty_struct *tty,
 
 	ark3116_write_reg(port->serial, UART_MCR, priv->mcr);
 
-	mutex_unlock(&priv->hw_lock);
-
 	return 0;
 }
 
@@ -440,7 +435,7 @@ static int ark3116_break_ctl(struct tty_struct *tty, int break_state)
 	int ret;
 
 	/* LCR is also used for other things: protect access */
-	mutex_lock(&priv->hw_lock);
+	guard(mutex)(&priv->hw_lock);
 
 	if (break_state)
 		priv->lcr |= UART_LCR_SBC;
@@ -449,8 +444,6 @@ static int ark3116_break_ctl(struct tty_struct *tty, int break_state)
 
 	ret = ark3116_write_reg(port->serial, UART_LCR, priv->lcr);
 
-	mutex_unlock(&priv->hw_lock);
-
 	return ret;
 }
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-14 19:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-14 19:23 [PATCH] usb: serial: replacing mutex_lock to guard(mutex) Leonid Konontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox