diff mbox

[05/17,v2] ASoC: adav80x: Update locking around use of DAPM pin API

Message ID 1392736948-26623-6-git-send-email-ckeepax@opensource.wolfsonmicro.com (mailing list archive)
State Accepted
Commit 1bf1b8cf4faf279c3643c5c8045bec53b047ca9a
Delegated to: Mark Brown
Headers show

Commit Message

Charles Keepax Feb. 18, 2014, 3:22 p.m. UTC
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>
---
 sound/soc/codecs/adav80x.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

Comments

Lars-Peter Clausen Feb. 18, 2014, 4:12 p.m. UTC | #1
On 02/18/2014 04:22 PM, Charles Keepax wrote:
> 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>

Thanks.

> ---
>   sound/soc/codecs/adav80x.c |   17 +++++++++++------
>   1 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c
> index 09d5609..9eb53c8 100644
> --- a/sound/soc/codecs/adav80x.c
> +++ b/sound/soc/codecs/adav80x.c
> @@ -539,6 +539,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) {
> @@ -571,7 +572,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;
> @@ -598,17 +599,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;
>
Mark Brown Feb. 20, 2014, 10:25 a.m. UTC | #2
On Tue, Feb 18, 2014 at 03:22:16PM +0000, Charles Keepax wrote:
> The pin updates in this driver look like they are intended to be done
> atomically, update to do so.

Applied, thanks.
diff mbox

Patch

diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c
index 09d5609..9eb53c8 100644
--- a/sound/soc/codecs/adav80x.c
+++ b/sound/soc/codecs/adav80x.c
@@ -539,6 +539,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) {
@@ -571,7 +572,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;
@@ -598,17 +599,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;