summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2015-04-10 08:49:49 +0000
committerMark Brown <broonie@kernel.org>2015-04-27 20:57:38 +0100
commite9c390df671fadc829550935ffb6b23549f26ded (patch)
tree61669925f96241c05e861886b3ab84a8a24e86c5
parenteb2535f542b4279b42518d6a312c6f7290434e55 (diff)
ASoC: rsnd: make sure it uses lock when it calls rsnd_dai_call
rsnd_dai_call() should be called under rsnd_lock Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sh/rcar/core.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index a2a0b5768c44..164653c0bc10 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -731,10 +731,15 @@ static int rsnd_hw_params(struct snd_pcm_substream *substream,
{
struct snd_soc_dai *dai = rsnd_substream_to_dai(substream);
struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
+ struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
+ unsigned long flags;
int ret;
+ rsnd_lock(priv, flags);
ret = rsnd_dai_call(hw_params, io, substream, hw_params);
+ rsnd_unlock(priv, flags);
+
if (ret)
return ret;
@@ -919,14 +924,16 @@ int rsnd_kctrl_new_e(struct rsnd_mod *mod,
static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_dai *dai = rtd->cpu_dai;
+ struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
- int ret;
+ unsigned long flags;
+ int ret = 0;
- ret = rsnd_dai_call(pcm_new, &rdai->playback, rtd);
- if (ret)
- return ret;
+ rsnd_lock(priv, flags);
+ ret |= rsnd_dai_call(pcm_new, &rdai->playback, rtd);
+ ret |= rsnd_dai_call(pcm_new, &rdai->capture, rtd);
+ rsnd_unlock(priv, flags);
- ret = rsnd_dai_call(pcm_new, &rdai->capture, rtd);
if (ret)
return ret;
@@ -949,8 +956,11 @@ static const struct snd_soc_component_driver rsnd_soc_component = {
static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv,
struct rsnd_dai_stream *io)
{
+ unsigned long flags;
int ret;
+ rsnd_lock(priv, flags);
+
ret = rsnd_dai_call(probe, io, priv);
if (ret == -EAGAIN) {
/*
@@ -983,6 +993,7 @@ static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv,
*/
ret = rsnd_dai_call(probe, io, priv);
}
+ rsnd_unlock(priv, flags);
return ret;
}
@@ -998,6 +1009,7 @@ static int rsnd_probe(struct platform_device *pdev)
struct rsnd_dai *rdai;
const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev);
const struct rsnd_of_data *of_data;
+ unsigned long flags;
int (*probe_func[])(struct platform_device *pdev,
const struct rsnd_of_data *of_data,
struct rsnd_priv *priv) = {
@@ -1084,10 +1096,12 @@ static int rsnd_probe(struct platform_device *pdev)
exit_snd_soc:
snd_soc_unregister_platform(dev);
exit_snd_probe:
+ rsnd_lock(priv, flags);
for_each_rsnd_dai(rdai, priv, i) {
rsnd_dai_call(remove, &rdai->playback, priv);
rsnd_dai_call(remove, &rdai->capture, priv);
}
+ rsnd_unlock(priv, flags);
return ret;
}
@@ -1096,6 +1110,7 @@ static int rsnd_remove(struct platform_device *pdev)
{
struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev);
struct rsnd_dai *rdai;
+ unsigned long flags;
void (*remove_func[])(struct platform_device *pdev,
struct rsnd_priv *priv) = {
rsnd_ssi_remove,
@@ -1106,10 +1121,12 @@ static int rsnd_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
+ rsnd_lock(priv, flags);
for_each_rsnd_dai(rdai, priv, i) {
ret |= rsnd_dai_call(remove, &rdai->playback, priv);
ret |= rsnd_dai_call(remove, &rdai->capture, priv);
}
+ rsnd_unlock(priv, flags);
for (i = 0; i < ARRAY_SIZE(remove_func); i++)
remove_func[i](pdev, priv);