public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: broonie@kernel.org
Cc: myungjoo.ham@samsung.com, cw00.choi@samsung.com,
	dmitry.torokhov@gmail.com, lgirdwood@gmail.com, lars@metafoo.de,
	peter.ujfalusi@ti.com, jarkko.nikula@bitmer.com,
	eric.y.miao@gmail.com, haojian.zhuang@gmail.com,
	linux-kernel@vger.kernel.org,
	patches@opensource.wolfsonmicro.com, alsa-devel@alsa-project.org,
	linux@arm.linux.org.uk
Subject: [PATCH 04/17 v2] ASoC: dapm: Add unlocked version of snd_soc_dapm_sync
Date: Tue, 18 Feb 2014 15:22:15 +0000	[thread overview]
Message-ID: <1392736948-26623-5-git-send-email-ckeepax@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1392736948-26623-1-git-send-email-ckeepax@opensource.wolfsonmicro.com>

We will often call sync after several functions that require the DAPM
mutex to be held. Rather than release and immediately relock the mutex
provide an unlocked function for this situation.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 include/sound/soc-dapm.h |    1 +
 sound/soc/soc-dapm.c     |   27 ++++++++++++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 6e89ef6..3b99176 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -461,6 +461,7 @@ int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
 int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
 				const char *pin);
 int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm);
+int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm);
 int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
 				  const char *pin);
 int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 1a3fe85..cf8ba48 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2342,18 +2342,18 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
 }
 
 /**
- * snd_soc_dapm_sync - scan and power dapm paths
+ * snd_soc_dapm_sync_unlocked - scan and power dapm paths
  * @dapm: DAPM context
  *
  * Walks all dapm audio paths and powers widgets according to their
  * stream or path usage.
  *
+ * Requires external locking.
+ *
  * Returns 0 for success.
  */
-int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
+int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm)
 {
-	int ret;
-
 	/*
 	 * Suppress early reports (eg, jacks syncing their state) to avoid
 	 * silly DAPM runs during card startup.
@@ -2361,8 +2361,25 @@ int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
 	if (!dapm->card || !dapm->card->instantiated)
 		return 0;
 
+	return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_unlocked);
+
+/**
+ * snd_soc_dapm_sync - scan and power dapm paths
+ * @dapm: DAPM context
+ *
+ * Walks all dapm audio paths and powers widgets according to their
+ * stream or path usage.
+ *
+ * Returns 0 for success.
+ */
+int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
+{
+	int ret;
+
 	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
-	ret = dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP);
+	ret = snd_soc_dapm_sync_unlocked(dapm);
 	mutex_unlock(&dapm->card->dapm_mutex);
 	return ret;
 }
-- 
1.7.2.5


  parent reply	other threads:[~2014-02-18 15:30 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-18 15:22 [PATCH 00/17 v2] Update locking for snd_soc_dapm_xxxx_pin functions Charles Keepax
2014-02-18 15:22 ` [PATCH 01/17 v2] Input - arizona-haptics: Fix double lock of dapm_mutex Charles Keepax
2014-02-20  3:54   ` Mark Brown
2014-02-20  4:20     ` Dmitry Torokhov
2014-02-20  9:12   ` Mark Brown
2014-02-18 15:22 ` [PATCH 02/17 v2] ASoC: dapm: Add helpers to lock/unlock DAPM mutex Charles Keepax
2014-02-20 10:23   ` Mark Brown
2014-02-18 15:22 ` [PATCH 03/17 v2] ASoC: dapm: Add locking to snd_soc_dapm_xxxx_pin functions Charles Keepax
2014-02-20  9:40   ` Mark Brown
2014-02-18 15:22 ` Charles Keepax [this message]
2014-02-18 16:14   ` [PATCH 04/17 v2] ASoC: dapm: Add unlocked version of snd_soc_dapm_sync Lars-Peter Clausen
2014-02-19  3:28     ` Mark Brown
2014-02-20 10:24   ` Mark Brown
2014-02-18 15:22 ` [PATCH 05/17 v2] ASoC: adav80x: Update locking around use of DAPM pin API Charles Keepax
2014-02-18 16:12   ` Lars-Peter Clausen
2014-02-20 10:25   ` Mark Brown
2014-02-18 15:22 ` [PATCH 06/17 v2] ASoC: wm5100: " Charles Keepax
2014-02-20 10:26   ` Mark Brown
2014-02-18 15:22 ` [PATCH 07/17 v2] ASoC: wm8962: " Charles Keepax
2014-02-20 10:26   ` Mark Brown
2014-02-18 15:22 ` [PATCH 08/17 v2] ASoC: wm8994: " Charles Keepax
2014-02-20 10:26   ` Mark Brown
2014-02-18 15:22 ` [PATCH 09/17 v2] ASoC: wm8996: " Charles Keepax
2014-02-20 10:27   ` Mark Brown
2014-02-18 15:22 ` [PATCH 10/17 v2] ASoC: mfld_machine: " Charles Keepax
2014-02-20 10:27   ` Mark Brown
2014-02-18 15:22 ` [PATCH 11/17 v2] ASoC: ams-delta: " Charles Keepax
2014-02-20 10:27   ` Mark Brown
2014-02-18 15:22 ` [PATCH 12/17 v2] ASoC: omap: n810: " Charles Keepax
2014-02-20 10:28   ` Mark Brown
2014-02-18 15:22 ` [PATCH 13/17 v2] ASoC: omap: rx51: " Charles Keepax
2014-02-20 10:28   ` Mark Brown
2014-02-18 15:22 ` [PATCH 14/17 v2] ASoC: pxa: corgi: " Charles Keepax
2014-02-20 10:53   ` Mark Brown
2014-02-18 15:22 ` [PATCH 15/17 v2] ASoC: pxa: magician: " Charles Keepax
2014-02-20 10:54   ` Mark Brown
2014-02-18 15:22 ` [PATCH 16/17 v2] ASoC: pxa: spitz: " Charles Keepax
2014-02-20 10:54   ` Mark Brown
2014-02-18 15:22 ` [PATCH 17/17 v2] ASoC: pxa: tosa: " Charles Keepax
2014-02-20 10:54   ` 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=1392736948-26623-5-git-send-email-ckeepax@opensource.wolfsonmicro.com \
    --to=ckeepax@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eric.y.miao@gmail.com \
    --cc=haojian.zhuang@gmail.com \
    --cc=jarkko.nikula@bitmer.com \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=myungjoo.ham@samsung.com \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=peter.ujfalusi@ti.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