From: H Hartley Sweeten Date: Thu, 4 Sep 2014 19:14:19 +0000 (-0700) Subject: staging: comedi: adl_pci9118: introduce pci9118_ai_start_conv() X-Git-Tag: v3.18-rc1~130^2~676 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1750bed3f795ad33d9b37c3669f97fe036fa7570;p=karo-tx-linux.git staging: comedi: adl_pci9118: introduce pci9118_ai_start_conv() Writing any value to the "software trigger" register generates a trigger pulse to start an A/D conversion. Introduce a helper function to clarify this. For aesthetics, rename the define used for the register. According to the datasheet the extra delay is not needed after starting the conversion. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 6fb46cb03594..5eca67f13cc7 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -130,8 +130,8 @@ #define PCI9118_AI_CTRL_INT (1 << 1) /* 1=enable interrupt */ #define PCI9118_AI_CTRL_DMA (1 << 0) /* 1=enable DMA */ #define PCI9118_DIO_REG 0x1c +#define PCI9118_SOFTTRG_REG 0x20 -#define PCI9118_SOFTTRG 0x20 /* W: soft trigger for A/D */ #define PCI9118_GAIN 0x24 /* W: A/D gain/channel register */ #define PCI9118_BURST 0x28 /* W: A/D burst number register */ #define PCI9118_SCANMOD 0x2c /* W: A/D auto scan mode */ @@ -485,6 +485,12 @@ static int pci9118_ai_eoc(struct comedi_device *dev, return -EBUSY; } +static void pci9118_ai_start_conv(struct comedi_device *dev) +{ + /* writing any value triggers an A/D conversion */ + outl(0, dev->iobase + PCI9118_SOFTTRG_REG); +} + static int pci9118_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -511,8 +517,7 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ for (n = 0; n < insn->n; n++) { - outl(0, dev->iobase + PCI9118_SOFTTRG); /* start conversion */ - udelay(2); + pci9118_ai_start_conv(dev); ret = comedi_timeout(dev, s, insn, pci9118_ai_eoc, 0); if (ret) {