[PATCH] usb: serial: replacing mutex_lock to guard(mutex)
From: Leonid Konontsov
Date: Sun Jun 14 2026 - 15:25:30 EST
Moving from manual mutex_lock's and mutex_unlock's to guard(mutex) in
ark3116.c file.
Signed-off-by: Leonid Konontsov <lkonontsov@xxxxxxxxx>
---
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