aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2006-10-11 12:52:53 -0400
committerJaroslav Kysela <perex@suse.cz>2006-10-22 04:51:10 -0400
commit30b35399ceb2398d05837863476dcb12f12f3a82 (patch)
tree14a7cfad1c5d28d207bb1be8addb86ead33f7b63
parentc06134d73cdc02bb8ab1fad180f6da1f28d2e049 (diff)
[ALSA] Various fixes for suspend/resume of ALSA PCI drivers
- Check the return value of pci_enable_device() and request_irq() in the suspend. If any error occurs there, disable the device using snd_card_disconnect(). - Call pci_set_power_state() properly with pci_choose_state(). - Fix the order to call pci_set_power_state(). - Removed obsolete house-made PM codes in some drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
-rw-r--r--sound/pci/ali5451/ali5451.c11
-rw-r--r--sound/pci/als300.c11
-rw-r--r--sound/pci/als4000.c11
-rw-r--r--sound/pci/atiixp.c11
-rw-r--r--sound/pci/atiixp_modem.c11
-rw-r--r--sound/pci/azt3328.c11
-rw-r--r--sound/pci/cmipci.c11
-rw-r--r--sound/pci/cs4281.c9
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c11
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pm.c11
-rw-r--r--sound/pci/emu10k1/emu10k1.c13
-rw-r--r--sound/pci/ens1370.c12
-rw-r--r--sound/pci/es1938.c29
-rw-r--r--sound/pci/es1968.c71
-rw-r--r--sound/pci/fm801.c11
-rw-r--r--sound/pci/hda/hda_intel.c33
-rw-r--r--sound/pci/intel8x0.c23
-rw-r--r--sound/pci/intel8x0m.c23
-rw-r--r--sound/pci/maestro3.c13
-rw-r--r--sound/pci/nm256/nm256.c12
-rw-r--r--sound/pci/riptide/riptide.c11
-rw-r--r--sound/pci/trident/trident_main.c18
-rw-r--r--sound/pci/via82xx.c12
-rw-r--r--sound/pci/via82xx_modem.c12
-rw-r--r--sound/pci/vx222/vx222.c11
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c9
26 files changed, 276 insertions, 145 deletions
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 13a8cefa7749..a7edd56542d4 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -2032,8 +2032,10 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2032 outl(0xffffffff, ALI_REG(chip, ALI_STOP)); 2032 outl(0xffffffff, ALI_REG(chip, ALI_STOP));
2033 2033
2034 spin_unlock_irq(&chip->reg_lock); 2034 spin_unlock_irq(&chip->reg_lock);
2035
2035 pci_disable_device(pci); 2036 pci_disable_device(pci);
2036 pci_save_state(pci); 2037 pci_save_state(pci);
2038 pci_set_power_state(pci, pci_choose_state(pci, state));
2037 return 0; 2039 return 0;
2038} 2040}
2039 2041
@@ -2048,8 +2050,15 @@ static int ali_resume(struct pci_dev *pci)
2048 if (! im) 2050 if (! im)
2049 return 0; 2051 return 0;
2050 2052
2053 pci_set_power_state(pci, PCI_D0);
2051 pci_restore_state(pci); 2054 pci_restore_state(pci);
2052 pci_enable_device(pci); 2055 if (pci_enable_device(pci) < 0) {
2056 printk(KERN_ERR "ali5451: pci_enable_device failed, "
2057 "disabling device\n");
2058 snd_card_disconnect(card);
2059 return -EIO;
2060 }
2061 pci_set_master(pci);
2053 2062
2054 spin_lock_irq(&chip->reg_lock); 2063 spin_lock_irq(&chip->reg_lock);
2055 2064
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 9b16c299f0a9..95f70f3cc37e 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -768,9 +768,9 @@ static int snd_als300_suspend(struct pci_dev *pci, pm_message_t state)
768 snd_pcm_suspend_all(chip->pcm); 768 snd_pcm_suspend_all(chip->pcm);
769 snd_ac97_suspend(chip->ac97); 769 snd_ac97_suspend(chip->ac97);
770 770
771 pci_set_power_state(pci, PCI_D3hot);
772 pci_disable_device(pci); 771 pci_disable_device(pci);
773 pci_save_state(pci); 772 pci_save_state(pci);
773 pci_set_power_state(pci, pci_choose_state(pci, state));
774 return 0; 774 return 0;
775} 775}
776 776
@@ -779,9 +779,14 @@ static int snd_als300_resume(struct pci_dev *pci)
779 struct snd_card *card = pci_get_drvdata(pci); 779 struct snd_card *card = pci_get_drvdata(pci);
780 struct snd_als300 *chip = card->private_data; 780 struct snd_als300 *chip = card->private_data;
781 781
782 pci_restore_state(pci);
783 pci_enable_device(pci);
784 pci_set_power_state(pci, PCI_D0); 782 pci_set_power_state(pci, PCI_D0);
783 pci_restore_state(pci);
784 if (pci_enable_device(pci) < 0) {
785 printk(KERN_ERR "als300: pci_enable_device failed, "
786 "disabling device\n");
787 snd_card_disconnect(card);
788 return -EIO;
789 }
785 pci_set_master(pci); 790 pci_set_master(pci);
786 791
787 snd_als300_init(chip); 792 snd_als300_init(chip);
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 15fc3929b5f7..8fb55d3b454b 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -804,9 +804,9 @@ static int snd_als4000_suspend(struct pci_dev *pci, pm_message_t state)
804 snd_pcm_suspend_all(chip->pcm); 804 snd_pcm_suspend_all(chip->pcm);
805 snd_sbmixer_suspend(chip); 805 snd_sbmixer_suspend(chip);
806 806
807 pci_set_power_state(pci, PCI_D3hot);
808 pci_disable_device(pci); 807 pci_disable_device(pci);
809 pci_save_state(pci); 808 pci_save_state(pci);
809 pci_set_power_state(pci, pci_choose_state(pci, state));
810 return 0; 810 return 0;
811} 811}
812 812
@@ -816,9 +816,14 @@ static int snd_als4000_resume(struct pci_dev *pci)
816 struct snd_card_als4000 *acard = card->private_data; 816 struct snd_card_als4000 *acard = card->private_data;
817 struct snd_sb *chip = acard->chip; 817 struct snd_sb *chip = acard->chip;
818 818
819 pci_restore_state(pci);
820 pci_enable_device(pci);
821 pci_set_power_state(pci, PCI_D0); 819 pci_set_power_state(pci, PCI_D0);
820 pci_restore_state(pci);
821 if (pci_enable_device(pci) < 0) {
822 printk(KERN_ERR "als4000: pci_enable_device failed, "
823 "disabling device\n");
824 snd_card_disconnect(card);
825 return -EIO;
826 }
822 pci_set_master(pci); 827 pci_set_master(pci);
823 828
824 snd_als4000_configure(chip); 829 snd_als4000_configure(chip);
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 3e8fc5a0006a..e3e99f396711 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1442,9 +1442,9 @@ static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state)
1442 snd_atiixp_aclink_down(chip); 1442 snd_atiixp_aclink_down(chip);
1443 snd_atiixp_chip_stop(chip); 1443 snd_atiixp_chip_stop(chip);
1444 1444
1445 pci_set_power_state(pci, PCI_D3hot);
1446 pci_disable_device(pci); 1445 pci_disable_device(pci);
1447 pci_save_state(pci); 1446 pci_save_state(pci);
1447 pci_set_power_state(pci, pci_choose_state(pci, state));
1448 return 0; 1448 return 0;
1449} 1449}
1450 1450
@@ -1454,9 +1454,14 @@ static int snd_atiixp_resume(struct pci_dev *pci)
1454 struct atiixp *chip = card->private_data; 1454 struct atiixp *chip = card->private_data;
1455 int i; 1455 int i;
1456 1456
1457 pci_restore_state(pci);
1458 pci_enable_device(pci);
1459 pci_set_power_state(pci, PCI_D0); 1457 pci_set_power_state(pci, PCI_D0);
1458 pci_restore_state(pci);
1459 if (pci_enable_device(pci) < 0) {
1460 printk(KERN_ERR "atiixp: pci_enable_device failed, "
1461 "disabling device\n");
1462 snd_card_disconnect(card);
1463 return -EIO;
1464 }
1460 pci_set_master(pci); 1465 pci_set_master(pci);
1461 1466
1462 snd_atiixp_aclink_reset(chip); 1467 snd_atiixp_aclink_reset(chip);
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index c5dda1bf3d46..dc54f2c68ed7 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1128,9 +1128,9 @@ static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state)
1128 snd_atiixp_aclink_down(chip); 1128 snd_atiixp_aclink_down(chip);
1129 snd_atiixp_chip_stop(chip); 1129 snd_atiixp_chip_stop(chip);
1130 1130
1131 pci_set_power_state(pci, PCI_D3hot);
1132 pci_disable_device(pci); 1131 pci_disable_device(pci);
1133 pci_save_state(pci); 1132 pci_save_state(pci);
1133 pci_set_power_state(pci, pci_choose_state(pci, state));
1134 return 0; 1134 return 0;
1135} 1135}
1136 1136
@@ -1140,9 +1140,14 @@ static int snd_atiixp_resume(struct pci_dev *pci)
1140 struct atiixp_modem *chip = card->private_data; 1140 struct atiixp_modem *chip = card->private_data;
1141 int i; 1141 int i;
1142 1142
1143 pci_restore_state(pci);
1144 pci_enable_device(pci);
1145 pci_set_power_state(pci, PCI_D0); 1143 pci_set_power_state(pci, PCI_D0);
1144 pci_restore_state(pci);
1145 if (pci_enable_device(pci) < 0) {
1146 printk(KERN_ERR "atiixp-modem: pci_enable_device failed, "
1147 "disabling device\n");
1148 snd_card_disconnect(card);
1149 return -EIO;
1150 }
1146 pci_set_master(pci); 1151 pci_set_master(pci);
1147 1152
1148 snd_atiixp_aclink_reset(chip); 1153 snd_atiixp_aclink_reset(chip);
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 692f203d65d8..2414ee630756 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1903,9 +1903,9 @@ snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state)
1903 for (reg = 0; reg < AZF_IO_SIZE_SYNTH_PM / 2; reg++) 1903 for (reg = 0; reg < AZF_IO_SIZE_SYNTH_PM / 2; reg++)
1904 chip->saved_regs_synth[reg] = inw(chip->synth_port + reg * 2); 1904 chip->saved_regs_synth[reg] = inw(chip->synth_port + reg * 2);
1905 1905
1906 pci_set_power_state(pci, PCI_D3hot);
1907 pci_disable_device(pci); 1906 pci_disable_device(pci);
1908 pci_save_state(pci); 1907 pci_save_state(pci);
1908 pci_set_power_state(pci, pci_choose_state(pci, state));
1909 return 0; 1909 return 0;
1910} 1910}
1911 1911
@@ -1916,9 +1916,14 @@ snd_azf3328_resume(struct pci_dev *pci)
1916 struct snd_azf3328 *chip = card->private_data; 1916 struct snd_azf3328 *chip = card->private_data;
1917 int reg; 1917 int reg;
1918 1918
1919 pci_restore_state(pci);
1920 pci_enable_device(pci);
1921 pci_set_power_state(pci, PCI_D0); 1919 pci_set_power_state(pci, PCI_D0);
1920 pci_restore_state(pci);
1921 if (pci_enable_device(pci) < 0) {
1922 printk(KERN_ERR "azt3328: pci_enable_device failed, "
1923 "disabling device\n");
1924 snd_card_disconnect(card);
1925 return -EIO;
1926 }
1922 pci_set_master(pci); 1927 pci_set_master(pci);
1923 1928
1924 for (reg = 0; reg < AZF_IO_SIZE_IO2_PM / 2; reg++) 1929 for (reg = 0; reg < AZF_IO_SIZE_IO2_PM / 2; reg++)
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 1f7e71083069..0093cd1f92db 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -3122,9 +3122,9 @@ static int snd_cmipci_suspend(struct pci_dev *pci, pm_message_t state)
3122 /* disable ints */ 3122 /* disable ints */
3123 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); 3123 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0);
3124 3124
3125 pci_set_power_state(pci, PCI_D3hot);
3126 pci_disable_device(pci); 3125 pci_disable_device(pci);
3127 pci_save_state(pci); 3126 pci_save_state(pci);
3127 pci_set_power_state(pci, pci_choose_state(pci, state));
3128 return 0; 3128 return 0;
3129} 3129}
3130 3130
@@ -3134,9 +3134,14 @@ static int snd_cmipci_resume(struct pci_dev *pci)
3134 struct cmipci *cm = card->private_data; 3134 struct cmipci *cm = card->private_data;
3135 int i; 3135 int i;
3136 3136
3137 pci_restore_state(pci);
3138 pci_enable_device(pci);
3139 pci_set_power_state(pci, PCI_D0); 3137 pci_set_power_state(pci, PCI_D0);
3138 pci_restore_state(pci);
3139 if (pci_enable_device(pci) < 0) {
3140 printk(KERN_ERR "cmipci: pci_enable_device failed, "
3141 "disabling device\n");
3142 snd_card_disconnect(card);
3143 return -EIO;
3144 }
3140 pci_set_master(pci); 3145 pci_set_master(pci);
3141 3146
3142 /* reset / initialize to a sane state */ 3147 /* reset / initialize to a sane state */
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index d54924e60bb1..0905fa88129d 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -2050,6 +2050,7 @@ static int cs4281_suspend(struct pci_dev *pci, pm_message_t state)
2050 2050
2051 pci_disable_device(pci); 2051 pci_disable_device(pci);
2052 pci_save_state(pci); 2052 pci_save_state(pci);
2053 pci_set_power_state(pci, pci_choose_state(pci, state));
2053 return 0; 2054 return 0;
2054} 2055}
2055 2056
@@ -2060,8 +2061,14 @@ static int cs4281_resume(struct pci_dev *pci)
2060 unsigned int i; 2061 unsigned int i;
2061 u32 ulCLK; 2062 u32 ulCLK;
2062 2063
2064 pci_set_power_state(pci, PCI_D0);
2063 pci_restore_state(pci); 2065 pci_restore_state(pci);
2064 pci_enable_device(pci); 2066 if (pci_enable_device(pci) < 0) {
2067 printk(KERN_ERR "cs4281: pci_enable_device failed, "
2068 "disabling device\n");
2069 snd_card_disconnect(card);
2070 return -EIO;
2071 }
2065 pci_set_master(pci); 2072 pci_set_master(pci);
2066 2073
2067 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); 2074 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1);
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 16d4ebf2a33f..2807b9756ef0 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -3687,8 +3687,10 @@ int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state)
3687 /* disable CLKRUN */ 3687 /* disable CLKRUN */
3688 chip->active_ctrl(chip, -chip->amplifier); 3688 chip->active_ctrl(chip, -chip->amplifier);
3689 chip->amplifier = amp_saved; /* restore the status */ 3689 chip->amplifier = amp_saved; /* restore the status */
3690
3690 pci_disable_device(pci); 3691 pci_disable_device(pci);
3691 pci_save_state(pci); 3692 pci_save_state(pci);
3693 pci_set_power_state(pci, pci_choose_state(pci, state));
3692 return 0; 3694 return 0;
3693} 3695}
3694 3696
@@ -3698,9 +3700,16 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3698 struct snd_cs46xx *chip = card->private_data; 3700 struct snd_cs46xx *chip = card->private_data;
3699 int amp_saved; 3701 int amp_saved;
3700 3702
3703 pci_set_power_state(pci, PCI_D0);
3701 pci_restore_state(pci); 3704 pci_restore_state(pci);
3702 pci_enable_device(pci); 3705 if (pci_enable_device(pci) < 0) {
3706 printk(KERN_ERR "cs46xx: pci_enable_device failed, "
3707 "disabling device\n");
3708 snd_card_disconnect(card);
3709 return -EIO;
3710 }
3703 pci_set_master(pci); 3711 pci_set_master(pci);
3712
3704 amp_saved = chip->amplifier; 3713 amp_saved = chip->amplifier;
3705 chip->amplifier = 0; 3714 chip->amplifier = 0;
3706 chip->active_ctrl(chip, 1); /* force to on */ 3715 chip->active_ctrl(chip, 1); /* force to on */
diff --git a/sound/pci/cs5535audio/cs5535audio_pm.c b/sound/pci/cs5535audio/cs5535audio_pm.c
index aad0e69db9c1..3e4d198a4502 100644
--- a/sound/pci/cs5535audio/cs5535audio_pm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pm.c
@@ -73,9 +73,10 @@ int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state)
73 snd_ac97_suspend(cs5535au->ac97); 73 snd_ac97_suspend(cs5535au->ac97);
74 /* save important regs, then disable aclink in hw */ 74 /* save important regs, then disable aclink in hw */
75 snd_cs5535audio_stop_hardware(cs5535au); 75 snd_cs5535audio_stop_hardware(cs5535au);
76
76 pci_disable_device(pci); 77 pci_disable_device(pci);
77 pci_save_state(pci); 78 pci_save_state(pci);
78 79 pci_set_power_state(pci, pci_choose_state(pci, state));
79 return 0; 80 return 0;
80} 81}
81 82
@@ -87,8 +88,14 @@ int snd_cs5535audio_resume(struct pci_dev *pci)
87 int timeout; 88 int timeout;
88 int i; 89 int i;
89 90
91 pci_set_power_state(pci, PCI_D0);
90 pci_restore_state(pci); 92 pci_restore_state(pci);
91 pci_enable_device(pci); 93 if (pci_enable_device(pci) < 0) {
94 printk(KERN_ERR "cs5535audio: pci_enable_device failed, "
95 "disabling device\n");
96 snd_card_disconnect(card);
97 return -EIO;
98 }
92 pci_set_master(pci); 99 pci_set_master(pci);
93 100
94 /* set LNK_WRM_RST to reset AC link */ 101 /* set LNK_WRM_RST to reset AC link */
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index 493ec0816bb3..55caf341933a 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -226,9 +226,9 @@ static int snd_emu10k1_suspend(struct pci_dev *pci, pm_message_t state)
226 226
227 snd_emu10k1_done(emu); 227 snd_emu10k1_done(emu);
228 228
229 pci_set_power_state(pci, PCI_D3hot);
230 pci_disable_device(pci); 229 pci_disable_device(pci);
231 pci_save_state(pci); 230 pci_save_state(pci);
231 pci_set_power_state(pci, pci_choose_state(pci, state));
232 return 0; 232 return 0;
233} 233}
234 234
@@ -237,11 +237,16 @@ static int snd_emu10k1_resume(struct pci_dev *pci)
237 struct snd_card *card = pci_get_drvdata(pci); 237 struct snd_card *card = pci_get_drvdata(pci);
238 struct snd_emu10k1 *emu = card->private_data; 238 struct snd_emu10k1 *emu = card->private_data;
239 239
240 pci_restore_state(pci);
241 pci_enable_device(pci);
242 pci_set_power_state(pci, PCI_D0); 240 pci_set_power_state(pci, PCI_D0);
241 pci_restore_state(pci);
242 if (pci_enable_device(pci) < 0) {
243 printk(KERN_ERR "emu10k1: pci_enable_device failed, "
244 "disabling device\n");
245 snd_card_disconnect(card);
246 return -EIO;
247 }
243 pci_set_master(pci); 248 pci_set_master(pci);
244 249
245 snd_emu10k1_resume_init(emu); 250 snd_emu10k1_resume_init(emu);
246 snd_emu10k1_efx_resume(emu); 251 snd_emu10k1_efx_resume(emu);
247 snd_ac97_resume(emu->ac97); 252 snd_ac97_resume(emu->ac97);
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 8cb4fb2412db..d2a811f222c9 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -2072,9 +2072,10 @@ static int snd_ensoniq_suspend(struct pci_dev *pci, pm_message_t state)
2072 udelay(100); 2072 udelay(100);
2073 snd_ak4531_suspend(ensoniq->u.es1370.ak4531); 2073 snd_ak4531_suspend(ensoniq->u.es1370.ak4531);
2074#endif 2074#endif
2075 pci_set_power_state(pci, PCI_D3hot); 2075
2076 pci_disable_device(pci); 2076 pci_disable_device(pci);
2077 pci_save_state(pci); 2077 pci_save_state(pci);
2078 pci_set_power_state(pci, pci_choose_state(pci, state));
2078 return 0; 2079 return 0;
2079} 2080}
2080 2081
@@ -2083,9 +2084,14 @@ static int snd_ensoniq_resume(struct pci_dev *pci)
2083 struct snd_card *card = pci_get_drvdata(pci); 2084 struct snd_card *card = pci_get_drvdata(pci);
2084 struct ensoniq *ensoniq = card->private_data; 2085 struct ensoniq *ensoniq = card->private_data;
2085 2086
2086 pci_restore_state(pci);
2087 pci_enable_device(pci);
2088 pci_set_power_state(pci, PCI_D0); 2087 pci_set_power_state(pci, PCI_D0);
2088 pci_restore_state(pci);
2089 if (pci_enable_device(pci) < 0) {
2090 printk(KERN_ERR DRIVER_NAME ": pci_enable_device failed, "
2091 "disabling device\n");
2092 snd_card_disconnect(card);
2093 return -EIO;
2094 }
2089 pci_set_master(pci); 2095 pci_set_master(pci);
2090 2096
2091 snd_ensoniq_chip_init(ensoniq); 2097 snd_ensoniq_chip_init(ensoniq);
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 2da988f78ba7..1a8d36df4b5d 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1481,10 +1481,14 @@ static int es1938_suspend(struct pci_dev *pci, pm_message_t state)
1481 *d = snd_es1938_reg_read(chip, *s); 1481 *d = snd_es1938_reg_read(chip, *s);
1482 1482
1483 outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ 1483 outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
1484 if (chip->irq >= 0) 1484 if (chip->irq >= 0) {
1485 synchronize_irq(chip->irq);
1485 free_irq(chip->irq, chip); 1486 free_irq(chip->irq, chip);
1487 chip->irq = -1;
1488 }
1486 pci_disable_device(pci); 1489 pci_disable_device(pci);
1487 pci_save_state(pci); 1490 pci_save_state(pci);
1491 pci_set_power_state(pci, pci_choose_state(pci, state));
1488 return 0; 1492 return 0;
1489} 1493}
1490 1494
@@ -1494,10 +1498,22 @@ static int es1938_resume(struct pci_dev *pci)
1494 struct es1938 *chip = card->private_data; 1498 struct es1938 *chip = card->private_data;
1495 unsigned char *s, *d; 1499 unsigned char *s, *d;
1496 1500
1501 pci_set_power_state(pci, PCI_D0);
1497 pci_restore_state(pci); 1502 pci_restore_state(pci);
1498 pci_enable_device(pci); 1503 if (pci_enable_device(pci) < 0) {
1499 request_irq(pci->irq, snd_es1938_interrupt, 1504 printk(KERN_ERR "es1938: pci_enable_device failed, "
1500 IRQF_DISABLED|IRQF_SHARED, "ES1938", chip); 1505 "disabling device\n");
1506 snd_card_disconnect(card);
1507 return -EIO;
1508 }
1509
1510 if (request_irq(pci->irq, snd_es1938_interrupt,
1511 IRQF_DISABLED|IRQF_SHARED, "ES1938", chip)) {
1512 printk(KERN_ERR "es1938: unable to grab IRQ %d, "
1513 "disabling device\n", pci->irq);
1514 snd_card_disconnect(card);
1515 return -EIO;
1516 }
1501 chip->irq = pci->irq; 1517 chip->irq = pci->irq;
1502 snd_es1938_chip_init(chip); 1518 snd_es1938_chip_init(chip);
1503 1519
@@ -1556,8 +1572,10 @@ static int snd_es1938_free(struct es1938 *chip)
1556 1572
1557 snd_es1938_free_gameport(chip); 1573 snd_es1938_free_gameport(chip);
1558 1574
1559 if (chip->irq >= 0) 1575 if (chip->irq >= 0) {
1576 synchronize_irq(chip->irq);
1560 free_irq(chip->irq, chip); 1577 free_irq(chip->irq, chip);
1578 }
1561 pci_release_regions(chip->pci); 1579 pci_release_regions(chip->pci);
1562 pci_disable_device(chip->pci); 1580 pci_disable_device(chip->pci);
1563 kfree(chip); 1581 kfree(chip);
@@ -1602,6 +1620,7 @@ static int __devinit snd_es1938_create(struct snd_card *card,
1602 spin_lock_init(&chip->mixer_lock); 1620 spin_lock_init(&chip->mixer_lock);
1603 chip->card = card; 1621 chip->card = card;
1604 chip->pci = pci; 1622 chip->pci = pci;
1623 chip->irq = -1;
1605 if ((err = pci_request_regions(pci, "ESS Solo-1")) < 0) { 1624 if ((err = pci_request_regions(pci, "ESS Solo-1")) < 0) {
1606 kfree(chip); 1625 kfree(chip);
1607 pci_disable_device(pci); 1626 pci_disable_device(pci);
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index b9d723c7e1db..092da53e1464 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -432,46 +432,6 @@ MODULE_PARM_DESC(joystick, "Enable joystick.");
432#define ESM_MODE_PLAY 0 432#define ESM_MODE_PLAY 0
433#define ESM_MODE_CAPTURE 1 433#define ESM_MODE_CAPTURE 1
434 434
435/* acpi states */
436enum {
437 ACPI_D0=0,
438 ACPI_D1,
439 ACPI_D2,
440 ACPI_D3
441};
442
443/* bits in the acpi masks */
444#define ACPI_12MHZ ( 1 << 15)
445#define ACPI_24MHZ ( 1 << 14)
446#define ACPI_978 ( 1 << 13)
447#define ACPI_SPDIF ( 1 << 12)
448#define ACPI_GLUE ( 1 << 11)
449#define ACPI__10 ( 1 << 10) /* reserved */
450#define ACPI_PCIINT ( 1 << 9)
451#define ACPI_HV ( 1 << 8) /* hardware volume */
452#define ACPI_GPIO ( 1 << 7)
453#define ACPI_ASSP ( 1 << 6)
454#define ACPI_SB ( 1 << 5) /* sb emul */
455#define ACPI_FM ( 1 << 4) /* fm emul */
456#define ACPI_RB ( 1 << 3) /* ringbus / aclink */
457#define ACPI_MIDI ( 1 << 2)
458#define ACPI_GP ( 1 << 1) /* game port */
459#define ACPI_WP ( 1 << 0) /* wave processor */
460
461#define ACPI_ALL (0xffff)
462#define ACPI_SLEEP (~(ACPI_SPDIF|ACPI_ASSP|ACPI_SB|ACPI_FM| \
463 ACPI_MIDI|ACPI_GP|ACPI_WP))
464#define ACPI_NONE (ACPI__10)
465
466/* these masks indicate which units we care about at
467 which states */
468static u16 acpi_state_mask[] = {
469 [ACPI_D0] = ACPI_ALL,
470 [ACPI_D1] = ACPI_SLEEP,
471 [ACPI_D2] = ACPI_SLEEP,
472 [ACPI_D3] = ACPI_NONE
473};
474
475 435
476/* APU use in the driver */ 436/* APU use in the driver */
477enum snd_enum_apu_type { 437enum snd_enum_apu_type {
@@ -2160,21 +2120,6 @@ static void snd_es1968_reset(struct es1968 *chip)
2160} 2120}
2161 2121
2162/* 2122/*
2163 * power management
2164 */
2165static void snd_es1968_set_acpi(struct es1968 *chip, int state)
2166{
2167 u16 active_mask = acpi_state_mask[state];
2168
2169 pci_set_power_state(chip->pci, state);
2170 /* make sure the units we care about are on
2171 XXX we might want to do this before state flipping? */
2172 pci_write_config_word(chip->pci, 0x54, ~ active_mask);
2173 pci_write_config_word(chip->pci, 0x56, ~ active_mask);
2174}
2175
2176
2177/*
2178 * initialize maestro chip 2123 * initialize maestro chip
2179 */ 2124 */
2180static void snd_es1968_chip_init(struct es1968 *chip) 2125static void snd_es1968_chip_init(struct es1968 *chip)
@@ -2196,9 +2141,6 @@ static void snd_es1968_chip_init(struct es1968 *chip)
2196 * IRQs. 2141 * IRQs.
2197 */ 2142 */
2198 2143
2199 /* do config work at full power */
2200 snd_es1968_set_acpi(chip, ACPI_D0);
2201
2202 /* Config Reg A */ 2144 /* Config Reg A */
2203 pci_read_config_word(pci, ESM_CONFIG_A, &w); 2145 pci_read_config_word(pci, ESM_CONFIG_A, &w);
2204 2146
@@ -2397,9 +2339,10 @@ static int es1968_suspend(struct pci_dev *pci, pm_message_t state)
2397 snd_pcm_suspend_all(chip->pcm); 2339 snd_pcm_suspend_all(chip->pcm);
2398 snd_ac97_suspend(chip->ac97); 2340 snd_ac97_suspend(chip->ac97);
2399 snd_es1968_bob_stop(chip); 2341 snd_es1968_bob_stop(chip);
2400 snd_es1968_set_acpi(chip, ACPI_D3); 2342
2401 pci_disable_device(pci); 2343 pci_disable_device(pci);
2402 pci_save_state(pci); 2344 pci_save_state(pci);
2345 pci_set_power_state(pci, pci_choose_state(pci, state));
2403 return 0; 2346 return 0;
2404} 2347}
2405 2348
@@ -2413,9 +2356,16 @@ static int es1968_resume(struct pci_dev *pci)
2413 return 0; 2356 return 0;
2414 2357
2415 /* restore all our config */ 2358 /* restore all our config */
2359 pci_set_power_state(pci, PCI_D0);
2416 pci_restore_state(pci); 2360 pci_restore_state(pci);
2417 pci_enable_device(pci); 2361 if (pci_enable_device(pci) < 0) {
2362 printk(KERN_ERR "es1968: pci_enable_device failed, "
2363 "disabling device\n");
2364 snd_card_disconnect(card);
2365 return -EIO;
2366 }
2418 pci_set_master(pci); 2367 pci_set_master(pci);
2368
2419 snd_es1968_chip_init(chip); 2369 snd_es1968_chip_init(chip);
2420 2370
2421 /* need to restore the base pointers.. */ 2371 /* need to restore the base pointers.. */
@@ -2514,7 +2464,6 @@ static int snd_es1968_free(struct es1968 *chip)
2514 if (chip->irq >= 0) 2464 if (chip->irq >= 0)
2515 free_irq(chip->irq, (void *)chip); 2465 free_irq(chip->irq, (void *)chip);
2516 snd_es1968_free_gameport(chip); 2466 snd_es1968_free_gameport(chip);
2517 snd_es1968_set_acpi(chip, ACPI_D3);
2518 chip->master_switch = NULL; 2467 chip->master_switch = NULL;
2519 chip->master_volume = NULL; 2468 chip->master_volume = NULL;
2520 pci_release_regions(chip->pci); 2469 pci_release_regions(chip->pci);
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 3ec7d7ee04dd..77e3d5c18302 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1531,9 +1531,9 @@ static int snd_fm801_suspend(struct pci_dev *pci, pm_message_t state)
1531 chip->saved_regs[i] = inw(chip->port + saved_regs[i]); 1531 chip->saved_regs[i] = inw(chip->port + saved_regs[i]);
1532 /* FIXME: tea575x suspend */ 1532 /* FIXME: tea575x suspend */
1533 1533
1534 pci_set_power_state(pci, PCI_D3hot);
1535 pci_disable_device(pci); 1534 pci_disable_device(pci);
1536 pci_save_state(pci); 1535 pci_save_state(pci);
1536 pci_set_power_state(pci, pci_choose_state(pci, state));
1537 return 0; 1537 return 0;
1538} 1538}
1539 1539
@@ -1543,9 +1543,14 @@ static int snd_fm801_resume(struct pci_dev *pci)
1543 struct fm801 *chip = card->private_data; 1543 struct fm801 *chip = card->private_data;
1544 int i; 1544 int i;
1545 1545
1546 pci_restore_state(pci);
1547 pci_enable_device(pci);
1548 pci_set_power_state(pci, PCI_D0); 1546 pci_set_power_state(pci, PCI_D0);
1547 pci_restore_state(pci);
1548 if (pci_enable_device(pci) < 0) {
1549 printk(KERN_ERR "fm801: pci_enable_device failed, "
1550 "disabling device\n");
1551 snd_card_disconnect(card);
1552 return -EIO;
1553 }
1549 pci_set_master(pci); 1554 pci_set_master(pci);
1550 1555
1551 snd_fm801_chip_init(chip, 1); 1556 snd_fm801_chip_init(chip, 1);
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index feeed12920b4..7c96361b95e3 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1379,12 +1379,16 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1379 snd_pcm_suspend_all(chip->pcm[i]); 1379 snd_pcm_suspend_all(chip->pcm[i]);
1380 snd_hda_suspend(chip->bus, state); 1380 snd_hda_suspend(chip->bus, state);
1381 azx_free_cmd_io(chip); 1381 azx_free_cmd_io(chip);
1382 if (chip->irq >= 0) 1382 if (chip->irq >= 0) {
1383 synchronize_irq(chip->irq);
1383 free_irq(chip->irq, chip); 1384 free_irq(chip->irq, chip);
1385 chip->irq = -1;
1386 }
1384 if (!disable_msi) 1387 if (!disable_msi)
1385 pci_disable_msi(chip->pci); 1388 pci_disable_msi(chip->pci);
1386 pci_disable_device(pci); 1389 pci_disable_device(pci);
1387 pci_save_state(pci); 1390 pci_save_state(pci);
1391 pci_set_power_state(pci, pci_choose_state(pci, state));
1388 return 0; 1392 return 0;
1389} 1393}
1390 1394
@@ -1393,15 +1397,25 @@ static int azx_resume(struct pci_dev *pci)
1393 struct snd_card *card = pci_get_drvdata(pci); 1397 struct snd_card *card = pci_get_drvdata(pci);
1394 struct azx *chip = card->private_data; 1398 struct azx *chip = card->private_data;
1395 1399
1400 pci_set_power_state(pci, PCI_D0);
1396 pci_restore_state(pci); 1401 pci_restore_state(pci);
1397 pci_enable_device(pci); 1402 if (pci_enable_device(pci) < 0) {
1403 printk(KERN_ERR "hda-intel: pci_enable_device failed, "
1404 "disabling device\n");
1405 snd_card_disconnect(card);
1406 return -EIO;
1407 }
1408 pci_set_master(pci);
1398 if (!disable_msi) 1409 if (!disable_msi)
1399 pci_enable_msi(pci); 1410 pci_enable_msi(pci);
1400 /* FIXME: need proper error handling */ 1411 if (request_irq(pci->irq, azx_interrupt, IRQF_DISABLED|IRQF_SHARED,
1401 request_irq(pci->irq, azx_interrupt, IRQF_DISABLED|IRQF_SHARED, 1412 "HDA Intel", chip)) {
1402 "HDA Intel", chip); 1413 printk(KERN_ERR "hda-intel: unable to grab IRQ %d, "
1414 "disabling device\n", pci->irq);
1415 snd_card_disconnect(card);
1416 return -EIO;
1417 }
1403 chip->irq = pci->irq; 1418 chip->irq = pci->irq;
1404 pci_set_master(pci);
1405 azx_init_chip(chip); 1419 azx_init_chip(chip);
1406 snd_hda_resume(chip->bus); 1420 snd_hda_resume(chip->bus);
1407 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 1421 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
@@ -1431,15 +1445,14 @@ static int azx_free(struct azx *chip)
1431 /* disable position buffer */ 1445 /* disable position buffer */
1432 azx_writel(chip, DPLBASE, 0); 1446 azx_writel(chip, DPLBASE, 0);
1433 azx_writel(chip, DPUBASE, 0); 1447 azx_writel(chip, DPUBASE, 0);
1434
1435 synchronize_irq(chip->irq);
1436 } 1448 }
1437 1449
1438 if (chip->irq >= 0) { 1450 if (chip->irq >= 0) {
1451 synchronize_irq(chip->irq);
1439 free_irq(chip->irq, (void*)chip); 1452 free_irq(chip->irq, (void*)chip);
1440 if (!disable_msi)
1441 pci_disable_msi(chip->pci);
1442 } 1453 }
1454 if (!disable_msi)
1455 pci_disable_msi(chip->pci);
1443 if (chip->remap_addr) 1456 if (chip->remap_addr)
1444 iounmap(chip->remap_addr); 1457 iounmap(chip->remap_addr);
1445 1458
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index f4319b8d4644..7f22dab07240 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2476,10 +2476,14 @@ static int intel8x0_suspend(struct pci_dev *pci, pm_message_t state)
2476 if (chip->device_type == DEVICE_INTEL_ICH4) 2476 if (chip->device_type == DEVICE_INTEL_ICH4)
2477 chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); 2477 chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
2478 2478
2479 if (chip->irq >= 0) 2479 if (chip->irq >= 0) {
2480 synchronize_irq(chip->irq);
2480 free_irq(chip->irq, chip); 2481 free_irq(chip->irq, chip);
2482 chip->irq = -1;
2483 }
2481 pci_disable_device(pci); 2484 pci_disable_device(pci);
2482 pci_save_state(pci); 2485 pci_save_state(pci);
2486 pci_set_power_state(pci, pci_choose_state(pci, state));
2483 return 0; 2487 return 0;
2484} 2488}
2485 2489
@@ -2489,11 +2493,22 @@ static int intel8x0_resume(struct pci_dev *pci)
2489 struct intel8x0 *chip = card->private_data; 2493 struct intel8x0 *chip = card->private_data;
2490 int i; 2494 int i;
2491 2495
2496 pci_set_power_state(pci, PCI_D0);
2492 pci_restore_state(pci); 2497 pci_restore_state(pci);
2493 pci_enable_device(pci); 2498 if (pci_enable_device(pci) < 0) {
2499 printk(KERN_ERR "intel8x0: pci_enable_device failed, "
2500 "disabling device\n");
2501 snd_card_disconnect(card);
2502 return -EIO;
2503 }
2494 pci_set_master(pci); 2504 pci_set_master(pci);
2495 request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_DISABLED|IRQF_SHARED, 2505 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2496 card->shortname, chip); 2506 IRQF_DISABLED|IRQF_SHARED, card->shortname, chip)) {
2507 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
2508 "disabling device\n", pci->irq);
2509 snd_card_disconnect(card);
2510 return -EIO;
2511 }
2497 chip->irq = pci->irq; 2512 chip->irq = pci->irq;
2498 synchronize_irq(chip->irq); 2513 synchronize_irq(chip->irq);
2499 snd_intel8x0_chip_init(chip, 0); 2514 snd_intel8x0_chip_init(chip, 0);
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 6703f5cb5569..bd467c501123 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -1045,10 +1045,14 @@ static int intel8x0m_suspend(struct pci_dev *pci, pm_message_t state)
1045 for (i = 0; i < chip->pcm_devs; i++) 1045 for (i = 0; i < chip->pcm_devs; i++)
1046 snd_pcm_suspend_all(chip->pcm[i]); 1046 snd_pcm_suspend_all(chip->pcm[i]);
1047 snd_ac97_suspend(chip->ac97); 1047 snd_ac97_suspend(chip->ac97);
1048 if (chip->irq >= 0) 1048 if (chip->irq >= 0) {
1049 synchronize_irq(chip->irq);
1049 free_irq(chip->irq, chip); 1050 free_irq(chip->irq, chip);
1051 chip->irq = -1;
1052 }
1050 pci_disable_device(pci); 1053 pci_disable_device(pci);
1051 pci_save_state(pci); 1054 pci_save_state(pci);
1055 pci_set_power_state(pci, pci_choose_state(pci, state));
1052 return 0; 1056 return 0;
1053} 1057}
1054 1058
@@ -1057,11 +1061,22 @@ static int intel8x0m_resume(struct pci_dev *pci)
1057 struct snd_card *card = pci_get_drvdata(pci); 1061 struct snd_card *card = pci_get_drvdata(pci);
1058 struct intel8x0m *chip = card->private_data; 1062 struct intel8x0m *chip = card->private_data;
1059 1063
1064 pci_set_power_state(pci, PCI_D0);
1060 pci_restore_state(pci); 1065 pci_restore_state(pci);
1061 pci_enable_device(pci); 1066 if (pci_enable_device(pci) < 0) {
1067 printk(KERN_ERR "intel8x0m: pci_enable_device failed, "
1068 "disabling device\n");
1069 snd_card_disconnect(card);
1070 return -EIO;
1071 }
1062 pci_set_master(pci); 1072 pci_set_master(pci);
1063 request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_DISABLED|IRQF_SHARED, 1073 if (request_irq(pci->irq, snd_intel8x0_interrupt,
1064 card->shortname, chip); 1074 IRQF_DISABLED|IRQF_SHARED, card->shortname, chip)) {
1075 printk(KERN_ERR "intel8x0m: unable to grab IRQ %d, "
1076 "disabling device\n", pci->irq);
1077 snd_card_disconnect(card);
1078 return -EIO;
1079 }
1065 chip->irq = pci->irq; 1080 chip->irq = pci->irq;
1066 snd_intel8x0_chip_init(chip, 0); 1081 snd_intel8x0_chip_init(chip, 0);
1067 snd_ac97_resume(chip->ac97); 1082 snd_ac97_resume(chip->ac97);
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 05605f474a72..8cab342bbaaf 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2589,12 +2589,9 @@ static int m3_suspend(struct pci_dev *pci, pm_message_t state)
2589 chip->suspend_mem[index++] = 2589 chip->suspend_mem[index++] =
2590 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i); 2590 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i);
2591 2591
2592 /* power down apci registers */
2593 snd_m3_outw(chip, 0xffff, 0x54);
2594 snd_m3_outw(chip, 0xffff, 0x56);
2595
2596 pci_disable_device(pci); 2592 pci_disable_device(pci);
2597 pci_save_state(pci); 2593 pci_save_state(pci);
2594 pci_set_power_state(pci, pci_choose_state(pci, state));
2598 return 0; 2595 return 0;
2599} 2596}
2600 2597
@@ -2607,8 +2604,14 @@ static int m3_resume(struct pci_dev *pci)
2607 if (chip->suspend_mem == NULL) 2604 if (chip->suspend_mem == NULL)
2608 return 0; 2605 return 0;
2609 2606
2607 pci_set_power_state(pci, PCI_D0);
2610 pci_restore_state(pci); 2608 pci_restore_state(pci);
2611 pci_enable_device(pci); 2609 if (pci_enable_device(pci) < 0) {
2610 printk(KERN_ERR "maestor3: pci_enable_device failed, "
2611 "disabling device\n");
2612 snd_card_disconnect(card);
2613 return -EIO;
2614 }
2612 pci_set_master(pci); 2615 pci_set_master(pci);
2613 2616
2614 /* first lets just bring everything back. .*/ 2617 /* first lets just bring everything back. .*/
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index b1bbdb9e3b7b..945d21bf187e 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1390,6 +1390,7 @@ static int nm256_suspend(struct pci_dev *pci, pm_message_t state)
1390 chip->coeffs_current = 0; 1390 chip->coeffs_current = 0;
1391 pci_disable_device(pci); 1391 pci_disable_device(pci);
1392 pci_save_state(pci); 1392 pci_save_state(pci);
1393 pci_set_power_state(pci, pci_choose_state(pci, state));
1393 return 0; 1394 return 0;
1394} 1395}
1395 1396
@@ -1401,8 +1402,17 @@ static int nm256_resume(struct pci_dev *pci)
1401 1402
1402 /* Perform a full reset on the hardware */ 1403 /* Perform a full reset on the hardware */
1403 chip->in_resume = 1; 1404 chip->in_resume = 1;
1405
1406 pci_set_power_state(pci, PCI_D0);
1404 pci_restore_state(pci); 1407 pci_restore_state(pci);
1405 pci_enable_device(pci); 1408 if (pci_enable_device(pci) < 0) {
1409 printk(KERN_ERR "nm256: pci_enable_device failed, "
1410 "disabling device\n");
1411 snd_card_disconnect(card);
1412 return -EIO;
1413 }
1414 pci_set_master(pci);
1415
1406 snd_nm256_init_chip(chip); 1416 snd_nm256_init_chip(chip);
1407 1417
1408 /* restore ac97 */ 1418 /* restore ac97 */
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index ec4899147e1d..56e0c01123e7 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1178,9 +1178,9 @@ static int riptide_suspend(struct pci_dev *pci, pm_message_t state)
1178 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1178 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1179 snd_pcm_suspend_all(chip->pcm); 1179 snd_pcm_suspend_all(chip->pcm);
1180 snd_ac97_suspend(chip->ac97); 1180 snd_ac97_suspend(chip->ac97);
1181 pci_set_power_state(pci, PCI_D3hot);
1182 pci_disable_device(pci); 1181 pci_disable_device(pci);
1183 pci_save_state(pci); 1182 pci_save_state(pci);
1183 pci_set_power_state(pci, pci_choose_state(pci, state));
1184 return 0; 1184 return 0;
1185} 1185}
1186 1186
@@ -1189,9 +1189,14 @@ static int riptide_resume(struct pci_dev *pci)
1189 struct snd_card *card = pci_get_drvdata(pci); 1189 struct snd_card *card = pci_get_drvdata(pci);
1190 struct snd_riptide *chip = card->private_data; 1190 struct snd_riptide *chip = card->private_data;
1191 1191
1192 pci_restore_state(pci);
1193 pci_enable_device(pci);
1194 pci_set_power_state(pci, PCI_D0); 1192 pci_set_power_state(pci, PCI_D0);
1193 pci_restore_state(pci);
1194 if (pci_enable_device(pci) < 0) {
1195 printk(KERN_ERR "riptide: pci_enable_device failed, "
1196 "disabling device\n");
1197 snd_card_disconnect(card);
1198 return -EIO;
1199 }
1195 pci_set_master(pci); 1200 pci_set_master(pci);
1196 snd_riptide_initialize(chip); 1201 snd_riptide_initialize(chip);
1197 snd_ac97_resume(chip->ac97); 1202 snd_ac97_resume(chip->ac97);
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 0d478871808d..1fbc4321122f 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3966,15 +3966,9 @@ int snd_trident_suspend(struct pci_dev *pci, pm_message_t state)
3966 snd_ac97_suspend(trident->ac97); 3966 snd_ac97_suspend(trident->ac97);
3967 snd_ac97_suspend(trident->ac97_sec); 3967 snd_ac97_suspend(trident->ac97_sec);
3968 3968
3969 switch (trident->device) {
3970 case TRIDENT_DEVICE_ID_DX:
3971 case TRIDENT_DEVICE_ID_NX:
3972 break; /* TODO */
3973 case TRIDENT_DEVICE_ID_SI7018:
3974 break;
3975 }
3976 pci_disable_device(pci); 3969 pci_disable_device(pci);
3977 pci_save_state(pci); 3970 pci_save_state(pci);
3971 pci_set_power_state(pci, pci_choose_state(pci, state));
3978 return 0; 3972 return 0;
3979} 3973}
3980 3974
@@ -3983,9 +3977,15 @@ int snd_trident_resume(struct pci_dev *pci)
3983 struct snd_card *card = pci_get_drvdata(pci); 3977 struct snd_card *card = pci_get_drvdata(pci);
3984 struct snd_trident *trident = card->private_data; 3978 struct snd_trident *trident = card->private_data;
3985 3979
3980 pci_set_power_state(pci, PCI_D0);
3986 pci_restore_state(pci); 3981 pci_restore_state(pci);
3987 pci_enable_device(pci); 3982 if (pci_enable_device(pci) < 0) {
3988 pci_set_master(pci); /* to be sure */ 3983 printk(KERN_ERR "trident: pci_enable_device failed, "
3984 "disabling device\n");
3985 snd_card_disconnect(card);
3986 return -EIO;
3987 }
3988 pci_set_master(pci);
3989 3989
3990 switch (trident->device) { 3990 switch (trident->device) {
3991 case TRIDENT_DEVICE_ID_DX: 3991 case TRIDENT_DEVICE_ID_DX:
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index e6990e0bbf23..92b0736c0fdb 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2185,9 +2185,9 @@ static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state)
2185 chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); 2185 chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10);
2186 } 2186 }
2187 2187
2188 pci_set_power_state(pci, PCI_D3hot);
2189 pci_disable_device(pci); 2188 pci_disable_device(pci);
2190 pci_save_state(pci); 2189 pci_save_state(pci);
2190 pci_set_power_state(pci, pci_choose_state(pci, state));
2191 return 0; 2191 return 0;
2192} 2192}
2193 2193
@@ -2197,9 +2197,15 @@ static int snd_via82xx_resume(struct pci_dev *pci)
2197 struct via82xx *chip = card->private_data; 2197 struct via82xx *chip = card->private_data;
2198 int i; 2198 int i;
2199 2199
2200 pci_restore_state(pci);
2201 pci_enable_device(pci);
2202 pci_set_power_state(pci, PCI_D0); 2200 pci_set_power_state(pci, PCI_D0);
2201 pci_restore_state(pci);
2202 if (pci_enable_device(pci) < 0) {
2203 printk(KERN_ERR "via82xx: pci_enable_device failed, "
2204 "disabling device\n");
2205 snd_card_disconnect(card);
2206 return -EIO;
2207 }
2208 pci_set_master(pci);
2203 2209
2204 snd_via82xx_chip_init(chip); 2210 snd_via82xx_chip_init(chip);
2205 2211
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 5ab1cf3d434b..feb27c966256 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1032,9 +1032,10 @@ static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state)
1032 snd_via82xx_channel_reset(chip, &chip->devs[i]); 1032 snd_via82xx_channel_reset(chip, &chip->devs[i]);
1033 synchronize_irq(chip->irq); 1033 synchronize_irq(chip->irq);
1034 snd_ac97_suspend(chip->ac97); 1034 snd_ac97_suspend(chip->ac97);
1035 pci_set_power_state(pci, PCI_D3hot); 1035
1036 pci_disable_device(pci); 1036 pci_disable_device(pci);
1037 pci_save_state(pci); 1037 pci_save_state(pci);
1038 pci_set_power_state(pci, pci_choose_state(pci, state));
1038 return 0; 1039 return 0;
1039} 1040}
1040 1041
@@ -1044,9 +1045,14 @@ static int snd_via82xx_resume(struct pci_dev *pci)
1044 struct via82xx_modem *chip = card->private_data; 1045 struct via82xx_modem *chip = card->private_data;
1045 int i; 1046 int i;
1046 1047
1047 pci_restore_state(pci);
1048 pci_enable_device(pci);
1049 pci_set_power_state(pci, PCI_D0); 1048 pci_set_power_state(pci, PCI_D0);
1049 pci_restore_state(pci);
1050 if (pci_enable_device(pci) < 0) {
1051 printk(KERN_ERR "via82xx-modem: pci_enable_device failed, "
1052 "disabling device\n");
1053 snd_card_disconnect(card);
1054 return -EIO;
1055 }
1050 pci_set_master(pci); 1056 pci_set_master(pci);
1051 1057
1052 snd_via82xx_chip_init(chip); 1058 snd_via82xx_chip_init(chip);
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index e7cd8acab59a..af49e8aabf55 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -266,9 +266,9 @@ static int snd_vx222_suspend(struct pci_dev *pci, pm_message_t state)
266 int err; 266 int err;
267 267
268 err = snd_vx_suspend(&vx->core, state); 268 err = snd_vx_suspend(&vx->core, state);
269 pci_set_power_state(pci, PCI_D3hot);
270 pci_disable_device(pci); 269 pci_disable_device(pci);
271 pci_save_state(pci); 270 pci_save_state(pci);
271 pci_set_power_state(pci, pci_choose_state(pci, state));
272 return err; 272 return err;
273} 273}
274 274
@@ -277,9 +277,14 @@ static int snd_vx222_resume(struct pci_dev *pci)
277 struct snd_card *card = pci_get_drvdata(pci); 277 struct snd_card *card = pci_get_drvdata(pci);
278 struct snd_vx222 *vx = card->private_data; 278 struct snd_vx222 *vx = card->private_data;
279 279
280 pci_restore_state(pci);
281 pci_enable_device(pci);
282 pci_set_power_state(pci, PCI_D0); 280 pci_set_power_state(pci, PCI_D0);
281 pci_restore_state(pci);
282 if (pci_enable_device(pci) < 0) {
283 printk(KERN_ERR "vx222: pci_enable_device failed, "
284 "disabling device\n");
285 snd_card_disconnect(card);
286 return -EIO;
287 }
283 pci_set_master(pci); 288 pci_set_master(pci);
284 return snd_vx_resume(&vx->core); 289 return snd_vx_resume(&vx->core);
285} 290}
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index ebc6da89edf3..a40c1085fd20 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -2218,6 +2218,7 @@ int snd_ymfpci_suspend(struct pci_dev *pci, pm_message_t state)
2218 snd_ymfpci_disable_dsp(chip); 2218 snd_ymfpci_disable_dsp(chip);
2219 pci_disable_device(pci); 2219 pci_disable_device(pci);
2220 pci_save_state(pci); 2220 pci_save_state(pci);
2221 pci_set_power_state(pci, pci_choose_state(pci, state));
2221 return 0; 2222 return 0;
2222} 2223}
2223 2224
@@ -2227,8 +2228,14 @@ int snd_ymfpci_resume(struct pci_dev *pci)
2227 struct snd_ymfpci *chip = card->private_data; 2228 struct snd_ymfpci *chip = card->private_data;
2228 unsigned int i; 2229 unsigned int i;
2229 2230
2231 pci_set_power_state(pci, PCI_D0);
2230 pci_restore_state(pci); 2232 pci_restore_state(pci);
2231 pci_enable_device(pci); 2233 if (pci_enable_device(pci) < 0) {
2234 printk(KERN_ERR "ymfpci: pci_enable_device failed, "
2235 "disabling device\n");
2236 snd_card_disconnect(card);
2237 return -EIO;
2238 }
2232 pci_set_master(pci); 2239 pci_set_master(pci);
2233 snd_ymfpci_aclink_reset(pci); 2240 snd_ymfpci_aclink_reset(pci);
2234 snd_ymfpci_codec_ready(chip, 0); 2241 snd_ymfpci_codec_ready(chip, 0);