Re: [PATCH] usb: serial: replacing mutex_lock to guard(mutex)
From: Greg Kroah-Hartman
Date: Sun Jun 14 2026 - 22:30:25 EST
On Sun, Jun 14, 2026 at 10:23:37PM +0300, Leonid Konontsov wrote:
> 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);
As "proof" you shouldn't be doing this, you just changed the logic here
and might have broken the driver :(
Did you test this change?
thanks,
greg k-h