ASoC: adav80x: Update locking around use of DAPM pin API
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Tue, 18 Feb 2014 15:22:16 +0000 (15:22 +0000)
committerMark Brown <broonie@linaro.org>
Thu, 20 Feb 2014 10:22:44 +0000 (19:22 +0900)
The pin updates in this driver look like they are intended to be done
atomically, update to do so.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/codecs/adav80x.c

index f78b27a7c461d3e5580dad311fd583f30755a3b4..ab790d5fe53dfff8596136e925adbe653cbe837f 100644 (file)
@@ -541,6 +541,7 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec,
                              unsigned int freq, int dir)
 {
        struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
+       struct snd_soc_dapm_context *dapm = &codec->dapm;
 
        if (dir == SND_SOC_CLOCK_IN) {
                switch (clk_id) {
@@ -573,7 +574,7 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec,
                        regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL2,
                                iclk_ctrl2);
 
-                       snd_soc_dapm_sync(&codec->dapm);
+                       snd_soc_dapm_sync(dapm);
                }
        } else {
                unsigned int mask;
@@ -600,17 +601,21 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec,
                        adav80x->sysclk_pd[clk_id] = false;
                }
 
+               snd_soc_dapm_mutex_lock(dapm);
+
                if (adav80x->sysclk_pd[0])
-                       snd_soc_dapm_disable_pin(&codec->dapm, "PLL1");
+                       snd_soc_dapm_disable_pin_unlocked(dapm, "PLL1");
                else
-                       snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL1");
+                       snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLL1");
 
                if (adav80x->sysclk_pd[1] || adav80x->sysclk_pd[2])
-                       snd_soc_dapm_disable_pin(&codec->dapm, "PLL2");
+                       snd_soc_dapm_disable_pin_unlocked(dapm, "PLL2");
                else
-                       snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL2");
+                       snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLL2");
 
-               snd_soc_dapm_sync(&codec->dapm);
+               snd_soc_dapm_sync_unlocked(dapm);
+
+               snd_soc_dapm_mutex_unlock(dapm);
        }
 
        return 0;