Skip to content

Commit 6917b59

Browse files
committed
ASoC: renesas: Use guard() for spin locks
Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>: Hi Mark, Iwai-san This patch-set follows Iwai-san's guard() update on Renesas drivers. Kuninori Morimoto (4): ASoC: renesas: msiof: Use guard() for spin locks ASoC: renesas: rsnd: Use guard() for spin locks ASoC: renesas: fsi: Use guard() for spin locks ASoC: renesas: rz-ssi: Use guard() for spin locks sound/soc/renesas/fsi.c | 30 ++++++++--------------------- sound/soc/renesas/rcar/core.c | 18 +++++------------ sound/soc/renesas/rcar/msiof.c | 26 ++++++++----------------- sound/soc/renesas/rcar/src.c | 19 ++++++++---------- sound/soc/renesas/rcar/ssi.c | 35 +++++++++++++++++----------------- sound/soc/renesas/rz-ssi.c | 14 ++++---------- 6 files changed, 50 insertions(+), 92 deletions(-) -- 2.43.0
2 parents 843e94c + 7d08366 commit 6917b59

6 files changed

Lines changed: 50 additions & 92 deletions

File tree

sound/soc/renesas/fsi.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -343,26 +343,19 @@ static void __fsi_reg_mask_set(u32 __iomem *reg, u32 mask, u32 data)
343343
#define fsi_core_read(p, r) _fsi_master_read(p, p->core->r)
344344
static u32 _fsi_master_read(struct fsi_master *master, u32 reg)
345345
{
346-
u32 ret;
347-
unsigned long flags;
346+
guard(spinlock_irqsave)(&master->lock);
348347

349-
spin_lock_irqsave(&master->lock, flags);
350-
ret = __fsi_reg_read(master->base + reg);
351-
spin_unlock_irqrestore(&master->lock, flags);
352-
353-
return ret;
348+
return __fsi_reg_read(master->base + reg);
354349
}
355350

356351
#define fsi_master_mask_set(p, r, m, d) _fsi_master_mask_set(p, MST_##r, m, d)
357352
#define fsi_core_mask_set(p, r, m, d) _fsi_master_mask_set(p, p->core->r, m, d)
358353
static void _fsi_master_mask_set(struct fsi_master *master,
359354
u32 reg, u32 mask, u32 data)
360355
{
361-
unsigned long flags;
356+
guard(spinlock_irqsave)(&master->lock);
362357

363-
spin_lock_irqsave(&master->lock, flags);
364358
__fsi_reg_mask_set(master->base + reg, mask, data);
365-
spin_unlock_irqrestore(&master->lock, flags);
366359
}
367360

368361
/*
@@ -499,14 +492,10 @@ static int fsi_stream_is_working(struct fsi_priv *fsi,
499492
struct fsi_stream *io)
500493
{
501494
struct fsi_master *master = fsi_get_master(fsi);
502-
unsigned long flags;
503-
int ret;
504495

505-
spin_lock_irqsave(&master->lock, flags);
506-
ret = !!(io->substream && io->substream->runtime);
507-
spin_unlock_irqrestore(&master->lock, flags);
496+
guard(spinlock_irqsave)(&master->lock);
508497

509-
return ret;
498+
return !!(io->substream && io->substream->runtime);
510499
}
511500

512501
static struct fsi_priv *fsi_stream_to_priv(struct fsi_stream *io)
@@ -520,9 +509,9 @@ static void fsi_stream_init(struct fsi_priv *fsi,
520509
{
521510
struct snd_pcm_runtime *runtime = substream->runtime;
522511
struct fsi_master *master = fsi_get_master(fsi);
523-
unsigned long flags;
524512

525-
spin_lock_irqsave(&master->lock, flags);
513+
guard(spinlock_irqsave)(&master->lock);
514+
526515
io->substream = substream;
527516
io->buff_sample_capa = fsi_frame2sample(fsi, runtime->buffer_size);
528517
io->buff_sample_pos = 0;
@@ -533,16 +522,14 @@ static void fsi_stream_init(struct fsi_priv *fsi,
533522
io->oerr_num = -1; /* ignore 1st err */
534523
io->uerr_num = -1; /* ignore 1st err */
535524
fsi_stream_handler_call(io, init, fsi, io);
536-
spin_unlock_irqrestore(&master->lock, flags);
537525
}
538526

539527
static void fsi_stream_quit(struct fsi_priv *fsi, struct fsi_stream *io)
540528
{
541529
struct snd_soc_dai *dai = fsi_get_dai(io->substream);
542530
struct fsi_master *master = fsi_get_master(fsi);
543-
unsigned long flags;
544531

545-
spin_lock_irqsave(&master->lock, flags);
532+
guard(spinlock_irqsave)(&master->lock);
546533

547534
if (io->oerr_num > 0)
548535
dev_err(dai->dev, "over_run = %d\n", io->oerr_num);
@@ -560,7 +547,6 @@ static void fsi_stream_quit(struct fsi_priv *fsi, struct fsi_stream *io)
560547
io->bus_option = 0;
561548
io->oerr_num = 0;
562549
io->uerr_num = 0;
563-
spin_unlock_irqrestore(&master->lock, flags);
564550
}
565551

566552
static int fsi_stream_transfer(struct fsi_stream *io)

sound/soc/renesas/rcar/core.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -696,25 +696,21 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
696696
struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
697697
struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
698698
int ret;
699-
unsigned long flags;
700699

701-
spin_lock_irqsave(&priv->lock, flags);
700+
guard(spinlock_irqsave)(&priv->lock);
702701

703702
switch (cmd) {
704703
case SNDRV_PCM_TRIGGER_START:
705704
case SNDRV_PCM_TRIGGER_RESUME:
706705
ret = rsnd_dai_call(init, io, priv);
707706
if (ret < 0)
708-
goto dai_trigger_end;
707+
break;
709708

710709
ret = rsnd_dai_call(start, io, priv);
711710
if (ret < 0)
712-
goto dai_trigger_end;
711+
break;
713712

714713
ret = rsnd_dai_call(irq, io, priv, 1);
715-
if (ret < 0)
716-
goto dai_trigger_end;
717-
718714
break;
719715
case SNDRV_PCM_TRIGGER_STOP:
720716
case SNDRV_PCM_TRIGGER_SUSPEND:
@@ -729,9 +725,6 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
729725
ret = -EINVAL;
730726
}
731727

732-
dai_trigger_end:
733-
spin_unlock_irqrestore(&priv->lock, flags);
734-
735728
return ret;
736729
}
737730

@@ -1545,15 +1538,14 @@ static int rsnd_hw_update(struct snd_pcm_substream *substream,
15451538
struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
15461539
struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
15471540
struct rsnd_priv *priv = rsnd_io_to_priv(io);
1548-
unsigned long flags;
15491541
int ret;
15501542

1551-
spin_lock_irqsave(&priv->lock, flags);
1543+
guard(spinlock_irqsave)(&priv->lock);
1544+
15521545
if (hw_params)
15531546
ret = rsnd_dai_call(hw_params, io, substream, hw_params);
15541547
else
15551548
ret = rsnd_dai_call(hw_free, io, substream);
1556-
spin_unlock_irqrestore(&priv->lock, flags);
15571549

15581550
return ret;
15591551
}

sound/soc/renesas/rcar/msiof.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,9 @@ static int msiof_trigger(struct snd_soc_component *component,
372372
{
373373
struct device *dev = component->dev;
374374
struct msiof_priv *priv = dev_get_drvdata(dev);
375-
unsigned long flags;
376375
int ret = -EINVAL;
377376

378-
spin_lock_irqsave(&priv->lock, flags);
377+
guard(spinlock_irqsave)(&priv->lock);
379378

380379
switch (cmd) {
381380
case SNDRV_PCM_TRIGGER_START:
@@ -392,8 +391,6 @@ static int msiof_trigger(struct snd_soc_component *component,
392391
break;
393392
}
394393

395-
spin_unlock_irqrestore(&priv->lock, flags);
396-
397394
return ret;
398395
}
399396

@@ -404,23 +401,18 @@ static int msiof_hw_params(struct snd_soc_component *component,
404401
struct msiof_priv *priv = dev_get_drvdata(component->dev);
405402
struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
406403
struct dma_slave_config cfg = {};
407-
unsigned long flags;
408404
int ret;
409405

410-
spin_lock_irqsave(&priv->lock, flags);
406+
guard(spinlock_irqsave)(&priv->lock);
411407

412408
ret = snd_hwparams_to_dma_slave_config(substream, params, &cfg);
413409
if (ret < 0)
414-
goto hw_params_out;
410+
return ret;
415411

416412
cfg.dst_addr = priv->phy_addr + SITFDR;
417413
cfg.src_addr = priv->phy_addr + SIRFDR;
418414

419-
ret = dmaengine_slave_config(chan, &cfg);
420-
hw_params_out:
421-
spin_unlock_irqrestore(&priv->lock, flags);
422-
423-
return ret;
415+
return dmaengine_slave_config(chan, &cfg);
424416
}
425417

426418
static const struct snd_soc_component_driver msiof_component_driver = {
@@ -439,12 +431,10 @@ static irqreturn_t msiof_interrupt(int irq, void *data)
439431
struct snd_pcm_substream *substream;
440432
u32 sistr;
441433

442-
spin_lock(&priv->lock);
443-
444-
sistr = msiof_read(priv, SISTR);
445-
msiof_write(priv, SISTR, SISTR_ERR_TX | SISTR_ERR_RX);
446-
447-
spin_unlock(&priv->lock);
434+
scoped_guard(spinlock, &priv->lock) {
435+
sistr = msiof_read(priv, SISTR);
436+
msiof_write(priv, SISTR, SISTR_ERR_TX | SISTR_ERR_RX);
437+
}
448438

449439
/* overflow/underflow error */
450440
substream = priv->substream[SNDRV_PCM_STREAM_PLAYBACK];

sound/soc/renesas/rcar/src.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -558,19 +558,16 @@ static void __rsnd_src_interrupt(struct rsnd_mod *mod,
558558
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
559559
bool stop = false;
560560

561-
spin_lock(&priv->lock);
562-
563-
/* ignore all cases if not working */
564-
if (!rsnd_io_is_working(io))
565-
goto rsnd_src_interrupt_out;
561+
scoped_guard(spinlock, &priv->lock) {
562+
/* ignore all cases if not working */
563+
if (!rsnd_io_is_working(io))
564+
break;
566565

567-
if (rsnd_src_error_occurred(mod))
568-
stop = true;
566+
if (rsnd_src_error_occurred(mod))
567+
stop = true;
569568

570-
rsnd_src_status_clear(mod);
571-
rsnd_src_interrupt_out:
572-
573-
spin_unlock(&priv->lock);
569+
rsnd_src_status_clear(mod);
570+
}
574571

575572
if (stop)
576573
snd_pcm_stop_xrun(io->substream);

sound/soc/renesas/rcar/ssi.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -680,31 +680,30 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
680680
bool elapsed = false;
681681
bool stop = false;
682682

683-
spin_lock(&priv->lock);
683+
scoped_guard(spinlock, &priv->lock) {
684684

685-
/* ignore all cases if not working */
686-
if (!rsnd_io_is_working(io))
687-
goto rsnd_ssi_interrupt_out;
685+
/* ignore all cases if not working */
686+
if (!rsnd_io_is_working(io))
687+
break;
688688

689-
status = rsnd_ssi_status_get(mod);
689+
status = rsnd_ssi_status_get(mod);
690690

691-
/* PIO only */
692-
if (!is_dma && (status & DIRQ))
693-
elapsed = rsnd_ssi_pio_interrupt(mod, io);
691+
/* PIO only */
692+
if (!is_dma && (status & DIRQ))
693+
elapsed = rsnd_ssi_pio_interrupt(mod, io);
694694

695-
/* DMA only */
696-
if (is_dma && (status & (UIRQ | OIRQ))) {
697-
rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
698-
rsnd_mod_name(mod), status);
695+
/* DMA only */
696+
if (is_dma && (status & (UIRQ | OIRQ))) {
697+
rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
698+
rsnd_mod_name(mod), status);
699699

700-
stop = true;
701-
}
700+
stop = true;
701+
}
702702

703-
stop |= rsnd_ssiu_busif_err_status_clear(mod);
703+
stop |= rsnd_ssiu_busif_err_status_clear(mod);
704704

705-
rsnd_ssi_status_clear(mod);
706-
rsnd_ssi_interrupt_out:
707-
spin_unlock(&priv->lock);
705+
rsnd_ssi_status_clear(mod);
706+
}
708707

709708
if (elapsed)
710709
snd_pcm_period_elapsed(io->substream);

sound/soc/renesas/rz-ssi.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,18 @@ static void rz_ssi_set_substream(struct rz_ssi_stream *strm,
188188
struct snd_pcm_substream *substream)
189189
{
190190
struct rz_ssi_priv *ssi = strm->priv;
191-
unsigned long flags;
192191

193-
spin_lock_irqsave(&ssi->lock, flags);
192+
guard(spinlock_irqsave)(&ssi->lock);
193+
194194
strm->substream = substream;
195-
spin_unlock_irqrestore(&ssi->lock, flags);
196195
}
197196

198197
static bool rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi,
199198
struct rz_ssi_stream *strm)
200199
{
201-
unsigned long flags;
202-
bool ret;
203-
204-
spin_lock_irqsave(&ssi->lock, flags);
205-
ret = strm->substream && strm->substream->runtime;
206-
spin_unlock_irqrestore(&ssi->lock, flags);
200+
guard(spinlock_irqsave)(&ssi->lock);
207201

208-
return ret;
202+
return strm->substream && strm->substream->runtime;
209203
}
210204

211205
static inline bool rz_ssi_is_stream_running(struct rz_ssi_stream *strm)

0 commit comments

Comments
 (0)