ALSA: sis7019: Use guard() for spin locks

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

Merely code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250829144342.4290-56-tiwai@suse.de
This commit is contained in:
Takashi Iwai 2025-08-29 16:43:30 +02:00
parent e7b99fdddf
commit 8e11f94ea1
1 changed files with 14 additions and 25 deletions

View File

@ -383,9 +383,7 @@ static void __sis_unmap_silence(struct sis7019 *sis)
static void sis_free_voice(struct sis7019 *sis, struct voice *voice) static void sis_free_voice(struct sis7019 *sis, struct voice *voice)
{ {
unsigned long flags; guard(spinlock_irqsave)(&sis->voice_lock);
spin_lock_irqsave(&sis->voice_lock, flags);
if (voice->timing) { if (voice->timing) {
__sis_unmap_silence(sis); __sis_unmap_silence(sis);
voice->timing->flags &= ~(VOICE_IN_USE | VOICE_SSO_TIMING | 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->timing = NULL;
} }
voice->flags &= ~(VOICE_IN_USE | VOICE_SSO_TIMING | VOICE_SYNC_TIMING); 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) 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) static struct voice *sis_alloc_playback_voice(struct sis7019 *sis)
{ {
struct voice *voice; guard(spinlock_irqsave)(&sis->voice_lock);
unsigned long flags; return __sis_alloc_playback_voice(sis);
spin_lock_irqsave(&sis->voice_lock, flags);
voice = __sis_alloc_playback_voice(sis);
spin_unlock_irqrestore(&sis->voice_lock, flags);
return voice;
} }
static int sis_alloc_timing_voice(struct snd_pcm_substream *substream, 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 snd_pcm_runtime *runtime = substream->runtime;
struct voice *voice = runtime->private_data; struct voice *voice = runtime->private_data;
unsigned int period_size, buffer_size; unsigned int period_size, buffer_size;
unsigned long flags;
int needed; int needed;
/* If there are one or two periods per buffer, we don't need a /* 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)); period_size != (buffer_size / 2));
if (needed && !voice->timing) { if (needed && !voice->timing) {
spin_lock_irqsave(&sis->voice_lock, flags); scoped_guard(spinlock_irqsave, &sis->voice_lock) {
voice->timing = __sis_alloc_playback_voice(sis); voice->timing = __sis_alloc_playback_voice(sis);
if (voice->timing) if (voice->timing)
__sis_map_silence(sis); __sis_map_silence(sis);
spin_unlock_irqrestore(&sis->voice_lock, flags); }
if (!voice->timing) if (!voice->timing)
return -ENOMEM; return -ENOMEM;
voice->timing->substream = substream; 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 sis7019 *sis = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct voice *voice = &sis->capture_voice; struct voice *voice = &sis->capture_voice;
unsigned long flags;
/* FIXME: The driver only supports recording from one channel /* FIXME: The driver only supports recording from one channel
* at the moment, but it could support more. * at the moment, but it could support more.
*/ */
spin_lock_irqsave(&sis->voice_lock, flags); scoped_guard(spinlock_irqsave, &sis->voice_lock) {
if (voice->flags & VOICE_IN_USE) if (voice->flags & VOICE_IN_USE)
voice = NULL; voice = NULL;
else else
voice->flags |= VOICE_IN_USE; voice->flags |= VOICE_IN_USE;
spin_unlock_irqrestore(&sis->voice_lock, flags); }
if (!voice) if (!voice)
return -EAGAIN; return -EAGAIN;