From: Leonid Konontsov <lkonontsov@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Leonid Konontsov <lkonontsov@gmail.com>
Subject: [PATCH] usb: serial: replacing mutex_lock to guard(mutex)
Date: Sun, 14 Jun 2026 22:23:37 +0300 [thread overview]
Message-ID: <20260614192337.9449-1-lkonontsov@gmail.com> (raw)
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
next reply other threads:[~2026-06-14 19:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-14 19:23 Leonid Konontsov [this message]
2026-06-15 2:28 ` [PATCH] usb: serial: replacing mutex_lock to guard(mutex) Greg Kroah-Hartman
2026-06-15 2:29 ` Greg Kroah-Hartman
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=20260614192337.9449-1-lkonontsov@gmail.com \
--to=lkonontsov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=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.