aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/gus
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-09-05 11:19:20 -0400
committerJaroslav Kysela <perex@suse.cz>2005-09-12 04:42:01 -0400
commit43bcd973d6d05d16b876e09dcc49a09d3e48e88d (patch)
tree8c8493b66c417402f6188051c57e55099bbd156d /sound/isa/gus
parent16dab54b8cbac39bd3f639db5d7d0fd8300a6cb0 (diff)
[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 <tiwai@suse.de>
Diffstat (limited to 'sound/isa/gus')
-rw-r--r--sound/isa/gus/gusclassic.c115
-rw-r--r--sound/isa/gus/gusextreme.c49
-rw-r--r--sound/isa/gus/gusmax.c145
-rw-r--r--sound/isa/gus/interwave.c167
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.");
72 72
73static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 73static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
74 74
75#define PFX "gusclassic: "
75 76
76static int __init snd_gusclassic_detect(snd_gus_card_t * gus) 77static int __init snd_gusclassic_detect(snd_gus_card_t * gus)
77{ 78{
78 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 79 unsigned char d;
79#ifdef CONFIG_SND_DEBUG_DETECT
80 {
81 unsigned char d;
82 80
83 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { 81 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
84 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); 82 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
85 return -ENODEV; 83 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
86 }
87 }
88#else
89 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
90 return -ENODEV; 84 return -ENODEV;
91#endif 85 }
92 udelay(160); 86 udelay(160);
93 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 87 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
94 udelay(160); 88 udelay(160);
95#ifdef CONFIG_SND_DEBUG_DETECT 89 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
96 { 90 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
97 unsigned char d;
98
99 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
100 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
101 return -ENODEV;
102 }
103 }
104#else
105 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
106 return -ENODEV; 91 return -ENODEV;
107#endif 92 }
108
109 return 0; 93 return 0;
110} 94}
111 95
@@ -137,25 +121,25 @@ static int __init snd_gusclassic_probe(int dev)
137 xirq = irq[dev]; 121 xirq = irq[dev];
138 if (xirq == SNDRV_AUTO_IRQ) { 122 if (xirq == SNDRV_AUTO_IRQ) {
139 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 123 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
140 snd_card_free(card); 124 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
141 snd_printk("unable to find a free IRQ\n"); 125 err = -EBUSY;
142 return -EBUSY; 126 goto _err;
143 } 127 }
144 } 128 }
145 xdma1 = dma1[dev]; 129 xdma1 = dma1[dev];
146 if (xdma1 == SNDRV_AUTO_DMA) { 130 if (xdma1 == SNDRV_AUTO_DMA) {
147 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 131 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
148 snd_card_free(card); 132 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
149 snd_printk("unable to find a free DMA1\n"); 133 err = -EBUSY;
150 return -EBUSY; 134 goto _err;
151 } 135 }
152 } 136 }
153 xdma2 = dma2[dev]; 137 xdma2 = dma2[dev];
154 if (xdma2 == SNDRV_AUTO_DMA) { 138 if (xdma2 == SNDRV_AUTO_DMA) {
155 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 139 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
156 snd_card_free(card); 140 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
157 snd_printk("unable to find a free DMA2\n"); 141 err = -EBUSY;
158 return -EBUSY; 142 goto _err;
159 } 143 }
160 } 144 }
161 145
@@ -164,47 +148,48 @@ static int __init snd_gusclassic_probe(int dev)
164 port[dev], 148 port[dev],
165 xirq, xdma1, xdma2, 149 xirq, xdma1, xdma2,
166 0, channels[dev], pcm_channels[dev], 150 0, channels[dev], pcm_channels[dev],
167 0, &gus)) < 0) { 151 0, &gus)) < 0)
168 snd_card_free(card); 152 goto _err;
169 return err; 153
170 } 154 if ((err = snd_gusclassic_detect(gus)) < 0)
171 if ((err = snd_gusclassic_detect(gus)) < 0) { 155 goto _err;
172 snd_card_free(card); 156
173 return err;
174 }
175 snd_gusclassic_init(dev, gus); 157 snd_gusclassic_init(dev, gus);
176 if ((err = snd_gus_initialize(gus)) < 0) { 158 if ((err = snd_gus_initialize(gus)) < 0)
177 snd_card_free(card); 159 goto _err;
178 return err; 160
179 }
180 if (gus->max_flag || gus->ess_flag) { 161 if (gus->max_flag || gus->ess_flag) {
181 snd_printdd("GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); 162 snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port);
182 snd_card_free(card); 163 err = -ENODEV;
183 return -ENODEV; 164 goto _err;
184 }
185 if ((err = snd_gf1_new_mixer(gus)) < 0) {
186 snd_card_free(card);
187 return err;
188 }
189 if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) {
190 snd_card_free(card);
191 return err;
192 } 165 }
166
167 if ((err = snd_gf1_new_mixer(gus)) < 0)
168 goto _err;
169
170 if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0)
171 goto _err;
172
193 if (!gus->ace_flag) { 173 if (!gus->ace_flag) {
194 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 174 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
195 snd_card_free(card); 175 goto _err;
196 return err;
197 }
198 } 176 }
199 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); 177 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1);
200 if (dma2 >= 0) 178 if (dma2 >= 0)
201 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 179 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
202 if ((err = snd_card_register(card)) < 0) { 180
203 snd_card_free(card); 181 if ((err = snd_card_set_generic_dev(card)) < 0)
204 return err; 182 goto _err;
205 } 183
184 if ((err = snd_card_register(card)) < 0)
185 goto _err;
186
206 snd_gusclassic_cards[dev] = card; 187 snd_gusclassic_cards[dev] = card;
207 return 0; 188 return 0;
189
190 _err:
191 snd_card_free(card);
192 return err;
208} 193}
209 194
210static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) 195static 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.");
87 87
88static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 88static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
89 89
90#define PFX "gusextreme: "
90 91
91static int __init snd_gusextreme_detect(int dev, 92static int __init snd_gusextreme_detect(int dev,
92 snd_card_t * card, 93 snd_card_t * card,
@@ -94,6 +95,7 @@ static int __init snd_gusextreme_detect(int dev,
94 es1688_t *es1688) 95 es1688_t *es1688)
95{ 96{
96 unsigned long flags; 97 unsigned long flags;
98 unsigned char d;
97 99
98 /* 100 /*
99 * This is main stuff - enable access to GF1 chip... 101 * This is main stuff - enable access to GF1 chip...
@@ -123,36 +125,17 @@ static int __init snd_gusextreme_detect(int dev,
123 udelay(100); 125 udelay(100);
124 126
125 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 127 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
126#ifdef CONFIG_SND_DEBUG_DETECT 128 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
127 { 129 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
128 unsigned char d;
129
130 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
131 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
132 return -EIO;
133 }
134 }
135#else
136 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
137 return -EIO; 130 return -EIO;
138#endif 131 }
139 udelay(160); 132 udelay(160);
140 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 133 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
141 udelay(160); 134 udelay(160);
142#ifdef CONFIG_SND_DEBUG_DETECT 135 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
143 { 136 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
144 unsigned char d;
145
146 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
147 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
148 return -EIO;
149 }
150 }
151#else
152 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
153 return -EIO; 137 return -EIO;
154#endif 138 }
155
156 return 0; 139 return 0;
157} 140}
158 141
@@ -205,7 +188,7 @@ static int __init snd_gusextreme_probe(int dev)
205 xgf1_irq = gf1_irq[dev]; 188 xgf1_irq = gf1_irq[dev];
206 if (xgf1_irq == SNDRV_AUTO_IRQ) { 189 if (xgf1_irq == SNDRV_AUTO_IRQ) {
207 if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) { 190 if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) {
208 snd_printk("unable to find a free IRQ for GF1\n"); 191 snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n");
209 err = -EBUSY; 192 err = -EBUSY;
210 goto out; 193 goto out;
211 } 194 }
@@ -213,7 +196,7 @@ static int __init snd_gusextreme_probe(int dev)
213 xess_irq = irq[dev]; 196 xess_irq = irq[dev];
214 if (xess_irq == SNDRV_AUTO_IRQ) { 197 if (xess_irq == SNDRV_AUTO_IRQ) {
215 if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) { 198 if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) {
216 snd_printk("unable to find a free IRQ for ES1688\n"); 199 snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n");
217 err = -EBUSY; 200 err = -EBUSY;
218 goto out; 201 goto out;
219 } 202 }
@@ -226,7 +209,7 @@ static int __init snd_gusextreme_probe(int dev)
226 xgf1_dma = dma1[dev]; 209 xgf1_dma = dma1[dev];
227 if (xgf1_dma == SNDRV_AUTO_DMA) { 210 if (xgf1_dma == SNDRV_AUTO_DMA) {
228 if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) { 211 if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) {
229 snd_printk("unable to find a free DMA for GF1\n"); 212 snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n");
230 err = -EBUSY; 213 err = -EBUSY;
231 goto out; 214 goto out;
232 } 215 }
@@ -234,7 +217,7 @@ static int __init snd_gusextreme_probe(int dev)
234 xess_dma = dma8[dev]; 217 xess_dma = dma8[dev];
235 if (xess_dma == SNDRV_AUTO_DMA) { 218 if (xess_dma == SNDRV_AUTO_DMA) {
236 if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) { 219 if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) {
237 snd_printk("unable to find a free DMA for ES1688\n"); 220 snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n");
238 err = -EBUSY; 221 err = -EBUSY;
239 goto out; 222 goto out;
240 } 223 }
@@ -264,7 +247,7 @@ static int __init snd_gusextreme_probe(int dev)
264 goto out; 247 goto out;
265 248
266 if (!gus->ess_flag) { 249 if (!gus->ess_flag) {
267 snd_printdd("GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); 250 snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port);
268 err = -ENODEV; 251 err = -ENODEV;
269 goto out; 252 goto out;
270 } 253 }
@@ -287,7 +270,7 @@ static int __init snd_gusextreme_probe(int dev)
287 270
288 if (snd_opl3_create(card, es1688->port, es1688->port + 2, 271 if (snd_opl3_create(card, es1688->port, es1688->port + 2,
289 OPL3_HW_OPL3, 0, &opl3) < 0) { 272 OPL3_HW_OPL3, 0, &opl3) < 0) {
290 printk(KERN_ERR "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); 273 printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port);
291 } else { 274 } else {
292 if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) 275 if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0)
293 goto out; 276 goto out;
@@ -303,6 +286,10 @@ static int __init snd_gusextreme_probe(int dev)
303 286
304 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", 287 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i",
305 es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); 288 es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma);
289
290 if ((err = snd_card_set_generic_dev(card)) < 0)
291 goto out;
292
306 if ((err = snd_card_register(card)) < 0) 293 if ((err = snd_card_register(card)) < 0)
307 goto out; 294 goto out;
308 295
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 {
82 82
83static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 83static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
84 84
85#define PFX "gusmax: "
85 86
86static int __init snd_gusmax_detect(snd_gus_card_t * gus) 87static int __init snd_gusmax_detect(snd_gus_card_t * gus)
87{ 88{
88 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 89 unsigned char d;
89#ifdef CONFIG_SND_DEBUG_DETECT
90 {
91 unsigned char d;
92 90
93 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { 91 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
94 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); 92 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
95 return -ENODEV; 93 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
96 }
97 }
98#else
99 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
100 return -ENODEV; 94 return -ENODEV;
101#endif 95 }
102 udelay(160); 96 udelay(160);
103 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 97 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
104 udelay(160); 98 udelay(160);
105#ifdef CONFIG_SND_DEBUG_DETECT 99 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
106 { 100 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
107 unsigned char d;
108
109 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
110 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
111 return -ENODEV;
112 }
113 }
114#else
115 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
116 return -ENODEV; 101 return -ENODEV;
117#endif 102 }
103
118 return 0; 104 return 0;
119} 105}
120 106
@@ -239,25 +225,25 @@ static int __init snd_gusmax_probe(int dev)
239 xirq = irq[dev]; 225 xirq = irq[dev];
240 if (xirq == SNDRV_AUTO_IRQ) { 226 if (xirq == SNDRV_AUTO_IRQ) {
241 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 227 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
242 snd_card_free(card); 228 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
243 snd_printk("unable to find a free IRQ\n"); 229 err = -EBUSY;
244 return -EBUSY; 230 goto _err;
245 } 231 }
246 } 232 }
247 xdma1 = dma1[dev]; 233 xdma1 = dma1[dev];
248 if (xdma1 == SNDRV_AUTO_DMA) { 234 if (xdma1 == SNDRV_AUTO_DMA) {
249 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 235 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
250 snd_card_free(card); 236 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
251 snd_printk("unable to find a free DMA1\n"); 237 err = -EBUSY;
252 return -EBUSY; 238 goto _err;
253 } 239 }
254 } 240 }
255 xdma2 = dma2[dev]; 241 xdma2 = dma2[dev];
256 if (xdma2 == SNDRV_AUTO_DMA) { 242 if (xdma2 == SNDRV_AUTO_DMA) {
257 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 243 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
258 snd_card_free(card); 244 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
259 snd_printk("unable to find a free DMA2\n"); 245 err = -EBUSY;
260 return -EBUSY; 246 goto _err;
261 } 247 }
262 } 248 }
263 249
@@ -266,31 +252,28 @@ static int __init snd_gusmax_probe(int dev)
266 -xirq, xdma1, xdma2, 252 -xirq, xdma1, xdma2,
267 0, channels[dev], 253 0, channels[dev],
268 pcm_channels[dev], 254 pcm_channels[dev],
269 0, &gus)) < 0) { 255 0, &gus)) < 0)
270 snd_card_free(card); 256 goto _err;
271 return err; 257
272 } 258 if ((err = snd_gusmax_detect(gus)) < 0)
273 if ((err = snd_gusmax_detect(gus)) < 0) { 259 goto _err;
274 snd_card_free(card); 260
275 return err;
276 }
277 maxcard->gus_status_reg = gus->gf1.reg_irqstat; 261 maxcard->gus_status_reg = gus->gf1.reg_irqstat;
278 maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; 262 maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2;
279 snd_gusmax_init(dev, card, gus); 263 snd_gusmax_init(dev, card, gus);
280 if ((err = snd_gus_initialize(gus)) < 0) { 264 if ((err = snd_gus_initialize(gus)) < 0)
281 snd_card_free(card); 265 goto _err;
282 return err; 266
283 }
284 if (!gus->max_flag) { 267 if (!gus->max_flag) {
285 printk(KERN_ERR "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); 268 snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port);
286 snd_card_free(card); 269 err = -ENODEV;
287 return -ENODEV; 270 goto _err;
288 } 271 }
289 272
290 if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) { 273 if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) {
291 snd_card_free(card); 274 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
292 printk(KERN_ERR "gusmax: unable to grab IRQ %d\n", xirq); 275 err = -EBUSY;
293 return -EBUSY; 276 goto _err;
294 } 277 }
295 maxcard->irq = xirq; 278 maxcard->irq = xirq;
296 279
@@ -301,50 +284,46 @@ static int __init snd_gusmax_probe(int dev)
301 CS4231_HWSHARE_IRQ | 284 CS4231_HWSHARE_IRQ |
302 CS4231_HWSHARE_DMA1 | 285 CS4231_HWSHARE_DMA1 |
303 CS4231_HWSHARE_DMA2, 286 CS4231_HWSHARE_DMA2,
304 &cs4231)) < 0) { 287 &cs4231)) < 0)
305 snd_card_free(card); 288 goto _err;
306 return err; 289
307 } 290 if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0)
308 if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) { 291 goto _err;
309 snd_card_free(card); 292
310 return err; 293 if ((err = snd_cs4231_mixer(cs4231)) < 0)
311 } 294 goto _err;
312 if ((err = snd_cs4231_mixer(cs4231)) < 0) { 295
313 snd_card_free(card); 296 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0)
314 return err; 297 goto _err;
315 } 298
316 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) {
317 snd_card_free(card);
318 return err;
319 }
320 if (pcm_channels[dev] > 0) { 299 if (pcm_channels[dev] > 0) {
321 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { 300 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
322 snd_card_free(card); 301 goto _err;
323 return err;
324 }
325 }
326 if ((err = snd_gusmax_mixer(cs4231)) < 0) {
327 snd_card_free(card);
328 return err;
329 } 302 }
303 if ((err = snd_gusmax_mixer(cs4231)) < 0)
304 goto _err;
330 305
331 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 306 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
332 snd_card_free(card); 307 goto _err;
333 return err;
334 }
335 308
336 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1); 309 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1);
337 if (xdma2 >= 0) 310 if (xdma2 >= 0)
338 sprintf(card->longname + strlen(card->longname), "&%i", xdma2); 311 sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
339 if ((err = snd_card_register(card)) < 0) { 312
340 snd_card_free(card); 313 if ((err = snd_card_set_generic_dev(card)) < 0)
341 return err; 314 goto _err;
342 } 315
316 if ((err = snd_card_register(card)) < 0)
317 goto _err;
343 318
344 maxcard->gus = gus; 319 maxcard->gus = gus;
345 maxcard->cs4231 = cs4231; 320 maxcard->cs4231 = cs4231;
346 snd_gusmax_cards[dev] = card; 321 snd_gusmax_cards[dev] = card;
347 return 0; 322 return 0;
323
324 _err:
325 snd_card_free(card);
326 return err;
348} 327}
349 328
350static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) 329static 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};
73static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 73static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
74static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; 74static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
75 75
76#ifdef SNDRV_STB
77#define PFX "interwave-stb: "
78#else
79#define PFX "interwave: "
80#endif
81
76module_param_array(index, int, NULL, 0444); 82module_param_array(index, int, NULL, 0444);
77MODULE_PARM_DESC(index, "Index value for InterWave soundcard."); 83MODULE_PARM_DESC(index, "Index value for InterWave soundcard.");
78module_param_array(id, charp, NULL, 0444); 84module_param_array(id, charp, NULL, 0444);
@@ -249,38 +255,20 @@ static int __devinit snd_interwave_detect(struct snd_interwave *iwcard,
249{ 255{
250 unsigned long flags; 256 unsigned long flags;
251 unsigned char rev1, rev2; 257 unsigned char rev1, rev2;
258 int d;
252 259
253 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 260 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
254#ifdef CONFIG_SND_DEBUG_DETECT 261 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
255 { 262 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
256 int d;
257
258 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
259 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
260 return -ENODEV;
261 }
262 }
263#else
264 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
265 return -ENODEV; 263 return -ENODEV;
266#endif 264 }
267 udelay(160); 265 udelay(160);
268 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 266 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
269 udelay(160); 267 udelay(160);
270#ifdef CONFIG_SND_DEBUG_DETECT 268 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
271 { 269 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
272 int d;
273
274 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
275 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
276 return -ENODEV;
277 }
278 }
279#else
280 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
281 return -ENODEV; 270 return -ENODEV;
282#endif 271 }
283
284 spin_lock_irqsave(&gus->reg_lock, flags); 272 spin_lock_irqsave(&gus->reg_lock, flags);
285 rev1 = snd_gf1_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER); 273 rev1 = snd_gf1_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER);
286 snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, ~rev1); 274 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,
686 card->private_free = snd_interwave_free; 674 card->private_free = snd_interwave_free;
687#ifdef CONFIG_PNP 675#ifdef CONFIG_PNP
688 if (isapnp[dev]) { 676 if (isapnp[dev]) {
689 if (snd_interwave_pnp(dev, iwcard, pcard, pid)) { 677 if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0)
690 snd_card_free(card); 678 goto _err;
691 return -ENODEV;
692 }
693 snd_card_set_dev(card, &pcard->card->dev); 679 snd_card_set_dev(card, &pcard->card->dev);
694 } 680 }
695#endif 681#endif
696 xirq = irq[dev]; 682 xirq = irq[dev];
697 if (xirq == SNDRV_AUTO_IRQ) { 683 if (xirq == SNDRV_AUTO_IRQ) {
698 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 684 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
699 snd_card_free(card); 685 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
700 snd_printk("unable to find a free IRQ\n"); 686 err = -EBUSY;
701 return -EBUSY; 687 goto _err;
702 } 688 }
703 } 689 }
704 xdma1 = dma1[dev]; 690 xdma1 = dma1[dev];
705 if (xdma1 == SNDRV_AUTO_DMA) { 691 if (xdma1 == SNDRV_AUTO_DMA) {
706 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 692 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
707 snd_card_free(card); 693 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
708 snd_printk("unable to find a free DMA1\n"); 694 err = -EBUSY;
709 return -EBUSY; 695 goto _err;
710 } 696 }
711 } 697 }
712 xdma2 = dma2[dev]; 698 xdma2 = dma2[dev];
713 if (xdma2 == SNDRV_AUTO_DMA) { 699 if (xdma2 == SNDRV_AUTO_DMA) {
714 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 700 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
715 snd_card_free(card); 701 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
716 snd_printk("unable to find a free DMA2\n"); 702 err = -EBUSY;
717 return -EBUSY; 703 goto _err;
718 } 704 }
719 } 705 }
720 706
@@ -722,32 +708,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
722 port[dev], 708 port[dev],
723 -xirq, xdma1, xdma2, 709 -xirq, xdma1, xdma2,
724 0, 32, 710 0, 32,
725 pcm_channels[dev], effect[dev], &gus)) < 0) { 711 pcm_channels[dev], effect[dev], &gus)) < 0)
726 snd_card_free(card); 712 goto _err;
727 return err; 713
728 }
729 if ((err = snd_interwave_detect(iwcard, gus, dev 714 if ((err = snd_interwave_detect(iwcard, gus, dev
730#ifdef SNDRV_STB 715#ifdef SNDRV_STB
731 , &i2c_bus 716 , &i2c_bus
732#endif 717#endif
733 )) < 0) { 718 )) < 0)
734 snd_card_free(card); 719 goto _err;
735 return err; 720
736 }
737 iwcard->gus_status_reg = gus->gf1.reg_irqstat; 721 iwcard->gus_status_reg = gus->gf1.reg_irqstat;
738 iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; 722 iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2;
739 723
740 snd_interwave_init(dev, gus); 724 snd_interwave_init(dev, gus);
741 snd_interwave_detect_memory(gus); 725 snd_interwave_detect_memory(gus);
742 if ((err = snd_gus_initialize(gus)) < 0) { 726 if ((err = snd_gus_initialize(gus)) < 0)
743 snd_card_free(card); 727 goto _err;
744 return err;
745 }
746 728
747 if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { 729 if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) {
748 snd_card_free(card); 730 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
749 snd_printk("unable to grab IRQ %d\n", xirq); 731 err = -EBUSY;
750 return -EBUSY; 732 goto _err;
751 } 733 }
752 iwcard->irq = xirq; 734 iwcard->irq = xirq;
753 735
@@ -758,34 +740,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
758 CS4231_HWSHARE_IRQ | 740 CS4231_HWSHARE_IRQ |
759 CS4231_HWSHARE_DMA1 | 741 CS4231_HWSHARE_DMA1 |
760 CS4231_HWSHARE_DMA2, 742 CS4231_HWSHARE_DMA2,
761 &cs4231)) < 0) { 743 &cs4231)) < 0)
762 snd_card_free(card); 744 goto _err;
763 return err; 745
764 } 746 if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0)
765 if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) { 747 goto _err;
766 snd_card_free(card); 748
767 return err;
768 }
769 sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); 749 sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A');
770 strcat(pcm->name, " (codec)"); 750 strcat(pcm->name, " (codec)");
771 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) { 751
772 snd_card_free(card); 752 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0)
773 return err; 753 goto _err;
774 } 754
775 if ((err = snd_cs4231_mixer(cs4231)) < 0) { 755 if ((err = snd_cs4231_mixer(cs4231)) < 0)
776 snd_card_free(card); 756 goto _err;
777 return err; 757
778 }
779 if (pcm_channels[dev] > 0) { 758 if (pcm_channels[dev] > 0) {
780 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { 759 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
781 snd_card_free(card); 760 goto _err;
782 return err;
783 }
784 }
785 if ((err = snd_interwave_mixer(cs4231)) < 0) {
786 snd_card_free(card);
787 return err;
788 } 761 }
762 if ((err = snd_interwave_mixer(cs4231)) < 0)
763 goto _err;
764
789#ifdef SNDRV_STB 765#ifdef SNDRV_STB
790 { 766 {
791 snd_ctl_elem_id_t id1, id2; 767 snd_ctl_elem_id_t id1, id2;
@@ -795,28 +771,20 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
795 strcpy(id1.name, "Master Playback Switch"); 771 strcpy(id1.name, "Master Playback Switch");
796 strcpy(id2.name, id1.name); 772 strcpy(id2.name, id1.name);
797 id2.index = 1; 773 id2.index = 1;
798 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { 774 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
799 snd_card_free(card); 775 goto _err;
800 return err;
801 }
802 strcpy(id1.name, "Master Playback Volume"); 776 strcpy(id1.name, "Master Playback Volume");
803 strcpy(id2.name, id1.name); 777 strcpy(id2.name, id1.name);
804 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { 778 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
805 snd_card_free(card); 779 goto _err;
806 return err; 780 if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0)
807 } 781 goto _err;
808 if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) {
809 snd_card_free(card);
810 return err;
811 }
812 } 782 }
813#endif 783#endif
814 784
815 gus->uart_enable = midi[dev]; 785 gus->uart_enable = midi[dev];
816 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 786 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
817 snd_card_free(card); 787 goto _err;
818 return err;
819 }
820 788
821#ifndef SNDRV_STB 789#ifndef SNDRV_STB
822 str = "AMD InterWave"; 790 str = "AMD InterWave";
@@ -835,10 +803,11 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
835 if (xdma2 >= 0) 803 if (xdma2 >= 0)
836 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 804 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
837 805
838 if ((err = snd_card_register(card)) < 0) { 806 if ((err = snd_card_set_generic_dev(card)) < 0)
839 snd_card_free(card); 807 goto _err;
840 return err; 808
841 } 809 if ((err = snd_card_register(card)) < 0)
810 goto _err;
842 811
843 iwcard->cs4231 = cs4231; 812 iwcard->cs4231 = cs4231;
844 iwcard->gus = gus; 813 iwcard->gus = gus;
@@ -847,6 +816,10 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
847 else 816 else
848 snd_interwave_legacy[dev++] = card; 817 snd_interwave_legacy[dev++] = card;
849 return 0; 818 return 0;
819
820 _err:
821 snd_card_free(card);
822 return err;
850} 823}
851 824
852static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) 825static int __devinit snd_interwave_probe_legacy_port(unsigned long xport)