aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-07-24 09:27:38 -0400
committerMark Brown <broonie@linaro.org>2013-07-24 09:56:19 -0400
commit6b3fc03b3b614ced09df96ca60ab6f627d8c240c (patch)
tree0c8dcd214e033bf050a70fa10cce10bbaacf40e7
parentce6cfaf1de136cd3e6ed7c0ed984be8d003a58c1 (diff)
ASoC: dapm: Add a update parameter to snd_soc_dapm_{mux,mixer}_update_power
In order to avoid race conditions the assignment of dapm->update should happen while card->dapm_mutex is being held. To allow CODEC drivers to run a register update when using snd_soc_dapm_mux_update_power() or snd_soc_dapm_mixer_update_power() add a update parameter to these two functions. The update parameter will be assigned to dapm->update while card->dapm_mutex is locked. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--include/sound/soc-dapm.h7
-rw-r--r--sound/soc/soc-dapm.c10
2 files changed, 13 insertions, 4 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 3717ad089486..e77c6f5a8390 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -333,6 +333,7 @@ struct snd_soc_dapm_route;
333struct snd_soc_dapm_context; 333struct snd_soc_dapm_context;
334struct regulator; 334struct regulator;
335struct snd_soc_dapm_widget_list; 335struct snd_soc_dapm_widget_list;
336struct snd_soc_dapm_update;
336 337
337int dapm_reg_event(struct snd_soc_dapm_widget *w, 338int dapm_reg_event(struct snd_soc_dapm_widget *w,
338 struct snd_kcontrol *kcontrol, int event); 339 struct snd_kcontrol *kcontrol, int event);
@@ -392,9 +393,11 @@ void snd_soc_dapm_shutdown(struct snd_soc_card *card);
392 393
393/* external DAPM widget events */ 394/* external DAPM widget events */
394int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, 395int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
395 struct snd_kcontrol *kcontrol, int connect); 396 struct snd_kcontrol *kcontrol, int connect,
397 struct snd_soc_dapm_update *update);
396int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm, 398int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
397 struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e); 399 struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e,
400 struct snd_soc_dapm_update *update);
398 401
399/* dapm sys fs - used by the core */ 402/* dapm sys fs - used by the core */
400int snd_soc_dapm_sys_add(struct device *dev); 403int snd_soc_dapm_sys_add(struct device *dev);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 6f8a01bf6ca8..758761146a42 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1982,13 +1982,16 @@ static int soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
1982} 1982}
1983 1983
1984int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm, 1984int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
1985 struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e) 1985 struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e,
1986 struct snd_soc_dapm_update *update)
1986{ 1987{
1987 struct snd_soc_card *card = dapm->card; 1988 struct snd_soc_card *card = dapm->card;
1988 int ret; 1989 int ret;
1989 1990
1990 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 1991 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
1992 dapm->update = update;
1991 ret = soc_dapm_mux_update_power(dapm, kcontrol, mux, e); 1993 ret = soc_dapm_mux_update_power(dapm, kcontrol, mux, e);
1994 dapm->update = NULL;
1992 mutex_unlock(&card->dapm_mutex); 1995 mutex_unlock(&card->dapm_mutex);
1993 if (ret > 0) 1996 if (ret > 0)
1994 soc_dpcm_runtime_update(card); 1997 soc_dpcm_runtime_update(card);
@@ -2022,13 +2025,16 @@ static int soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
2022} 2025}
2023 2026
2024int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, 2027int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
2025 struct snd_kcontrol *kcontrol, int connect) 2028 struct snd_kcontrol *kcontrol, int connect,
2029 struct snd_soc_dapm_update *update)
2026{ 2030{
2027 struct snd_soc_card *card = dapm->card; 2031 struct snd_soc_card *card = dapm->card;
2028 int ret; 2032 int ret;
2029 2033
2030 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 2034 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
2035 dapm->update = update;
2031 ret = soc_dapm_mixer_update_power(dapm, kcontrol, connect); 2036 ret = soc_dapm_mixer_update_power(dapm, kcontrol, connect);
2037 dapm->update = NULL;
2032 mutex_unlock(&card->dapm_mutex); 2038 mutex_unlock(&card->dapm_mutex);
2033 if (ret > 0) 2039 if (ret > 0)
2034 soc_dpcm_runtime_update(card); 2040 soc_dpcm_runtime_update(card);