summaryrefslogtreecommitdiff
path: root/sound/drivers/mpu401/mpu401_uart.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/drivers/mpu401/mpu401_uart.c')
-rw-r--r--sound/drivers/mpu401/mpu401_uart.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
index 3daa9fa56c0b..85aedc348e2d 100644
--- a/sound/drivers/mpu401/mpu401_uart.c
+++ b/sound/drivers/mpu401/mpu401_uart.c
@@ -266,6 +266,16 @@ static int snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd,
return 0;
}
+static int snd_mpu401_do_reset(struct snd_mpu401 *mpu)
+{
+ if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1))
+ return -EIO;
+ if (!(mpu->info_flags & MPU401_INFO_UART_ONLY) &&
+ snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
+ return -EIO;
+ return 0;
+}
+
/*
* input/output open/close - protected by open_mutex in rawmidi.c
*/
@@ -278,9 +288,7 @@ static int snd_mpu401_uart_input_open(struct snd_rawmidi_substream *substream)
if (mpu->open_input && (err = mpu->open_input(mpu)) < 0)
return err;
if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) {
- if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1))
- goto error_out;
- if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
+ if (snd_mpu401_do_reset(mpu) < 0)
goto error_out;
}
mpu->substream_input = substream;
@@ -302,9 +310,7 @@ static int snd_mpu401_uart_output_open(struct snd_rawmidi_substream *substream)
if (mpu->open_output && (err = mpu->open_output(mpu)) < 0)
return err;
if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) {
- if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1))
- goto error_out;
- if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
+ if (snd_mpu401_do_reset(mpu) < 0)
goto error_out;
}
mpu->substream_output = substream;