diff options
Diffstat (limited to 'sound/isa/gus')
-rw-r--r-- | sound/isa/gus/gusclassic.c | 115 | ||||
-rw-r--r-- | sound/isa/gus/gusextreme.c | 49 | ||||
-rw-r--r-- | sound/isa/gus/gusmax.c | 145 | ||||
-rw-r--r-- | sound/isa/gus/interwave.c | 167 |
4 files changed, 200 insertions, 276 deletions
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index a99fa5040b46..39cef38835ca 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -72,40 +72,24 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "gusclassic: " static int __init snd_gusclassic_detect(snd_gus_card_t * gus) { - snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; + unsigned char d; - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0) + snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { + snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif + } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { + snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif - + } return 0; } @@ -137,25 +121,25 @@ static int __init snd_gusclassic_probe(int dev) xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + err = -EBUSY; + goto _err; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + err = -EBUSY; + goto _err; } } @@ -164,47 +148,48 @@ static int __init snd_gusclassic_probe(int dev) port[dev], xirq, xdma1, xdma2, 0, channels[dev], pcm_channels[dev], - 0, &gus)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_gusclassic_detect(gus)) < 0) { - snd_card_free(card); - return err; - } + 0, &gus)) < 0) + goto _err; + + if ((err = snd_gusclassic_detect(gus)) < 0) + goto _err; + snd_gusclassic_init(dev, gus); - if ((err = snd_gus_initialize(gus)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gus_initialize(gus)) < 0) + goto _err; + if (gus->max_flag || gus->ess_flag) { - snd_printdd("GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); - snd_card_free(card); - return -ENODEV; - } - if ((err = snd_gf1_new_mixer(gus)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) { - snd_card_free(card); - return err; + snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); + err = -ENODEV; + goto _err; } + + if ((err = snd_gf1_new_mixer(gus)) < 0) + goto _err; + + if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) + goto _err; + if (!gus->ace_flag) { - if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) + goto _err; } sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + snd_gusclassic_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index bc6fecb18dcf..d2e7cb1df537 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -87,6 +87,7 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "gusextreme: " static int __init snd_gusextreme_detect(int dev, snd_card_t * card, @@ -94,6 +95,7 @@ static int __init snd_gusextreme_detect(int dev, es1688_t *es1688) { unsigned long flags; + unsigned char d; /* * This is main stuff - enable access to GF1 chip... @@ -123,36 +125,17 @@ static int __init snd_gusextreme_detect(int dev, udelay(100); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); - return -EIO; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { + snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -EIO; -#endif + } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); - return -EIO; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { + snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -EIO; -#endif - + } return 0; } @@ -205,7 +188,7 @@ static int __init snd_gusextreme_probe(int dev) xgf1_irq = gf1_irq[dev]; if (xgf1_irq == SNDRV_AUTO_IRQ) { if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) { - snd_printk("unable to find a free IRQ for GF1\n"); + snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n"); err = -EBUSY; goto out; } @@ -213,7 +196,7 @@ static int __init snd_gusextreme_probe(int dev) xess_irq = irq[dev]; if (xess_irq == SNDRV_AUTO_IRQ) { if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) { - snd_printk("unable to find a free IRQ for ES1688\n"); + snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n"); err = -EBUSY; goto out; } @@ -226,7 +209,7 @@ static int __init snd_gusextreme_probe(int dev) xgf1_dma = dma1[dev]; if (xgf1_dma == SNDRV_AUTO_DMA) { if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) { - snd_printk("unable to find a free DMA for GF1\n"); + snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n"); err = -EBUSY; goto out; } @@ -234,7 +217,7 @@ static int __init snd_gusextreme_probe(int dev) xess_dma = dma8[dev]; if (xess_dma == SNDRV_AUTO_DMA) { if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) { - snd_printk("unable to find a free DMA for ES1688\n"); + snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n"); err = -EBUSY; goto out; } @@ -264,7 +247,7 @@ static int __init snd_gusextreme_probe(int dev) goto out; if (!gus->ess_flag) { - snd_printdd("GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); + snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); err = -ENODEV; goto out; } @@ -287,7 +270,7 @@ static int __init snd_gusextreme_probe(int dev) if (snd_opl3_create(card, es1688->port, es1688->port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { - printk(KERN_ERR "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); + printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) goto out; @@ -303,6 +286,10 @@ static int __init snd_gusextreme_probe(int dev) sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto out; + if ((err = snd_card_register(card)) < 0) goto out; diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 400ff34710fb..0bb44b519340 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -82,39 +82,25 @@ struct snd_gusmax { static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "gusmax: " static int __init snd_gusmax_detect(snd_gus_card_t * gus) { - snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; + unsigned char d; - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0) + snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { + snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif + } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { + snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif + } + return 0; } @@ -239,25 +225,25 @@ static int __init snd_gusmax_probe(int dev) xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + err = -EBUSY; + goto _err; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + err = -EBUSY; + goto _err; } } @@ -266,31 +252,28 @@ static int __init snd_gusmax_probe(int dev) -xirq, xdma1, xdma2, 0, channels[dev], pcm_channels[dev], - 0, &gus)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_gusmax_detect(gus)) < 0) { - snd_card_free(card); - return err; - } + 0, &gus)) < 0) + goto _err; + + if ((err = snd_gusmax_detect(gus)) < 0) + goto _err; + maxcard->gus_status_reg = gus->gf1.reg_irqstat; maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; snd_gusmax_init(dev, card, gus); - if ((err = snd_gus_initialize(gus)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gus_initialize(gus)) < 0) + goto _err; + if (!gus->max_flag) { - printk(KERN_ERR "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); - snd_card_free(card); - return -ENODEV; + snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); + err = -ENODEV; + goto _err; } if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) { - snd_card_free(card); - printk(KERN_ERR "gusmax: unable to grab IRQ %d\n", xirq); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); + err = -EBUSY; + goto _err; } maxcard->irq = xirq; @@ -301,50 +284,46 @@ static int __init snd_gusmax_probe(int dev) CS4231_HWSHARE_IRQ | CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, - &cs4231)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_mixer(cs4231)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) { - snd_card_free(card); - return err; - } + &cs4231)) < 0) + goto _err; + + if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) + goto _err; + + if ((err = snd_cs4231_mixer(cs4231)) < 0) + goto _err; + + if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) + goto _err; + if (pcm_channels[dev] > 0) { - if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } - } - if ((err = snd_gusmax_mixer(cs4231)) < 0) { - snd_card_free(card); - return err; + if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) + goto _err; } + if ((err = snd_gusmax_mixer(cs4231)) < 0) + goto _err; - if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) + goto _err; sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1); if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%i", xdma2); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; maxcard->gus = gus; maxcard->cs4231 = cs4231; snd_gusmax_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 46e867daba6a..358cba9d738f 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -73,6 +73,12 @@ static int midi[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; +#ifdef SNDRV_STB +#define PFX "interwave-stb: " +#else +#define PFX "interwave: " +#endif + module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for InterWave soundcard."); module_param_array(id, charp, NULL, 0444); @@ -249,38 +255,20 @@ static int __devinit snd_interwave_detect(struct snd_interwave *iwcard, { unsigned long flags; unsigned char rev1, rev2; + int d; snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ -#ifdef CONFIG_SND_DEBUG_DETECT - { - int d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { + snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif + } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); -#ifdef CONFIG_SND_DEBUG_DETECT - { - int d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { + snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif - + } spin_lock_irqsave(&gus->reg_lock, flags); rev1 = snd_gf1_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER); snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, ~rev1); @@ -686,35 +674,33 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, card->private_free = snd_interwave_free; #ifdef CONFIG_PNP if (isapnp[dev]) { - if (snd_interwave_pnp(dev, iwcard, pcard, pid)) { - snd_card_free(card); - return -ENODEV; - } + if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0) + goto _err; snd_card_set_dev(card, &pcard->card->dev); } #endif xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + err = -EBUSY; + goto _err; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + err = -EBUSY; + goto _err; } } @@ -722,32 +708,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, port[dev], -xirq, xdma1, xdma2, 0, 32, - pcm_channels[dev], effect[dev], &gus)) < 0) { - snd_card_free(card); - return err; - } + pcm_channels[dev], effect[dev], &gus)) < 0) + goto _err; + if ((err = snd_interwave_detect(iwcard, gus, dev #ifdef SNDRV_STB , &i2c_bus #endif - )) < 0) { - snd_card_free(card); - return err; - } + )) < 0) + goto _err; + iwcard->gus_status_reg = gus->gf1.reg_irqstat; iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; snd_interwave_init(dev, gus); snd_interwave_detect_memory(gus); - if ((err = snd_gus_initialize(gus)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gus_initialize(gus)) < 0) + goto _err; if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { - snd_card_free(card); - snd_printk("unable to grab IRQ %d\n", xirq); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); + err = -EBUSY; + goto _err; } iwcard->irq = xirq; @@ -758,34 +740,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, CS4231_HWSHARE_IRQ | CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, - &cs4231)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) { - snd_card_free(card); - return err; - } + &cs4231)) < 0) + goto _err; + + if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) + goto _err; + sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); strcat(pcm->name, " (codec)"); - if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_mixer(cs4231)) < 0) { - snd_card_free(card); - return err; - } + + if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) + goto _err; + + if ((err = snd_cs4231_mixer(cs4231)) < 0) + goto _err; + if (pcm_channels[dev] > 0) { - if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } - } - if ((err = snd_interwave_mixer(cs4231)) < 0) { - snd_card_free(card); - return err; + if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) + goto _err; } + if ((err = snd_interwave_mixer(cs4231)) < 0) + goto _err; + #ifdef SNDRV_STB { snd_ctl_elem_id_t id1, id2; @@ -795,28 +771,20 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, strcpy(id1.name, "Master Playback Switch"); strcpy(id2.name, id1.name); id2.index = 1; - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + goto _err; strcpy(id1.name, "Master Playback Volume"); strcpy(id2.name, id1.name); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + goto _err; + if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) + goto _err; } #endif gus->uart_enable = midi[dev]; - if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) + goto _err; #ifndef SNDRV_STB str = "AMD InterWave"; @@ -835,10 +803,11 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; iwcard->cs4231 = cs4231; iwcard->gus = gus; @@ -847,6 +816,10 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, else snd_interwave_legacy[dev++] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) |