[alsa-devel] [RFC] [PATCH 02/62] mpu401:snd_mpu401_uart_new(): split semantic of irq_flags
Clemens Ladisch
clemens at ladisch.de
Mon Sep 12 15:16:14 CEST 2011
Takashi Iwai wrote:
> Clemens Ladisch wrote:
> > --- a/sound/isa/als100.c
> > +++ b/sound/isa/als100.c
> > @@ -245,18 +245,22 @@ static int __devinit snd_card_als100_probe(int dev,
> >
> > if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
> > int mpu_type = MPU401_HW_ALS100;
> > + int mpu_flags = 0;
> >
> > - if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
> > + if (mpu_irq[dev] == SNDRV_AUTO_IRQ) {
> > mpu_irq[dev] = -1;
> > + mpu_flags = MPU401_INFO_RX_POLL;
> > + }
>
> When mpu_irq[dev] is set to -1, it won't work.
Thanks for noticing this!
> Instead of setting mpu_flag in this if block, you'd need another check
> of mpu_irq[], i.e.
>
> if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
> mpu_irq[dev] = -1;
> if (mpu_irq[dev] < 0)
> mpu_flags = MPU401_INFO_RX_POLL;
I didn't like all the duplicated code I added to the ISA drivers, and
the more code it becomes, the less I like it.
But it should be possible to avoid this duplication:
snd_mpu401_uart_new() needs to differentiate between three cases:
1) allocate a separate interrupt;
2) do not allocate, use the callback from the driver's interrupt handler;
3) do not allocate, use a timer for polling.
Case 1) is indicated by a valid irq number, the other two cases need
a flag. All drivers that might use polling switch between 1) or 3),
while 2) is always used unconditionally. So if we have this flag for 2)
instead of 3), no additional logic is needed in the drivers.
(Furthermore, snd_mpu401_uart_new() could check for SNDRV_AUTO_IRQ
instead of letting all drivers do this, and the hardware and info_flags
parameters could be merged. But this can wait for later.)
I'll have a new patch until tomorrow.
Regards,
Clemens
More information about the Alsa-devel
mailing list