staging: comedi: pcmuio: fix interrupt requests

Legacy (ISA) interrupts are not sharable so this driver should not
be passing the IRQF_SHARED flag when requesting the interrupts.

This driver supports two board types:
  PCM-UIO48 with one asic (one interrupt source)
  PCM-UIO96 with two asics (two interrupt sources)

The PCM-UIO96 has a jumper that allows the two interrupt sources to
share an interrupt. This is safe for legacy interrupts as long as
the "shared" interrupt is handled by a single driver.

Modify the request_irq() code in this driver to correctly request the
interrupts. For the PCM-UI048 case (one asic) only one request_irq()
is needed. For the PCM-UIO96 (two asics) there are three cases:

  1) irq is shared, one request_irq() call
  2) only one asic has an irq, one request_irq() call
  3) two irqs, two request_irq() calls

The irq for the first asic (dev->irq) will be requested during the
attach if required. The comedi core will handle the freeing of this
irq during the detach.

The irq for the second asic (devpriv->irq2) will also be requested
during the attach if required. The freeing of this irq will be
handled by the driver during the detach.

Move the board reset and interrupt request code so it occurs early
in the attach. We can then check dev->irq and devpriv->irq2 to see
if the subdevice command support actually needs to be initialized.

This also simplifies the interrupt handler. The irq can be simply
checked against dev->irq and devpriv->irq2 to see which asic caused
the interrupt.

Add a call to pcmuio_reset() in the (*detach) to make sure the
interrupts are disabled before freeing the irqs.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 file changed