ASoC: wm8958: Move DSP firmware lock to driver level
authorLars-Peter Clausen <lars@metafoo.de>
Sun, 9 Nov 2014 16:01:02 +0000 (17:01 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 10 Nov 2014 19:08:22 +0000 (19:08 +0000)
The wm8958 driver uses the snd_soc_codec mutex to protect the various
firmware pointers from concurrent assignment. 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>
sound/soc/codecs/wm8958-dsp2.c
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm8994.h

index 0dada7f0105e8fd51f6af7888d9a670d08f81c3b..3cbc82b3329288e8d16f33acaa4782dac147a542 100644 (file)
@@ -867,9 +867,9 @@ static void wm8958_enh_eq_loaded(const struct firmware *fw, void *context)
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        if (fw && (wm8958_dsp2_fw(codec, "ENH_EQ", fw, true) == 0)) {
-               mutex_lock(&codec->mutex);
+               mutex_lock(&wm8994->fw_lock);
                wm8994->enh_eq = fw;
-               mutex_unlock(&codec->mutex);
+               mutex_unlock(&wm8994->fw_lock);
        }
 }
 
@@ -879,9 +879,9 @@ static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context)
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        if (fw && (wm8958_dsp2_fw(codec, "MBC+VSS", fw, true) == 0)) {
-               mutex_lock(&codec->mutex);
+               mutex_lock(&wm8994->fw_lock);
                wm8994->mbc_vss = fw;
-               mutex_unlock(&codec->mutex);
+               mutex_unlock(&wm8994->fw_lock);
        }
 }
 
@@ -891,9 +891,9 @@ static void wm8958_mbc_loaded(const struct firmware *fw, void *context)
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        if (fw && (wm8958_dsp2_fw(codec, "MBC", fw, true) == 0)) {
-               mutex_lock(&codec->mutex);
+               mutex_lock(&wm8994->fw_lock);
                wm8994->mbc = fw;
-               mutex_unlock(&codec->mutex);
+               mutex_unlock(&wm8994->fw_lock);
        }
 }
 
index 1fcb9f3f309762d2793b59ccd094b26a55f84111..dbca6e0cc93a2d8d0fdd9e5e535b1a8c1f537655 100644 (file)
@@ -4457,6 +4457,8 @@ static int wm8994_probe(struct platform_device *pdev)
                return -ENOMEM;
        platform_set_drvdata(pdev, wm8994);
 
+       mutex_init(&wm8994->fw_lock);
+
        wm8994->wm8994 = dev_get_drvdata(pdev->dev.parent);
 
        pm_runtime_enable(&pdev->dev);
index 6536f8d45ac6bb0c4a13409582e299020bf0245d..dd73387b1cc49b286c58bfcc99561cf676512c88 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/firmware.h>
 #include <linux/completion.h>
 #include <linux/workqueue.h>
+#include <linux/mutex.h>
 
 #include "wm_hubs.h"
 
@@ -156,6 +157,7 @@ struct wm8994_priv {
        unsigned int aif1clk_disable:1;
        unsigned int aif2clk_disable:1;
 
+       struct mutex fw_lock;
        int dsp_active;
        const struct firmware *cur_fw;
        const struct firmware *mbc;