Skip to content

Commit 15583c4

Browse files
morimotobroonie
authored andcommitted
ASoC: renesas: fsi: Use guard() for spin locks
Clean up the code using guard() for spin locks. Merely code refactoring, and no behavior change. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Message-ID: <87h5xd1ypa.wl-kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 075a730 commit 15583c4

1 file changed

Lines changed: 8 additions & 22 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)

0 commit comments

Comments
 (0)