Skip to content

Commit 205cc2a

Browse files
BuiDucPhucbroonie
authored andcommitted
ASoC: sti: uniperif_reader: Use guard() for spin locks
Clean up the code using guard() for spin locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Link: https://patch.msgid.link/20260527100206.26788-2-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e43ffb6 commit 205cc2a

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

sound/soc/sti/uniperif_reader.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
4646
struct uniperif *reader = dev_id;
4747
unsigned int status;
4848

49-
spin_lock(&reader->irq_lock);
49+
guard(spinlock)(&reader->irq_lock);
5050
if (!reader->substream)
51-
goto irq_spin_unlock;
51+
return ret;
5252

5353
snd_pcm_stream_lock(reader->substream);
5454
if (reader->state == UNIPERIF_STATE_STOPPED) {
5555
/* Unexpected IRQ: do nothing */
5656
dev_warn(reader->dev, "unexpected IRQ\n");
57-
goto stream_unlock;
57+
snd_pcm_stream_unlock(reader->substream);
58+
return ret;
5859
}
5960

6061
/* Get interrupt status & clear them immediately */
@@ -70,10 +71,7 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
7071
ret = IRQ_HANDLED;
7172
}
7273

73-
stream_unlock:
7474
snd_pcm_stream_unlock(reader->substream);
75-
irq_spin_unlock:
76-
spin_unlock(&reader->irq_lock);
7775

7876
return ret;
7977
}
@@ -355,12 +353,10 @@ static int uni_reader_startup(struct snd_pcm_substream *substream,
355353
{
356354
struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
357355
struct uniperif *reader = priv->dai_data.uni;
358-
unsigned long flags;
359356
int ret;
360357

361-
spin_lock_irqsave(&reader->irq_lock, flags);
362-
reader->substream = substream;
363-
spin_unlock_irqrestore(&reader->irq_lock, flags);
358+
scoped_guard(spinlock_irqsave, &reader->irq_lock)
359+
reader->substream = substream;
364360

365361
if (!UNIPERIF_TYPE_IS_TDM(reader))
366362
return 0;
@@ -386,15 +382,13 @@ static void uni_reader_shutdown(struct snd_pcm_substream *substream,
386382
{
387383
struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
388384
struct uniperif *reader = priv->dai_data.uni;
389-
unsigned long flags;
390385

391-
spin_lock_irqsave(&reader->irq_lock, flags);
386+
guard(spinlock_irqsave)(&reader->irq_lock);
392387
if (reader->state != UNIPERIF_STATE_STOPPED) {
393388
/* Stop the reader */
394389
uni_reader_stop(reader);
395390
}
396391
reader->substream = NULL;
397-
spin_unlock_irqrestore(&reader->irq_lock, flags);
398392
}
399393

400394
static const struct snd_soc_dai_ops uni_reader_dai_ops = {

0 commit comments

Comments
 (0)