Skip to content

Commit 7e18682

Browse files
committed
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>
1 parent 9fc4a3d commit 7e18682

1 file changed

Lines changed: 24 additions & 28 deletions

File tree

sound/spi/at73c213.c

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,8 @@ static int snd_at73c213_pcm_trigger(struct snd_pcm_substream *substream,
273273
int cmd)
274274
{
275275
struct snd_at73c213 *chip = snd_pcm_substream_chip(substream);
276-
int retval = 0;
277276

278-
spin_lock(&chip->lock);
277+
guard(spinlock)(&chip->lock);
279278

280279
switch (cmd) {
281280
case SNDRV_PCM_TRIGGER_START:
@@ -288,13 +287,11 @@ static int snd_at73c213_pcm_trigger(struct snd_pcm_substream *substream,
288287
break;
289288
default:
290289
dev_dbg(&chip->spi->dev, "spurious command %x\n", cmd);
291-
retval = -EINVAL;
290+
return -EINVAL;
292291
break;
293292
}
294293

295-
spin_unlock(&chip->lock);
296-
297-
return retval;
294+
return 0;
298295
}
299296

300297
static snd_pcm_uframes_t
@@ -358,30 +355,29 @@ static irqreturn_t snd_at73c213_interrupt(int irq, void *dev_id)
358355
int next_period;
359356
int retval = IRQ_NONE;
360357

361-
spin_lock(&chip->lock);
358+
scoped_guard(spinlock, &chip->lock) {
359+
block_size = frames_to_bytes(runtime, runtime->period_size);
360+
status = ssc_readl(chip->ssc->regs, IMR);
362361

363-
block_size = frames_to_bytes(runtime, runtime->period_size);
364-
status = ssc_readl(chip->ssc->regs, IMR);
365-
366-
if (status & SSC_BIT(IMR_ENDTX)) {
367-
chip->period++;
368-
if (chip->period == runtime->periods)
369-
chip->period = 0;
370-
next_period = chip->period + 1;
371-
if (next_period == runtime->periods)
372-
next_period = 0;
373-
374-
offset = block_size * next_period;
375-
376-
ssc_writel(chip->ssc->regs, PDC_TNPR,
377-
(long)runtime->dma_addr + offset);
378-
ssc_writel(chip->ssc->regs, PDC_TNCR,
379-
runtime->period_size * runtime->channels);
380-
retval = IRQ_HANDLED;
381-
}
362+
if (status & SSC_BIT(IMR_ENDTX)) {
363+
chip->period++;
364+
if (chip->period == runtime->periods)
365+
chip->period = 0;
366+
next_period = chip->period + 1;
367+
if (next_period == runtime->periods)
368+
next_period = 0;
369+
370+
offset = block_size * next_period;
382371

383-
ssc_readl(chip->ssc->regs, IMR);
384-
spin_unlock(&chip->lock);
372+
ssc_writel(chip->ssc->regs, PDC_TNPR,
373+
(long)runtime->dma_addr + offset);
374+
ssc_writel(chip->ssc->regs, PDC_TNCR,
375+
runtime->period_size * runtime->channels);
376+
retval = IRQ_HANDLED;
377+
}
378+
379+
ssc_readl(chip->ssc->regs, IMR);
380+
}
385381

386382
if (status & SSC_BIT(IMR_ENDTX))
387383
snd_pcm_period_elapsed(chip->substream);

0 commit comments

Comments
 (0)