From 43bcd973d6d05d16b876e09dcc49a09d3e48e88d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Sep 2005 17:19:20 +0200 Subject: [ALSA] Add snd_card_set_generic_dev() call to ISA drivers ISA,CMI8330 driver,ES18xx driver,OPL3SA2 driver,Sound Galaxy driver Sound Scape driver,AD1848 driver,CS4231 driver,CS4236+ driver ES1688 driver,GUS Classic driver,GUS Extreme driver,GUS MAX driver AMD InterWave driver,Opti9xx drivers,SB16/AWE driver,SB8 driver Wavefront drivers - Added snd_card_set_generic_dev() call. - Added SND_GENERIC_DRIVER to Kconfig. - Clean up the error path in probe if necessary. Signed-off-by: Takashi Iwai --- sound/isa/gus/gusmax.c | 145 +++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 83 deletions(-) (limited to 'sound/isa/gus/gusmax.c') diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 400ff34710f..0bb44b51934 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) -- cgit v1.2.3