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

ALSA: snd-n64: 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>

+5 -12
+5 -12
sound/mips/snd-n64.c
··· 81 81 static void n64audio_push(struct n64audio *priv) 82 82 { 83 83 struct snd_pcm_runtime *runtime = priv->chan.substream->runtime; 84 - unsigned long flags; 85 84 u32 count; 86 85 87 - spin_lock_irqsave(&priv->chan.lock, flags); 86 + guard(spinlock_irqsave)(&priv->chan.lock); 88 87 89 88 count = priv->chan.writesize; 90 89 ··· 103 104 priv->chan.nextpos %= priv->chan.bufsize; 104 105 105 106 runtime->delay = runtime->period_size; 106 - 107 - spin_unlock_irqrestore(&priv->chan.lock, flags); 108 107 } 109 108 110 109 static irqreturn_t n64audio_isr(int irq, void *dev_id) 111 110 { 112 111 struct n64audio *priv = dev_id; 113 112 const u32 intrs = n64mi_read_reg(priv, MI_INTR_REG); 114 - unsigned long flags; 115 113 116 114 // Check it's ours 117 115 if (!(intrs & MI_INTR_AI)) ··· 117 121 n64audio_write_reg(priv, AI_STATUS_REG, 1); 118 122 119 123 if (priv->chan.substream && snd_pcm_running(priv->chan.substream)) { 120 - spin_lock_irqsave(&priv->chan.lock, flags); 121 - 122 - priv->chan.pos = priv->chan.nextpos; 123 - 124 - spin_unlock_irqrestore(&priv->chan.lock, flags); 124 + scoped_guard(spinlock_irqsave, &priv->chan.lock) { 125 + priv->chan.pos = priv->chan.nextpos; 126 + } 125 127 126 128 snd_pcm_period_elapsed(priv->chan.substream); 127 129 if (priv->chan.substream && snd_pcm_running(priv->chan.substream)) ··· 215 221 rate = 16; 216 222 n64audio_write_reg(priv, AI_BITCLOCK_REG, rate - 1); 217 223 218 - spin_lock_irq(&priv->chan.lock); 224 + guard(spinlock_irq)(&priv->chan.lock); 219 225 220 226 /* Setup the pseudo-dma transfer pointers. */ 221 227 priv->chan.pos = 0; ··· 224 230 priv->chan.writesize = snd_pcm_lib_period_bytes(substream); 225 231 priv->chan.bufsize = snd_pcm_lib_buffer_bytes(substream); 226 232 227 - spin_unlock_irq(&priv->chan.lock); 228 233 return 0; 229 234 } 230 235