Skip to content

Commit d819387

Browse files
committed
ALSA: hda - Clean up redundant FG checks
Just refactoring, no functional changes. Signed-off-by: Takashi Iwai <[email protected]>
1 parent 08fa20a commit d819387

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

sound/pci/hda/hda_codec.c

+12-18
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
12221222
static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
12231223
hda_nid_t fg, unsigned int power_state);
12241224

1225-
static unsigned int hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
1225+
static unsigned int hda_set_power_state(struct hda_codec *codec,
12261226
unsigned int power_state);
12271227

12281228
/**
@@ -1239,6 +1239,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
12391239
{
12401240
struct hda_codec *codec;
12411241
char component[31];
1242+
hda_nid_t fg;
12421243
int err;
12431244

12441245
if (snd_BUG_ON(!bus))
@@ -1315,7 +1316,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
13151316
goto error;
13161317
}
13171318

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

13271329
if (!codec->subsystem_id) {
1328-
hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
13291330
codec->subsystem_id =
1330-
snd_hda_codec_read(codec, nid, 0,
1331+
snd_hda_codec_read(codec, fg, 0,
13311332
AC_VERB_GET_SUBSYSTEM_ID, 0);
13321333
}
13331334

13341335
#ifdef CONFIG_PM
1335-
codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec,
1336-
codec->afg ? codec->afg : codec->mfg,
1336+
codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec, fg,
13371337
AC_PWRST_CLKSTOP);
13381338
if (!codec->d3_stop_clk)
13391339
bus->power_keep_link_on = 1;
13401340
#endif
1341-
codec->epss = snd_hda_codec_get_supported_ps(codec,
1342-
codec->afg ? codec->afg : codec->mfg,
1341+
codec->epss = snd_hda_codec_get_supported_ps(codec, fg,
13431342
AC_PWRST_EPSS);
13441343

13451344
/* power-up all before initialization */
1346-
hda_set_power_state(codec,
1347-
codec->afg ? codec->afg : codec->mfg,
1348-
AC_PWRST_D0);
1345+
hda_set_power_state(codec, AC_PWRST_D0);
13491346

13501347
snd_hda_codec_proc_new(codec);
13511348

@@ -3566,9 +3563,10 @@ static unsigned int hda_sync_power_state(struct hda_codec *codec,
35663563
/*
35673564
* set power state of the codec, and return the power state
35683565
*/
3569-
static unsigned int hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
3566+
static unsigned int hda_set_power_state(struct hda_codec *codec,
35703567
unsigned int power_state)
35713568
{
3569+
hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;
35723570
int count;
35733571
unsigned int state;
35743572

@@ -3621,9 +3619,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
36213619
if (codec->patch_ops.suspend)
36223620
codec->patch_ops.suspend(codec);
36233621
hda_cleanup_all_streams(codec);
3624-
state = hda_set_power_state(codec,
3625-
codec->afg ? codec->afg : codec->mfg,
3626-
AC_PWRST_D3);
3622+
state = hda_set_power_state(codec, AC_PWRST_D3);
36273623
cancel_delayed_work(&codec->power_work);
36283624
spin_lock(&codec->power_lock);
36293625
snd_hda_update_power_acct(codec);
@@ -3644,9 +3640,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
36443640
* in the resume / power-save sequence
36453641
*/
36463642
hda_keep_power_on(codec);
3647-
hda_set_power_state(codec,
3648-
codec->afg ? codec->afg : codec->mfg,
3649-
AC_PWRST_D0);
3643+
hda_set_power_state(codec, AC_PWRST_D0);
36503644
restore_pincfgs(codec); /* restore all current pin configs */
36513645
restore_shutup_pins(codec);
36523646
hda_exec_init_verbs(codec);

0 commit comments

Comments
 (0)