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

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: spi/at73c213: 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>

+21 -25
+21 -25
sound/spi/at73c213.c
··· 273 273 int cmd) 274 274 { 275 275 struct snd_at73c213 *chip = snd_pcm_substream_chip(substream); 276 - int retval = 0; 277 276 278 - spin_lock(&chip->lock); 277 + guard(spinlock)(&chip->lock); 279 278 280 279 switch (cmd) { 281 280 case SNDRV_PCM_TRIGGER_START: ··· 287 288 break; 288 289 default: 289 290 dev_dbg(&chip->spi->dev, "spurious command %x\n", cmd); 290 - retval = -EINVAL; 291 + return -EINVAL; 291 292 break; 292 293 } 293 294 294 - spin_unlock(&chip->lock); 295 - 296 - return retval; 295 + return 0; 297 296 } 298 297 299 298 static snd_pcm_uframes_t ··· 355 358 int next_period; 356 359 int retval = IRQ_NONE; 357 360 358 - spin_lock(&chip->lock); 361 + scoped_guard(spinlock, &chip->lock) { 362 + block_size = frames_to_bytes(runtime, runtime->period_size); 363 + status = ssc_readl(chip->ssc->regs, IMR); 359 364 360 - block_size = frames_to_bytes(runtime, runtime->period_size); 361 - status = ssc_readl(chip->ssc->regs, IMR); 365 + if (status & SSC_BIT(IMR_ENDTX)) { 366 + chip->period++; 367 + if (chip->period == runtime->periods) 368 + chip->period = 0; 369 + next_period = chip->period + 1; 370 + if (next_period == runtime->periods) 371 + next_period = 0; 362 372 363 - if (status & SSC_BIT(IMR_ENDTX)) { 364 - chip->period++; 365 - if (chip->period == runtime->periods) 366 - chip->period = 0; 367 - next_period = chip->period + 1; 368 - if (next_period == runtime->periods) 369 - next_period = 0; 373 + offset = block_size * next_period; 370 374 371 - offset = block_size * next_period; 375 + ssc_writel(chip->ssc->regs, PDC_TNPR, 376 + (long)runtime->dma_addr + offset); 377 + ssc_writel(chip->ssc->regs, PDC_TNCR, 378 + runtime->period_size * runtime->channels); 379 + retval = IRQ_HANDLED; 380 + } 372 381 373 - ssc_writel(chip->ssc->regs, PDC_TNPR, 374 - (long)runtime->dma_addr + offset); 375 - ssc_writel(chip->ssc->regs, PDC_TNCR, 376 - runtime->period_size * runtime->channels); 377 - retval = IRQ_HANDLED; 382 + ssc_readl(chip->ssc->regs, IMR); 378 383 } 379 - 380 - ssc_readl(chip->ssc->regs, IMR); 381 - spin_unlock(&chip->lock); 382 384 383 385 if (status & SSC_BIT(IMR_ENDTX)) 384 386 snd_pcm_period_elapsed(chip->substream);