sound: don't use flush_scheduled_work()
Tejun Heo [Sat, 11 Dec 2010 16:51:26 +0000 (17:51 +0100)]
flush_scheduled_work() is deprecated and scheduled to be removed.

* cancel[_delayed]_work() + flush_scheduled_work() ->
  cancel[_delayed]_work_sync().

* wm8350, wm8753 and soc-core use custom code to cancel a delayed
  work, execute it immediately if it was pending and wait for its
  completion.  This is equivalent to flush_delayed_work_sync().  Use
  it instead.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

sound/aoa/core/gpio-feature.c
sound/aoa/core/gpio-pmf.c
sound/i2c/other/ak4113.c
sound/i2c/other/ak4114.c
sound/pci/ac97/ac97_codec.c
sound/pci/hda/patch_via.c
sound/pci/oxygen/oxygen_lib.c
sound/soc/codecs/wm8350.c
sound/soc/codecs/wm8753.c
sound/soc/soc-core.c

index de8e03a..faa3174 100644 (file)
@@ -287,10 +287,9 @@ static void ftr_gpio_exit(struct gpio_runtime *rt)
                free_irq(linein_detect_irq, &rt->line_in_notify);
        if (rt->line_out_notify.gpio_private)
                free_irq(lineout_detect_irq, &rt->line_out_notify);
-       cancel_delayed_work(&rt->headphone_notify.work);
-       cancel_delayed_work(&rt->line_in_notify.work);
-       cancel_delayed_work(&rt->line_out_notify.work);
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&rt->headphone_notify.work);
+       cancel_delayed_work_sync(&rt->line_in_notify.work);
+       cancel_delayed_work_sync(&rt->line_out_notify.work);
        mutex_destroy(&rt->headphone_notify.mutex);
        mutex_destroy(&rt->line_in_notify.mutex);
        mutex_destroy(&rt->line_out_notify.mutex);
index 7e267c9..c8d8a1a 100644 (file)
@@ -107,10 +107,9 @@ static void pmf_gpio_exit(struct gpio_runtime *rt)
 
        /* make sure no work is pending before freeing
         * all things */
-       cancel_delayed_work(&rt->headphone_notify.work);
-       cancel_delayed_work(&rt->line_in_notify.work);
-       cancel_delayed_work(&rt->line_out_notify.work);
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&rt->headphone_notify.work);
+       cancel_delayed_work_sync(&rt->line_in_notify.work);
+       cancel_delayed_work_sync(&rt->line_out_notify.work);
 
        mutex_destroy(&rt->headphone_notify.mutex);
        mutex_destroy(&rt->line_in_notify.mutex);
index 971a84a..c424d32 100644 (file)
@@ -57,8 +57,7 @@ static void snd_ak4113_free(struct ak4113 *chip)
 {
        chip->init = 1; /* don't schedule new work */
        mb();
-       cancel_delayed_work(&chip->work);
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&chip->work);
        kfree(chip);
 }
 
@@ -141,7 +140,7 @@ void snd_ak4113_reinit(struct ak4113 *chip)
 {
        chip->init = 1;
        mb();
-       flush_scheduled_work();
+       flush_delayed_work_sync(&chip->work);
        ak4113_init_regs(chip);
        /* bring up statistics / event queing */
        chip->init = 0;
index 0341451..d9fb537 100644 (file)
@@ -67,8 +67,7 @@ static void snd_ak4114_free(struct ak4114 *chip)
 {
        chip->init = 1; /* don't schedule new work */
        mb();
-       cancel_delayed_work(&chip->work);
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&chip->work);
        kfree(chip);
 }
 
@@ -154,7 +153,7 @@ void snd_ak4114_reinit(struct ak4114 *chip)
 {
        chip->init = 1;
        mb();
-       flush_scheduled_work();
+       flush_delayed_work_sync(&chip->work);
        ak4114_init_regs(chip);
        /* bring up statistics / event queing */
        chip->init = 0;
index a7630e9..0fc614c 100644 (file)
@@ -1014,8 +1014,7 @@ static int snd_ac97_free(struct snd_ac97 *ac97)
 {
        if (ac97) {
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-               cancel_delayed_work(&ac97->power_work);
-               flush_scheduled_work();
+               cancel_delayed_work_sync(&ac97->power_work);
 #endif
                snd_ac97_proc_done(ac97);
                if (ac97->bus)
@@ -2456,8 +2455,7 @@ void snd_ac97_suspend(struct snd_ac97 *ac97)
        if (ac97->build_ops->suspend)
                ac97->build_ops->suspend(ac97);
 #ifdef CONFIG_SND_AC97_POWER_SAVE
-       cancel_delayed_work(&ac97->power_work);
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&ac97->power_work);
 #endif
        snd_ac97_powerdown(ac97);
 }
index d1c3f8d..7f4852a 100644 (file)
@@ -263,8 +263,7 @@ static void vt1708_stop_hp_work(struct via_spec *spec)
                return;
        snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81,
                            !spec->vt1708_jack_detectect);
-       cancel_delayed_work(&spec->vt1708_hp_work);
-       flush_scheduled_work();
+       cancel_delayed_work_sync(&spec->vt1708_hp_work);
 }
 
 
index e5ebe56..969605f 100644 (file)
@@ -557,7 +557,8 @@ static void oxygen_card_free(struct snd_card *card)
        oxygen_shutdown(chip);
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-       flush_scheduled_work();
+       flush_work_sync(&chip->spdif_input_bits_work);
+       flush_work_sync(&chip->gpio_work);
        chip->model.cleanup(chip);
        kfree(chip->model_data);
        mutex_destroy(&chip->mutex);
@@ -733,7 +734,8 @@ int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state)
        spin_unlock_irq(&chip->reg_lock);
 
        synchronize_irq(chip->irq);
-       flush_scheduled_work();
+       flush_work_sync(&chip->spdif_input_bits_work);
+       flush_work_sync(&chip->gpio_work);
        chip->interrupt_mask = saved_interrupt_mask;
 
        pci_disable_device(pci);
index 7611add..b3e9fac 100644 (file)
@@ -1626,7 +1626,6 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
 {
        struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
        struct wm8350 *wm8350 = dev_get_platdata(codec->dev);
-       int ret;
 
        wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
                          WM8350_JDL_ENA | WM8350_JDR_ENA);
@@ -1641,15 +1640,9 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
        priv->hpr.jack = NULL;
        priv->mic.jack = NULL;
 
-       /* cancel any work waiting to be queued. */
-       ret = cancel_delayed_work(&codec->delayed_work);
-
        /* if there was any work waiting then we run it now and
         * wait for its completion */
-       if (ret) {
-               schedule_delayed_work(&codec->delayed_work, 0);
-               flush_scheduled_work();
-       }
+       flush_delayed_work_sync(&codec->delayed_work);
 
        wm8350_set_bias_level(codec, SND_SOC_BIAS_OFF);
 
index 8f679a1..84a2367 100644 (file)
@@ -1526,25 +1526,6 @@ static int wm8753_resume(struct snd_soc_codec *codec)
        return 0;
 }
 
-/*
- * 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;
-}
-
 static int wm8753_probe(struct snd_soc_codec *codec)
 {
        struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
@@ -1604,7 +1585,7 @@ static int wm8753_probe(struct snd_soc_codec *codec)
 /* power down chip */
 static int wm8753_remove(struct snd_soc_codec *codec)
 {
-       run_delayed_work(&codec->delayed_work);
+       flush_delayed_work_sync(&codec->delayed_work);
        wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF);
 
        return 0;
index 441285a..b54ea9a 100644 (file)
@@ -67,25 +67,6 @@ 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;
-}
-
 /* codec register dump */
 static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
 {
@@ -1016,7 +997,7 @@ static int soc_suspend(struct device *dev)
 
        /* close any waiting streams and save state */
        for (i = 0; i < card->num_rtd; i++) {
-               run_delayed_work(&card->rtd[i].delayed_work);
+               flush_delayed_work_sync(&card->rtd[i].delayed_work);
                card->rtd[i].codec->suspend_bias_level = card->rtd[i].codec->bias_level;
        }
 
@@ -1687,7 +1668,7 @@ static int soc_remove(struct platform_device *pdev)
                /* make sure any delayed work runs */
                for (i = 0; i < card->num_rtd; i++) {
                        struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
-                       run_delayed_work(&rtd->delayed_work);
+                       flush_delayed_work_sync(&rtd->delayed_work);
                }
 
                /* remove and free each DAI */
@@ -1718,7 +1699,7 @@ static int soc_poweroff(struct device *dev)
         * now, we're shutting down so no imminent restart. */
        for (i = 0; i < card->num_rtd; i++) {
                struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
-               run_delayed_work(&rtd->delayed_work);
+               flush_delayed_work_sync(&rtd->delayed_work);
        }
 
        snd_soc_dapm_shutdown(card);