linux-sound.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH 55/61] ALSA: sis7019: Use guard() for spin locks
Date: Fri, 29 Aug 2025 16:43:30 +0200	[thread overview]
Message-ID: <20250829144342.4290-56-tiwai@suse.de> (raw)
In-Reply-To: <20250829144342.4290-1-tiwai@suse.de>

Clean up the code using guard() for spin locks.

Merely code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/sis7019.c | 39 ++++++++++++++-------------------------
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index a1341af8c41f..4be085d27712 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -383,9 +383,7 @@ static void __sis_unmap_silence(struct sis7019 *sis)
 
 static void sis_free_voice(struct sis7019 *sis, struct voice *voice)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&sis->voice_lock, flags);
+	guard(spinlock_irqsave)(&sis->voice_lock);
 	if (voice->timing) {
 		__sis_unmap_silence(sis);
 		voice->timing->flags &= ~(VOICE_IN_USE | VOICE_SSO_TIMING |
@@ -393,7 +391,6 @@ static void sis_free_voice(struct sis7019 *sis, struct voice *voice)
 		voice->timing = NULL;
 	}
 	voice->flags &= ~(VOICE_IN_USE | VOICE_SSO_TIMING | VOICE_SYNC_TIMING);
-	spin_unlock_irqrestore(&sis->voice_lock, flags);
 }
 
 static struct voice *__sis_alloc_playback_voice(struct sis7019 *sis)
@@ -417,14 +414,8 @@ static struct voice *__sis_alloc_playback_voice(struct sis7019 *sis)
 
 static struct voice *sis_alloc_playback_voice(struct sis7019 *sis)
 {
-	struct voice *voice;
-	unsigned long flags;
-
-	spin_lock_irqsave(&sis->voice_lock, flags);
-	voice = __sis_alloc_playback_voice(sis);
-	spin_unlock_irqrestore(&sis->voice_lock, flags);
-
-	return voice;
+	guard(spinlock_irqsave)(&sis->voice_lock);
+	return __sis_alloc_playback_voice(sis);
 }
 
 static int sis_alloc_timing_voice(struct snd_pcm_substream *substream,
@@ -434,7 +425,6 @@ static int sis_alloc_timing_voice(struct snd_pcm_substream *substream,
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct voice *voice = runtime->private_data;
 	unsigned int period_size, buffer_size;
-	unsigned long flags;
 	int needed;
 
 	/* If there are one or two periods per buffer, we don't need a
@@ -447,11 +437,11 @@ static int sis_alloc_timing_voice(struct snd_pcm_substream *substream,
 			period_size != (buffer_size / 2));
 
 	if (needed && !voice->timing) {
-		spin_lock_irqsave(&sis->voice_lock, flags);
-		voice->timing = __sis_alloc_playback_voice(sis);
-		if (voice->timing)
-			__sis_map_silence(sis);
-		spin_unlock_irqrestore(&sis->voice_lock, flags);
+		scoped_guard(spinlock_irqsave, &sis->voice_lock) {
+			voice->timing = __sis_alloc_playback_voice(sis);
+			if (voice->timing)
+				__sis_map_silence(sis);
+		}
 		if (!voice->timing)
 			return -ENOMEM;
 		voice->timing->substream = substream;
@@ -645,17 +635,16 @@ static int sis_capture_open(struct snd_pcm_substream *substream)
 	struct sis7019 *sis = snd_pcm_substream_chip(substream);
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct voice *voice = &sis->capture_voice;
-	unsigned long flags;
 
 	/* FIXME: The driver only supports recording from one channel
 	 * at the moment, but it could support more.
 	 */
-	spin_lock_irqsave(&sis->voice_lock, flags);
-	if (voice->flags & VOICE_IN_USE)
-		voice = NULL;
-	else
-		voice->flags |= VOICE_IN_USE;
-	spin_unlock_irqrestore(&sis->voice_lock, flags);
+	scoped_guard(spinlock_irqsave, &sis->voice_lock) {
+		if (voice->flags & VOICE_IN_USE)
+			voice = NULL;
+		else
+			voice->flags |= VOICE_IN_USE;
+	}
 
 	if (!voice)
 		return -EAGAIN;
-- 
2.50.1


  parent reply	other threads:[~2025-08-29 14:46 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29 14:42 [PATCH 00/61] ALSA: Use auto-cleanup for PCI drivers Takashi Iwai
2025-08-29 14:42 ` [PATCH 01/61] ALSA: ac97: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 02/61] ALSA: ac97: Use guard() for spin locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 03/61] ALSA: ali5451: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 04/61] ALSA: azt3328: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 05/61] ALSA: ens137x: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 06/61] ALSA: ens137x: Use guard() for spin locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 07/61] ALSA: als300: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 08/61] ALSA: als4000: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 09/61] ALSA: ad1889: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 10/61] ALSA: atiixp: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 11/61] ALSA: atiixp: Use guard() for spin locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 12/61] ALSA: aw2: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 13/61] ALSA: aw2: Use guard() for spin locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 14/61] ALSA: bt87x: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 15/61] ALSA: ca0106: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 16/61] ALSA: cmipci: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 17/61] ALSA: cmipci: Use guard() for spin locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 18/61] ALSA: cs4281: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 19/61] ALSA: cs46xx: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 20/61] ALSA: cs46xx: Use guard() for spin locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 21/61] ALSA: cs5535audio: " Takashi Iwai
2025-08-29 14:42 ` [PATCH 22/61] ALSA: ctxfi: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 23/61] ALSA: ctxfi: Use guard() for spin locks Takashi Iwai
2025-08-29 14:42 ` [PATCH 24/61] ALSA: echoaudio: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 25/61] ALSA: echoaudio: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 26/61] ALSA: emu10k1: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 27/61] ALSA: emu10k1: Use guard() for emu1010 FPGA locking Takashi Iwai
2025-08-29 14:43 ` [PATCH 28/61] ALSA: emu10k1: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 29/61] ALSA: emu10k1x: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 30/61] ALSA: es1938: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 31/61] ALSA: es1968: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 32/61] ALSA: es1968: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 33/61] ALSA: fm801: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 34/61] ALSA: ice1712: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 35/61] ALSA: ice1712: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 36/61] ALSA: intel8x0: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 37/61] ALSA: korg1212: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 38/61] ALSA: korg1212: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 39/61] ALSA: lola: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 40/61] ALSA: lola: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 41/61] ALSA: lx6464es: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 42/61] ALSA: maestro3: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 43/61] ALSA: mixart: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 44/61] ALSA: nm256: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 45/61] ALSA: nm256: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 46/61] ALSA: oxygen: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 47/61] ALSA: oxygen: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 48/61] ALSA: pcxhr: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 49/61] ALSA: rme32: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 50/61] ALSA: rme96: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 51/61] ALSA: hdsp: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 52/61] ALSA: hdspm: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 53/61] ALSA: rme9652: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 54/61] ALSA: sis7019: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` Takashi Iwai [this message]
2025-08-29 14:43 ` [PATCH 56/61] ALSA: sonicvibes: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 57/61] ALSA: trident: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 58/61] ALSA: trident: Use guard() for spin locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 59/61] ALSA: via82xx: " Takashi Iwai
2025-08-29 14:43 ` [PATCH 60/61] ALSA: vx222: Use guard() for mutex locks Takashi Iwai
2025-08-29 14:43 ` [PATCH 61/61] ALSA: ymfpci: Use guard() for spin locks Takashi Iwai

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=20250829144342.4290-56-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).