Commit dd89a8b6 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: pcl711: factor out the ai end-of-conversion wait

Factor out the analog input end-of-conversion wait to clarify the
pcl711_ai_insn() function a bit.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8f494fe6
...@@ -71,6 +71,7 @@ supported. ...@@ -71,6 +71,7 @@ supported.
#define PCL711_CTRCTL 0x03 #define PCL711_CTRCTL 0x03
#define PCL711_AI_LSB_REG 0x04 #define PCL711_AI_LSB_REG 0x04
#define PCL711_AI_MSB_REG 0x05 #define PCL711_AI_MSB_REG 0x05
#define PCL711_AI_MSB_DRDY (1 << 4)
#define PCL711_AO_LSB_REG(x) (0x04 + ((x) * 2)) #define PCL711_AO_LSB_REG(x) (0x04 + ((x) * 2))
#define PCL711_AO_MSB_REG(x) (0x05 + ((x) * 2)) #define PCL711_AO_MSB_REG(x) (0x05 + ((x) * 2))
#define PCL711_DI_LO 0x06 #define PCL711_DI_LO 0x06
...@@ -124,13 +125,6 @@ static const struct comedi_lrange range_acl8112dg_ai = { ...@@ -124,13 +125,6 @@ static const struct comedi_lrange range_acl8112dg_ai = {
} }
}; };
/*
* flags
*/
#define PCL711_TIMEOUT 100
#define PCL711_DRDY 0x10
static const int i8253_osc_base = 500; /* 2 Mhz */ static const int i8253_osc_base = 500; /* 2 Mhz */
struct pcl711_board { struct pcl711_board {
...@@ -254,12 +248,26 @@ static void pcl711_set_changain(struct comedi_device *dev, int chan) ...@@ -254,12 +248,26 @@ static void pcl711_set_changain(struct comedi_device *dev, int chan)
} }
} }
static int pcl711_ai_wait_for_eoc(struct comedi_device *dev,
unsigned int timeout)
{
unsigned int msb;
while (timeout--) {
msb = inb(dev->iobase + PCL711_AI_MSB_REG);
if ((msb & PCL711_AI_MSB_DRDY) == 0)
return 0;
udelay(1);
}
return -ETIME;
}
static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
const struct pcl711_board *board = comedi_board(dev); const struct pcl711_board *board = comedi_board(dev);
int i, n; int ret;
int hi; int n;
pcl711_set_changain(dev, insn->chanspec); pcl711_set_changain(dev, insn->chanspec);
...@@ -273,17 +281,10 @@ static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -273,17 +281,10 @@ static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
if (!board->is_8112) if (!board->is_8112)
outb(0, dev->iobase + PCL711_SOFTTRIG); outb(0, dev->iobase + PCL711_SOFTTRIG);
i = PCL711_TIMEOUT; ret = pcl711_ai_wait_for_eoc(dev, 100);
while (--i) { if (ret)
hi = inb(dev->iobase + PCL711_AI_MSB_REG); return ret;
if (!(hi & PCL711_DRDY))
goto ok;
udelay(1);
}
printk(KERN_ERR "comedi%d: pcl711: A/D timeout\n", dev->minor);
return -ETIME;
ok:
data[n] = pcl711_ai_get_sample(dev, s); data[n] = pcl711_ai_get_sample(dev, s);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment