ASoC: wm5102: Move ultrasonic response settings lock to the driver level
authorLars-Peter Clausen <lars@metafoo.de>
Sun, 9 Nov 2014 16:00:59 +0000 (17:00 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 10 Nov 2014 19:07:57 +0000 (19:07 +0000)
The wm5102 driver currently uses the snd_soc_codec mutex to protect its
ultrasonic response settings from concurrent access. This patch moves this
lock to the driver level. This will allow us to eventually remove the
snd_soc_codec mutex.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/linux/mfd/arizona/core.h
sound/soc/codecs/arizona.c
sound/soc/codecs/wm5102.c

index f34723f7663c722c6983dcda572f7d342def4b74..910e3aa1e9652861333a383ef65934b4e6822f69 100644 (file)
@@ -141,6 +141,7 @@ struct arizona {
 
        uint16_t dac_comp_coeff;
        uint8_t dac_comp_enabled;
+       struct mutex dac_comp_lock;
 };
 
 int arizona_clk32k_enable(struct arizona *arizona);
index 0c05e7a7945fe203a760eb0f412b97bd48d29783..730636c14f2e7ee0e37eeb160076e64be8e4b4bd 100644 (file)
@@ -1164,13 +1164,13 @@ static void arizona_wm5102_set_dac_comp(struct snd_soc_codec *codec,
                { 0x80, 0x0 },
        };
 
-       mutex_lock(&codec->mutex);
+       mutex_lock(&arizona->dac_comp_lock);
 
        dac_comp[1].def = arizona->dac_comp_coeff;
        if (rate >= 176400)
                dac_comp[2].def = arizona->dac_comp_enabled;
 
-       mutex_unlock(&codec->mutex);
+       mutex_unlock(&arizona->dac_comp_lock);
 
        regmap_multi_reg_write(arizona->regmap,
                               dac_comp,
index f602349625278fb7c9717990f07c739276109130..1f755349266762410a0758bc4beb520f926df95f 100644 (file)
@@ -619,10 +619,10 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
        struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
        uint16_t data;
 
-       mutex_lock(&codec->mutex);
+       mutex_lock(&arizona->dac_comp_lock);
        data = cpu_to_be16(arizona->dac_comp_coeff);
        memcpy(ucontrol->value.bytes.data, &data, sizeof(data));
-       mutex_unlock(&codec->mutex);
+       mutex_unlock(&arizona->dac_comp_lock);
 
        return 0;
 }
@@ -633,11 +633,11 @@ static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
 
-       mutex_lock(&codec->mutex);
+       mutex_lock(&arizona->dac_comp_lock);
        memcpy(&arizona->dac_comp_coeff, ucontrol->value.bytes.data,
               sizeof(arizona->dac_comp_coeff));
        arizona->dac_comp_coeff = be16_to_cpu(arizona->dac_comp_coeff);
-       mutex_unlock(&codec->mutex);
+       mutex_unlock(&arizona->dac_comp_lock);
 
        return 0;
 }
@@ -648,9 +648,9 @@ static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
 
-       mutex_lock(&codec->mutex);
+       mutex_lock(&arizona->dac_comp_lock);
        ucontrol->value.integer.value[0] = arizona->dac_comp_enabled;
-       mutex_unlock(&codec->mutex);
+       mutex_unlock(&arizona->dac_comp_lock);
 
        return 0;
 }
@@ -661,9 +661,9 @@ static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
 
-       mutex_lock(&codec->mutex);
+       mutex_lock(&arizona->dac_comp_lock);
        arizona->dac_comp_enabled = ucontrol->value.integer.value[0];
-       mutex_unlock(&codec->mutex);
+       mutex_unlock(&arizona->dac_comp_lock);
 
        return 0;
 }