From: H Hartley Sweeten Date: Tue, 4 Mar 2014 18:30:04 +0000 (-0700) Subject: staging: comedi: pcl816: introduce pcl816_ai_clear_eoc() X-Git-Tag: firefly_0821_release~176^2~4193^2~639 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=97880eaf9b965dd121b8fc2ef0a8fb3f4beaddbe;p=firefly-linux-kernel-4.4.55.git staging: comedi: pcl816: introduce pcl816_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. Move the call in pcl816_ai_cancel() so that the flag is reset after stopping the A/D. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index e9795106b848..40fd27789886 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -208,6 +208,12 @@ static void pcl816_ai_setup_next_dma(struct comedi_device *dev, devpriv->dma_runs_to_end--; } +static void pcl816_ai_clear_eoc(struct comedi_device *dev) +{ + /* writing any value clears the interrupt request */ + outb(0, dev->iobase + PCL816_CLRINT); +} + static unsigned int pcl816_ai_get_sample(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -283,13 +289,13 @@ static irqreturn_t pcl816_interrupt(int irq, void *d) unsigned int len; if (!dev->attached || !devpriv->ai_cmd_running) { - outb(0, dev->iobase + PCL816_CLRINT); + pcl816_ai_clear_eoc(dev); return IRQ_HANDLED; } if (devpriv->ai_cmd_canceled) { devpriv->ai_cmd_canceled = 0; - outb(0, dev->iobase + PCL816_CLRINT); + pcl816_ai_clear_eoc(dev); return IRQ_HANDLED; } @@ -303,7 +309,7 @@ static irqreturn_t pcl816_interrupt(int irq, void *d) transfer_from_dma_buf(dev, s, ptr, bufptr, len); - outb(0, dev->iobase + PCL816_CLRINT); + pcl816_ai_clear_eoc(dev); comedi_event(dev, s); return IRQ_HANDLED; @@ -505,8 +511,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev, outb(0, dev->iobase + PCL816_AD_LO); pcl816_ai_get_sample(dev, s); - /* clear INT request */ - outb(0, dev->iobase + PCL816_CLRINT); + pcl816_ai_clear_eoc(dev); /* Stop A/D */ outb(0, dev->iobase + PCL816_CONTROL); @@ -613,8 +618,7 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, outb(range, dev->iobase + PCL816_RANGE); for (i = 0; i < insn->n; i++) { - /* clear INT (conversion end) flag */ - outb(0, dev->iobase + PCL816_CLRINT); + pcl816_ai_clear_eoc(dev); /* start conversion */ outb(0, dev->iobase + PCL816_AD_LO); @@ -624,8 +628,7 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, data[i] = pcl816_ai_get_sample(dev, s); } - /* clear INT (conversion end) flag */ - outb(0, dev->iobase + PCL816_CLRINT); + pcl816_ai_clear_eoc(dev); return ret ? ret : insn->n; } @@ -662,7 +665,7 @@ static void pcl816_reset(struct comedi_device *dev) outb(0, dev->iobase + PCL816_CONTROL); outb(0, dev->iobase + PCL816_MUX); - outb(0, dev->iobase + PCL816_CLRINT); + pcl816_ai_clear_eoc(dev); /* Stop pacer */ i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY);