Update of /cvsroot/alsa/alsa-kernel/pci/ymfpci
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19034/pci/ymfpci

Modified Files:
        ymfpci.c ymfpci_main.c 
Log Message:
Clean up of power-management codes.

- moved commonly used codes to the core layer.
- using the unified suspend/resume callbacks for PCI and ISA
- added snd_card_set_pm_callbacks() and snd_card_set_isa_pm_callbacks()
  as the registration functions.


Index: ymfpci.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ymfpci/ymfpci.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- ymfpci.c    7 Apr 2004 17:48:21 -0000       1.34
+++ ymfpci.c    8 Apr 2004 16:35:00 -0000       1.35
@@ -312,31 +312,14 @@
                snd_card_free(card);
                return err;
        }
-       pci_set_drvdata(pci, chip);
+       pci_set_drvdata(pci, card);
        dev++;
        return 0;
 }
 
-#ifdef CONFIG_PM
-static int snd_card_ymfpci_suspend(struct pci_dev *pci, u32 state)
-{
-       ymfpci_t *chip = snd_magic_cast(ymfpci_t, pci_get_drvdata(pci), return -ENXIO);
-       snd_ymfpci_suspend(chip);
-       return 0;
-}
-static int snd_card_ymfpci_resume(struct pci_dev *pci)
-{
-       ymfpci_t *chip = snd_magic_cast(ymfpci_t, pci_get_drvdata(pci), return -ENXIO);
-       snd_ymfpci_resume(chip);
-       return 0;
-}
-#endif
-
 static void __devexit snd_card_ymfpci_remove(struct pci_dev *pci)
 {
-       ymfpci_t *chip = snd_magic_cast(ymfpci_t, pci_get_drvdata(pci), return);
-       if (chip)
-               snd_card_free(chip->card);
+       snd_card_free(pci_get_drvdata(pci));
        pci_set_drvdata(pci, NULL);
 }
 
@@ -345,10 +328,7 @@
        .id_table = snd_ymfpci_ids,
        .probe = snd_card_ymfpci_probe,
        .remove = __devexit_p(snd_card_ymfpci_remove),
-#ifdef CONFIG_PM
-       .suspend = snd_card_ymfpci_suspend,
-       .resume = snd_card_ymfpci_resume,
-#endif 
+       SND_PCI_PM_CALLBACKS
 };
 
 static int __init alsa_card_ymfpci_init(void)

Index: ymfpci_main.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ymfpci/ymfpci_main.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- ymfpci_main.c       6 Mar 2004 16:51:31 -0000       1.49
+++ ymfpci_main.c       8 Apr 2004 16:35:00 -0000       1.50
@@ -2157,13 +2157,11 @@
 };
 #define YDSXGR_NUM_SAVED_REGS  ARRAY_SIZE(saved_regs_index)
 
-void snd_ymfpci_suspend(ymfpci_t *chip)
+static int snd_ymfpci_suspend(snd_card_t *card, unsigned int state)
 {
-       snd_card_t *card = chip->card;
+       ymfpci_t *chip = snd_magic_cast(ymfpci_t, card->pm_private_data, return 
-EINVAL);
        unsigned int i;
        
-       if (card->power_state == SNDRV_CTL_POWER_D3hot)
-               return;
        snd_pcm_suspend_all(chip->pcm);
        snd_pcm_suspend_all(chip->pcm2);
        snd_pcm_suspend_all(chip->pcm_spdif);
@@ -2174,16 +2172,14 @@
        snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);
        snd_ymfpci_disable_dsp(chip);
        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+       return 0;
 }
 
-void snd_ymfpci_resume(ymfpci_t *chip)
+static int snd_ymfpci_resume(snd_card_t *card, unsigned int state)
 {
-       snd_card_t *card = chip->card;
+       ymfpci_t *chip = snd_magic_cast(ymfpci_t, card->pm_private_data, return 
-EINVAL);
        unsigned int i;
 
-       if (card->power_state == SNDRV_CTL_POWER_D0)
-               return;
-
        pci_enable_device(chip->pci);
        pci_set_master(chip->pci);
        snd_ymfpci_aclink_reset(chip->pci);
@@ -2205,25 +2201,6 @@
                spin_unlock_irqrestore(&chip->reg_lock, flags);
        }
        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
-}
-
-static int snd_ymfpci_set_power_state(snd_card_t *card, unsigned int power_state)
-{
-       ymfpci_t *chip = snd_magic_cast(ymfpci_t, card->power_state_private_data, 
return -ENXIO);
-
-       switch (power_state) {
-       case SNDRV_CTL_POWER_D0:
-       case SNDRV_CTL_POWER_D1:
-       case SNDRV_CTL_POWER_D2:
-               snd_ymfpci_resume(chip);
-               break;
-       case SNDRV_CTL_POWER_D3hot:
-       case SNDRV_CTL_POWER_D3cold:
-               snd_ymfpci_suspend(chip);
-               break;
-       default:
-               return -EINVAL;
-       }
        return 0;
 }
 #endif /* CONFIG_PM */
@@ -2304,8 +2281,7 @@
                snd_ymfpci_free(chip);
                return -ENOMEM;
        }
-       card->set_power_state = snd_ymfpci_set_power_state;
-       card->power_state_private_data = chip;
+       snd_card_set_pm_callback(card, snd_ymfpci_suspend, snd_ymfpci_resume, chip);
 #endif
 
        snd_ymfpci_proc_init(card, chip);



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to