aboutsummaryrefslogtreecommitdiffstats
path: root/sound/drivers
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2011-09-13 05:24:41 -0400
committerTakashi Iwai <tiwai@suse.de>2011-09-14 05:00:51 -0400
commitdba8b46992c55946d3b092934f581a343403118f (patch)
tree7ea5af971bc5cc8ecf4c8af1e0547fa11291ba86 /sound/drivers
parent47124373b59e43fd07cbf7b44d9288f19c1d5a93 (diff)
ALSA: mpu401: clean up interrupt specification
The semantics of snd_mpu401_uart_new()'s interrupt parameters are somewhat counterintuitive: To prevent the function from allocating its own interrupt, either the irq number must be invalid, or the irq_flags parameter must be zero. At the same time, the irq parameter being invalid specifies that the mpu401 code has to work without an interrupt allocated by the caller. This implies that, if there is an interrupt and it is allocated by the caller, the irq parameter must be set to a valid-looking number which then isn't actually used. With the removal of IRQF_DISABLED, zero becomes a valid irq_flags value, which forces us to handle the parameters differently. This patch introduces a new flag MPU401_INFO_IRQ_HOOK for when the device interrupt is handled by the caller, and makes the allocation of the interrupt to depend only on the irq parameter. As suggested by Takashi, the irq_flags parameter was dropped because, when used, it had the constant value IRQF_DISABLED. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/drivers')
-rw-r--r--sound/drivers/mpu401/mpu401.c3
-rw-r--r--sound/drivers/mpu401/mpu401_uart.c20
2 files changed, 11 insertions, 12 deletions
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index 149d05a8202d..1c02852aceea 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -86,8 +86,7 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard)
86 } 86 }
87 87
88 err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev], 0, 88 err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev], 0,
89 irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, 89 irq[dev], NULL);
90 NULL);
91 if (err < 0) { 90 if (err < 0) {
92 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); 91 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]);
93 goto _err; 92 goto _err;
diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
index 2af09996a3d0..9d01c181feca 100644
--- a/sound/drivers/mpu401/mpu401_uart.c
+++ b/sound/drivers/mpu401/mpu401_uart.c
@@ -3,7 +3,7 @@
3 * Routines for control of MPU-401 in UART mode 3 * Routines for control of MPU-401 in UART mode
4 * 4 *
5 * MPU-401 supports UART mode which is not capable generate transmit 5 * MPU-401 supports UART mode which is not capable generate transmit
6 * interrupts thus output is done via polling. Also, if irq < 0, then 6 * interrupts thus output is done via polling. Without interrupt,
7 * input is done also via polling. Do not expect good performance. 7 * input is done also via polling. Do not expect good performance.
8 * 8 *
9 * 9 *
@@ -374,7 +374,7 @@ snd_mpu401_uart_input_trigger(struct snd_rawmidi_substream *substream, int up)
374 /* first time - flush FIFO */ 374 /* first time - flush FIFO */
375 while (max-- > 0) 375 while (max-- > 0)
376 mpu->read(mpu, MPU401D(mpu)); 376 mpu->read(mpu, MPU401D(mpu));
377 if (mpu->irq < 0) 377 if (mpu->info_flags & MPU401_INFO_USE_TIMER)
378 snd_mpu401_uart_add_timer(mpu, 1); 378 snd_mpu401_uart_add_timer(mpu, 1);
379 } 379 }
380 380
@@ -383,7 +383,7 @@ snd_mpu401_uart_input_trigger(struct snd_rawmidi_substream *substream, int up)
383 snd_mpu401_uart_input_read(mpu); 383 snd_mpu401_uart_input_read(mpu);
384 spin_unlock_irqrestore(&mpu->input_lock, flags); 384 spin_unlock_irqrestore(&mpu->input_lock, flags);
385 } else { 385 } else {
386 if (mpu->irq < 0) 386 if (mpu->info_flags & MPU401_INFO_USE_TIMER)
387 snd_mpu401_uart_remove_timer(mpu, 1); 387 snd_mpu401_uart_remove_timer(mpu, 1);
388 clear_bit(MPU401_MODE_BIT_INPUT_TRIGGER, &mpu->mode); 388 clear_bit(MPU401_MODE_BIT_INPUT_TRIGGER, &mpu->mode);
389 } 389 }
@@ -496,7 +496,7 @@ static struct snd_rawmidi_ops snd_mpu401_uart_input =
496static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi) 496static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi)
497{ 497{
498 struct snd_mpu401 *mpu = rmidi->private_data; 498 struct snd_mpu401 *mpu = rmidi->private_data;
499 if (mpu->irq_flags && mpu->irq >= 0) 499 if (mpu->irq >= 0)
500 free_irq(mpu->irq, (void *) mpu); 500 free_irq(mpu->irq, (void *) mpu);
501 release_and_free_resource(mpu->res); 501 release_and_free_resource(mpu->res);
502 kfree(mpu); 502 kfree(mpu);
@@ -509,8 +509,7 @@ static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi)
509 * @hardware: the hardware type, MPU401_HW_XXXX 509 * @hardware: the hardware type, MPU401_HW_XXXX
510 * @port: the base address of MPU401 port 510 * @port: the base address of MPU401 port
511 * @info_flags: bitflags MPU401_INFO_XXX 511 * @info_flags: bitflags MPU401_INFO_XXX
512 * @irq: the irq number, -1 if no interrupt for mpu 512 * @irq: the ISA irq number, -1 if not to be allocated
513 * @irq_flags: the irq request flags (SA_XXX), 0 if irq was already reserved.
514 * @rrawmidi: the pointer to store the new rawmidi instance 513 * @rrawmidi: the pointer to store the new rawmidi instance
515 * 514 *
516 * Creates a new MPU-401 instance. 515 * Creates a new MPU-401 instance.
@@ -525,7 +524,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,
525 unsigned short hardware, 524 unsigned short hardware,
526 unsigned long port, 525 unsigned long port,
527 unsigned int info_flags, 526 unsigned int info_flags,
528 int irq, int irq_flags, 527 int irq,
529 struct snd_rawmidi ** rrawmidi) 528 struct snd_rawmidi ** rrawmidi)
530{ 529{
531 struct snd_mpu401 *mpu; 530 struct snd_mpu401 *mpu;
@@ -577,8 +576,8 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,
577 mpu->cport = port + 2; 576 mpu->cport = port + 2;
578 else 577 else
579 mpu->cport = port + 1; 578 mpu->cport = port + 1;
580 if (irq >= 0 && irq_flags) { 579 if (irq >= 0) {
581 if (request_irq(irq, snd_mpu401_uart_interrupt, irq_flags, 580 if (request_irq(irq, snd_mpu401_uart_interrupt, IRQF_DISABLED,
582 "MPU401 UART", (void *) mpu)) { 581 "MPU401 UART", (void *) mpu)) {
583 snd_printk(KERN_ERR "mpu401_uart: " 582 snd_printk(KERN_ERR "mpu401_uart: "
584 "unable to grab IRQ %d\n", irq); 583 "unable to grab IRQ %d\n", irq);
@@ -586,9 +585,10 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,
586 return -EBUSY; 585 return -EBUSY;
587 } 586 }
588 } 587 }
588 if (irq < 0 && !(info_flags & MPU401_INFO_IRQ_HOOK))
589 info_flags |= MPU401_INFO_USE_TIMER;
589 mpu->info_flags = info_flags; 590 mpu->info_flags = info_flags;
590 mpu->irq = irq; 591 mpu->irq = irq;
591 mpu->irq_flags = irq_flags;
592 if (card->shortname[0]) 592 if (card->shortname[0])
593 snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI", 593 snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI",
594 card->shortname); 594 card->shortname);