Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+14 -25
+14 -25
sound/pci/sis7019.c
··· 383 383 384 384 static void sis_free_voice(struct sis7019 *sis, struct voice *voice) 385 385 { 386 - unsigned long flags; 387 - 388 - spin_lock_irqsave(&sis->voice_lock, flags); 386 + guard(spinlock_irqsave)(&sis->voice_lock); 389 387 if (voice->timing) { 390 388 __sis_unmap_silence(sis); 391 389 voice->timing->flags &= ~(VOICE_IN_USE | VOICE_SSO_TIMING | ··· 391 393 voice->timing = NULL; 392 394 } 393 395 voice->flags &= ~(VOICE_IN_USE | VOICE_SSO_TIMING | VOICE_SYNC_TIMING); 394 - spin_unlock_irqrestore(&sis->voice_lock, flags); 395 396 } 396 397 397 398 static struct voice *__sis_alloc_playback_voice(struct sis7019 *sis) ··· 414 417 415 418 static struct voice *sis_alloc_playback_voice(struct sis7019 *sis) 416 419 { 417 - struct voice *voice; 418 - unsigned long flags; 419 - 420 - spin_lock_irqsave(&sis->voice_lock, flags); 421 - voice = __sis_alloc_playback_voice(sis); 422 - spin_unlock_irqrestore(&sis->voice_lock, flags); 423 - 424 - return voice; 420 + guard(spinlock_irqsave)(&sis->voice_lock); 421 + return __sis_alloc_playback_voice(sis); 425 422 } 426 423 427 424 static int sis_alloc_timing_voice(struct snd_pcm_substream *substream, ··· 425 434 struct snd_pcm_runtime *runtime = substream->runtime; 426 435 struct voice *voice = runtime->private_data; 427 436 unsigned int period_size, buffer_size; 428 - unsigned long flags; 429 437 int needed; 430 438 431 439 /* If there are one or two periods per buffer, we don't need a ··· 437 447 period_size != (buffer_size / 2)); 438 448 439 449 if (needed && !voice->timing) { 440 - spin_lock_irqsave(&sis->voice_lock, flags); 441 - voice->timing = __sis_alloc_playback_voice(sis); 442 - if (voice->timing) 443 - __sis_map_silence(sis); 444 - spin_unlock_irqrestore(&sis->voice_lock, flags); 450 + scoped_guard(spinlock_irqsave, &sis->voice_lock) { 451 + voice->timing = __sis_alloc_playback_voice(sis); 452 + if (voice->timing) 453 + __sis_map_silence(sis); 454 + } 445 455 if (!voice->timing) 446 456 return -ENOMEM; 447 457 voice->timing->substream = substream; ··· 635 645 struct sis7019 *sis = snd_pcm_substream_chip(substream); 636 646 struct snd_pcm_runtime *runtime = substream->runtime; 637 647 struct voice *voice = &sis->capture_voice; 638 - unsigned long flags; 639 648 640 649 /* FIXME: The driver only supports recording from one channel 641 650 * at the moment, but it could support more. 642 651 */ 643 - spin_lock_irqsave(&sis->voice_lock, flags); 644 - if (voice->flags & VOICE_IN_USE) 645 - voice = NULL; 646 - else 647 - voice->flags |= VOICE_IN_USE; 648 - spin_unlock_irqrestore(&sis->voice_lock, flags); 652 + scoped_guard(spinlock_irqsave, &sis->voice_lock) { 653 + if (voice->flags & VOICE_IN_USE) 654 + voice = NULL; 655 + else 656 + voice->flags |= VOICE_IN_USE; 657 + } 649 658 650 659 if (!voice) 651 660 return -EAGAIN;