aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorRandy Dunlap <randy.dunlap@oracle.com>2006-07-04 08:25:26 -0400
committerJaroslav Kysela <perex@suse.cz>2006-07-12 14:07:51 -0400
commitb130807dce4a8f91f9662e93d1aa813d806e14a8 (patch)
treeb8570b43ecf1d0347b46eba67082d623a74c7cc8 /sound
parent40e1a9c0d428740a5c10a5be2335b9d7c39df043 (diff)
[ALSA] Fix no mpu401 interface can cause hard freeze
This patch fixes the remaining instances in our tree where a non- existent mpu401 interface can cause a hard freeze when i/o is issued. This commit closes Malone #34831. Bug: https://launchpad.net/distros/ubuntu/+source/linux-source-2.6.15/+bug/34831 patch location: http://www.kernel.org/git/?p=linux/kernel/git/bcollins/ubuntu-dapper.git;a=commitdiff;h=b422309cdd980cfefe99379796c04e961d3c1544 From: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/emu10k1/emu10k1x.c35
-rw-r--r--sound/pci/emu10k1/emumpu401.c35
2 files changed, 50 insertions, 20 deletions
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 2167279429b8..d0aa1e1031d6 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -1286,7 +1286,7 @@ static void snd_emu10k1x_midi_interrupt(struct emu10k1x *emu, unsigned int statu
1286 do_emu10k1x_midi_interrupt(emu, &emu->midi, status); 1286 do_emu10k1x_midi_interrupt(emu, &emu->midi, status);
1287} 1287}
1288 1288
1289static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu, 1289static int snd_emu10k1x_midi_cmd(struct emu10k1x * emu,
1290 struct emu10k1x_midi *midi, unsigned char cmd, int ack) 1290 struct emu10k1x_midi *midi, unsigned char cmd, int ack)
1291{ 1291{
1292 unsigned long flags; 1292 unsigned long flags;
@@ -1312,11 +1312,14 @@ static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu,
1312 ok = 1; 1312 ok = 1;
1313 } 1313 }
1314 spin_unlock_irqrestore(&midi->input_lock, flags); 1314 spin_unlock_irqrestore(&midi->input_lock, flags);
1315 if (!ok) 1315 if (!ok) {
1316 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 1316 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",
1317 cmd, emu->port, 1317 cmd, emu->port,
1318 mpu401_read_stat(emu, midi), 1318 mpu401_read_stat(emu, midi),
1319 mpu401_read_data(emu, midi)); 1319 mpu401_read_data(emu, midi));
1320 return 1;
1321 }
1322 return 0;
1320} 1323}
1321 1324
1322static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream) 1325static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream)
@@ -1332,12 +1335,17 @@ static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream)
1332 midi->substream_input = substream; 1335 midi->substream_input = substream;
1333 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) { 1336 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) {
1334 spin_unlock_irqrestore(&midi->open_lock, flags); 1337 spin_unlock_irqrestore(&midi->open_lock, flags);
1335 snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1); 1338 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1))
1336 snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1); 1339 goto error_out;
1340 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1))
1341 goto error_out;
1337 } else { 1342 } else {
1338 spin_unlock_irqrestore(&midi->open_lock, flags); 1343 spin_unlock_irqrestore(&midi->open_lock, flags);
1339 } 1344 }
1340 return 0; 1345 return 0;
1346
1347error_out:
1348 return -EIO;
1341} 1349}
1342 1350
1343static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream) 1351static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream)
@@ -1353,12 +1361,17 @@ static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream
1353 midi->substream_output = substream; 1361 midi->substream_output = substream;
1354 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { 1362 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) {
1355 spin_unlock_irqrestore(&midi->open_lock, flags); 1363 spin_unlock_irqrestore(&midi->open_lock, flags);
1356 snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1); 1364 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1))
1357 snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1); 1365 goto error_out;
1366 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1))
1367 goto error_out;
1358 } else { 1368 } else {
1359 spin_unlock_irqrestore(&midi->open_lock, flags); 1369 spin_unlock_irqrestore(&midi->open_lock, flags);
1360 } 1370 }
1361 return 0; 1371 return 0;
1372
1373error_out:
1374 return -EIO;
1362} 1375}
1363 1376
1364static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream) 1377static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream)
@@ -1366,6 +1379,7 @@ static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream
1366 struct emu10k1x *emu; 1379 struct emu10k1x *emu;
1367 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1380 struct emu10k1x_midi *midi = substream->rmidi->private_data;
1368 unsigned long flags; 1381 unsigned long flags;
1382 int err = 0;
1369 1383
1370 emu = midi->emu; 1384 emu = midi->emu;
1371 snd_assert(emu, return -ENXIO); 1385 snd_assert(emu, return -ENXIO);
@@ -1375,11 +1389,11 @@ static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream
1375 midi->substream_input = NULL; 1389 midi->substream_input = NULL;
1376 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) { 1390 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) {
1377 spin_unlock_irqrestore(&midi->open_lock, flags); 1391 spin_unlock_irqrestore(&midi->open_lock, flags);
1378 snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0); 1392 err = snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0);
1379 } else { 1393 } else {
1380 spin_unlock_irqrestore(&midi->open_lock, flags); 1394 spin_unlock_irqrestore(&midi->open_lock, flags);
1381 } 1395 }
1382 return 0; 1396 return err;
1383} 1397}
1384 1398
1385static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream) 1399static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream)
@@ -1387,6 +1401,7 @@ static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substrea
1387 struct emu10k1x *emu; 1401 struct emu10k1x *emu;
1388 struct emu10k1x_midi *midi = substream->rmidi->private_data; 1402 struct emu10k1x_midi *midi = substream->rmidi->private_data;
1389 unsigned long flags; 1403 unsigned long flags;
1404 int err = 0;
1390 1405
1391 emu = midi->emu; 1406 emu = midi->emu;
1392 snd_assert(emu, return -ENXIO); 1407 snd_assert(emu, return -ENXIO);
@@ -1396,11 +1411,11 @@ static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substrea
1396 midi->substream_output = NULL; 1411 midi->substream_output = NULL;
1397 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { 1412 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) {
1398 spin_unlock_irqrestore(&midi->open_lock, flags); 1413 spin_unlock_irqrestore(&midi->open_lock, flags);
1399 snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0); 1414 err = snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0);
1400 } else { 1415 } else {
1401 spin_unlock_irqrestore(&midi->open_lock, flags); 1416 spin_unlock_irqrestore(&midi->open_lock, flags);
1402 } 1417 }
1403 return 0; 1418 return err;
1404} 1419}
1405 1420
1406static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 1421static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
diff --git a/sound/pci/emu10k1/emumpu401.c b/sound/pci/emu10k1/emumpu401.c
index d96eb455103f..950c6bcd6b7d 100644
--- a/sound/pci/emu10k1/emumpu401.c
+++ b/sound/pci/emu10k1/emumpu401.c
@@ -116,7 +116,7 @@ static void snd_emu10k1_midi_interrupt2(struct snd_emu10k1 *emu, unsigned int st
116 do_emu10k1_midi_interrupt(emu, &emu->midi2, status); 116 do_emu10k1_midi_interrupt(emu, &emu->midi2, status);
117} 117}
118 118
119static void snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_midi *midi, unsigned char cmd, int ack) 119static int snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_midi *midi, unsigned char cmd, int ack)
120{ 120{
121 unsigned long flags; 121 unsigned long flags;
122 int timeout, ok; 122 int timeout, ok;
@@ -141,11 +141,14 @@ static void snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_mi
141 ok = 1; 141 ok = 1;
142 } 142 }
143 spin_unlock_irqrestore(&midi->input_lock, flags); 143 spin_unlock_irqrestore(&midi->input_lock, flags);
144 if (!ok) 144 if (!ok) {
145 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 145 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",
146 cmd, emu->port, 146 cmd, emu->port,
147 mpu401_read_stat(emu, midi), 147 mpu401_read_stat(emu, midi),
148 mpu401_read_data(emu, midi)); 148 mpu401_read_data(emu, midi));
149 return 1;
150 }
151 return 0;
149} 152}
150 153
151static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream) 154static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream)
@@ -161,12 +164,17 @@ static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream)
161 midi->substream_input = substream; 164 midi->substream_input = substream;
162 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 165 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) {
163 spin_unlock_irqrestore(&midi->open_lock, flags); 166 spin_unlock_irqrestore(&midi->open_lock, flags);
164 snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1); 167 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1))
165 snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1); 168 goto error_out;
169 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1))
170 goto error_out;
166 } else { 171 } else {
167 spin_unlock_irqrestore(&midi->open_lock, flags); 172 spin_unlock_irqrestore(&midi->open_lock, flags);
168 } 173 }
169 return 0; 174 return 0;
175
176error_out:
177 return -EIO;
170} 178}
171 179
172static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream) 180static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream)
@@ -182,12 +190,17 @@ static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream)
182 midi->substream_output = substream; 190 midi->substream_output = substream;
183 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 191 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) {
184 spin_unlock_irqrestore(&midi->open_lock, flags); 192 spin_unlock_irqrestore(&midi->open_lock, flags);
185 snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1); 193 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1))
186 snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1); 194 goto error_out;
195 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1))
196 goto error_out;
187 } else { 197 } else {
188 spin_unlock_irqrestore(&midi->open_lock, flags); 198 spin_unlock_irqrestore(&midi->open_lock, flags);
189 } 199 }
190 return 0; 200 return 0;
201
202error_out:
203 return -EIO;
191} 204}
192 205
193static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream) 206static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream)
@@ -195,6 +208,7 @@ static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream)
195 struct snd_emu10k1 *emu; 208 struct snd_emu10k1 *emu;
196 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 209 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data;
197 unsigned long flags; 210 unsigned long flags;
211 int err = 0;
198 212
199 emu = midi->emu; 213 emu = midi->emu;
200 snd_assert(emu, return -ENXIO); 214 snd_assert(emu, return -ENXIO);
@@ -204,11 +218,11 @@ static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream)
204 midi->substream_input = NULL; 218 midi->substream_input = NULL;
205 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 219 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) {
206 spin_unlock_irqrestore(&midi->open_lock, flags); 220 spin_unlock_irqrestore(&midi->open_lock, flags);
207 snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 221 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0);
208 } else { 222 } else {
209 spin_unlock_irqrestore(&midi->open_lock, flags); 223 spin_unlock_irqrestore(&midi->open_lock, flags);
210 } 224 }
211 return 0; 225 return err;
212} 226}
213 227
214static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream) 228static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream)
@@ -216,6 +230,7 @@ static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream
216 struct snd_emu10k1 *emu; 230 struct snd_emu10k1 *emu;
217 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 231 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data;
218 unsigned long flags; 232 unsigned long flags;
233 int err = 0;
219 234
220 emu = midi->emu; 235 emu = midi->emu;
221 snd_assert(emu, return -ENXIO); 236 snd_assert(emu, return -ENXIO);
@@ -225,11 +240,11 @@ static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream
225 midi->substream_output = NULL; 240 midi->substream_output = NULL;
226 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 241 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) {
227 spin_unlock_irqrestore(&midi->open_lock, flags); 242 spin_unlock_irqrestore(&midi->open_lock, flags);
228 snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 243 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0);
229 } else { 244 } else {
230 spin_unlock_irqrestore(&midi->open_lock, flags); 245 spin_unlock_irqrestore(&midi->open_lock, flags);
231 } 246 }
232 return 0; 247 return err;
233} 248}
234 249
235static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 250static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)