summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/pcl816.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-03-04 11:29:52 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-03-06 17:06:14 -0800
commitfb98ec17ee55c1fea78a6513df697d7ab125e729 (patch)
tree9ea5860498c58b13ed411f3c50bcb19d926d9b12 /drivers/staging/comedi/drivers/pcl816.c
parentd106c298165082b44c310ca6e2d2d69771c0d6f9 (diff)
staging: comedi: pcl816: consolidate the interrupt code
This driver only supports interrupt driven DMA transfers for async command support. Absorb the interrupt_pcl816_ai_mode13_dma() helper into the interrupt handler to clarify the code. At some point during the interrupt, comedi_event() is called to pass any events to the comedi subsystem. Move this to the interrupt handler. Add a comedi_event() call to pcl816_ai_poll() due to the removal of the call from transfer_from_dma_buf(). For aesthetics, rename the interrupt function so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/pcl816.c')
-rw-r--r--drivers/staging/comedi/drivers/pcl816.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 348fc683f0e3..0d20fba0abea 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -286,7 +286,6 @@ static bool pcl816_ai_next_chan(struct comedi_device *dev,
/* all data sampled */
s->cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
- comedi_event(dev, s);
return false;
}
@@ -306,38 +305,16 @@ static void transfer_from_dma_buf(struct comedi_device *dev,
if (!pcl816_ai_next_chan(dev, s))
return;
}
-
- comedi_event(dev, s);
}
-static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d)
+static irqreturn_t pcl816_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- struct pcl816_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
- int len, bufptr, this_dma_buf;
- unsigned short *ptr;
-
- this_dma_buf = devpriv->next_dma_buf;
-
- pcl816_ai_setup_next_dma(dev, s);
-
- outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */
-
- ptr = (unsigned short *)devpriv->dmabuf[this_dma_buf];
-
- len = (devpriv->hwdmasize >> 1) - devpriv->ai_poll_ptr;
- bufptr = devpriv->ai_poll_ptr;
- devpriv->ai_poll_ptr = 0;
-
- transfer_from_dma_buf(dev, s, ptr, bufptr, len);
- return IRQ_HANDLED;
-}
-
-static irqreturn_t interrupt_pcl816(int irq, void *d)
-{
- struct comedi_device *dev = d;
struct pcl816_private *devpriv = dev->private;
+ unsigned short *ptr;
+ unsigned int bufptr;
+ unsigned int len;
if (!dev->attached || !devpriv->ai_cmd_running) {
outb(0, dev->iobase + PCL816_CLRINT);
@@ -350,7 +327,20 @@ static irqreturn_t interrupt_pcl816(int irq, void *d)
return IRQ_HANDLED;
}
- return interrupt_pcl816_ai_mode13_dma(irq, d);
+ ptr = (unsigned short *)devpriv->dmabuf[devpriv->next_dma_buf];
+
+ pcl816_ai_setup_next_dma(dev, s);
+
+ len = (devpriv->hwdmasize >> 1) - devpriv->ai_poll_ptr;
+ bufptr = devpriv->ai_poll_ptr;
+ devpriv->ai_poll_ptr = 0;
+
+ transfer_from_dma_buf(dev, s, ptr, bufptr, len);
+
+ outb(0, dev->iobase + PCL816_CLRINT);
+
+ comedi_event(dev, s);
+ return IRQ_HANDLED;
}
static int pcl816_ai_cmdtest(struct comedi_device *dev,
@@ -521,6 +511,8 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->ai_poll_ptr = top1; /* new buffer position */
spin_unlock_irqrestore(&dev->spinlock, flags);
+ comedi_event(dev, s);
+
return s->async->buf_write_count - s->async->buf_read_count;
}
@@ -676,7 +668,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* we can use IRQ 2-7 for async command support */
if (it->options[1] >= 2 && it->options[1] <= 7) {
- ret = request_irq(it->options[1], interrupt_pcl816, 0,
+ ret = request_irq(it->options[1], pcl816_interrupt, 0,
dev->board_name, dev);
if (ret == 0)
dev->irq = it->options[1];