Skip to content

Commit

Permalink
sound: don't use flush_scheduled_work()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Mark Brown <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
htejun authored and tiwai committed Dec 13, 2010
1 parent cf7d7e5 commit 5b84ba2
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 72 deletions.
7 changes: 3 additions & 4 deletions sound/aoa/core/gpio-feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions sound/aoa/core/gpio-pmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions sound/i2c/other/ak4113.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions sound/i2c/other/ak4114.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions sound/pci/ac97/ac97_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/hda/patch_via.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
6 changes: 4 additions & 2 deletions sound/pci/oxygen/oxygen_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 1 addition & 8 deletions sound/soc/codecs/wm8350.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
21 changes: 1 addition & 20 deletions sound/soc/codecs/wm8753.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 3 additions & 22 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5b84ba2

Please sign in to comment.