alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 01/10] ASoC: dapm: Move snd_soc_dapm_update from dapm context to card
Date: Mon, 29 Jul 2013 17:13:55 +0200	[thread overview]
Message-ID: <1375110845-8069-1-git-send-email-lars@metafoo.de> (raw)

The update field of a DAPM context is only assigned while the card's dapm_mutex
is locked, the field is also cleared again while the mutex is stil locked. So
there will only ever be one DAPM context at a time with a non-NULL update field.
So it is safe to move the update field from the DAPM context struct to the card
struct. Doing so will allow further cleanups in this area.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc-dapm.h |  2 --
 include/sound/soc.h      |  1 +
 sound/soc/soc-dapm.c     | 22 +++++++++++-----------
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index e77c6f5..3397292 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -575,8 +575,6 @@ struct snd_soc_dapm_context {
 	struct delayed_work delayed_work;
 	unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
 
-	struct snd_soc_dapm_update *update;
-
 	void (*seq_notifier)(struct snd_soc_dapm_context *,
 			     enum snd_soc_dapm_type, int);
 
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 6eabee7..b1e1f96 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1042,6 +1042,7 @@ struct snd_soc_card {
 	/* Generic DAPM context for the card */
 	struct snd_soc_dapm_context dapm;
 	struct snd_soc_dapm_stats dapm_stats;
+	struct snd_soc_dapm_update *update;
 
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *debugfs_card_root;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 366daef..7449e27 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1425,7 +1425,7 @@ static void dapm_seq_run(struct snd_soc_dapm_context *dapm,
 
 static void dapm_widget_update(struct snd_soc_dapm_context *dapm)
 {
-	struct snd_soc_dapm_update *update = dapm->update;
+	struct snd_soc_dapm_update *update = dapm->card->update;
 	struct snd_soc_dapm_widget_list *wlist;
 	struct snd_soc_dapm_widget *w = NULL;
 	unsigned int wi;
@@ -1959,9 +1959,9 @@ int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
 	int ret;
 
 	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
-	dapm->update = update;
+	card->update = update;
 	ret = soc_dapm_mux_update_power(dapm, kcontrol, mux, e);
-	dapm->update = NULL;
+	card->update = NULL;
 	mutex_unlock(&card->dapm_mutex);
 	if (ret > 0)
 		soc_dpcm_runtime_update(card);
@@ -2002,9 +2002,9 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
 	int ret;
 
 	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
-	dapm->update = update;
+	card->update = update;
 	ret = soc_dapm_mixer_update_power(dapm, kcontrol, connect);
-	dapm->update = NULL;
+	card->update = NULL;
 	mutex_unlock(&card->dapm_mutex);
 	if (ret > 0)
 		soc_dpcm_runtime_update(card);
@@ -2693,11 +2693,11 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
 		update.mask = mask;
 		update.val = val;
 
-		widget->dapm->update = &update;
+		card->update = &update;
 
 		soc_dapm_mixer_update_power(widget->dapm, kcontrol, connect);
 
-		widget->dapm->update = NULL;
+		card->update = NULL;
 	}
 
 	mutex_unlock(&card->dapm_mutex);
@@ -2775,11 +2775,11 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
 		update.reg = e->reg;
 		update.mask = mask;
 		update.val = val;
-		widget->dapm->update = &update;
+		card->update = &update;
 
 		soc_dapm_mux_update_power(widget->dapm, kcontrol, mux, e);
 
-		widget->dapm->update = NULL;
+		card->update = NULL;
 	}
 
 	mutex_unlock(&card->dapm_mutex);
@@ -2928,11 +2928,11 @@ int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
 		update.reg = e->reg;
 		update.mask = mask;
 		update.val = val;
-		widget->dapm->update = &update;
+		card->update = &update;
 
 		soc_dapm_mux_update_power(widget->dapm, kcontrol, mux, e);
 
-		widget->dapm->update = NULL;
+		card->update = NULL;
 	}
 
 	mutex_unlock(&card->dapm_mutex);
-- 
1.8.0

             reply	other threads:[~2013-07-29 15:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 15:13 Lars-Peter Clausen [this message]
2013-07-29 15:13 ` [PATCH 02/10] ASoC: dapm: Pass card instead of dapm context to dapm_power_widgets() Lars-Peter Clausen
2013-07-29 15:13 ` [PATCH 03/10] ASoC: dapm: Add a helper to get the CODEC for DAPM kcontrol Lars-Peter Clausen
2013-07-29 15:13 ` [PATCH 04/10] ASoC: dapm: Wrap kcontrol widget list access Lars-Peter Clausen
2013-07-29 15:13 ` [PATCH 05/10] ASoC: dapm: Move 'value' field from widget to control Lars-Peter Clausen
2013-07-29 15:14 ` [PATCH 06/10] ASoC: dapm: Keep a list of paths per kcontrol Lars-Peter Clausen
2013-07-29 15:14 ` [PATCH 07/10] ASoC: dapm: Make widget power register settings more flexible Lars-Peter Clausen
2013-07-29 15:14 ` [PATCH 08/10] ASoC: dapm: Add snd_soc_dapm_add_path() helper function Lars-Peter Clausen
2013-07-29 17:45   ` Mark Brown
2013-07-30 11:35     ` Lars-Peter Clausen
2013-07-29 15:14 ` [PATCH 09/10] ASoC: dapm: Delay w->power update until the changes are written Lars-Peter Clausen
2013-07-29 15:14 ` [PATCH 10/10] ASoC: dapm: Implement mixer input auto-disable Lars-Peter Clausen
2013-08-01 10:48   ` Mark Brown
2013-08-01 19:24     ` Lars-Peter Clausen
2013-08-02  9:53       ` Mark Brown
2013-08-02 10:22   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1375110845-8069-1-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).