static int pcl812_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s);
+static unsigned int pcl812_ai_get_sample(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ unsigned int val;
+
+ val = inb(dev->iobase + PCL812_AD_HI) << 8;
+ val |= inb(dev->iobase + PCL812_AD_LO);
+
+ return val & s->maxdata;
+}
+
static int pcl812_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
struct pcl812_private *devpriv = dev->private;
int ret = 0;
int n;
- int hi;
/* select software trigger */
outb(devpriv->mode_reg_int | 1, dev->iobase + PCL812_MODE);
if (ret)
break;
- hi = inb(dev->iobase + PCL812_AD_HI);
- data[n] = ((hi & 0xf) << 8) | inb(dev->iobase + PCL812_AD_LO);
+ data[n] = pcl812_ai_get_sample(dev, s);
}
outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE);
if (ret)
break;
- data[n] =
- (inb(dev->iobase +
- PCL812_AD_HI) << 8) | inb(dev->iobase + PCL812_AD_LO);
+ data[n] = pcl812_ai_get_sample(dev, s);
}
outb(0, dev->iobase + PCL812_MODE);
static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d)
{
char err = 1;
- unsigned int mask, timeout;
+ unsigned int timeout;
struct comedi_device *dev = d;
struct pcl812_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
timeout = 50; /* wait max 50us, it must finish under 33us */
if (devpriv->ai_is16b) {
- mask = 0xffff;
while (timeout--) {
if (!(inb(dev->iobase + ACL8216_STATUS) & ACL8216_DRDY)) {
err = 0;
udelay(1);
}
} else {
- mask = 0x0fff;
while (timeout--) {
if (!(inb(dev->iobase + PCL812_AD_HI) & PCL812_DRDY)) {
err = 0;
return IRQ_HANDLED;
}
- comedi_buf_put(s->async,
- ((inb(dev->iobase + PCL812_AD_HI) << 8) |
- inb(dev->iobase + PCL812_AD_LO)) & mask);
+ comedi_buf_put(s->async, pcl812_ai_get_sample(dev, s));
/* Set up next channel. Added by abbotti 2010-01-20, but untested. */
next_chan = s->async->cur_chan + 1;