Unverified Commit 6917b595 authored by Mark Brown's avatar Mark Brown
Browse files

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
parents 843e94cc 7d083666
Loading
Loading
Loading
Loading
+8 −22
Original line number Diff line number Diff line
@@ -343,14 +343,9 @@ static void __fsi_reg_mask_set(u32 __iomem *reg, u32 mask, u32 data)
#define fsi_core_read(p, r)   _fsi_master_read(p, p->core->r)
static u32 _fsi_master_read(struct fsi_master *master, u32 reg)
{
	u32 ret;
	unsigned long flags;
	guard(spinlock_irqsave)(&master->lock);

	spin_lock_irqsave(&master->lock, flags);
	ret = __fsi_reg_read(master->base + reg);
	spin_unlock_irqrestore(&master->lock, flags);

	return ret;
	return __fsi_reg_read(master->base + reg);
}

#define fsi_master_mask_set(p, r, m, d) _fsi_master_mask_set(p, MST_##r, m, d)
@@ -358,11 +353,9 @@ static u32 _fsi_master_read(struct fsi_master *master, u32 reg)
static void _fsi_master_mask_set(struct fsi_master *master,
			       u32 reg, u32 mask, u32 data)
{
	unsigned long flags;
	guard(spinlock_irqsave)(&master->lock);

	spin_lock_irqsave(&master->lock, flags);
	__fsi_reg_mask_set(master->base + reg, mask, data);
	spin_unlock_irqrestore(&master->lock, flags);
}

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

	spin_lock_irqsave(&master->lock, flags);
	ret = !!(io->substream && io->substream->runtime);
	spin_unlock_irqrestore(&master->lock, flags);
	guard(spinlock_irqsave)(&master->lock);

	return ret;
	return !!(io->substream && io->substream->runtime);
}

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,
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct fsi_master *master = fsi_get_master(fsi);
	unsigned long flags;

	spin_lock_irqsave(&master->lock, flags);
	guard(spinlock_irqsave)(&master->lock);

	io->substream	= substream;
	io->buff_sample_capa	= fsi_frame2sample(fsi, runtime->buffer_size);
	io->buff_sample_pos	= 0;
@@ -533,16 +522,14 @@ static void fsi_stream_init(struct fsi_priv *fsi,
	io->oerr_num	= -1; /* ignore 1st err */
	io->uerr_num	= -1; /* ignore 1st err */
	fsi_stream_handler_call(io, init, fsi, io);
	spin_unlock_irqrestore(&master->lock, flags);
}

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

	spin_lock_irqsave(&master->lock, flags);
	guard(spinlock_irqsave)(&master->lock);

	if (io->oerr_num > 0)
		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)
	io->bus_option		= 0;
	io->oerr_num	= 0;
	io->uerr_num	= 0;
	spin_unlock_irqrestore(&master->lock, flags);
}

static int fsi_stream_transfer(struct fsi_stream *io)
+5 −13
Original line number Diff line number Diff line
@@ -696,25 +696,21 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
	struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
	struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
	int ret;
	unsigned long flags;

	spin_lock_irqsave(&priv->lock, flags);
	guard(spinlock_irqsave)(&priv->lock);

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
	case SNDRV_PCM_TRIGGER_RESUME:
		ret = rsnd_dai_call(init, io, priv);
		if (ret < 0)
			goto dai_trigger_end;
			break;

		ret = rsnd_dai_call(start, io, priv);
		if (ret < 0)
			goto dai_trigger_end;
			break;

		ret = rsnd_dai_call(irq, io, priv, 1);
		if (ret < 0)
			goto dai_trigger_end;

		break;
	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_SUSPEND:
@@ -729,9 +725,6 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
		ret = -EINVAL;
	}

dai_trigger_end:
	spin_unlock_irqrestore(&priv->lock, flags);

	return ret;
}

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

	spin_lock_irqsave(&priv->lock, flags);
	guard(spinlock_irqsave)(&priv->lock);

	if (hw_params)
		ret = rsnd_dai_call(hw_params, io, substream, hw_params);
	else
		ret = rsnd_dai_call(hw_free, io, substream);
	spin_unlock_irqrestore(&priv->lock, flags);

	return ret;
}
+8 −18
Original line number Diff line number Diff line
@@ -372,10 +372,9 @@ static int msiof_trigger(struct snd_soc_component *component,
{
	struct device *dev = component->dev;
	struct msiof_priv *priv = dev_get_drvdata(dev);
	unsigned long flags;
	int ret = -EINVAL;

	spin_lock_irqsave(&priv->lock, flags);
	guard(spinlock_irqsave)(&priv->lock);

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

	spin_unlock_irqrestore(&priv->lock, flags);

	return ret;
}

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

	spin_lock_irqsave(&priv->lock, flags);
	guard(spinlock_irqsave)(&priv->lock);

	ret = snd_hwparams_to_dma_slave_config(substream, params, &cfg);
	if (ret < 0)
		goto hw_params_out;
		return ret;

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

	ret = dmaengine_slave_config(chan, &cfg);
hw_params_out:
	spin_unlock_irqrestore(&priv->lock, flags);

	return ret;
	return dmaengine_slave_config(chan, &cfg);
}

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

	spin_lock(&priv->lock);

	scoped_guard(spinlock, &priv->lock) {
		sistr = msiof_read(priv, SISTR);
		msiof_write(priv, SISTR, SISTR_ERR_TX | SISTR_ERR_RX);

	spin_unlock(&priv->lock);
	}

	/* overflow/underflow error */
	substream = priv->substream[SNDRV_PCM_STREAM_PLAYBACK];
+8 −11
Original line number Diff line number Diff line
@@ -558,19 +558,16 @@ static void __rsnd_src_interrupt(struct rsnd_mod *mod,
	struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
	bool stop = false;

	spin_lock(&priv->lock);

	scoped_guard(spinlock, &priv->lock) {
		/* ignore all cases if not working */
		if (!rsnd_io_is_working(io))
		goto rsnd_src_interrupt_out;
			break;

		if (rsnd_src_error_occurred(mod))
			stop = true;

		rsnd_src_status_clear(mod);
rsnd_src_interrupt_out:

	spin_unlock(&priv->lock);
	}

	if (stop)
		snd_pcm_stop_xrun(io->substream);
+17 −18
Original line number Diff line number Diff line
@@ -680,11 +680,11 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
	bool elapsed = false;
	bool stop = false;

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

		/* ignore all cases if not working */
		if (!rsnd_io_is_working(io))
		goto rsnd_ssi_interrupt_out;
			break;

		status = rsnd_ssi_status_get(mod);

@@ -703,8 +703,7 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
		stop |= rsnd_ssiu_busif_err_status_clear(mod);

		rsnd_ssi_status_clear(mod);
rsnd_ssi_interrupt_out:
	spin_unlock(&priv->lock);
	}

	if (elapsed)
		snd_pcm_period_elapsed(io->substream);
Loading