Commit 9d7939c9 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mark Brown

ASoC: samsung: i2s: Drop spinlock pointer from i2s_dai data structure

As we now have the 'priv' pointer in most of the places we can use
priv->lock directly, dropping extra indirection in the SFR region
spinlock access.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent e2e16fa6
...@@ -87,8 +87,6 @@ struct i2s_dai { ...@@ -87,8 +87,6 @@ struct i2s_dai {
u32 quirks; u32 quirks;
const struct samsung_i2s_variant_regs *variant_regs; const struct samsung_i2s_variant_regs *variant_regs;
spinlock_t *lock;
struct samsung_i2s_priv *priv; struct samsung_i2s_priv *priv;
}; };
...@@ -103,7 +101,7 @@ struct samsung_i2s_priv { ...@@ -103,7 +101,7 @@ struct samsung_i2s_priv {
void __iomem *addr; void __iomem *addr;
/* Spinlock protecting access to the device's registers */ /* Spinlock protecting access to the device's registers */
spinlock_t spinlock; spinlock_t lock;
/* CPU DAIs and their corresponding drivers */ /* CPU DAIs and their corresponding drivers */
struct i2s_dai *dai; struct i2s_dai *dai;
...@@ -527,9 +525,9 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs, ...@@ -527,9 +525,9 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
pm_runtime_get_sync(dai->dev); pm_runtime_get_sync(dai->dev);
spin_lock_irqsave(i2s->lock, flags); spin_lock_irqsave(&priv->lock, flags);
mod = readl(priv->addr + I2SMOD); mod = readl(priv->addr + I2SMOD);
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
switch (clk_id) { switch (clk_id) {
case SAMSUNG_I2S_OPCLK: case SAMSUNG_I2S_OPCLK:
...@@ -624,11 +622,11 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs, ...@@ -624,11 +622,11 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
goto err; goto err;
} }
spin_lock_irqsave(i2s->lock, flags); spin_lock_irqsave(&priv->lock, flags);
mod = readl(priv->addr + I2SMOD); mod = readl(priv->addr + I2SMOD);
mod = (mod & ~mask) | val; mod = (mod & ~mask) | val;
writel(mod, priv->addr + I2SMOD); writel(mod, priv->addr + I2SMOD);
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
done: done:
pm_runtime_put(dai->dev); pm_runtime_put(dai->dev);
...@@ -709,7 +707,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -709,7 +707,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
} }
pm_runtime_get_sync(dai->dev); pm_runtime_get_sync(dai->dev);
spin_lock_irqsave(i2s->lock, flags); spin_lock_irqsave(&priv->lock, flags);
mod = readl(priv->addr + I2SMOD); mod = readl(priv->addr + I2SMOD);
/* /*
* Don't change the I2S mode if any controller is active on this * Don't change the I2S mode if any controller is active on this
...@@ -717,7 +715,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -717,7 +715,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
*/ */
if (any_active(i2s) && if (any_active(i2s) &&
((mod & (sdf_mask | lrp_rlow | mod_slave)) != tmp)) { ((mod & (sdf_mask | lrp_rlow | mod_slave)) != tmp)) {
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
pm_runtime_put(dai->dev); pm_runtime_put(dai->dev);
dev_err(&i2s->pdev->dev, dev_err(&i2s->pdev->dev,
"%s:%d Other DAI busy\n", __func__, __LINE__); "%s:%d Other DAI busy\n", __func__, __LINE__);
...@@ -727,7 +725,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -727,7 +725,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
mod &= ~(sdf_mask | lrp_rlow | mod_slave); mod &= ~(sdf_mask | lrp_rlow | mod_slave);
mod |= tmp; mod |= tmp;
writel(mod, priv->addr + I2SMOD); writel(mod, priv->addr + I2SMOD);
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
pm_runtime_put(dai->dev); pm_runtime_put(dai->dev);
return 0; return 0;
...@@ -812,11 +810,11 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -812,11 +810,11 @@ static int i2s_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
spin_lock_irqsave(i2s->lock, flags); spin_lock_irqsave(&priv->lock, flags);
mod = readl(priv->addr + I2SMOD); mod = readl(priv->addr + I2SMOD);
mod = (mod & ~mask) | val; mod = (mod & ~mask) | val;
writel(mod, priv->addr + I2SMOD); writel(mod, priv->addr + I2SMOD);
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
...@@ -944,6 +942,7 @@ static int config_setup(struct i2s_dai *i2s) ...@@ -944,6 +942,7 @@ static int config_setup(struct i2s_dai *i2s)
static int i2s_trigger(struct snd_pcm_substream *substream, static int i2s_trigger(struct snd_pcm_substream *substream,
int cmd, struct snd_soc_dai *dai) int cmd, struct snd_soc_dai *dai)
{ {
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct i2s_dai *i2s = to_info(rtd->cpu_dai); struct i2s_dai *i2s = to_info(rtd->cpu_dai);
...@@ -954,10 +953,10 @@ static int i2s_trigger(struct snd_pcm_substream *substream, ...@@ -954,10 +953,10 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
pm_runtime_get_sync(dai->dev); pm_runtime_get_sync(dai->dev);
spin_lock_irqsave(i2s->lock, flags); spin_lock_irqsave(&priv->lock, flags);
if (config_setup(i2s)) { if (config_setup(i2s)) {
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
return -EINVAL; return -EINVAL;
} }
...@@ -966,12 +965,12 @@ static int i2s_trigger(struct snd_pcm_substream *substream, ...@@ -966,12 +965,12 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
else else
i2s_txctrl(i2s, 1); i2s_txctrl(i2s, 1);
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
break; break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
spin_lock_irqsave(i2s->lock, flags); spin_lock_irqsave(&priv->lock, flags);
if (capture) { if (capture) {
i2s_rxctrl(i2s, 0); i2s_rxctrl(i2s, 0);
...@@ -981,7 +980,7 @@ static int i2s_trigger(struct snd_pcm_substream *substream, ...@@ -981,7 +980,7 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
i2s_fifo(i2s, FIC_TXFLUSH); i2s_fifo(i2s, FIC_TXFLUSH);
} }
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
pm_runtime_put(dai->dev); pm_runtime_put(dai->dev);
break; break;
} }
...@@ -1081,13 +1080,13 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) ...@@ -1081,13 +1080,13 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
i2s->rfs = 0; i2s->rfs = 0;
i2s->bfs = 0; i2s->bfs = 0;
spin_lock_irqsave(i2s->lock, flags); spin_lock_irqsave(&priv->lock, flags);
i2s_txctrl(i2s, 0); i2s_txctrl(i2s, 0);
i2s_rxctrl(i2s, 0); i2s_rxctrl(i2s, 0);
i2s_fifo(i2s, FIC_TXFLUSH); i2s_fifo(i2s, FIC_TXFLUSH);
i2s_fifo(other, FIC_TXFLUSH); i2s_fifo(other, FIC_TXFLUSH);
i2s_fifo(i2s, FIC_RXFLUSH); i2s_fifo(i2s, FIC_RXFLUSH);
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
/* Gate CDCLK by default */ /* Gate CDCLK by default */
if (!is_opened(other)) if (!is_opened(other))
...@@ -1108,9 +1107,9 @@ static int samsung_i2s_dai_remove(struct snd_soc_dai *dai) ...@@ -1108,9 +1107,9 @@ static int samsung_i2s_dai_remove(struct snd_soc_dai *dai)
if (!is_secondary(i2s)) { if (!is_secondary(i2s)) {
if (i2s->quirks & QUIRK_NEED_RSTCLR) { if (i2s->quirks & QUIRK_NEED_RSTCLR) {
spin_lock_irqsave(i2s->lock, flags); spin_lock_irqsave(&priv->lock, flags);
writel(0, priv->addr + I2SCON); writel(0, priv->addr + I2SCON);
spin_unlock_irqrestore(i2s->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
} }
} }
...@@ -1317,13 +1316,13 @@ static int i2s_register_clock_provider(struct samsung_i2s_priv *priv) ...@@ -1317,13 +1316,13 @@ static int i2s_register_clock_provider(struct samsung_i2s_priv *priv)
ARRAY_SIZE(p_names), ARRAY_SIZE(p_names),
CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT,
priv->addr + I2SMOD, reg_info->rclksrc_off, priv->addr + I2SMOD, reg_info->rclksrc_off,
1, 0, i2s->lock); 1, 0, &priv->lock);
priv->clk_table[CLK_I2S_RCLK_PSR] = clk_register_divider(dev, priv->clk_table[CLK_I2S_RCLK_PSR] = clk_register_divider(dev,
i2s_clk_name[CLK_I2S_RCLK_PSR], i2s_clk_name[CLK_I2S_RCLK_PSR],
i2s_clk_name[CLK_I2S_RCLK_SRC], i2s_clk_name[CLK_I2S_RCLK_SRC],
CLK_SET_RATE_PARENT, CLK_SET_RATE_PARENT,
priv->addr + I2SPSR, 8, 6, 0, i2s->lock); priv->addr + I2SPSR, 8, 6, 0, &priv->lock);
p_names[0] = i2s_clk_name[CLK_I2S_RCLK_PSR]; p_names[0] = i2s_clk_name[CLK_I2S_RCLK_PSR];
priv->clk_data.clk_num = 2; priv->clk_data.clk_num = 2;
...@@ -1333,7 +1332,7 @@ static int i2s_register_clock_provider(struct samsung_i2s_priv *priv) ...@@ -1333,7 +1332,7 @@ static int i2s_register_clock_provider(struct samsung_i2s_priv *priv)
i2s_clk_name[CLK_I2S_CDCLK], p_names[0], i2s_clk_name[CLK_I2S_CDCLK], p_names[0],
CLK_SET_RATE_PARENT, CLK_SET_RATE_PARENT,
priv->addr + I2SMOD, reg_info->cdclkcon_off, priv->addr + I2SMOD, reg_info->cdclkcon_off,
CLK_GATE_SET_TO_DISABLE, i2s->lock); CLK_GATE_SET_TO_DISABLE, &priv->lock);
priv->clk_data.clk_num += 1; priv->clk_data.clk_num += 1;
priv->clk_data.clks = priv->clk_table; priv->clk_data.clks = priv->clk_table;
...@@ -1411,8 +1410,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) ...@@ -1411,8 +1410,7 @@ static int samsung_i2s_probe(struct platform_device *pdev)
pri_dai = &priv->dai[SAMSUNG_I2S_ID_PRIMARY - 1]; pri_dai = &priv->dai[SAMSUNG_I2S_ID_PRIMARY - 1];
spin_lock_init(&priv->spinlock); spin_lock_init(&priv->lock);
pri_dai->lock = &priv->spinlock;
if (!np) { if (!np) {
if (i2s_pdata == NULL) { if (i2s_pdata == NULL) {
...@@ -1474,7 +1472,6 @@ static int samsung_i2s_probe(struct platform_device *pdev) ...@@ -1474,7 +1472,6 @@ static int samsung_i2s_probe(struct platform_device *pdev)
if (quirks & QUIRK_SEC_DAI) { if (quirks & QUIRK_SEC_DAI) {
sec_dai = &priv->dai[SAMSUNG_I2S_ID_SECONDARY - 1]; sec_dai = &priv->dai[SAMSUNG_I2S_ID_SECONDARY - 1];
sec_dai->lock = &priv->spinlock;
sec_dai->variant_regs = pri_dai->variant_regs; sec_dai->variant_regs = pri_dai->variant_regs;
sec_dai->dma_playback.addr = regs_base + I2STXDS; sec_dai->dma_playback.addr = regs_base + I2STXDS;
sec_dai->dma_playback.chan_name = "tx-sec"; sec_dai->dma_playback.chan_name = "tx-sec";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment