diff options
author | Jaroslav Kysela <perex@suse.cz> | 2004-11-29 11:10:14 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2004-11-29 11:10:14 +0100 |
commit | f99f253c3f524592224f85303da729db4bde0107 (patch) | |
tree | 08739870c0a53d3e9761e7e38574d7ab05092e82 /sound | |
parent | 9853138610a1469cdb404270dc5fa0e2bb96223c (diff) | |
download | history-f99f253c3f524592224f85303da729db4bde0107.tar.gz |
[ALSA] Add pci_disable_device() to removal and error paths
ALS4000 driver,ATIIXP driver,ATIIXP-modem driver,AZT3328 driver
BT87x driver,CMIPCI driver,CS4281 driver,ENS1370/1+ driver
ES1938 driver,ES1968 driver,FM801 driver,Intel8x0 driver
Intel8x0-modem driver,Maestro3 driver,RME32 driver,RME96 driver
SonicVibes driver,VIA82xx driver,ALI5451 driver,CS46xx driver
EMU10K1/EMU10K2 driver,ICE1712 driver,ICE1724 driver,KORG1212 driver
MIXART driver,NM256 driver,RME HDSP driver,RME9652 driver
Trident driver,Digigram VX222 driver,YMFPCI driver
pci_disable_device() is called properly in the removal and error
paths. Also, the pci_set_master() is added to the resume callbacks if
missing (just to be sure).
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
31 files changed, 181 insertions, 33 deletions
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index ee3c6b5d04eff6..f186ac70959a2a 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1932,6 +1932,7 @@ static int ali_suspend(snd_card_t *card, unsigned int state) outl(0xffffffff, ALI_REG(chip, ALI_STOP)); spin_unlock_irq(&chip->reg_lock); + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -1986,6 +1987,7 @@ static int snd_ali_free(ali_t * codec) } if (codec->port) pci_release_regions(codec->pci); + pci_disable_device(codec->pci); #ifdef CONFIG_PM if (codec->image) kfree(codec->image); @@ -2093,11 +2095,14 @@ static int __devinit snd_ali_create(snd_card_t * card, if (pci_set_dma_mask(pci, 0x7fffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x7fffffff) < 0) { snd_printk("architecture does not support 31bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } - if ((codec = kcalloc(1, sizeof(*codec), GFP_KERNEL)) == NULL) + if ((codec = kcalloc(1, sizeof(*codec), GFP_KERNEL)) == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&codec->reg_lock); spin_lock_init(&codec->voice_alloc); diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 992c97320f695e..7be0f0d6d06898 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -582,6 +582,7 @@ static void snd_card_als4000_free( snd_card_t *card ) } #endif pci_release_regions(acard->pci); + pci_disable_device(acard->pci); } static int __devinit snd_card_als4000_probe(struct pci_dev *pci, @@ -612,11 +613,14 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci, if (pci_set_dma_mask(pci, 0x00ffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) { snd_printk("architecture does not support 24bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } - if ((err = pci_request_regions(pci, "ALS4000")) < 0) + if ((err = pci_request_regions(pci, "ALS4000")) < 0) { + pci_disable_device(pci); return err; + } gcr = pci_resource_start(pci, 0); pci_read_config_word(pci, PCI_COMMAND, &word); @@ -627,6 +631,7 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci, sizeof( snd_card_als4000_t ) ); if (card == NULL) { pci_release_regions(pci); + pci_disable_device(pci); return -ENOMEM; } diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 6129fa79c4bbb0..36010940e1d1cc 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1420,6 +1420,7 @@ static int snd_atiixp_resume(snd_card_t *card, unsigned int state) pci_enable_device(chip->pci); pci_set_power_state(chip->pci, 0); + pci_set_master(chip->pci); snd_atiixp_aclink_reset(chip); snd_atiixp_chip_start(chip); @@ -1473,6 +1474,7 @@ static int snd_atiixp_free(atiixp_t *chip) if (chip->remap_addr) iounmap(chip->remap_addr); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -1500,8 +1502,10 @@ static int __devinit snd_atiixp_create(snd_card_t *card, return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->ac97_lock); @@ -1510,6 +1514,7 @@ static int __devinit snd_atiixp_create(snd_card_t *card, chip->pci = pci; chip->irq = -1; if ((err = pci_request_regions(pci, "ATI IXP AC97")) < 0) { + pci_disable_device(pci); kfree(chip); return err; } diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index da18e00bd8879b..e1ed2e3a87fbab 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1142,6 +1142,7 @@ static int snd_atiixp_resume(snd_card_t *card, unsigned int state) pci_enable_device(chip->pci); pci_set_power_state(chip->pci, 0); + pci_set_master(chip->pci); snd_atiixp_aclink_reset(chip); snd_atiixp_chip_start(chip); @@ -1195,6 +1196,7 @@ static int snd_atiixp_free(atiixp_t *chip) if (chip->remap_addr) iounmap(chip->remap_addr); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -1222,8 +1224,10 @@ static int __devinit snd_atiixp_create(snd_card_t *card, return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->ac97_lock); @@ -1233,6 +1237,7 @@ static int __devinit snd_atiixp_create(snd_card_t *card, chip->irq = -1; if ((err = pci_request_regions(pci, "ATI IXP MC97")) < 0) { kfree(chip); + pci_disable_device(pci); return err; } chip->addr = pci_resource_start(pci, 0); diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index bc7c0346cc9f93..02c835a31604aa 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1268,6 +1268,7 @@ static int snd_azf3328_free(azf3328_t *chip) if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; @@ -1317,8 +1318,10 @@ static int __devinit snd_azf3328_create(snd_card_t * card, return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); chip->card = card; chip->pci = pci; @@ -1328,11 +1331,13 @@ static int __devinit snd_azf3328_create(snd_card_t * card, if (pci_set_dma_mask(pci, 0x00ffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) { snd_printk("architecture does not support 24bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } if ((err = pci_request_regions(pci, "Aztech AZF3328")) < 0) { kfree(chip); + pci_disable_device(pci); return err; } diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index e2fd248a0dcb37..a850d709a11eca 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -675,6 +675,7 @@ static int snd_bt87x_free(bt87x_t *chip) if (chip->irq >= 0) free_irq(chip->irq, chip); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -720,8 +721,10 @@ static int __devinit snd_bt87x_create(snd_card_t *card, return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (!chip) + if (!chip) { + pci_disable_device(pci); return -ENOMEM; + } chip->card = card; chip->pci = pci; chip->irq = -1; @@ -729,6 +732,7 @@ static int __devinit snd_bt87x_create(snd_card_t *card, if ((err = pci_request_regions(pci, "Bt87x audio")) < 0) { kfree(chip); + pci_disable_device(pci); return err; } chip->mmio = ioremap_nocache(pci_resource_start(pci, 0), diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index f40f9b931c70d3..b30bdd3a38762e 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2550,6 +2550,7 @@ static int snd_cmipci_free(cmipci_t *cm) } #endif pci_release_regions(cm->pci); + pci_disable_device(cm->pci); kfree(cm); return 0; } @@ -2579,8 +2580,10 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, return err; cm = kcalloc(1, sizeof(*cm), GFP_KERNEL); - if (cm == NULL) + if (cm == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&cm->reg_lock); init_MUTEX(&cm->open_mutex); @@ -2594,6 +2597,7 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, if ((err = pci_request_regions(pci, card->driver)) < 0) { kfree(cm); + pci_disable_device(pci); return err; } cm->iobase = pci_resource_start(pci, 0); diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index c2d4a6a92659a1..d1ac0dd2814f13 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1362,6 +1362,7 @@ static int snd_cs4281_free(cs4281_t *chip) if (chip->ba1) iounmap(chip->ba1); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; @@ -1395,8 +1396,10 @@ static int __devinit snd_cs4281_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); chip->card = card; chip->pci = pci; @@ -1410,6 +1413,7 @@ static int __devinit snd_cs4281_create(snd_card_t * card, if ((err = pci_request_regions(pci, "CS4281")) < 0) { kfree(chip); + pci_disable_device(pci); return err; } chip->ba0_addr = pci_resource_start(pci, 0); @@ -2074,6 +2078,7 @@ static int cs4281_suspend(snd_card_t *card, unsigned int state) ulCLK &= ~CLKCR1_CKRA; snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK); + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -2085,6 +2090,7 @@ static int cs4281_resume(snd_card_t *card, unsigned int state) u32 ulCLK; pci_enable_device(chip->pci); + pci_set_master(chip->pci); ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); ulCLK |= CLKCR1_CKRA; diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 296e0650ffae6e..565c45b5a0e278 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -2885,6 +2885,7 @@ static int snd_cs46xx_free(cs46xx_t *chip) } #endif + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -3678,6 +3679,7 @@ static int snd_cs46xx_suspend(snd_card_t *card, unsigned int state) /* disable CLKRUN */ chip->active_ctrl(chip, -chip->amplifier); chip->amplifier = amp_saved; /* restore the status */ + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -3688,6 +3690,7 @@ static int snd_cs46xx_resume(snd_card_t *card, unsigned int state) int amp_saved; pci_enable_device(chip->pci); + pci_set_master(chip->pci); amp_saved = chip->amplifier; chip->amplifier = 0; chip->active_ctrl(chip, 1); /* force to on */ @@ -3744,8 +3747,10 @@ int __devinit snd_cs46xx_create(snd_card_t * card, return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); #ifdef CONFIG_SND_CS46XX_NEW_DSP init_MUTEX(&chip->spos_mutex); diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 4f7a0ea6075454..45f3ceda5c3c41 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -561,6 +561,7 @@ static int snd_emu10k1_free(emu10k1_t *emu) free_irq(emu->irq, (void *)emu); if (emu->port) pci_release_regions(emu->pci); + pci_disable_device(emu->pci); kfree(emu); return 0; } @@ -596,14 +597,17 @@ int __devinit snd_emu10k1_create(snd_card_t * card, return err; emu = kcalloc(1, sizeof(*emu), GFP_KERNEL); - if (emu == NULL) + if (emu == NULL) { + pci_disable_device(pci); return -ENOMEM; + } /* set the DMA transfer mask */ emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK; if (pci_set_dma_mask(pci, emu->dma_mask) < 0 || pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) { snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask); kfree(emu); + pci_disable_device(pci); return -ENXIO; } emu->card = card; @@ -629,6 +633,7 @@ int __devinit snd_emu10k1_create(snd_card_t * card, if ((err = pci_request_regions(pci, "EMU10K1")) < 0) { kfree(emu); + pci_disable_device(pci); return err; } emu->port = pci_resource_start(pci, 0); diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 70d07014b675e8..d2d9d4c5c979f2 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1839,6 +1839,7 @@ static int snd_ensoniq_free(ensoniq_t *ensoniq) if (ensoniq->irq >= 0) free_irq(ensoniq->irq, (void *)ensoniq); pci_release_regions(ensoniq->pci); + pci_disable_device(ensoniq->pci); kfree(ensoniq); return 0; } @@ -1893,8 +1894,10 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; ensoniq = kcalloc(1, sizeof(*ensoniq), GFP_KERNEL); - if (ensoniq == NULL) + if (ensoniq == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&ensoniq->reg_lock); init_MUTEX(&ensoniq->src_mutex); ensoniq->card = card; @@ -1902,6 +1905,7 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, ensoniq->irq = -1; if ((err = pci_request_regions(pci, "Ensoniq AudioPCI")) < 0) { kfree(ensoniq); + pci_disable_device(pci); return err; } ensoniq->port = pci_resource_start(pci, 0); diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index d056ce3675febd..4ef94409b9c4a5 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1394,6 +1394,7 @@ static int es1938_suspend(snd_card_t *card, unsigned int state) outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -1432,6 +1433,7 @@ static int snd_es1938_free(es1938_t *chip) if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -1461,18 +1463,22 @@ static int __devinit snd_es1938_create(snd_card_t * card, if (pci_set_dma_mask(pci, 0x00ffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) { snd_printk("architecture does not support 24bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->mixer_lock); chip->card = card; chip->pci = pci; if ((err = pci_request_regions(pci, "ESS Solo-1")) < 0) { kfree(chip); + pci_disable_device(pci); return err; } chip->io_port = pci_resource_start(pci, 0); diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 806f496147fb09..b8efd0d4cf0ac8 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2405,6 +2405,7 @@ static int es1968_suspend(snd_card_t *card, unsigned int state) snd_ac97_suspend(chip->ac97); snd_es1968_bob_stop(chip); snd_es1968_set_acpi(chip, ACPI_D3); + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -2418,6 +2419,7 @@ static int es1968_resume(snd_card_t *card, unsigned int state) /* restore all our config */ pci_enable_device(chip->pci); + pci_set_master(chip->pci); snd_es1968_chip_init(chip); /* need to restore the base pointers.. */ @@ -2461,6 +2463,7 @@ static int snd_es1968_free(es1968_t *chip) chip->master_switch = NULL; chip->master_volume = NULL; pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -2512,12 +2515,15 @@ static int __devinit snd_es1968_create(snd_card_t * card, if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { snd_printk("architecture does not support 28bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (! chip) + if (! chip) { + pci_disable_device(pci); return -ENOMEM; + } /* Set Vars */ chip->type = chip_type; @@ -2537,6 +2543,7 @@ static int __devinit snd_es1968_create(snd_card_t * card, if ((err = pci_request_regions(pci, "ESS Maestro")) < 0) { kfree(chip); + pci_disable_device(pci); return err; } chip->io_port = pci_resource_start(pci, 0); diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 2f19d7601da2ea..606b5cce5359d1 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1234,6 +1234,7 @@ static int snd_fm801_free(fm801_t *chip) if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; @@ -1263,14 +1264,17 @@ static int __devinit snd_fm801_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); chip->card = card; chip->pci = pci; chip->irq = -1; if ((err = pci_request_regions(pci, "FM801")) < 0) { kfree(chip); + pci_disable_device(pci); return err; } chip->port = pci_resource_start(pci, 0); diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 9063929b0d8468..fddd9e0e5c430d 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -2495,6 +2495,7 @@ static int snd_ice1712_free(ice1712_t *ice) if (ice->port) pci_release_regions(ice->pci); snd_ice1712_akm4xxx_free(ice); + pci_disable_device(ice->pci); kfree(ice); return 0; } @@ -2527,12 +2528,15 @@ static int __devinit snd_ice1712_create(snd_card_t * card, if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { snd_printk("architecture does not support 28bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } ice = kcalloc(1, sizeof(*ice), GFP_KERNEL); - if (ice == NULL) + if (ice == NULL) { + pci_disable_device(pci); return -ENOMEM; + } ice->omni = omni ? 1 : 0; if (cs8427_timeout < 1) cs8427_timeout = 1; @@ -2562,6 +2566,7 @@ static int __devinit snd_ice1712_create(snd_card_t * card, if ((err = pci_request_regions(pci, "ICE1712")) < 0) { kfree(ice); + pci_disable_device(pci); return err; } ice->port = pci_resource_start(pci, 0); diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 5688b6d7a17038..91c961dd49947e 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2076,6 +2076,7 @@ static int snd_vt1724_free(ice1712_t *ice) } pci_release_regions(ice->pci); snd_ice1712_akm4xxx_free(ice); + pci_disable_device(ice->pci); kfree(ice); return 0; } @@ -2105,8 +2106,10 @@ static int __devinit snd_vt1724_create(snd_card_t * card, return err; ice = kcalloc(1, sizeof(*ice), GFP_KERNEL); - if (ice == NULL) + if (ice == NULL) { + pci_disable_device(pci); return -ENOMEM; + } ice->vt1724 = 1; spin_lock_init(&ice->reg_lock); init_MUTEX(&ice->gpio_mutex); @@ -2124,6 +2127,7 @@ static int __devinit snd_vt1724_create(snd_card_t * card, if ((err = pci_request_regions(pci, "ICE1724")) < 0) { kfree(ice); + pci_disable_device(pci); return err; } ice->port = pci_resource_start(pci, 0); diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 669a9b842dfd14..a31bdc961cad24 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2275,6 +2275,7 @@ static int snd_intel8x0_free(intel8x0_t *chip) if (chip->remap_bmaddr) iounmap(chip->remap_bmaddr); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -2293,6 +2294,7 @@ static int intel8x0_suspend(snd_card_t *card, unsigned int state) for (i = 0; i < 3; i++) if (chip->ac97[i]) snd_ac97_suspend(chip->ac97[i]); + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -2510,8 +2512,10 @@ static int __devinit snd_intel8x0_create(snd_card_t * card, return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->ac97_lock); chip->device_type = device_type; @@ -2531,6 +2535,7 @@ static int __devinit snd_intel8x0_create(snd_card_t * card, if ((err = pci_request_regions(pci, card->shortname)) < 0) { kfree(chip); + pci_disable_device(pci); return err; } diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 96ee78dda0bc9b..e97b41452df9fc 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1074,6 +1074,7 @@ static int snd_intel8x0_free(intel8x0_t *chip) if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -1091,6 +1092,7 @@ static int intel8x0m_suspend(snd_card_t *card, unsigned int state) snd_pcm_suspend_all(chip->pcm[i]); if (chip->ac97) snd_ac97_suspend(chip->ac97); + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -1172,8 +1174,10 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card, return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->ac97_lock); chip->device_type = device_type; @@ -1183,6 +1187,7 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card, if ((err = pci_request_regions(pci, card->shortname)) < 0) { kfree(chip); + pci_disable_device(pci); return err; } diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index b3eb3b62aee53e..ca256c4f18b9a0 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2179,6 +2179,7 @@ snd_korg1212_free(korg1212_t *korg1212) korg1212->dma_shared.area = NULL; } + pci_disable_device(korg1212->pci); kfree(korg1212); return 0; } @@ -2210,8 +2211,10 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, return err; korg1212 = kcalloc(1, sizeof(*korg1212), GFP_KERNEL); - if (korg1212 == NULL) + if (korg1212 == NULL) { + pci_disable_device(pci); return -ENOMEM; + } korg1212->card = card; korg1212->pci = pci; @@ -2244,6 +2247,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if ((err = pci_request_regions(pci, "korg1212")) < 0) { kfree(korg1212); + pci_disable_device(pci); return err; } @@ -2270,6 +2274,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) { snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem, korg1212->iomem + iomem_size - 1); + snd_korg1212_free(korg1212); return -EBUSY; } @@ -2279,6 +2284,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if (err) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); + snd_korg1212_free(korg1212); return -EBUSY; } @@ -2326,6 +2332,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) { snd_printk(KERN_ERR "can not allocate shared buffer memory (%Zd bytes)\n", sizeof(KorgSharedBuffer)); + snd_korg1212_free(korg1212); return -ENOMEM; } korg1212->sharedBufferPtr = (KorgSharedBuffer *)korg1212->dma_shared.area; @@ -2342,6 +2349,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->DataBufsSize, &korg1212->dma_play) < 0) { snd_printk(KERN_ERR "can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize); + snd_korg1212_free(korg1212); return -ENOMEM; } korg1212->playDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_play.area; @@ -2355,6 +2363,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->DataBufsSize, &korg1212->dma_rec) < 0) { snd_printk(KERN_ERR "can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize); + snd_korg1212_free(korg1212); return -ENOMEM; } korg1212->recordDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_rec.area; @@ -2386,6 +2395,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) { snd_printk(KERN_ERR "can not allocate dsp code memory (%d bytes)\n", korg1212->dspCodeSize); + snd_korg1212_free(korg1212); return -ENOMEM; } @@ -2405,8 +2415,10 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, mdelay(CARD_BOOT_DELAY_IN_MS); - if (snd_korg1212_downloadDSPCode(korg1212)) + if (snd_korg1212_downloadDSPCode(korg1212)) { + snd_korg1212_free(korg1212); return -EBUSY; + } printk(KERN_INFO "dspMemPhy = %08x U[%08x]\n" "PlayDataPhy = %08x L[%08x]\n" @@ -2421,8 +2433,10 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy), korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy)); - if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0) + if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0) { + snd_korg1212_free(korg1212); return err; + } korg1212->pcm->private_data = korg1212; korg1212->pcm->private_free = snd_korg1212_free_pcm; @@ -2439,8 +2453,10 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) { err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212)); - if (err < 0) + if (err < 0) { + snd_korg1212_free(korg1212); return err; + } } snd_korg1212_proc_init(korg1212); diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 4b3d2b4c0e2bbd..a68504b20e8846 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2386,6 +2386,7 @@ static int snd_m3_free(m3_t *chip) if (chip->iobase) pci_release_regions(chip->pci); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -2422,6 +2423,8 @@ static int m3_suspend(snd_card_t *card, unsigned int state) /* power down apci registers */ snd_m3_outw(chip, 0xffff, 0x54); snd_m3_outw(chip, 0xffff, 0x56); + + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -2434,6 +2437,7 @@ static int m3_resume(snd_card_t *card, unsigned int state) if (chip->suspend_mem == NULL) return 0; + pci_enable_device(chip->pci); pci_set_master(chip->pci); /* first lets just bring everything back. .*/ @@ -2502,12 +2506,15 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { snd_printk("architecture does not support 28bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&chip->reg_lock); switch (pci->device) { @@ -2549,6 +2556,7 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, chip->substreams = kmalloc(sizeof(m3_dma_t) * chip->num_substreams, GFP_KERNEL); if (chip->substreams == NULL) { kfree(chip); + pci_disable_device(pci); return -ENOMEM; } memset(chip->substreams, 0, sizeof(m3_dma_t) * chip->num_substreams); diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 65e96f82e2ecaf..32a728ffb1bcd6 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1092,6 +1092,7 @@ static int snd_mixart_free(mixart_mgr_t *mgr) mgr->bufferinfo.area = NULL; } + pci_disable_device(mgr->pci); kfree(mgr); return 0; } @@ -1292,14 +1293,17 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, /* check if we can restrict PCI DMA transfers to 32 bits */ if (pci_set_dma_mask(pci, 0xffffffff) < 0) { snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } /* */ mgr = kcalloc(1, sizeof(*mgr), GFP_KERNEL); - if (! mgr) + if (! mgr) { + pci_disable_device(pci); return -ENOMEM; + } mgr->pci = pci; mgr->irq = -1; @@ -1307,6 +1311,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, /* resource assignment */ if ((err = pci_request_regions(pci, CARD_NAME)) < 0) { kfree(mgr); + pci_disable_device(pci); return err; } for (i = 0; i < 2; i++) { diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index a30e487f333b7f..25949c43497bd5 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1274,6 +1274,7 @@ static int nm256_suspend(snd_card_t *card, unsigned int state) snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); chip->coeffs_current = 0; + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -1319,6 +1320,7 @@ static int snd_nm256_free(nm256_t *chip) if (chip->irq >= 0) free_irq(chip->irq, (void*)chip); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -1346,9 +1348,14 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci, *chip_ret = NULL; + if ((err = pci_enable_device(pci)) < 0) + return err; + chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } chip->card = card; chip->pci = pci; @@ -1535,9 +1542,6 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, struct nm256_quirk *q; u16 subsystem_vendor, subsystem_device; - if ((err = pci_enable_device(pci)) < 0) - return err; - if (dev >= SNDRV_CARDS) return -ENODEV; if (!enable[dev]) { diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 00ca48d7459859..2c131766a5a2db 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -1350,6 +1350,7 @@ static void snd_rme32_free(void *private_data) pci_release_regions(rme32->pci); rme32->port = 0; } + pci_disable_device(rme32->pci); } static void snd_rme32_free_spdif_pcm(snd_pcm_t * pcm) diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 5360cdef82dab9..8ab9ba8cb77eff 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -1553,6 +1553,7 @@ snd_rme96_free(void *private_data) pci_release_regions(rme96->pci); rme96->port = 0; } + pci_disable_device(rme96->pci); } static void diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 48962810a1de2f..05665b08bda985 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -5061,6 +5061,7 @@ static int snd_hdsp_free(hdsp_t *hdsp) if (hdsp->port) pci_release_regions(hdsp->pci); + pci_disable_device(hdsp->pci); return 0; } diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 10784f736b81e7..420779931869e7 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -1812,6 +1812,7 @@ static int snd_rme9652_free(rme9652_t *rme9652) if (rme9652->port) pci_release_regions(rme9652->pci); + pci_disable_device(rme9652->pci); return 0; } diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 54e6c20d3f3b2c..8dcfc0800c4933 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1185,6 +1185,7 @@ static int snd_sonicvibes_free(sonicvibes_t *sonic) kfree_nocheck(sonic->res_dmac); } pci_release_regions(sonic->pci); + pci_disable_device(sonic->pci); kfree(sonic); return 0; } @@ -1216,12 +1217,15 @@ static int __devinit snd_sonicvibes_create(snd_card_t * card, if (pci_set_dma_mask(pci, 0x00ffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) { snd_printk("architecture does not support 24bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } sonic = kcalloc(1, sizeof(*sonic), GFP_KERNEL); - if (sonic == NULL) + if (sonic == NULL) { + pci_disable_device(pci); return -ENOMEM; + } spin_lock_init(&sonic->reg_lock); sonic->card = card; sonic->pci = pci; @@ -1229,6 +1233,7 @@ static int __devinit snd_sonicvibes_create(snd_card_t * card, if ((err = pci_request_regions(pci, "S3 SonicVibes")) < 0) { kfree(sonic); + pci_disable_device(pci); return err; } diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 46d050d2bd6d93..815e87883e8628 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -3537,12 +3537,15 @@ int __devinit snd_trident_create(snd_card_t * card, if (pci_set_dma_mask(pci, 0x3fffffff) < 0 || pci_set_consistent_dma_mask(pci, 0x3fffffff) < 0) { snd_printk("architecture does not support 30bit PCI busmaster DMA\n"); + pci_disable_device(pci); return -ENXIO; } trident = kcalloc(1, sizeof(*trident), GFP_KERNEL); - if (trident == NULL) + if (trident == NULL) { + pci_disable_device(pci); return -ENOMEM; + } trident->device = (pci->vendor << 16) | pci->device; trident->card = card; trident->pci = pci; @@ -3564,6 +3567,7 @@ int __devinit snd_trident_create(snd_card_t * card, if ((err = pci_request_regions(pci, "Trident Audio")) < 0) { kfree(trident); + pci_disable_device(pci); return err; } trident->port = pci_resource_start(pci, 0); @@ -3682,6 +3686,7 @@ int snd_trident_free(trident_t *trident) if (trident->irq >= 0) free_irq(trident->irq, (void *)trident); pci_release_regions(trident->pci); + pci_disable_device(trident->pci); kfree(trident); return 0; } @@ -3949,6 +3954,7 @@ static int snd_trident_suspend(snd_card_t *card, unsigned int state) case TRIDENT_DEVICE_ID_SI7018: break; } + pci_disable_device(trident->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 1d3d2f01578a94..a4c8344fb1ba75 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1980,6 +1980,7 @@ static int snd_via82xx_free(via82xx_t *chip) pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy); pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg); } + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -2006,8 +2007,10 @@ static int __devinit snd_via82xx_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) + if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) { + pci_disable_device(pci); return -ENOMEM; + } chip->chip_type = chip_type; chip->revision = revision; @@ -2025,6 +2028,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card, if ((err = pci_request_regions(pci, card->driver)) < 0) { kfree(chip); + pci_disable_device(pci); return err; } chip->port = pci_resource_start(pci, 0); diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index 44495958984016..75e53b50924afe 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -116,6 +116,7 @@ static int snd_vx222_free(vx_core_t *chip) free_irq(chip->irq, (void*)chip); if (vx->port[0]) pci_release_regions(vx->pci); + pci_disable_device(vx->pci); kfree(chip); return 0; } @@ -147,8 +148,10 @@ static int __devinit snd_vx222_create(snd_card_t *card, struct pci_dev *pci, vx_ops = hw->type == VX_TYPE_BOARD ? &vx222_old_ops : &vx222_ops; chip = snd_vx_create(card, hw, vx_ops, sizeof(struct snd_vx222) - sizeof(vx_core_t)); - if (! chip) + if (! chip) { + pci_disable_device(pci); return -ENOMEM; + } vx = (struct snd_vx222 *)chip; vx->pci = pci; diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 1f43d9e48a5619..87214a02b50ac8 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2098,6 +2098,7 @@ static int snd_ymfpci_free(ymfpci_t *chip) pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); + pci_disable_device(chip->pci); kfree(chip); return 0; } @@ -2153,6 +2154,7 @@ static int snd_ymfpci_suspend(snd_card_t *card, unsigned int state) chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE); snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); snd_ymfpci_disable_dsp(chip); + pci_disable_device(chip->pci); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); return 0; } @@ -2204,8 +2206,10 @@ int __devinit snd_ymfpci_create(snd_card_t * card, return err; chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); - if (chip == NULL) + if (chip == NULL) { + pci_disable_device(pci); return -ENOMEM; + } chip->old_legacy_ctrl = old_legacy_ctrl; spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->voice_lock); |