Commit 97c236e2 authored by Mark Brown's avatar Mark Brown

ASoC: cleanup mutex lock

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

ASoC is using many type of mutex lock, but
some of them has helper function, but some doesn't.
Or, it has helper function, but is static.

This patch-set adds helper function and use it.
parents 59de6c38 0f3b8184
...@@ -9,10 +9,25 @@ ...@@ -9,10 +9,25 @@
#define __SOC_CARD_H #define __SOC_CARD_H
enum snd_soc_card_subclass { enum snd_soc_card_subclass {
SND_SOC_CARD_CLASS_INIT = 0, SND_SOC_CARD_CLASS_ROOT = 0,
SND_SOC_CARD_CLASS_RUNTIME = 1, SND_SOC_CARD_CLASS_RUNTIME = 1,
}; };
static inline void snd_soc_card_mutex_lock_root(struct snd_soc_card *card)
{
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_ROOT);
}
static inline void snd_soc_card_mutex_lock(struct snd_soc_card *card)
{
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
}
static inline void snd_soc_card_mutex_unlock(struct snd_soc_card *card)
{
mutex_unlock(&card->mutex);
}
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name); const char *name);
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type, int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
......
...@@ -527,11 +527,6 @@ enum snd_soc_dapm_type { ...@@ -527,11 +527,6 @@ enum snd_soc_dapm_type {
SND_SOC_DAPM_TYPE_COUNT SND_SOC_DAPM_TYPE_COUNT
}; };
enum snd_soc_dapm_subclass {
SND_SOC_DAPM_CLASS_INIT = 0,
SND_SOC_DAPM_CLASS_RUNTIME = 1,
};
/* /*
* DAPM audio route definition. * DAPM audio route definition.
* *
......
...@@ -1364,17 +1364,112 @@ extern struct dentry *snd_soc_debugfs_root; ...@@ -1364,17 +1364,112 @@ extern struct dentry *snd_soc_debugfs_root;
extern const struct dev_pm_ops snd_soc_pm_ops; extern const struct dev_pm_ops snd_soc_pm_ops;
/* Helper functions */ /*
static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm) * DAPM helper functions
*/
enum snd_soc_dapm_subclass {
SND_SOC_DAPM_CLASS_ROOT = 0,
SND_SOC_DAPM_CLASS_RUNTIME = 1,
};
static inline void _snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card *card)
{
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_ROOT);
}
static inline void _snd_soc_dapm_mutex_lock_c(struct snd_soc_card *card)
{
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
}
static inline void _snd_soc_dapm_mutex_unlock_c(struct snd_soc_card *card)
{
mutex_unlock(&card->dapm_mutex);
}
static inline void _snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card *card)
{
lockdep_assert_held(&card->dapm_mutex);
}
static inline void _snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context *dapm)
{
_snd_soc_dapm_mutex_lock_root_c(dapm->card);
}
static inline void _snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context *dapm)
{
_snd_soc_dapm_mutex_lock_c(dapm->card);
}
static inline void _snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context *dapm)
{
_snd_soc_dapm_mutex_unlock_c(dapm->card);
}
static inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context *dapm)
{
_snd_soc_dapm_mutex_assert_held_c(dapm->card);
}
#define snd_soc_dapm_mutex_lock_root(x) _Generic((x), \
struct snd_soc_card * : _snd_soc_dapm_mutex_lock_root_c, \
struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_root_d)(x)
#define snd_soc_dapm_mutex_lock(x) _Generic((x), \
struct snd_soc_card * : _snd_soc_dapm_mutex_lock_c, \
struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_d)(x)
#define snd_soc_dapm_mutex_unlock(x) _Generic((x), \
struct snd_soc_card * : _snd_soc_dapm_mutex_unlock_c, \
struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_unlock_d)(x)
#define snd_soc_dapm_mutex_assert_held(x) _Generic((x), \
struct snd_soc_card * : _snd_soc_dapm_mutex_assert_held_c, \
struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_assert_held_d)(x)
/*
* PCM helper functions
*/
static inline void _snd_soc_dpcm_mutex_lock_c(struct snd_soc_card *card)
{
mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass);
}
static inline void _snd_soc_dpcm_mutex_unlock_c(struct snd_soc_card *card)
{ {
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); mutex_unlock(&card->pcm_mutex);
} }
static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) static inline void _snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card *card)
{ {
mutex_unlock(&dapm->card->dapm_mutex); lockdep_assert_held(&card->pcm_mutex);
} }
static inline void _snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime *rtd)
{
_snd_soc_dpcm_mutex_lock_c(rtd->card);
}
static inline void _snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime *rtd)
{
_snd_soc_dpcm_mutex_unlock_c(rtd->card);
}
static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime *rtd)
{
_snd_soc_dpcm_mutex_assert_held_c(rtd->card);
}
#define snd_soc_dpcm_mutex_lock(x) _Generic((x), \
struct snd_soc_card * : _snd_soc_dpcm_mutex_lock_c, \
struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_lock_r)(x)
#define snd_soc_dpcm_mutex_unlock(x) _Generic((x), \
struct snd_soc_card * : _snd_soc_dpcm_mutex_unlock_c, \
struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_unlock_r)(x)
#define snd_soc_dpcm_mutex_assert_held(x) _Generic((x), \
struct snd_soc_card * : _snd_soc_dpcm_mutex_assert_held_c, \
struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_assert_held_r)(x)
#include <sound/soc-component.h> #include <sound/soc-component.h>
#include <sound/soc-card.h> #include <sound/soc-card.h>
#include <sound/soc-jack.h> #include <sound/soc-jack.h>
......
...@@ -550,7 +550,7 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream, ...@@ -550,7 +550,7 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
struct snd_soc_component *component; struct snd_soc_component *component;
int i, ret = 0; int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
for_each_rtd_components(rtd, i, component) { for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops && if (component->driver->compress_ops &&
...@@ -561,7 +561,7 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream, ...@@ -561,7 +561,7 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
} }
} }
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
return soc_component_ret(component, ret); return soc_component_ret(component, ret);
} }
...@@ -574,7 +574,7 @@ int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream, ...@@ -574,7 +574,7 @@ int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
struct snd_soc_component *component; struct snd_soc_component *component;
int i, ret = 0; int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
for_each_rtd_components(rtd, i, component) { for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops && if (component->driver->compress_ops &&
...@@ -585,7 +585,7 @@ int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream, ...@@ -585,7 +585,7 @@ int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
} }
} }
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
return soc_component_ret(component, ret); return soc_component_ret(component, ret);
} }
...@@ -638,7 +638,7 @@ int snd_soc_component_compr_copy(struct snd_compr_stream *cstream, ...@@ -638,7 +638,7 @@ int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
struct snd_soc_component *component; struct snd_soc_component *component;
int i, ret = 0; int i, ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
for_each_rtd_components(rtd, i, component) { for_each_rtd_components(rtd, i, component) {
if (component->driver->compress_ops && if (component->driver->compress_ops &&
...@@ -649,7 +649,7 @@ int snd_soc_component_compr_copy(struct snd_compr_stream *cstream, ...@@ -649,7 +649,7 @@ int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
} }
} }
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
return soc_component_ret(component, ret); return soc_component_ret(component, ret);
} }
......
...@@ -62,7 +62,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback) ...@@ -62,7 +62,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
if (!rollback) if (!rollback)
snd_soc_runtime_deactivate(rtd, stream); snd_soc_runtime_deactivate(rtd, stream);
...@@ -84,7 +84,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback) ...@@ -84,7 +84,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
if (!rollback) if (!rollback)
snd_soc_dapm_stream_stop(rtd, stream); snd_soc_dapm_stream_stop(rtd, stream);
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
snd_soc_pcm_component_pm_runtime_put(rtd, cstream, rollback); snd_soc_pcm_component_pm_runtime_put(rtd, cstream, rollback);
...@@ -107,7 +107,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) ...@@ -107,7 +107,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
if (ret < 0) if (ret < 0)
goto err_no_lock; goto err_no_lock;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_dai_compr_startup(cpu_dai, cstream); ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
if (ret < 0) if (ret < 0)
...@@ -123,7 +123,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) ...@@ -123,7 +123,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
snd_soc_runtime_activate(rtd, stream); snd_soc_runtime_activate(rtd, stream);
err: err:
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
err_no_lock: err_no_lock:
if (ret < 0) if (ret < 0)
soc_compr_clean(cstream, 1); soc_compr_clean(cstream, 1);
...@@ -140,13 +140,13 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) ...@@ -140,13 +140,13 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
int ret; int ret;
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_card_mutex_lock(fe->card);
ret = dpcm_path_get(fe, stream, &list); ret = dpcm_path_get(fe, stream, &list);
if (ret < 0) if (ret < 0)
goto be_err; goto be_err;
mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); snd_soc_dpcm_mutex_lock(fe);
/* calculate valid and active FE <-> BE dpcms */ /* calculate valid and active FE <-> BE dpcms */
dpcm_process_paths(fe, stream, &list, 1); dpcm_process_paths(fe, stream, &list, 1);
...@@ -182,9 +182,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) ...@@ -182,9 +182,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
snd_soc_runtime_activate(fe, stream); snd_soc_runtime_activate(fe, stream);
mutex_unlock(&fe->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(fe);
mutex_unlock(&fe->card->mutex); snd_soc_card_mutex_unlock(fe->card);
return 0; return 0;
...@@ -196,7 +196,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) ...@@ -196,7 +196,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
dpcm_path_put(&list); dpcm_path_put(&list);
be_err: be_err:
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
mutex_unlock(&fe->card->mutex); snd_soc_card_mutex_unlock(fe->card);
return ret; return ret;
} }
...@@ -207,9 +207,9 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) ...@@ -207,9 +207,9 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
struct snd_soc_dpcm *dpcm; struct snd_soc_dpcm *dpcm;
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_card_mutex_lock(fe->card);
mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); snd_soc_dpcm_mutex_lock(fe);
snd_soc_runtime_deactivate(fe, stream); snd_soc_runtime_deactivate(fe, stream);
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
...@@ -229,7 +229,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) ...@@ -229,7 +229,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
dpcm_be_disconnect(fe, stream); dpcm_be_disconnect(fe, stream);
mutex_unlock(&fe->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(fe);
snd_soc_link_compr_shutdown(cstream, 0); snd_soc_link_compr_shutdown(cstream, 0);
...@@ -237,7 +237,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) ...@@ -237,7 +237,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0); snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0);
mutex_unlock(&fe->card->mutex); snd_soc_card_mutex_unlock(fe->card);
return 0; return 0;
} }
...@@ -249,7 +249,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) ...@@ -249,7 +249,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
int ret; int ret;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_component_compr_trigger(cstream, cmd); ret = snd_soc_component_compr_trigger(cstream, cmd);
if (ret < 0) if (ret < 0)
...@@ -269,7 +269,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) ...@@ -269,7 +269,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
} }
out: out:
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
return ret; return ret;
} }
...@@ -284,7 +284,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) ...@@ -284,7 +284,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
cmd == SND_COMPR_TRIGGER_DRAIN) cmd == SND_COMPR_TRIGGER_DRAIN)
return snd_soc_component_compr_trigger(cstream, cmd); return snd_soc_component_compr_trigger(cstream, cmd);
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_card_mutex_lock(fe->card);
ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd); ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
if (ret < 0) if (ret < 0)
...@@ -315,7 +315,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) ...@@ -315,7 +315,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
out: out:
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
mutex_unlock(&fe->card->mutex); snd_soc_card_mutex_unlock(fe->card);
return ret; return ret;
} }
...@@ -327,7 +327,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, ...@@ -327,7 +327,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
int ret; int ret;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
/* /*
* First we call set_params for the CPU DAI, then the component * First we call set_params for the CPU DAI, then the component
...@@ -352,14 +352,14 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, ...@@ -352,14 +352,14 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
/* cancel any delayed stream shutdown that is pending */ /* cancel any delayed stream shutdown that is pending */
rtd->pop_wait = 0; rtd->pop_wait = 0;
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
cancel_delayed_work_sync(&rtd->delayed_work); cancel_delayed_work_sync(&rtd->delayed_work);
return 0; return 0;
err: err:
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
return ret; return ret;
} }
...@@ -373,7 +373,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, ...@@ -373,7 +373,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
int ret; int ret;
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); snd_soc_card_mutex_lock(fe->card);
/* /*
* Create an empty hw_params for the BE as the machine driver must * Create an empty hw_params for the BE as the machine driver must
...@@ -404,14 +404,14 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, ...@@ -404,14 +404,14 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
ret = snd_soc_link_compr_set_params(cstream); ret = snd_soc_link_compr_set_params(cstream);
if (ret < 0) if (ret < 0)
goto out; goto out;
mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); snd_soc_dpcm_mutex_lock(fe);
dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START); dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START);
mutex_unlock(&fe->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(fe);
fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
out: out:
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
mutex_unlock(&fe->card->mutex); snd_soc_card_mutex_unlock(fe->card);
return ret; return ret;
} }
...@@ -422,7 +422,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, ...@@ -422,7 +422,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int ret = 0; int ret = 0;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params); ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params);
if (ret < 0) if (ret < 0)
...@@ -430,7 +430,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, ...@@ -430,7 +430,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
ret = snd_soc_component_compr_get_params(cstream, params); ret = snd_soc_component_compr_get_params(cstream, params);
err: err:
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
return ret; return ret;
} }
...@@ -440,7 +440,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) ...@@ -440,7 +440,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int ret; int ret;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes); ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes);
if (ret < 0) if (ret < 0)
...@@ -448,7 +448,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) ...@@ -448,7 +448,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
ret = snd_soc_component_compr_ack(cstream, bytes); ret = snd_soc_component_compr_ack(cstream, bytes);
err: err:
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
return ret; return ret;
} }
...@@ -459,7 +459,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, ...@@ -459,7 +459,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
int ret; int ret;
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp); ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp);
if (ret < 0) if (ret < 0)
...@@ -467,7 +467,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, ...@@ -467,7 +467,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
ret = snd_soc_component_compr_pointer(cstream, tstamp); ret = snd_soc_component_compr_pointer(cstream, tstamp);
out: out:
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
return ret; return ret;
} }
......
...@@ -348,7 +348,7 @@ void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd) ...@@ -348,7 +348,7 @@ void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd)
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
int playback = SNDRV_PCM_STREAM_PLAYBACK; int playback = SNDRV_PCM_STREAM_PLAYBACK;
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); snd_soc_dpcm_mutex_lock(rtd);
dev_dbg(rtd->dev, dev_dbg(rtd->dev,
"ASoC: pop wq checking: %s status: %s waiting: %s\n", "ASoC: pop wq checking: %s status: %s waiting: %s\n",
...@@ -364,7 +364,7 @@ void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd) ...@@ -364,7 +364,7 @@ void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd)
SND_SOC_DAPM_STREAM_STOP); SND_SOC_DAPM_STREAM_STOP);
} }
mutex_unlock(&rtd->card->pcm_mutex); snd_soc_dpcm_mutex_unlock(rtd);
} }
EXPORT_SYMBOL_GPL(snd_soc_close_delayed_work); EXPORT_SYMBOL_GPL(snd_soc_close_delayed_work);
...@@ -1938,7 +1938,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) ...@@ -1938,7 +1938,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
int ret; int ret;
mutex_lock(&client_mutex); mutex_lock(&client_mutex);
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); snd_soc_card_mutex_lock_root(card);
snd_soc_dapm_init(&card->dapm, card, NULL); snd_soc_dapm_init(&card->dapm, card, NULL);
...@@ -2093,7 +2093,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) ...@@ -2093,7 +2093,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
if (ret < 0) if (ret < 0)
soc_cleanup_card_resources(card); soc_cleanup_card_resources(card);
mutex_unlock(&card->mutex); snd_soc_card_mutex_unlock(card);
mutex_unlock(&client_mutex); mutex_unlock(&client_mutex);
return ret; return ret;
......
...@@ -150,7 +150,7 @@ static int dapm_down_seq[] = { ...@@ -150,7 +150,7 @@ static int dapm_down_seq[] = {
static void dapm_assert_locked(struct snd_soc_dapm_context *dapm) static void dapm_assert_locked(struct snd_soc_dapm_context *dapm)
{ {
if (snd_soc_card_is_instantiated(dapm->card)) if (snd_soc_card_is_instantiated(dapm->card))
lockdep_assert_held(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_assert_held(dapm);
} }
static void pop_wait(u32 pop_time) static void pop_wait(u32 pop_time)
...@@ -302,7 +302,7 @@ void dapm_mark_endpoints_dirty(struct snd_soc_card *card) ...@@ -302,7 +302,7 @@ void dapm_mark_endpoints_dirty(struct snd_soc_card *card)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
mutex_lock(&card->dapm_mutex); snd_soc_dapm_mutex_lock_root(card);
for_each_card_widgets(card, w) { for_each_card_widgets(card, w) {
if (w->is_ep) { if (w->is_ep) {
...@@ -314,7 +314,7 @@ void dapm_mark_endpoints_dirty(struct snd_soc_card *card) ...@@ -314,7 +314,7 @@ void dapm_mark_endpoints_dirty(struct snd_soc_card *card)
} }
} }
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
} }
EXPORT_SYMBOL_GPL(dapm_mark_endpoints_dirty); EXPORT_SYMBOL_GPL(dapm_mark_endpoints_dirty);
...@@ -604,7 +604,7 @@ static void dapm_reset(struct snd_soc_card *card) ...@@ -604,7 +604,7 @@ static void dapm_reset(struct snd_soc_card *card)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
lockdep_assert_held(&card->dapm_mutex); snd_soc_dapm_mutex_assert_held(card);
memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); memset(&card->dapm_stats, 0, sizeof(card->dapm_stats));
...@@ -1302,7 +1302,7 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, ...@@ -1302,7 +1302,7 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,
int paths; int paths;
int ret; int ret;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(card);
if (stream == SNDRV_PCM_STREAM_PLAYBACK) { if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
invalidate_paths_ep(w, SND_SOC_DAPM_DIR_OUT); invalidate_paths_ep(w, SND_SOC_DAPM_DIR_OUT);
...@@ -1322,7 +1322,7 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, ...@@ -1322,7 +1322,7 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,
paths = ret; paths = ret;
trace_snd_soc_dapm_connected(paths, stream); trace_snd_soc_dapm_connected(paths, stream);
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
return paths; return paths;
} }
...@@ -1952,7 +1952,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event) ...@@ -1952,7 +1952,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
enum snd_soc_bias_level bias; enum snd_soc_bias_level bias;
int ret; int ret;
lockdep_assert_held(&card->dapm_mutex); snd_soc_dapm_mutex_assert_held(card);
trace_snd_soc_dapm_start(card); trace_snd_soc_dapm_start(card);
...@@ -2090,7 +2090,6 @@ static ssize_t dapm_widget_power_read_file(struct file *file, ...@@ -2090,7 +2090,6 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct snd_soc_dapm_widget *w = file->private_data; struct snd_soc_dapm_widget *w = file->private_data;
struct snd_soc_card *card = w->dapm->card;
enum snd_soc_dapm_direction dir, rdir; enum snd_soc_dapm_direction dir, rdir;
char *buf; char *buf;
int in, out; int in, out;
...@@ -2101,7 +2100,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file, ...@@ -2101,7 +2100,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
mutex_lock(&card->dapm_mutex); snd_soc_dapm_mutex_lock_root(w->dapm);
/* Supply widgets are not handled by is_connected_{input,output}_ep() */ /* Supply widgets are not handled by is_connected_{input,output}_ep() */
if (w->is_supply) { if (w->is_supply) {
...@@ -2145,7 +2144,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file, ...@@ -2145,7 +2144,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
} }
} }
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(w->dapm);
ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
...@@ -2266,7 +2265,7 @@ static int soc_dapm_mux_update_power(struct snd_soc_card *card, ...@@ -2266,7 +2265,7 @@ static int soc_dapm_mux_update_power(struct snd_soc_card *card,
int found = 0; int found = 0;
bool connect; bool connect;
lockdep_assert_held(&card->dapm_mutex); snd_soc_dapm_mutex_assert_held(card);
/* find dapm widget path assoc with kcontrol */ /* find dapm widget path assoc with kcontrol */
dapm_kcontrol_for_each_path(path, kcontrol) { dapm_kcontrol_for_each_path(path, kcontrol) {
...@@ -2293,11 +2292,11 @@ int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm, ...@@ -2293,11 +2292,11 @@ int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
struct snd_soc_card *card = dapm->card; struct snd_soc_card *card = dapm->card;
int ret; int ret;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(card);
card->update = update; card->update = update;
ret = soc_dapm_mux_update_power(card, kcontrol, mux, e); ret = soc_dapm_mux_update_power(card, kcontrol, mux, e);
card->update = NULL; card->update = NULL;
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
if (ret > 0) if (ret > 0)
snd_soc_dpcm_runtime_update(card); snd_soc_dpcm_runtime_update(card);
return ret; return ret;
...@@ -2312,7 +2311,7 @@ static int soc_dapm_mixer_update_power(struct snd_soc_card *card, ...@@ -2312,7 +2311,7 @@ static int soc_dapm_mixer_update_power(struct snd_soc_card *card,
struct snd_soc_dapm_path *path; struct snd_soc_dapm_path *path;
int found = 0; int found = 0;
lockdep_assert_held(&card->dapm_mutex); snd_soc_dapm_mutex_assert_held(card);
/* find dapm widget path assoc with kcontrol */ /* find dapm widget path assoc with kcontrol */
dapm_kcontrol_for_each_path(path, kcontrol) { dapm_kcontrol_for_each_path(path, kcontrol) {
...@@ -2358,11 +2357,11 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, ...@@ -2358,11 +2357,11 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
struct snd_soc_card *card = dapm->card; struct snd_soc_card *card = dapm->card;
int ret; int ret;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(card);
card->update = update; card->update = update;
ret = soc_dapm_mixer_update_power(card, kcontrol, connect, -1); ret = soc_dapm_mixer_update_power(card, kcontrol, connect, -1);
card->update = NULL; card->update = NULL;
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
if (ret > 0) if (ret > 0)
snd_soc_dpcm_runtime_update(card); snd_soc_dpcm_runtime_update(card);
return ret; return ret;
...@@ -2441,7 +2440,7 @@ static ssize_t dapm_widget_show(struct device *dev, ...@@ -2441,7 +2440,7 @@ static ssize_t dapm_widget_show(struct device *dev,
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
int i, count = 0; int i, count = 0;
mutex_lock(&rtd->card->dapm_mutex); snd_soc_dapm_mutex_lock_root(rtd->card);
for_each_rtd_codec_dais(rtd, i, codec_dai) { for_each_rtd_codec_dais(rtd, i, codec_dai) {
struct snd_soc_component *cmpnt = codec_dai->component; struct snd_soc_component *cmpnt = codec_dai->component;
...@@ -2449,7 +2448,7 @@ static ssize_t dapm_widget_show(struct device *dev, ...@@ -2449,7 +2448,7 @@ static ssize_t dapm_widget_show(struct device *dev,
count = dapm_widget_show_component(cmpnt, buf, count); count = dapm_widget_show_component(cmpnt, buf, count);
} }
mutex_unlock(&rtd->card->dapm_mutex); snd_soc_dapm_mutex_unlock(rtd->card);
return count; return count;
} }
...@@ -2632,9 +2631,9 @@ int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm) ...@@ -2632,9 +2631,9 @@ int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
{ {
int ret; int ret;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
ret = snd_soc_dapm_sync_unlocked(dapm); ret = snd_soc_dapm_sync_unlocked(dapm);
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_sync); EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
...@@ -2703,9 +2702,9 @@ int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream, ...@@ -2703,9 +2702,9 @@ int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
int ret; int ret;
mutex_lock_nested(&rtd->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(rtd->card);
ret = dapm_update_dai_unlocked(substream, params, dai); ret = dapm_update_dai_unlocked(substream, params, dai);
mutex_unlock(&rtd->card->dapm_mutex); snd_soc_dapm_mutex_unlock(rtd->card);
return ret; return ret;
} }
...@@ -3090,14 +3089,14 @@ int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, ...@@ -3090,14 +3089,14 @@ int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
{ {
int i, ret = 0; int i, ret = 0;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
int r = snd_soc_dapm_add_route(dapm, route); int r = snd_soc_dapm_add_route(dapm, route);
if (r < 0) if (r < 0)
ret = r; ret = r;
route++; route++;
} }
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return ret; return ret;
} }
...@@ -3116,12 +3115,12 @@ int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm, ...@@ -3116,12 +3115,12 @@ int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm,
{ {
int i; int i;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
snd_soc_dapm_del_route(dapm, route); snd_soc_dapm_del_route(dapm, route);
route++; route++;
} }
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return 0; return 0;
} }
...@@ -3194,14 +3193,14 @@ int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, ...@@ -3194,14 +3193,14 @@ int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
int i; int i;
int ret = 0; int ret = 0;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); snd_soc_dapm_mutex_lock_root(dapm);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
int err = snd_soc_dapm_weak_route(dapm, route); int err = snd_soc_dapm_weak_route(dapm, route);
if (err) if (err)
ret = err; ret = err;
route++; route++;
} }
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return ret; return ret;
} }
...@@ -3220,7 +3219,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) ...@@ -3220,7 +3219,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
unsigned int val; unsigned int val;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); snd_soc_dapm_mutex_lock_root(card);
for_each_card_widgets(card, w) for_each_card_widgets(card, w)
{ {
...@@ -3232,7 +3231,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) ...@@ -3232,7 +3231,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
sizeof(struct snd_kcontrol *), sizeof(struct snd_kcontrol *),
GFP_KERNEL); GFP_KERNEL);
if (!w->kcontrols) { if (!w->kcontrols) {
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
return -ENOMEM; return -ENOMEM;
} }
} }
...@@ -3275,7 +3274,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) ...@@ -3275,7 +3274,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
} }
dapm_power_widgets(card, SND_SOC_DAPM_STREAM_NOP); dapm_power_widgets(card, SND_SOC_DAPM_STREAM_NOP);
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
...@@ -3293,7 +3292,6 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, ...@@ -3293,7 +3292,6 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_card *card = dapm->card;
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
int reg = mc->reg; int reg = mc->reg;
...@@ -3304,7 +3302,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, ...@@ -3304,7 +3302,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
unsigned int invert = mc->invert; unsigned int invert = mc->invert;
unsigned int reg_val, val, rval = 0; unsigned int reg_val, val, rval = 0;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) { if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) {
reg_val = soc_dapm_read(dapm, reg); reg_val = soc_dapm_read(dapm, reg);
val = (reg_val >> shift) & mask; val = (reg_val >> shift) & mask;
...@@ -3321,7 +3319,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, ...@@ -3321,7 +3319,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
if (snd_soc_volsw_is_stereo(mc)) if (snd_soc_volsw_is_stereo(mc))
rval = (reg_val >> width) & mask; rval = (reg_val >> width) & mask;
} }
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
if (invert) if (invert)
ucontrol->value.integer.value[0] = max - val; ucontrol->value.integer.value[0] = max - val;
...@@ -3379,7 +3377,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, ...@@ -3379,7 +3377,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
rval = max - rval; rval = max - rval;
} }
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(card);
/* This assumes field width < (bits in unsigned int / 2) */ /* This assumes field width < (bits in unsigned int / 2) */
if (width > sizeof(unsigned int) * 8 / 2) if (width > sizeof(unsigned int) * 8 / 2)
...@@ -3421,7 +3419,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, ...@@ -3421,7 +3419,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
card->update = NULL; card->update = NULL;
} }
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
if (ret > 0) if (ret > 0)
snd_soc_dpcm_runtime_update(card); snd_soc_dpcm_runtime_update(card);
...@@ -3443,17 +3441,16 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, ...@@ -3443,17 +3441,16 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_card *card = dapm->card;
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int reg_val, val; unsigned int reg_val, val;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) { if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) {
reg_val = soc_dapm_read(dapm, e->reg); reg_val = soc_dapm_read(dapm, e->reg);
} else { } else {
reg_val = dapm_kcontrol_get_value(kcontrol); reg_val = dapm_kcontrol_get_value(kcontrol);
} }
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
val = (reg_val >> e->shift_l) & e->mask; val = (reg_val >> e->shift_l) & e->mask;
ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val);
...@@ -3500,7 +3497,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, ...@@ -3500,7 +3497,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
mask |= e->mask << e->shift_r; mask |= e->mask << e->shift_r;
} }
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(card);
change = dapm_kcontrol_set_value(kcontrol, val); change = dapm_kcontrol_set_value(kcontrol, val);
...@@ -3521,7 +3518,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, ...@@ -3521,7 +3518,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
card->update = NULL; card->update = NULL;
} }
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
if (ret > 0) if (ret > 0)
snd_soc_dpcm_runtime_update(card); snd_soc_dpcm_runtime_update(card);
...@@ -3562,12 +3559,12 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, ...@@ -3562,12 +3559,12 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
const char *pin = (const char *)kcontrol->private_value; const char *pin = (const char *)kcontrol->private_value;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(card);
ucontrol->value.integer.value[0] = ucontrol->value.integer.value[0] =
snd_soc_dapm_get_pin_status(&card->dapm, pin); snd_soc_dapm_get_pin_status(&card->dapm, pin);
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
return 0; return 0;
} }
...@@ -3586,10 +3583,10 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, ...@@ -3586,10 +3583,10 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
const char *pin = (const char *)kcontrol->private_value; const char *pin = (const char *)kcontrol->private_value;
int ret; int ret;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(card);
ret = __snd_soc_dapm_set_pin(&card->dapm, pin, ret = __snd_soc_dapm_set_pin(&card->dapm, pin,
!!ucontrol->value.integer.value[0]); !!ucontrol->value.integer.value[0]);
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
snd_soc_dapm_sync(&card->dapm); snd_soc_dapm_sync(&card->dapm);
return ret; return ret;
...@@ -3762,9 +3759,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, ...@@ -3762,9 +3759,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
w = snd_soc_dapm_new_control_unlocked(dapm, widget); w = snd_soc_dapm_new_control_unlocked(dapm, widget);
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return w; return w;
} }
...@@ -3787,7 +3784,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, ...@@ -3787,7 +3784,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
int i; int i;
int ret = 0; int ret = 0;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); snd_soc_dapm_mutex_lock_root(dapm);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget);
if (IS_ERR(w)) { if (IS_ERR(w)) {
...@@ -3796,7 +3793,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, ...@@ -3796,7 +3793,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
} }
widget++; widget++;
} }
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls); EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
...@@ -4499,9 +4496,9 @@ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, ...@@ -4499,9 +4496,9 @@ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
{ {
struct snd_soc_card *card = rtd->card; struct snd_soc_card *card = rtd->card;
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(card);
soc_dapm_stream_event(rtd, stream, event); soc_dapm_stream_event(rtd, stream, event);
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
} }
void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream) void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream)
...@@ -4562,11 +4559,11 @@ int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) ...@@ -4562,11 +4559,11 @@ int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin)
{ {
int ret; int ret;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
ret = snd_soc_dapm_set_pin(dapm, pin, 1); ret = snd_soc_dapm_set_pin(dapm, pin, 1);
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return ret; return ret;
} }
...@@ -4630,11 +4627,11 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, ...@@ -4630,11 +4627,11 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
{ {
int ret; int ret;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin); ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin);
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return ret; return ret;
} }
...@@ -4674,11 +4671,11 @@ int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, ...@@ -4674,11 +4671,11 @@ int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
{ {
int ret; int ret;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
ret = snd_soc_dapm_set_pin(dapm, pin, 0); ret = snd_soc_dapm_set_pin(dapm, pin, 0);
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return ret; return ret;
} }
...@@ -4725,11 +4722,11 @@ int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) ...@@ -4725,11 +4722,11 @@ int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin)
{ {
int ret; int ret;
mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mutex_lock(dapm);
ret = snd_soc_dapm_set_pin(dapm, pin, 0); ret = snd_soc_dapm_set_pin(dapm, pin, 0);
mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_mutex_unlock(dapm);
return ret; return ret;
} }
...@@ -4826,7 +4823,7 @@ static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm) ...@@ -4826,7 +4823,7 @@ static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm)
LIST_HEAD(down_list); LIST_HEAD(down_list);
int powerdown = 0; int powerdown = 0;
mutex_lock(&card->dapm_mutex); snd_soc_dapm_mutex_lock_root(card);
for_each_card_widgets(dapm->card, w) { for_each_card_widgets(dapm->card, w) {
if (w->dapm != dapm) if (w->dapm != dapm)
...@@ -4851,7 +4848,7 @@ static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm) ...@@ -4851,7 +4848,7 @@ static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm)
SND_SOC_BIAS_STANDBY); SND_SOC_BIAS_STANDBY);
} }
mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mutex_unlock(card);
} }
/* /*
......
...@@ -49,19 +49,6 @@ static inline int _soc_pcm_ret(struct snd_soc_pcm_runtime *rtd, ...@@ -49,19 +49,6 @@ static inline int _soc_pcm_ret(struct snd_soc_pcm_runtime *rtd,
return ret; return ret;
} }
static inline void snd_soc_dpcm_mutex_lock(struct snd_soc_pcm_runtime *rtd)
{
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
}
static inline void snd_soc_dpcm_mutex_unlock(struct snd_soc_pcm_runtime *rtd)
{
mutex_unlock(&rtd->card->pcm_mutex);
}
#define snd_soc_dpcm_mutex_assert_held(rtd) \
lockdep_assert_held(&(rtd)->card->pcm_mutex)
static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd, static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd,
int stream) int stream)
{ {
...@@ -2664,7 +2651,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card) ...@@ -2664,7 +2651,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card)
struct snd_soc_pcm_runtime *fe; struct snd_soc_pcm_runtime *fe;
int ret = 0; int ret = 0;
mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass); snd_soc_dpcm_mutex_lock(card);
/* shutdown all old paths first */ /* shutdown all old paths first */
for_each_card_rtds(card, fe) { for_each_card_rtds(card, fe) {
ret = soc_dpcm_fe_runtime_update(fe, 0); ret = soc_dpcm_fe_runtime_update(fe, 0);
...@@ -2680,7 +2667,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card) ...@@ -2680,7 +2667,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card)
} }
out: out:
mutex_unlock(&card->pcm_mutex); snd_soc_dpcm_mutex_unlock(card);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(snd_soc_dpcm_runtime_update); EXPORT_SYMBOL_GPL(snd_soc_dpcm_runtime_update);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment