From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Subject: [PATCH 4/4] tty: goldfish: use guard() for locks
Date: Fri, 3 Jul 2026 10:47:17 +0200 [thread overview]
Message-ID: <20260703084717.176442-4-jirislaby@kernel.org> (raw)
In-Reply-To: <20260703084717.176442-1-jirislaby@kernel.org>
Using guard()s is cleaner and safer.
goldfish_tty_probe() is omitted due to the crossing err_unmap
goto-label. Using scoped_guard() does not look that nice there. Perhaps
if someone refactored the locked part into a separate function...
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/goldfish.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index c643d76e9d1b..fa723a4ba7b3 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -60,10 +60,10 @@ static inline void gf_write_addr(unsigned long addr, void __iomem *portl, void _
static void do_rw_io(struct goldfish_tty *qtty, unsigned long address,
size_t count, bool is_write)
{
- unsigned long irq_flags;
void __iomem *base = qtty->base;
- spin_lock_irqsave(&qtty->lock, irq_flags);
+ guard(spinlock_irqsave)(&qtty->lock);
+
gf_write_addr(address, base + GOLDFISH_TTY_REG_DATA_PTR,
base + GOLDFISH_TTY_REG_DATA_PTR_HIGH);
gf_iowrite32(count, base + GOLDFISH_TTY_REG_DATA_LEN);
@@ -74,8 +74,6 @@ static void do_rw_io(struct goldfish_tty *qtty, unsigned long address,
else
gf_iowrite32(GOLDFISH_TTY_CMD_READ_BUFFER,
base + GOLDFISH_TTY_REG_CMD);
-
- spin_unlock_irqrestore(&qtty->lock, irq_flags);
}
static void goldfish_tty_rw(struct goldfish_tty *qtty, unsigned long addr,
@@ -417,7 +415,7 @@ static void goldfish_tty_remove(struct platform_device *pdev)
{
struct goldfish_tty *qtty = platform_get_drvdata(pdev);
- mutex_lock(&goldfish_tty_lock);
+ guard(mutex)(&goldfish_tty_lock);
unregister_console(&qtty->console);
tty_unregister_device(goldfish_tty_driver, qtty->console.index);
@@ -428,7 +426,6 @@ static void goldfish_tty_remove(struct platform_device *pdev)
goldfish_tty_current_line_count--;
if (goldfish_tty_current_line_count == 0)
goldfish_tty_delete_driver();
- mutex_unlock(&goldfish_tty_lock);
}
#ifdef CONFIG_GOLDFISH_TTY_EARLY_CONSOLE
--
2.54.0
prev parent reply other threads:[~2026-07-03 8:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 8:47 [PATCH 1/4] goldfish: remove unused gf_write_dma_addr() Jiri Slaby (SUSE)
2026-07-03 8:47 ` [PATCH 2/4] tty: goldfish: drop unused goldfish_tty::opencount Jiri Slaby (SUSE)
2026-07-03 8:47 ` [PATCH 3/4] tty: goldfish: move gf_write_ptr() to tty/goldfish.c Jiri Slaby (SUSE)
2026-07-03 8:47 ` Jiri Slaby (SUSE) [this message]
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=20260703084717.176442-4-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox