From 079dc9fe7770ea990c7f6f2094deb9bd8f172095 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 4 Mar 2014 11:30:03 -0700 Subject: [PATCH] staging: comedi: pcl812: introduce pcl812_ai_clear_eoc() Introduce a helper function to clear the end-of-conversion flag. This flag is set when an analog input conversion is finished and the hardware generates an interrupt request. Writing any value to the register resets the flag and re-enables the interrupt. Remove a redundant call in pcl812_ai_cancel(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index cf183c86fb5b..b41dbbc5e38e 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -637,6 +637,12 @@ static void pcl812_ai_setup_next_dma(struct comedi_device *dev, enable_dma(devpriv->dma); } +static void pcl812_ai_clear_eoc(struct comedi_device *dev) +{ + /* writing any value clears the interrupt request */ + outb(0, dev->iobase + PCL812_CLRINT); +} + static unsigned int pcl812_ai_get_sample(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -889,7 +895,7 @@ static irqreturn_t pcl812_interrupt(int irq, void *d) struct pcl812_private *devpriv = dev->private; if (!dev->attached) { - outb(0, dev->iobase + PCL812_CLRINT); + pcl812_ai_clear_eoc(dev); return IRQ_HANDLED; } @@ -898,7 +904,7 @@ static irqreturn_t pcl812_interrupt(int irq, void *d) else pcl812_handle_eoc(dev, s); - outb(0, dev->iobase + PCL812_CLRINT); + pcl812_ai_clear_eoc(dev); comedi_event(dev, s); return IRQ_HANDLED; @@ -997,11 +1003,11 @@ static int pcl812_ai_cancel(struct comedi_device *dev, if (devpriv->ai_dma) disable_dma(devpriv->dma); - outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ - /* Stop A/D */ + + /* Stop A/D */ outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); pcl812_start_pacer(dev, false); - outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ + pcl812_ai_clear_eoc(dev); return 0; } @@ -1021,8 +1027,7 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, setup_range_channel(dev, s, insn->chanspec, 1); for (i = 0; i < insn->n; i++) { - /* clear INT request */ - outb(0, dev->iobase + PCL812_CLRINT); + pcl812_ai_clear_eoc(dev); /* start conversion */ outb(255, dev->iobase + PCL812_SOFTTRIG); @@ -1032,9 +1037,8 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, data[i] = pcl812_ai_get_sample(dev, s); } - /* clear INT request */ - outb(0, dev->iobase + PCL812_CLRINT); outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); + pcl812_ai_clear_eoc(dev); return ret ? ret : insn->n; } @@ -1126,7 +1130,7 @@ static void pcl812_reset(struct comedi_device *dev) outb(0, dev->iobase + PCL812_DO_MSB_REG); outb(0, dev->iobase + PCL812_DO_LSB_REG); outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); - outb(0, dev->iobase + PCL812_CLRINT); + pcl812_ai_clear_eoc(dev); break; case boardPCL813B: case boardPCL813: -- 2.30.2