summaryrefslogtreecommitdiffstats
path: root/sound/isa/gus/gusmax.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/gus/gusmax.c')
-rw-r--r--sound/isa/gus/gusmax.c145
1 files changed, 62 insertions, 83 deletions
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)