diff options
Diffstat (limited to 'sound/pci/emu10k1/emu10k1x.c')
-rw-r--r-- | sound/pci/emu10k1/emu10k1x.c | 35 |
1 files changed, 25 insertions, 10 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 | ||
1289 | static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu, | 1289 | static 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 | ||
1322 | static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream) | 1325 | static 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 | |||
1347 | error_out: | ||
1348 | return -EIO; | ||
1341 | } | 1349 | } |
1342 | 1350 | ||
1343 | static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream) | 1351 | static 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 | |||
1373 | error_out: | ||
1374 | return -EIO; | ||
1362 | } | 1375 | } |
1363 | 1376 | ||
1364 | static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream) | 1377 | static 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 | ||
1385 | static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream) | 1399 | static 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 | ||
1406 | static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) | 1421 | static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) |