Commit 5b84ba26 authored by Tejun Heo's avatar Tejun Heo Committed by Takashi Iwai

sound: don't use flush_scheduled_work()

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: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent cf7d7e5a
...@@ -287,10 +287,9 @@ static void ftr_gpio_exit(struct gpio_runtime *rt) ...@@ -287,10 +287,9 @@ static void ftr_gpio_exit(struct gpio_runtime *rt)
free_irq(linein_detect_irq, &rt->line_in_notify); free_irq(linein_detect_irq, &rt->line_in_notify);
if (rt->line_out_notify.gpio_private) if (rt->line_out_notify.gpio_private)
free_irq(lineout_detect_irq, &rt->line_out_notify); free_irq(lineout_detect_irq, &rt->line_out_notify);
cancel_delayed_work(&rt->headphone_notify.work); cancel_delayed_work_sync(&rt->headphone_notify.work);
cancel_delayed_work(&rt->line_in_notify.work); cancel_delayed_work_sync(&rt->line_in_notify.work);
cancel_delayed_work(&rt->line_out_notify.work); cancel_delayed_work_sync(&rt->line_out_notify.work);
flush_scheduled_work();
mutex_destroy(&rt->headphone_notify.mutex); mutex_destroy(&rt->headphone_notify.mutex);
mutex_destroy(&rt->line_in_notify.mutex); mutex_destroy(&rt->line_in_notify.mutex);
mutex_destroy(&rt->line_out_notify.mutex); mutex_destroy(&rt->line_out_notify.mutex);
......
...@@ -107,10 +107,9 @@ static void pmf_gpio_exit(struct gpio_runtime *rt) ...@@ -107,10 +107,9 @@ static void pmf_gpio_exit(struct gpio_runtime *rt)
/* make sure no work is pending before freeing /* make sure no work is pending before freeing
* all things */ * all things */
cancel_delayed_work(&rt->headphone_notify.work); cancel_delayed_work_sync(&rt->headphone_notify.work);
cancel_delayed_work(&rt->line_in_notify.work); cancel_delayed_work_sync(&rt->line_in_notify.work);
cancel_delayed_work(&rt->line_out_notify.work); cancel_delayed_work_sync(&rt->line_out_notify.work);
flush_scheduled_work();
mutex_destroy(&rt->headphone_notify.mutex); mutex_destroy(&rt->headphone_notify.mutex);
mutex_destroy(&rt->line_in_notify.mutex); mutex_destroy(&rt->line_in_notify.mutex);
......
...@@ -57,8 +57,7 @@ static void snd_ak4113_free(struct ak4113 *chip) ...@@ -57,8 +57,7 @@ static void snd_ak4113_free(struct ak4113 *chip)
{ {
chip->init = 1; /* don't schedule new work */ chip->init = 1; /* don't schedule new work */
mb(); mb();
cancel_delayed_work(&chip->work); cancel_delayed_work_sync(&chip->work);
flush_scheduled_work();
kfree(chip); kfree(chip);
} }
...@@ -141,7 +140,7 @@ void snd_ak4113_reinit(struct ak4113 *chip) ...@@ -141,7 +140,7 @@ void snd_ak4113_reinit(struct ak4113 *chip)
{ {
chip->init = 1; chip->init = 1;
mb(); mb();
flush_scheduled_work(); flush_delayed_work_sync(&chip->work);
ak4113_init_regs(chip); ak4113_init_regs(chip);
/* bring up statistics / event queing */ /* bring up statistics / event queing */
chip->init = 0; chip->init = 0;
......
...@@ -67,8 +67,7 @@ static void snd_ak4114_free(struct ak4114 *chip) ...@@ -67,8 +67,7 @@ static void snd_ak4114_free(struct ak4114 *chip)
{ {
chip->init = 1; /* don't schedule new work */ chip->init = 1; /* don't schedule new work */
mb(); mb();
cancel_delayed_work(&chip->work); cancel_delayed_work_sync(&chip->work);
flush_scheduled_work();
kfree(chip); kfree(chip);
} }
...@@ -154,7 +153,7 @@ void snd_ak4114_reinit(struct ak4114 *chip) ...@@ -154,7 +153,7 @@ void snd_ak4114_reinit(struct ak4114 *chip)
{ {
chip->init = 1; chip->init = 1;
mb(); mb();
flush_scheduled_work(); flush_delayed_work_sync(&chip->work);
ak4114_init_regs(chip); ak4114_init_regs(chip);
/* bring up statistics / event queing */ /* bring up statistics / event queing */
chip->init = 0; chip->init = 0;
......
...@@ -1014,8 +1014,7 @@ static int snd_ac97_free(struct snd_ac97 *ac97) ...@@ -1014,8 +1014,7 @@ static int snd_ac97_free(struct snd_ac97 *ac97)
{ {
if (ac97) { if (ac97) {
#ifdef CONFIG_SND_AC97_POWER_SAVE #ifdef CONFIG_SND_AC97_POWER_SAVE
cancel_delayed_work(&ac97->power_work); cancel_delayed_work_sync(&ac97->power_work);
flush_scheduled_work();
#endif #endif
snd_ac97_proc_done(ac97); snd_ac97_proc_done(ac97);
if (ac97->bus) if (ac97->bus)
...@@ -2456,8 +2455,7 @@ void snd_ac97_suspend(struct snd_ac97 *ac97) ...@@ -2456,8 +2455,7 @@ void snd_ac97_suspend(struct snd_ac97 *ac97)
if (ac97->build_ops->suspend) if (ac97->build_ops->suspend)
ac97->build_ops->suspend(ac97); ac97->build_ops->suspend(ac97);
#ifdef CONFIG_SND_AC97_POWER_SAVE #ifdef CONFIG_SND_AC97_POWER_SAVE
cancel_delayed_work(&ac97->power_work); cancel_delayed_work_sync(&ac97->power_work);
flush_scheduled_work();
#endif #endif
snd_ac97_powerdown(ac97); snd_ac97_powerdown(ac97);
} }
......
...@@ -263,8 +263,7 @@ static void vt1708_stop_hp_work(struct via_spec *spec) ...@@ -263,8 +263,7 @@ static void vt1708_stop_hp_work(struct via_spec *spec)
return; return;
snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81,
!spec->vt1708_jack_detectect); !spec->vt1708_jack_detectect);
cancel_delayed_work(&spec->vt1708_hp_work); cancel_delayed_work_sync(&spec->vt1708_hp_work);
flush_scheduled_work();
} }
......
...@@ -557,7 +557,8 @@ static void oxygen_card_free(struct snd_card *card) ...@@ -557,7 +557,8 @@ static void oxygen_card_free(struct snd_card *card)
oxygen_shutdown(chip); oxygen_shutdown(chip);
if (chip->irq >= 0) if (chip->irq >= 0)
free_irq(chip->irq, chip); 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); chip->model.cleanup(chip);
kfree(chip->model_data); kfree(chip->model_data);
mutex_destroy(&chip->mutex); mutex_destroy(&chip->mutex);
...@@ -733,7 +734,8 @@ int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state) ...@@ -733,7 +734,8 @@ int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state)
spin_unlock_irq(&chip->reg_lock); spin_unlock_irq(&chip->reg_lock);
synchronize_irq(chip->irq); 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; chip->interrupt_mask = saved_interrupt_mask;
pci_disable_device(pci); pci_disable_device(pci);
......
...@@ -1626,7 +1626,6 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec) ...@@ -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_data *priv = snd_soc_codec_get_drvdata(codec);
struct wm8350 *wm8350 = dev_get_platdata(codec->dev); struct wm8350 *wm8350 = dev_get_platdata(codec->dev);
int ret;
wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
WM8350_JDL_ENA | WM8350_JDR_ENA); WM8350_JDL_ENA | WM8350_JDR_ENA);
...@@ -1641,15 +1640,9 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec) ...@@ -1641,15 +1640,9 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec)
priv->hpr.jack = NULL; priv->hpr.jack = NULL;
priv->mic.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 /* if there was any work waiting then we run it now and
* wait for its completion */ * wait for its completion */
if (ret) { flush_delayed_work_sync(&codec->delayed_work);
schedule_delayed_work(&codec->delayed_work, 0);
flush_scheduled_work();
}
wm8350_set_bias_level(codec, SND_SOC_BIAS_OFF); wm8350_set_bias_level(codec, SND_SOC_BIAS_OFF);
......
...@@ -1526,25 +1526,6 @@ static int wm8753_resume(struct snd_soc_codec *codec) ...@@ -1526,25 +1526,6 @@ static int wm8753_resume(struct snd_soc_codec *codec)
return 0; 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) static int wm8753_probe(struct snd_soc_codec *codec)
{ {
struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
...@@ -1604,7 +1585,7 @@ static int wm8753_probe(struct snd_soc_codec *codec) ...@@ -1604,7 +1585,7 @@ static int wm8753_probe(struct snd_soc_codec *codec)
/* power down chip */ /* power down chip */
static int wm8753_remove(struct snd_soc_codec *codec) 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); wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF);
return 0; return 0;
......
...@@ -67,25 +67,6 @@ static int pmdown_time = 5000; ...@@ -67,25 +67,6 @@ static int pmdown_time = 5000;
module_param(pmdown_time, int, 0); module_param(pmdown_time, int, 0);
MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)"); 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 */ /* codec register dump */
static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf) 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) ...@@ -1016,7 +997,7 @@ static int soc_suspend(struct device *dev)
/* close any waiting streams and save state */ /* close any waiting streams and save state */
for (i = 0; i < card->num_rtd; i++) { 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; 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) ...@@ -1687,7 +1668,7 @@ static int soc_remove(struct platform_device *pdev)
/* make sure any delayed work runs */ /* make sure any delayed work runs */
for (i = 0; i < card->num_rtd; i++) { for (i = 0; i < card->num_rtd; i++) {
struct snd_soc_pcm_runtime *rtd = &card->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 */ /* remove and free each DAI */
...@@ -1718,7 +1699,7 @@ static int soc_poweroff(struct device *dev) ...@@ -1718,7 +1699,7 @@ static int soc_poweroff(struct device *dev)
* now, we're shutting down so no imminent restart. */ * now, we're shutting down so no imminent restart. */
for (i = 0; i < card->num_rtd; i++) { for (i = 0; i < card->num_rtd; i++) {
struct snd_soc_pcm_runtime *rtd = &card->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); snd_soc_dapm_shutdown(card);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment