]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/cs5535audio/cs5535audio_pm.c
[NETNS]: Correctly fill fib_config data.
[linux-2.6-omap-h63xx.git] / sound / pci / cs5535audio / cs5535audio_pm.c
index aad0e69db9c1aed2d2cb40051957d1e01e0f6776..838708f6d45e45db3416ce6cf17429d50f1181c0 100644 (file)
@@ -64,18 +64,22 @@ int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state)
        int i;
 
        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+       snd_pcm_suspend_all(cs5535au->pcm);
+       snd_ac97_suspend(cs5535au->ac97);
        for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) {
                struct cs5535audio_dma *dma = &cs5535au->dmas[i];
-               if (dma && dma->substream && !dma->suspended) 
+               if (dma && dma->substream)
                        dma->saved_prd = dma->ops->read_prd(cs5535au);
        }
-       snd_pcm_suspend_all(cs5535au->pcm);
-       snd_ac97_suspend(cs5535au->ac97);
        /* save important regs, then disable aclink in hw */
        snd_cs5535audio_stop_hardware(cs5535au);
-       pci_disable_device(pci);
-       pci_save_state(pci);
 
+       if (pci_save_state(pci)) {
+               printk(KERN_ERR "cs5535audio: pci_save_state failed!\n");
+               return -EIO;
+       }
+       pci_disable_device(pci);
+       pci_set_power_state(pci, pci_choose_state(pci, state));
        return 0;
 }
 
@@ -87,8 +91,19 @@ int snd_cs5535audio_resume(struct pci_dev *pci)
        int timeout;
        int i;
 
-       pci_restore_state(pci);
-       pci_enable_device(pci);
+       pci_set_power_state(pci, PCI_D0);
+       if (pci_restore_state(pci) < 0) {
+               printk(KERN_ERR "cs5535audio: pci_restore_state failed, "
+                      "disabling device\n");
+               snd_card_disconnect(card);
+               return -EIO;
+       }
+       if (pci_enable_device(pci) < 0) {
+               printk(KERN_ERR "cs5535audio: pci_enable_device failed, "
+                      "disabling device\n");
+               snd_card_disconnect(card);
+               return -EIO;
+       }
        pci_set_master(pci);
 
        /* set LNK_WRM_RST to reset AC link */
@@ -105,17 +120,17 @@ int snd_cs5535audio_resume(struct pci_dev *pci)
        if (!timeout)
                snd_printk(KERN_ERR "Failure getting AC Link ready\n");
 
-       /* we depend on ac97 to perform the codec power up */
-       snd_ac97_resume(cs5535au->ac97);
        /* set up rate regs, dma. actual initiation is done in trig */
        for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) {
                struct cs5535audio_dma *dma = &cs5535au->dmas[i];
-               if (dma && dma->substream && dma->suspended) {
+               if (dma && dma->substream) {
                        dma->substream->ops->prepare(dma->substream);
                        dma->ops->setup_prd(cs5535au, dma->saved_prd);
                }
        }
-               
+
+       /* we depend on ac97 to perform the codec power up */
+       snd_ac97_resume(cs5535au->ac97);
        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 
        return 0;