Skip to content

Commit

Permalink
ALSA: hda - Clean up redundant FG checks
Browse files Browse the repository at this point in the history
Just refactoring, no functional changes.

Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Aug 31, 2012
1 parent 08fa20a commit d819387
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
hda_nid_t fg, unsigned int power_state);

static unsigned int hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
static unsigned int hda_set_power_state(struct hda_codec *codec,
unsigned int power_state);

/**
Expand All @@ -1239,6 +1239,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
{
struct hda_codec *codec;
char component[31];
hda_nid_t fg;
int err;

if (snd_BUG_ON(!bus))
Expand Down Expand Up @@ -1315,7 +1316,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
goto error;
}

err = read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg);
fg = codec->afg ? codec->afg : codec->mfg;
err = read_widget_caps(codec, fg);
if (err < 0) {
snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
goto error;
Expand All @@ -1325,27 +1327,22 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
goto error;

if (!codec->subsystem_id) {
hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
codec->subsystem_id =
snd_hda_codec_read(codec, nid, 0,
snd_hda_codec_read(codec, fg, 0,
AC_VERB_GET_SUBSYSTEM_ID, 0);
}

#ifdef CONFIG_PM
codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec,
codec->afg ? codec->afg : codec->mfg,
codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec, fg,
AC_PWRST_CLKSTOP);
if (!codec->d3_stop_clk)
bus->power_keep_link_on = 1;
#endif
codec->epss = snd_hda_codec_get_supported_ps(codec,
codec->afg ? codec->afg : codec->mfg,
codec->epss = snd_hda_codec_get_supported_ps(codec, fg,
AC_PWRST_EPSS);

/* power-up all before initialization */
hda_set_power_state(codec,
codec->afg ? codec->afg : codec->mfg,
AC_PWRST_D0);
hda_set_power_state(codec, AC_PWRST_D0);

snd_hda_codec_proc_new(codec);

Expand Down Expand Up @@ -3566,9 +3563,10 @@ static unsigned int hda_sync_power_state(struct hda_codec *codec,
/*
* set power state of the codec, and return the power state
*/
static unsigned int hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
static unsigned int hda_set_power_state(struct hda_codec *codec,
unsigned int power_state)
{
hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;
int count;
unsigned int state;

Expand Down Expand Up @@ -3621,9 +3619,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
if (codec->patch_ops.suspend)
codec->patch_ops.suspend(codec);
hda_cleanup_all_streams(codec);
state = hda_set_power_state(codec,
codec->afg ? codec->afg : codec->mfg,
AC_PWRST_D3);
state = hda_set_power_state(codec, AC_PWRST_D3);
cancel_delayed_work(&codec->power_work);
spin_lock(&codec->power_lock);
snd_hda_update_power_acct(codec);
Expand All @@ -3644,9 +3640,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
* in the resume / power-save sequence
*/
hda_keep_power_on(codec);
hda_set_power_state(codec,
codec->afg ? codec->afg : codec->mfg,
AC_PWRST_D0);
hda_set_power_state(codec, AC_PWRST_D0);
restore_pincfgs(codec); /* restore all current pin configs */
restore_shutup_pins(codec);
hda_exec_init_verbs(codec);
Expand Down

0 comments on commit d819387

Please sign in to comment.