summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby (SUSE) <jirislaby@kernel.org>2026-07-03 10:47:17 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-03 13:01:52 +0200
commite508a176d86f5ca0916ac1caf80806f9ad3d91ef (patch)
tree678bcb04d1ec021d5b85f483da3415d5867ff53d
parente31bd02f19ddb01c1e1fb6d79b72ace8f014cb27 (diff)
downloadlinux-e508a176d86f5ca0916ac1caf80806f9ad3d91ef.tar.gz
linux-e508a176d86f5ca0916ac1caf80806f9ad3d91ef.zip
tty: goldfish: use guard() for locks
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> Link: https://patch.msgid.link/20260703084717.176442-4-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/goldfish.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index fb135bf5996c..aace18e5f847 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -61,10 +61,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);
@@ -75,8 +75,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,
@@ -418,7 +416,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);
@@ -429,7 +427,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