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>
This commit is contained in:

committed by
Takashi Iwai

parent
47124373b5
commit
dba8b46992
@@ -204,7 +204,7 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard
|
||||
|
||||
if (mpu_port[dev] > 0) {
|
||||
if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
|
||||
mpu_port[dev], 0, mpu_irq[dev], IRQF_DISABLED,
|
||||
mpu_port[dev], 0, mpu_irq[dev],
|
||||
NULL) < 0)
|
||||
printk(KERN_ERR PFX "no MPU-401 device at 0x%lx.\n", mpu_port[dev]);
|
||||
}
|
||||
|
@@ -256,7 +256,6 @@ static int __devinit snd_card_als100_probe(int dev,
|
||||
mpu_type,
|
||||
mpu_port[dev], 0,
|
||||
mpu_irq[dev],
|
||||
mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0,
|
||||
NULL) < 0)
|
||||
snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]);
|
||||
}
|
||||
|
@@ -234,8 +234,7 @@ static int __devinit snd_card_azt2320_probe(int dev,
|
||||
if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
|
||||
if (snd_mpu401_uart_new(card, 0, MPU401_HW_AZT2320,
|
||||
mpu_port[dev], 0,
|
||||
mpu_irq[dev], IRQF_DISABLED,
|
||||
NULL) < 0)
|
||||
mpu_irq[dev], NULL) < 0)
|
||||
snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]);
|
||||
}
|
||||
|
||||
|
@@ -597,7 +597,7 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
|
||||
if (mpuport[dev] != SNDRV_AUTO_PORT) {
|
||||
if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
|
||||
mpuport[dev], 0, mpuirq[dev],
|
||||
IRQF_DISABLED, NULL) < 0)
|
||||
NULL) < 0)
|
||||
printk(KERN_ERR PFX "no MPU-401 device at 0x%lx.\n",
|
||||
mpuport[dev]);
|
||||
}
|
||||
|
@@ -131,7 +131,6 @@ static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n)
|
||||
mpu_irq[n] = -1;
|
||||
if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
|
||||
mpu_port[n], 0, mpu_irq[n],
|
||||
mpu_irq[n] >= 0 ? IRQF_DISABLED : 0,
|
||||
NULL) < 0)
|
||||
dev_warn(dev, "MPU401 not detected\n");
|
||||
}
|
||||
|
@@ -449,8 +449,7 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
|
||||
mpu_irq[dev] = -1;
|
||||
if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
|
||||
mpu_port[dev], 0,
|
||||
mpu_irq[dev],
|
||||
mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL) < 0)
|
||||
mpu_irq[dev], NULL) < 0)
|
||||
printk(KERN_WARNING IDENT ": MPU401 not detected\n");
|
||||
}
|
||||
|
||||
|
@@ -174,7 +174,7 @@ static int __devinit snd_es1688_probe(struct snd_card *card, unsigned int n)
|
||||
chip->mpu_port > 0) {
|
||||
error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
|
||||
chip->mpu_port, 0,
|
||||
mpu_irq[n], IRQF_DISABLED, NULL);
|
||||
mpu_irq[n], NULL);
|
||||
if (error < 0)
|
||||
return error;
|
||||
}
|
||||
|
@@ -2160,8 +2160,8 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
|
||||
|
||||
if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
|
||||
err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX,
|
||||
mpu_port[dev], 0,
|
||||
irq[dev], 0, &chip->rmidi);
|
||||
mpu_port[dev], MPU401_INFO_IRQ_HOOK,
|
||||
-1, &chip->rmidi);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
@@ -585,8 +585,7 @@ static int __devinit snd_galaxy_probe(struct device *dev, unsigned int n)
|
||||
|
||||
if (mpu_port[n] >= 0) {
|
||||
err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
|
||||
mpu_port[n], 0, mpu_irq[n],
|
||||
IRQF_DISABLED, NULL);
|
||||
mpu_port[n], 0, mpu_irq[n], NULL);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
}
|
||||
|
@@ -317,8 +317,7 @@ static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
|
||||
|
||||
if (es1688->mpu_port >= 0x300) {
|
||||
error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
|
||||
es1688->mpu_port, 0,
|
||||
mpu_irq[n], IRQF_DISABLED, NULL);
|
||||
es1688->mpu_port, 0, mpu_irq[n], NULL);
|
||||
if (error < 0)
|
||||
goto out;
|
||||
}
|
||||
|
@@ -600,7 +600,7 @@ static int __devinit snd_msnd_attach(struct snd_card *card)
|
||||
mpu_io[0],
|
||||
MPU401_MODE_INPUT |
|
||||
MPU401_MODE_OUTPUT,
|
||||
mpu_irq[0], IRQF_DISABLED,
|
||||
mpu_irq[0],
|
||||
&chip->rmidi);
|
||||
if (err < 0) {
|
||||
printk(KERN_ERR LOGNAME
|
||||
|
@@ -707,8 +707,9 @@ static int __devinit snd_opl3sa2_probe(struct snd_card *card, int dev)
|
||||
}
|
||||
if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) {
|
||||
if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2,
|
||||
midi_port[dev], 0,
|
||||
xirq, 0, &chip->rmidi)) < 0)
|
||||
midi_port[dev],
|
||||
MPU401_INFO_IRQ_HOOK, -1,
|
||||
&chip->rmidi)) < 0)
|
||||
return err;
|
||||
}
|
||||
sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
|
||||
|
@@ -1377,8 +1377,7 @@ static int __devinit snd_miro_probe(struct snd_card *card)
|
||||
rmidi = NULL;
|
||||
else {
|
||||
error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
|
||||
mpu_port, 0, miro->mpu_irq, IRQF_DISABLED,
|
||||
&rmidi);
|
||||
mpu_port, 0, miro->mpu_irq, &rmidi);
|
||||
if (error < 0)
|
||||
snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
|
||||
mpu_port);
|
||||
|
@@ -914,7 +914,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
|
||||
rmidi = NULL;
|
||||
else {
|
||||
error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
|
||||
mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi);
|
||||
mpu_port, 0, mpu_irq, &rmidi);
|
||||
if (error)
|
||||
snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
|
||||
mpu_port);
|
||||
|
@@ -322,7 +322,6 @@ static int __devinit snd_jazz16_probe(struct device *devptr, unsigned int dev)
|
||||
MPU401_HW_MPU401,
|
||||
mpu_port[dev], 0,
|
||||
mpu_irq[dev],
|
||||
mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0,
|
||||
NULL) < 0)
|
||||
snd_printk(KERN_ERR "no MPU-401 device at 0x%lx\n",
|
||||
mpu_port[dev]);
|
||||
|
@@ -394,8 +394,9 @@ static int __devinit snd_sb16_probe(struct snd_card *card, int dev)
|
||||
|
||||
if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) {
|
||||
if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB,
|
||||
chip->mpu_port, 0,
|
||||
xirq, 0, &chip->rmidi)) < 0)
|
||||
chip->mpu_port,
|
||||
MPU401_INFO_IRQ_HOOK, -1,
|
||||
&chip->rmidi)) < 0)
|
||||
return err;
|
||||
chip->rmidi_callback = snd_mpu401_uart_interrupt;
|
||||
}
|
||||
|
@@ -658,8 +658,7 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev)
|
||||
if (snd_mpu401_uart_new(card, 0,
|
||||
MPU401_HW_MPU401,
|
||||
mpu_port[dev], 0,
|
||||
mpu_irq[dev], IRQF_DISABLED,
|
||||
NULL) < 0)
|
||||
mpu_irq[dev], NULL) < 0)
|
||||
snd_printk(KERN_ERR "no MPU-401 device at 0x%lx ?\n",
|
||||
mpu_port[dev]);
|
||||
}
|
||||
|
@@ -825,8 +825,7 @@ static int __devinit create_mpu401(struct snd_card *card, int devnum,
|
||||
int err;
|
||||
|
||||
err = snd_mpu401_uart_new(card, devnum, MPU401_HW_MPU401, port,
|
||||
MPU401_INFO_INTEGRATED, irq, IRQF_DISABLED,
|
||||
&rawmidi);
|
||||
MPU401_INFO_INTEGRATED, irq, &rawmidi);
|
||||
if (err == 0) {
|
||||
struct snd_mpu401 *mpu = rawmidi->private_data;
|
||||
mpu->open_input = mpu401_open;
|
||||
|
@@ -449,8 +449,7 @@ snd_wavefront_probe (struct snd_card *card, int dev)
|
||||
if (cs4232_mpu_port[dev] > 0 && cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
|
||||
err = snd_mpu401_uart_new(card, midi_dev, MPU401_HW_CS4232,
|
||||
cs4232_mpu_port[dev], 0,
|
||||
cs4232_mpu_irq[dev], IRQF_DISABLED,
|
||||
NULL);
|
||||
cs4232_mpu_irq[dev], NULL);
|
||||
if (err < 0) {
|
||||
snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n");
|
||||
return err;
|
||||
|
Reference in New Issue
Block a user