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

ALSA: cs5535audio: 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-22-tiwai@suse.de

+12 -14
+8 -6
sound/pci/cs5535audio/cs5535audio.c
··· 176 176 static void process_bm0_irq(struct cs5535audio *cs5535au) 177 177 { 178 178 u8 bm_stat; 179 - spin_lock(&cs5535au->reg_lock); 180 - bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS); 181 - spin_unlock(&cs5535au->reg_lock); 179 + 180 + scoped_guard(spinlock, &cs5535au->reg_lock) { 181 + bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS); 182 + } 182 183 if (bm_stat & EOP) { 183 184 snd_pcm_period_elapsed(cs5535au->playback_substream); 184 185 } else { ··· 192 191 static void process_bm1_irq(struct cs5535audio *cs5535au) 193 192 { 194 193 u8 bm_stat; 195 - spin_lock(&cs5535au->reg_lock); 196 - bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS); 197 - spin_unlock(&cs5535au->reg_lock); 194 + 195 + scoped_guard(spinlock, &cs5535au->reg_lock) { 196 + bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS); 197 + } 198 198 if (bm_stat & EOP) 199 199 snd_pcm_period_elapsed(cs5535au->capture_substream); 200 200 }
+4 -8
sound/pci/cs5535audio/cs5535audio_pcm.c
··· 150 150 dma->substream = substream; 151 151 dma->period_bytes = period_bytes; 152 152 dma->periods = periods; 153 - spin_lock_irq(&cs5535au->reg_lock); 153 + guard(spinlock_irq)(&cs5535au->reg_lock); 154 154 dma->ops->disable_dma(cs5535au); 155 155 dma->ops->setup_prd(cs5535au, jmpprd_addr); 156 - spin_unlock_irq(&cs5535au->reg_lock); 157 156 return 0; 158 157 } 159 158 ··· 275 276 { 276 277 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); 277 278 struct cs5535audio_dma *dma = substream->runtime->private_data; 278 - int err = 0; 279 279 280 - spin_lock(&cs5535au->reg_lock); 280 + guard(spinlock)(&cs5535au->reg_lock); 281 281 switch (cmd) { 282 282 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 283 283 dma->ops->pause_dma(cs5535au); ··· 298 300 break; 299 301 default: 300 302 dev_err(cs5535au->card->dev, "unhandled trigger\n"); 301 - err = -EINVAL; 302 - break; 303 + return -EINVAL; 303 304 } 304 - spin_unlock(&cs5535au->reg_lock); 305 - return err; 305 + return 0; 306 306 } 307 307 308 308 static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(struct snd_pcm_substream