Update of /cvsroot/alsa/alsa-kernel/pci/trident In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19034/pci/trident
Modified Files: trident.c trident_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: trident.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/trident/trident.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- trident.c 7 Apr 2004 17:48:21 -0000 1.22 +++ trident.c 8 Apr 2004 16:35:00 -0000 1.23 @@ -170,43 +170,23 @@ snd_card_free(card); return err; } - pci_set_drvdata(pci, trident); + pci_set_drvdata(pci, card); dev++; return 0; } static void __devexit snd_trident_remove(struct pci_dev *pci) { - trident_t *trident = snd_magic_cast(trident_t, pci_get_drvdata(pci), return); - if (trident) - snd_card_free(trident->card); + snd_card_free(pci_get_drvdata(pci)); pci_set_drvdata(pci, NULL); } -#ifdef CONFIG_PM -static int snd_card_trident_suspend(struct pci_dev *pci, u32 state) -{ - trident_t *chip = snd_magic_cast(trident_t, pci_get_drvdata(pci), return -ENXIO); - snd_trident_suspend(chip); - return 0; -} -static int snd_card_trident_resume(struct pci_dev *pci) -{ - trident_t *chip = snd_magic_cast(trident_t, pci_get_drvdata(pci), return -ENXIO); - snd_trident_resume(chip); - return 0; -} -#endif - static struct pci_driver driver = { .name = "Trident4DWaveAudio", .id_table = snd_trident_ids, .probe = snd_trident_probe, .remove = __devexit_p(snd_trident_remove), -#ifdef CONFIG_PM - .suspend = snd_card_trident_suspend, - .resume = snd_card_trident_resume, -#endif + SND_PCI_PM_CALLBACKS }; static int __init alsa_card_trident_init(void) Index: trident_main.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/trident/trident_main.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- trident_main.c 6 Mar 2004 16:51:31 -0000 1.55 +++ trident_main.c 8 Apr 2004 16:35:00 -0000 1.56 @@ -50,7 +50,8 @@ static int snd_trident_pcm_mixer_free(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream); static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs); #ifdef CONFIG_PM -static int snd_trident_set_power_state(snd_card_t *card, unsigned int power_state); +static int snd_trident_suspend(snd_card_t *card, unsigned int state); +static int snd_trident_resume(snd_card_t *card, unsigned int state); #endif static int snd_trident_sis_reset(trident_t *trident); @@ -3646,10 +3647,8 @@ snd_trident_enable_eso(trident); -#ifdef CONFIG_PM - card->set_power_state = snd_trident_set_power_state; - card->power_state_private_data = trident; -#endif + + snd_card_set_pm_callback(card, snd_trident_suspend, snd_trident_resume, trident); snd_trident_proc_init(trident); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops)) < 0) { @@ -3949,13 +3948,10 @@ } #ifdef CONFIG_PM - -void snd_trident_suspend(trident_t *trident) +static int snd_trident_suspend(snd_card_t *card, unsigned int state) { - snd_card_t *card = trident->card; + trident_t *trident = snd_magic_cast(trident_t, card->pm_private_data, return -EINVAL); - if (card->power_state == SNDRV_CTL_POWER_D3hot) - return; trident->in_suspend = 1; snd_pcm_suspend_all(trident->pcm); if (trident->foldback) @@ -3970,14 +3966,12 @@ break; } snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + return 0; } -void snd_trident_resume(trident_t *trident) +static int snd_trident_resume(snd_card_t *card, unsigned int state) { - snd_card_t *card = trident->card; - - if (card->power_state == SNDRV_CTL_POWER_D0) - return; + trident_t *trident = snd_magic_cast(trident_t, card->pm_private_data, return -EINVAL); pci_enable_device(trident->pci); if (pci_set_dma_mask(trident->pci, 0x3fffffff) < 0 || @@ -4006,28 +4000,8 @@ snd_power_change_state(card, SNDRV_CTL_POWER_D0); trident->in_suspend = 0; + return 0; } - -static int snd_trident_set_power_state(snd_card_t *card, unsigned int power_state) -{ - trident_t *chip = snd_magic_cast(trident_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_trident_resume(chip); - break; - case SNDRV_CTL_POWER_D3hot: - case SNDRV_CTL_POWER_D3cold: - snd_trident_suspend(chip); - break; - default: - return -EINVAL; - } - return 0; -} - #endif /* CONFIG_PM */ EXPORT_SYMBOL(snd_trident_alloc_voice); ------------------------------------------------------- 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