From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH v2 11/11] ALSA: seq: oss/rw: Cleanup with guard
Date: Wed, 27 Aug 2025 10:05:17 +0200 [thread overview]
Message-ID: <20250827080520.7544-12-tiwai@suse.de> (raw)
In-Reply-To: <20250827080520.7544-1-tiwai@suse.de>
Replace the manual spin lock/unlock pairs with guard() for code
simplification.
Only code refactoring, and no behavior change.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/seq/oss/seq_oss_readq.c | 10 ++--------
sound/core/seq/oss/seq_oss_writeq.c | 5 +----
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/sound/core/seq/oss/seq_oss_readq.c b/sound/core/seq/oss/seq_oss_readq.c
index f0db5d3dcba4..bbaf72e70b35 100644
--- a/sound/core/seq/oss/seq_oss_readq.c
+++ b/sound/core/seq/oss/seq_oss_readq.c
@@ -140,13 +140,9 @@ int snd_seq_oss_readq_sysex(struct seq_oss_readq *q, int dev,
int
snd_seq_oss_readq_put_event(struct seq_oss_readq *q, union evrec *ev)
{
- unsigned long flags;
-
- spin_lock_irqsave(&q->lock, flags);
- if (q->qlen >= q->maxlen - 1) {
- spin_unlock_irqrestore(&q->lock, flags);
+ guard(spinlock_irqsave)(&q->lock);
+ if (q->qlen >= q->maxlen - 1)
return -ENOMEM;
- }
memcpy(&q->q[q->tail], ev, sizeof(*ev));
q->tail = (q->tail + 1) % q->maxlen;
@@ -155,8 +151,6 @@ snd_seq_oss_readq_put_event(struct seq_oss_readq *q, union evrec *ev)
/* wake up sleeper */
wake_up(&q->midi_sleep);
- spin_unlock_irqrestore(&q->lock, flags);
-
return 0;
}
diff --git a/sound/core/seq/oss/seq_oss_writeq.c b/sound/core/seq/oss/seq_oss_writeq.c
index 3e3209ce53b1..a93ff8315b8e 100644
--- a/sound/core/seq/oss/seq_oss_writeq.c
+++ b/sound/core/seq/oss/seq_oss_writeq.c
@@ -122,13 +122,10 @@ snd_seq_oss_writeq_sync(struct seq_oss_writeq *q)
void
snd_seq_oss_writeq_wakeup(struct seq_oss_writeq *q, abstime_t time)
{
- unsigned long flags;
-
- spin_lock_irqsave(&q->sync_lock, flags);
+ guard(spinlock_irqsave)(&q->sync_lock);
q->sync_time = time;
q->sync_event_put = 0;
wake_up(&q->sync_sleep);
- spin_unlock_irqrestore(&q->sync_lock, flags);
}
--
2.50.1
prev parent reply other threads:[~2025-08-27 8:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 8:05 [PATCH v2 00/11] ALSA: seq: Use auto-cleanup macros Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 01/11] ALSA: seq: Simplify internal command operation from OSS layer Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 02/11] ALSA: seq: Clean up spin lock with guard() Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 03/11] ALSA: seq: Use guard() for mutex and rwsem locks Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 04/11] ALSA: seq: Use auto-cleanup for client refcounting Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 05/11] ALSA: seq: Clean up port locking with auto cleanup Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 06/11] ALSA: seq: Clean up queue " Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 07/11] ALSA: seq: Clean up fifo locking with guard Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 08/11] ALSA: seq: oss: Clean up core code with guard() Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 09/11] ALSA: seq: oss/midi: Cleanup with guard and auto-cleanup Takashi Iwai
2025-08-27 8:05 ` [PATCH v2 10/11] ALSA: seq: oss/synth: Clean up with guard and auto cleanup Takashi Iwai
2025-08-27 8:05 ` Takashi Iwai [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=20250827080520.7544-12-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-sound@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;
as well as URLs for NNTP newsgroup(s).