Merge remote-tracking branches 'asoc/topic/max98088', 'asoc/topic/max98090', 'asoc...
[firefly-linux-kernel-4.4.55.git] / sound / soc / codecs / max98095.c
index d911d4cb9add43d1b4d723b7361aa29a3eecb9d5..8fba0c3db79827c97135928b4ed537bdec88bbaf 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/clk.h>
+#include <linux/mutex.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -57,6 +58,7 @@ struct max98095_priv {
        unsigned int mic2pre;
        struct snd_soc_jack *headphone_jack;
        struct snd_soc_jack *mic_jack;
+       struct mutex lock;
 };
 
 static const struct reg_default max98095_reg_def[] = {
@@ -1803,7 +1805,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
        regsave = snd_soc_read(codec, M98095_088_CFG_LEVEL);
        snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, 0);
 
-       mutex_lock(&codec->mutex);
+       mutex_lock(&max98095->lock);
        snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
        m98095_eq_band(codec, channel, 0, coef_set->band1);
        m98095_eq_band(codec, channel, 1, coef_set->band2);
@@ -1811,7 +1813,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
        m98095_eq_band(codec, channel, 3, coef_set->band4);
        m98095_eq_band(codec, channel, 4, coef_set->band5);
        snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, 0);
-       mutex_unlock(&codec->mutex);
+       mutex_unlock(&max98095->lock);
 
        /* Restore the original on/off state */
        snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, regsave);
@@ -1957,12 +1959,12 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
        regsave = snd_soc_read(codec, M98095_088_CFG_LEVEL);
        snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, 0);
 
-       mutex_lock(&codec->mutex);
+       mutex_lock(&max98095->lock);
        snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
        m98095_biquad_band(codec, channel, 0, coef_set->band1);
        m98095_biquad_band(codec, channel, 1, coef_set->band2);
        snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, 0);
-       mutex_unlock(&codec->mutex);
+       mutex_unlock(&max98095->lock);
 
        /* Restore the original on/off state */
        snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, regsave);
@@ -2390,6 +2392,8 @@ static int max98095_i2c_probe(struct i2c_client *i2c,
        if (max98095 == NULL)
                return -ENOMEM;
 
+       mutex_init(&max98095->lock);
+
        max98095->regmap = devm_regmap_init_i2c(i2c, &max98095_regmap);
        if (IS_ERR(max98095->regmap)) {
                ret = PTR_ERR(max98095->regmap);