X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sound%2Fdrivers%2Fmpu401%2Fmpu401_uart.c;h=b57f2d5a1c9dff920e17c2ada69d009e090bbd21;hb=8002cedc1adbf51e2d56091534ef7551b88329b4;hp=4bf07ca9b17d625bcfc49b30bc5e13729faf089c;hpb=eaa8568901b3164197ce727c4c9b4067383e526c;p=linux-2.6 diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 4bf07ca9b1..b57f2d5a1c 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -1,5 +1,5 @@ /* - * Copyright (c) by Jaroslav Kysela + * Copyright (c) by Jaroslav Kysela * Routines for control of MPU-401 in UART mode * * MPU-401 supports UART mode which is not capable generate transmit @@ -39,7 +39,7 @@ #include #include -MODULE_AUTHOR("Jaroslav Kysela "); +MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Routines for control of MPU-401 in UART mode"); MODULE_LICENSE("GPL"); @@ -97,23 +97,27 @@ static void snd_mpu401_uart_clear_rx(struct snd_mpu401 *mpu) static void uart_interrupt_tx(struct snd_mpu401 *mpu) { + unsigned long flags; + if (test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode) && test_bit(MPU401_MODE_BIT_OUTPUT_TRIGGER, &mpu->mode)) { - spin_lock(&mpu->output_lock); + spin_lock_irqsave(&mpu->output_lock, flags); snd_mpu401_uart_output_write(mpu); - spin_unlock(&mpu->output_lock); + spin_unlock_irqrestore(&mpu->output_lock, flags); } } static void _snd_mpu401_uart_interrupt(struct snd_mpu401 *mpu) { + unsigned long flags; + if (mpu->info_flags & MPU401_INFO_INPUT) { - spin_lock(&mpu->input_lock); + spin_lock_irqsave(&mpu->input_lock, flags); if (test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) snd_mpu401_uart_input_read(mpu); else snd_mpu401_uart_clear_rx(mpu); - spin_unlock(&mpu->input_lock); + spin_unlock_irqrestore(&mpu->input_lock, flags); } if (! (mpu->info_flags & MPU401_INFO_TX_IRQ)) /* ok. for better Tx performance try do some output @@ -125,12 +129,10 @@ static void _snd_mpu401_uart_interrupt(struct snd_mpu401 *mpu) * snd_mpu401_uart_interrupt - generic MPU401-UART interrupt handler * @irq: the irq number * @dev_id: mpu401 instance - * @regs: the reigster * * Processes the interrupt for MPU401-UART i/o. */ -irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id, - struct pt_regs *regs) +irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id) { struct snd_mpu401 *mpu = dev_id; @@ -146,12 +148,10 @@ EXPORT_SYMBOL(snd_mpu401_uart_interrupt); * snd_mpu401_uart_interrupt_tx - generic MPU401-UART transmit irq handler * @irq: the irq number * @dev_id: mpu401 instance - * @regs: the reigster * * Processes the interrupt for MPU401-UART output. */ -irqreturn_t snd_mpu401_uart_interrupt_tx(int irq, void *dev_id, - struct pt_regs *regs) +irqreturn_t snd_mpu401_uart_interrupt_tx(int irq, void *dev_id) { struct snd_mpu401 *mpu = dev_id; @@ -270,6 +270,15 @@ 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 (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 0)) + return -EIO; + return 0; +} + /* * input/output open/close - protected by open_mutex in rawmidi.c */ @@ -282,9 +291,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; @@ -306,9 +313,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;