summaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorLiam Girdwood <lg@opensource.wolfsonmicro.com>2007-01-31 14:14:57 +0100
committerJaroslav Kysela <perex@suse.cz>2007-02-09 09:03:27 +0100
commit965ac42ce919db225ee64678f0be02f2fdf5b5e4 (patch)
tree832436b24c8a02a879de8efc7869bbfe06de2018 /sound/soc
parent[ALSA] usbaudio - Fix Oops with broken usb descriptors (diff)
downloadlinux-965ac42ce919db225ee64678f0be02f2fdf5b5e4.tar.xz
linux-965ac42ce919db225ee64678f0be02f2fdf5b5e4.zip
[ALSA] ASoC force running of delayed PM work at suspend() and remove()
This patch fixes a bug whereby the power management delayed work would never be run at driver suspend() or module remove(). Delayed work would be created (after audio had finished) with a long delay (~5 secs) and was sometimes never queued before flush_scheduled_work() was being called at suspend or module remove. This caused the delayed work to queued after the module had been removed or after resume. This patch forces any delayed work to complete by cancelling it (timer cannot fire and add it to queue later), scheduling it for now and waiting on it's completion. This is something I probably would like to add to workqueue.c in the next merge window, however it's here atm because it can oops. Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/soc-core.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 736949fbb4d5..e5aa1c20dddb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -77,6 +77,25 @@ static int pmdown_time = 5000;
module_param(pmdown_time, int, 0);
MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
+/*
+ * This function forces any delayed work to be queued and run.
+ */
+static int run_delayed_work(struct delayed_work *dwork)
+{
+ int ret;
+
+ /* cancel any work waiting to be queued. */
+ ret = cancel_delayed_work(dwork);
+
+ /* if there was any work waiting then we run it now and
+ * wait for it's completion */
+ if (ret) {
+ schedule_delayed_work(dwork, 0);
+ flush_scheduled_work();
+ }
+ return ret;
+}
+
#ifdef CONFIG_SND_SOC_AC97_BUS
/* unregister ac97 codec */
static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
@@ -1101,7 +1120,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
}
/* close any waiting streams and save state */
- flush_scheduled_work();
+ run_delayed_work(&socdev->delayed_work);
codec->suspend_dapm_state = codec->dapm_state;
for(i = 0; i < codec->num_dai; i++) {
@@ -1255,6 +1274,8 @@ static int soc_remove(struct platform_device *pdev)
struct snd_soc_platform *platform = socdev->platform;
struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
+ run_delayed_work(&socdev->delayed_work);
+
if (platform->remove)
platform->remove(pdev);