aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-08-31 10:54:38 -0400
committerTakashi Iwai <tiwai@suse.de>2012-08-31 10:58:28 -0400
commitd819387ef7ca97b4cb3494bfaba9c0cd510122a0 (patch)
treeea20a06494af58ab55fe688d23a6c320760dbf34 /sound/pci/hda
parent08fa20ae20eb378225e5519db4e07f663ce405fa (diff)
ALSA: hda - Clean up redundant FG checks
Just refactoring, no functional changes. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r--sound/pci/hda/hda_codec.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 8e7dbb0921e6..ff97cf3e8bad 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1222,7 +1222,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
1222static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, 1222static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
1223 hda_nid_t fg, unsigned int power_state); 1223 hda_nid_t fg, unsigned int power_state);
1224 1224
1225static unsigned int hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, 1225static unsigned int hda_set_power_state(struct hda_codec *codec,
1226 unsigned int power_state); 1226 unsigned int power_state);
1227 1227
1228/** 1228/**
@@ -1239,6 +1239,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
1239{ 1239{
1240 struct hda_codec *codec; 1240 struct hda_codec *codec;
1241 char component[31]; 1241 char component[31];
1242 hda_nid_t fg;
1242 int err; 1243 int err;
1243 1244
1244 if (snd_BUG_ON(!bus)) 1245 if (snd_BUG_ON(!bus))
@@ -1315,7 +1316,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
1315 goto error; 1316 goto error;
1316 } 1317 }
1317 1318
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);
1319 if (err < 0) { 1321 if (err < 0) {
1320 snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); 1322 snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
1321 goto error; 1323 goto error;
@@ -1325,27 +1327,22 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
1325 goto error; 1327 goto error;
1326 1328
1327 if (!codec->subsystem_id) { 1329 if (!codec->subsystem_id) {
1328 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
1329 codec->subsystem_id = 1330 codec->subsystem_id =
1330 snd_hda_codec_read(codec, nid, 0, 1331 snd_hda_codec_read(codec, fg, 0,
1331 AC_VERB_GET_SUBSYSTEM_ID, 0); 1332 AC_VERB_GET_SUBSYSTEM_ID, 0);
1332 } 1333 }
1333 1334
1334#ifdef CONFIG_PM 1335#ifdef CONFIG_PM
1335 codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec, 1336 codec->d3_stop_clk = snd_hda_codec_get_supported_ps(codec, fg,
1336 codec->afg ? codec->afg : codec->mfg,
1337 AC_PWRST_CLKSTOP); 1337 AC_PWRST_CLKSTOP);
1338 if (!codec->d3_stop_clk) 1338 if (!codec->d3_stop_clk)
1339 bus->power_keep_link_on = 1; 1339 bus->power_keep_link_on = 1;
1340#endif 1340#endif
1341 codec->epss = snd_hda_codec_get_supported_ps(codec, 1341 codec->epss = snd_hda_codec_get_supported_ps(codec, fg,
1342 codec->afg ? codec->afg : codec->mfg,
1343 AC_PWRST_EPSS); 1342 AC_PWRST_EPSS);
1344 1343
1345 /* power-up all before initialization */ 1344 /* power-up all before initialization */
1346 hda_set_power_state(codec, 1345 hda_set_power_state(codec, AC_PWRST_D0);
1347 codec->afg ? codec->afg : codec->mfg,
1348 AC_PWRST_D0);
1349 1346
1350 snd_hda_codec_proc_new(codec); 1347 snd_hda_codec_proc_new(codec);
1351 1348
@@ -3566,9 +3563,10 @@ static unsigned int hda_sync_power_state(struct hda_codec *codec,
3566/* 3563/*
3567 * set power state of the codec, and return the power state 3564 * set power state of the codec, and return the power state
3568 */ 3565 */
3569static unsigned int hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, 3566static unsigned int hda_set_power_state(struct hda_codec *codec,
3570 unsigned int power_state) 3567 unsigned int power_state)
3571{ 3568{
3569 hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;
3572 int count; 3570 int count;
3573 unsigned int state; 3571 unsigned int state;
3574 3572
@@ -3621,9 +3619,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
3621 if (codec->patch_ops.suspend) 3619 if (codec->patch_ops.suspend)
3622 codec->patch_ops.suspend(codec); 3620 codec->patch_ops.suspend(codec);
3623 hda_cleanup_all_streams(codec); 3621 hda_cleanup_all_streams(codec);
3624 state = hda_set_power_state(codec, 3622 state = hda_set_power_state(codec, AC_PWRST_D3);
3625 codec->afg ? codec->afg : codec->mfg,
3626 AC_PWRST_D3);
3627 cancel_delayed_work(&codec->power_work); 3623 cancel_delayed_work(&codec->power_work);
3628 spin_lock(&codec->power_lock); 3624 spin_lock(&codec->power_lock);
3629 snd_hda_update_power_acct(codec); 3625 snd_hda_update_power_acct(codec);
@@ -3644,9 +3640,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
3644 * in the resume / power-save sequence 3640 * in the resume / power-save sequence
3645 */ 3641 */
3646 hda_keep_power_on(codec); 3642 hda_keep_power_on(codec);
3647 hda_set_power_state(codec, 3643 hda_set_power_state(codec, AC_PWRST_D0);
3648 codec->afg ? codec->afg : codec->mfg,
3649 AC_PWRST_D0);
3650 restore_pincfgs(codec); /* restore all current pin configs */ 3644 restore_pincfgs(codec); /* restore all current pin configs */
3651 restore_shutup_pins(codec); 3645 restore_shutup_pins(codec);
3652 hda_exec_init_verbs(codec); 3646 hda_exec_init_verbs(codec);