Skip to content

Commit

Permalink
[ALSA] hda-intel - Avoid unnecessary work scheduling
Browse files Browse the repository at this point in the history
Avoid unnecessary work scheduling for power-off.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
  • Loading branch information
Takashi Iwai authored and Jaroslav Kysela committed Oct 16, 2007
1 parent 676a9b5 commit a221e28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,7 @@ static void hda_call_codec_suspend(struct hda_codec *codec)
#ifdef CONFIG_SND_HDA_POWER_SAVE
cancel_delayed_work(&codec->power_work);
codec->power_on = 0;
codec->power_transition = 0;
#endif
}

Expand Down Expand Up @@ -2211,24 +2212,27 @@ static void hda_keep_power_on(struct hda_codec *codec)
void snd_hda_power_up(struct hda_codec *codec)
{
codec->power_count++;
if (codec->power_on)
if (codec->power_on || codec->power_transition)
return;

codec->power_on = 1;
if (codec->bus->ops.pm_notify)
codec->bus->ops.pm_notify(codec);
hda_call_codec_resume(codec);
cancel_delayed_work(&codec->power_work);
codec->power_transition = 0;
}

void snd_hda_power_down(struct hda_codec *codec)
{
--codec->power_count;
if (!codec->power_on || codec->power_count)
if (!codec->power_on || codec->power_count || codec->power_transition)
return;
if (power_save)
if (power_save) {
codec->power_transition = 1; /* avoid reentrance */
schedule_delayed_work(&codec->power_work,
msecs_to_jiffies(power_save * 1000));
}
}

int snd_hda_check_amp_list_power(struct hda_codec *codec,
Expand Down
3 changes: 2 additions & 1 deletion sound/pci/hda/hda_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ struct hda_codec {
struct snd_hwdep *hwdep; /* assigned hwdep device */

#ifdef CONFIG_SND_HDA_POWER_SAVE
int power_on; /* current (global) power-state */
unsigned int power_on :1; /* current (global) power-state */
unsigned int power_transition :1; /* power-state in transition */
int power_count; /* current (global) power refcount */
struct delayed_work power_work; /* delayed task for powerdown */
#endif
Expand Down

0 comments on commit a221e28

Please sign in to comment.