Commit e60eb4cc authored by Jaroslav Kysela's avatar Jaroslav Kysela

[ALSA] Fix the order of creation of instances

AZT3328 driver,CMIPCI driver,CS4281 driver,ENS1370/1+ driver
Maestro3 driver,SonicVibes driver,CS46xx driver,KORG1212 driver
NM256 driver,Trident driver,YMFPCI driver
Make sure that the chip instance is created at first before other components.
This will fix occasional oops at unloading due to the access to the released
resources.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d6d4c514
...@@ -1344,15 +1344,15 @@ static int __devinit snd_azf3328_create(snd_card_t * card, ...@@ -1344,15 +1344,15 @@ static int __devinit snd_azf3328_create(snd_card_t * card,
for (tmp=0; tmp <= 0x01; tmp += 1) for (tmp=0; tmp <= 0x01; tmp += 1)
snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp)); snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp));
/* create mixer interface & switches */
if ((err = snd_azf3328_mixer_new(chip)) < 0)
return err;
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
snd_azf3328_free(chip); snd_azf3328_free(chip);
return err; return err;
} }
/* create mixer interface & switches */
if ((err = snd_azf3328_mixer_new(chip)) < 0)
return err;
#if 0 #if 0
/* set very low bitrate to reduce noise and power consumption? */ /* set very low bitrate to reduce noise and power consumption? */
snd_azf3328_setfmt(chip, IDX_IO_PLAY_SOUNDFORMAT, 5512, 8, 1); snd_azf3328_setfmt(chip, IDX_IO_PLAY_SOUNDFORMAT, 5512, 8, 1);
......
...@@ -2608,8 +2608,8 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, ...@@ -2608,8 +2608,8 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci,
if (request_irq(pci->irq, snd_cmipci_interrupt, SA_INTERRUPT|SA_SHIRQ, card->driver, (void *)cm)) { if (request_irq(pci->irq, snd_cmipci_interrupt, SA_INTERRUPT|SA_SHIRQ, card->driver, (void *)cm)) {
snd_printk("unable to grab IRQ %d\n", pci->irq); snd_printk("unable to grab IRQ %d\n", pci->irq);
err = -EBUSY; snd_cmipci_free(cm);
goto __error; return -EBUSY;
} }
cm->irq = pci->irq; cm->irq = pci->irq;
...@@ -2662,6 +2662,11 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, ...@@ -2662,6 +2662,11 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci,
break; break;
} }
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cm, &ops)) < 0) {
snd_cmipci_free(cm);
return err;
}
/* set MPU address */ /* set MPU address */
switch (iomidi) { switch (iomidi) {
case 0x320: val = CM_VMPU_320; break; case 0x320: val = CM_VMPU_320; break;
...@@ -2717,22 +2722,22 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, ...@@ -2717,22 +2722,22 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci,
/* create pcm devices */ /* create pcm devices */
pcm_index = pcm_spdif_index = 0; pcm_index = pcm_spdif_index = 0;
if ((err = snd_cmipci_pcm_new(cm, pcm_index)) < 0) if ((err = snd_cmipci_pcm_new(cm, pcm_index)) < 0)
goto __error; return err;
pcm_index++; pcm_index++;
if (cm->has_dual_dac) { if (cm->has_dual_dac) {
if ((err = snd_cmipci_pcm2_new(cm, pcm_index)) < 0) if ((err = snd_cmipci_pcm2_new(cm, pcm_index)) < 0)
goto __error; return err;
pcm_index++; pcm_index++;
} }
if (cm->can_ac3_hw || cm->can_ac3_sw) { if (cm->can_ac3_hw || cm->can_ac3_sw) {
pcm_spdif_index = pcm_index; pcm_spdif_index = pcm_index;
if ((err = snd_cmipci_pcm_spdif_new(cm, pcm_index)) < 0) if ((err = snd_cmipci_pcm_spdif_new(cm, pcm_index)) < 0)
goto __error; return err;
} }
/* create mixer interface & switches */ /* create mixer interface & switches */
if ((err = snd_cmipci_mixer_new(cm, pcm_spdif_index)) < 0) if ((err = snd_cmipci_mixer_new(cm, pcm_spdif_index)) < 0)
goto __error; return err;
if (iomidi > 0) { if (iomidi > 0) {
if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI, if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
...@@ -2742,10 +2747,6 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, ...@@ -2742,10 +2747,6 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci,
} }
} }
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cm, &ops)) < 0) {
snd_cmipci_free(cm);
return err;
}
#ifdef USE_VAR48KRATE #ifdef USE_VAR48KRATE
for (val = 0; val < ARRAY_SIZE(rates); val++) for (val = 0; val < ARRAY_SIZE(rates); val++)
snd_cmipci_set_pll(cm, rates[val], val); snd_cmipci_set_pll(cm, rates[val], val);
...@@ -2785,10 +2786,6 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, ...@@ -2785,10 +2786,6 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci,
*rcmipci = cm; *rcmipci = cm;
return 0; return 0;
__error:
snd_cmipci_free(cm);
return err;
} }
/* /*
......
...@@ -1439,15 +1439,15 @@ static int __devinit snd_cs4281_create(snd_card_t * card, ...@@ -1439,15 +1439,15 @@ static int __devinit snd_cs4281_create(snd_card_t * card,
return tmp; return tmp;
} }
snd_cs4281_proc_init(chip);
snd_card_set_pm_callback(card, cs4281_suspend, cs4281_resume, chip);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
snd_cs4281_free(chip); snd_cs4281_free(chip);
return err; return err;
} }
snd_cs4281_proc_init(chip);
snd_card_set_pm_callback(card, cs4281_suspend, cs4281_resume, chip);
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
*rchip = chip; *rchip = chip;
......
...@@ -3909,15 +3909,15 @@ int __devinit snd_cs46xx_create(snd_card_t * card, ...@@ -3909,15 +3909,15 @@ int __devinit snd_cs46xx_create(snd_card_t * card,
return err; return err;
} }
snd_cs46xx_proc_init(card, chip);
snd_card_set_pm_callback(card, snd_cs46xx_suspend, snd_cs46xx_resume, chip);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
snd_cs46xx_free(chip); snd_cs46xx_free(chip);
return err; return err;
} }
snd_cs46xx_proc_init(card, chip);
snd_card_set_pm_callback(card, snd_cs46xx_suspend, snd_cs46xx_resume, chip);
chip->active_ctrl(chip, -1); /* disable CLKRUN */ chip->active_ctrl(chip, -1); /* disable CLKRUN */
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
......
...@@ -1924,7 +1924,6 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, ...@@ -1924,7 +1924,6 @@ static int __devinit snd_ensoniq_create(snd_card_t * card,
ensoniq->subsystem_vendor_id = cmdw; ensoniq->subsystem_vendor_id = cmdw;
pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &cmdw); pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &cmdw);
ensoniq->subsystem_device_id = cmdw; ensoniq->subsystem_device_id = cmdw;
snd_ensoniq_proc_init(ensoniq);
#ifdef CHIP1370 #ifdef CHIP1370
#if 0 #if 0
ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000));
...@@ -2017,6 +2016,8 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, ...@@ -2017,6 +2016,8 @@ static int __devinit snd_ensoniq_create(snd_card_t * card,
return err; return err;
} }
snd_ensoniq_proc_init(ensoniq);
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
*rensoniq = ensoniq; *rensoniq = ensoniq;
......
...@@ -2412,14 +2412,17 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, ...@@ -2412,14 +2412,17 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
#endif #endif
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
snd_korg1212_free(korg1212);
return err;
}
snd_korg1212_EnableCardInterrupts(korg1212); snd_korg1212_EnableCardInterrupts(korg1212);
mdelay(CARD_BOOT_DELAY_IN_MS); mdelay(CARD_BOOT_DELAY_IN_MS);
if (snd_korg1212_downloadDSPCode(korg1212)) { if (snd_korg1212_downloadDSPCode(korg1212))
snd_korg1212_free(korg1212);
return -EBUSY; return -EBUSY;
}
printk(KERN_INFO "dspMemPhy = %08x U[%08x]\n" printk(KERN_INFO "dspMemPhy = %08x U[%08x]\n"
"PlayDataPhy = %08x L[%08x]\n" "PlayDataPhy = %08x L[%08x]\n"
...@@ -2434,10 +2437,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, ...@@ -2434,10 +2437,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy), korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy),
korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy)); 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; return err;
}
korg1212->pcm->private_data = korg1212; korg1212->pcm->private_data = korg1212;
korg1212->pcm->private_free = snd_korg1212_free_pcm; korg1212->pcm->private_free = snd_korg1212_free_pcm;
...@@ -2454,19 +2455,12 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, ...@@ -2454,19 +2455,12 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) { for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) {
err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212)); 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; return err;
} }
}
snd_korg1212_proc_init(korg1212); snd_korg1212_proc_init(korg1212);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
snd_korg1212_free(korg1212);
return err;
}
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
* rchip = korg1212; * rchip = korg1212;
......
...@@ -2565,25 +2565,6 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, ...@@ -2565,25 +2565,6 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
snd_m3_assp_init(chip); snd_m3_assp_init(chip);
snd_m3_amp_enable(chip, 1); snd_m3_amp_enable(chip, 1);
if ((err = snd_m3_mixer(chip)) < 0) {
snd_m3_free(chip);
return err;
}
for (i = 0; i < chip->num_substreams; i++) {
m3_dma_t *s = &chip->substreams[i];
s->chip = chip;
if ((err = snd_m3_assp_client_init(chip, s, i)) < 0) {
snd_m3_free(chip);
return err;
}
}
if ((err = snd_m3_pcm(chip, 0)) < 0) {
snd_m3_free(chip);
return err;
}
if (request_irq(pci->irq, snd_m3_interrupt, SA_INTERRUPT|SA_SHIRQ, if (request_irq(pci->irq, snd_m3_interrupt, SA_INTERRUPT|SA_SHIRQ,
card->driver, (void *)chip)) { card->driver, (void *)chip)) {
snd_printk("unable to grab IRQ %d\n", pci->irq); snd_printk("unable to grab IRQ %d\n", pci->irq);
...@@ -2605,6 +2586,19 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, ...@@ -2605,6 +2586,19 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
return err; return err;
} }
if ((err = snd_m3_mixer(chip)) < 0)
return err;
for (i = 0; i < chip->num_substreams; i++) {
m3_dma_t *s = &chip->substreams[i];
s->chip = chip;
if ((err = snd_m3_assp_client_init(chip, s, i)) < 0)
return err;
}
if ((err = snd_m3_pcm(chip, 0)) < 0)
return err;
snd_m3_enable_ints(chip); snd_m3_enable_ints(chip);
snd_m3_assp_continue(chip); snd_m3_assp_continue(chip);
......
...@@ -1486,12 +1486,6 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci, ...@@ -1486,12 +1486,6 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci,
snd_nm256_init_chip(chip); snd_nm256_init_chip(chip);
if ((err = snd_nm256_pcm(chip, 0)) < 0)
goto __error;
if ((err = snd_nm256_mixer(chip)) < 0)
goto __error;
// pci_set_master(pci); /* needed? */ // pci_set_master(pci); /* needed? */
snd_card_set_pm_callback(card, nm256_suspend, nm256_resume, chip); snd_card_set_pm_callback(card, nm256_suspend, nm256_resume, chip);
...@@ -1612,6 +1606,12 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, ...@@ -1612,6 +1606,12 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci,
chip->reset_workaround = 1; chip->reset_workaround = 1;
} }
if ((err = snd_nm256_pcm(chip, 0)) < 0 ||
(err = snd_nm256_mixer(chip)) < 0) {
snd_card_free(card);
return err;
}
sprintf(card->shortname, "NeoMagic %s", card->driver); sprintf(card->shortname, "NeoMagic %s", card->driver);
sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %d", sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %d",
card->shortname, card->shortname,
......
...@@ -1333,13 +1333,14 @@ static int __devinit snd_sonicvibes_create(snd_card_t * card, ...@@ -1333,13 +1333,14 @@ static int __devinit snd_sonicvibes_create(snd_card_t * card,
#endif #endif
sonic->revision = snd_sonicvibes_in(sonic, SV_IREG_REVISION); sonic->revision = snd_sonicvibes_in(sonic, SV_IREG_REVISION);
snd_ctl_add(card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); snd_ctl_add(card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic));
snd_sonicvibes_proc_init(sonic);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, sonic, &ops)) < 0) { if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, sonic, &ops)) < 0) {
snd_sonicvibes_free(sonic); snd_sonicvibes_free(sonic);
return err; return err;
} }
snd_sonicvibes_proc_init(sonic);
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
*rsonic = sonic; *rsonic = sonic;
......
...@@ -3614,11 +3614,14 @@ int __devinit snd_trident_create(snd_card_t * card, ...@@ -3614,11 +3614,14 @@ int __devinit snd_trident_create(snd_card_t * card,
return err; return err;
} }
if ((err = snd_trident_mixer(trident, pcm_spdif_device)) < 0) { if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops)) < 0) {
snd_trident_free(trident); snd_trident_free(trident);
return err; return err;
} }
if ((err = snd_trident_mixer(trident, pcm_spdif_device)) < 0)
return err;
/* initialise synth voices */ /* initialise synth voices */
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
voice = &trident->synth.voices[i]; voice = &trident->synth.voices[i];
...@@ -3638,12 +3641,7 @@ int __devinit snd_trident_create(snd_card_t * card, ...@@ -3638,12 +3641,7 @@ int __devinit snd_trident_create(snd_card_t * card,
snd_card_set_pm_callback(card, snd_trident_suspend, snd_trident_resume, trident); snd_card_set_pm_callback(card, snd_trident_suspend, snd_trident_resume, trident);
snd_trident_proc_init(trident); snd_trident_proc_init(trident);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops)) < 0) {
snd_trident_free(trident);
return err;
}
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
*rtrident = trident; *rtrident = trident;
return 0; return 0;
...@@ -3653,7 +3651,7 @@ int __devinit snd_trident_create(snd_card_t * card, ...@@ -3653,7 +3651,7 @@ int __devinit snd_trident_create(snd_card_t * card,
snd_trident_free snd_trident_free
Description: This routine will free the device specific class for Description: This routine will free the device specific class for
q the 4DWave card. the 4DWave card.
Paramters: trident - device specific private data for 4DWave card Paramters: trident - device specific private data for 4DWave card
......
...@@ -2266,13 +2266,13 @@ int __devinit snd_ymfpci_create(snd_card_t * card, ...@@ -2266,13 +2266,13 @@ int __devinit snd_ymfpci_create(snd_card_t * card,
snd_card_set_pm_callback(card, snd_ymfpci_suspend, snd_ymfpci_resume, chip); snd_card_set_pm_callback(card, snd_ymfpci_suspend, snd_ymfpci_resume, chip);
#endif #endif
snd_ymfpci_proc_init(card, chip);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
snd_ymfpci_free(chip); snd_ymfpci_free(chip);
return err; return err;
} }
snd_ymfpci_proc_init(card, chip);
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
*rchip = chip; *rchip = chip;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment