]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: adv_pci1710: tidy up pci1710_reset()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 13 Nov 2015 18:11:22 +0000 (11:11 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Dec 2015 22:56:30 +0000 (14:56 -0800)
Change the return type to void, this function always succeeds and the
caller does not check the return value anyway.

Fix the initial programming of the control register. The SW bit enables
the software trigger and should not be set here. Setting CNT0 selects the
external clock source for counter 0 (the user counter). It makes more
sense to select the internal 1 MHz clock.

Remove the unnecessary initialization of the private data members. This
function is only called during the (*auto_attach) after the private
data was kzalloc'ed.

Remove the redundant clearing of the A/D FIFO and pending interrupts.
Just do it once.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/adv_pci1710.c

index 737d40867d3b69899679b5f522c956c0f2a4b708..8bd9edfca2f2c2e4b6afe5caadac5bb5ac2da516 100644 (file)
@@ -711,29 +711,29 @@ static int pci1710_counter_insn_config(struct comedi_device *dev,
        return insn->n;
 }
 
-static int pci1710_reset(struct comedi_device *dev)
+static void pci1710_reset(struct comedi_device *dev)
 {
        const struct boardtype *board = dev->board_ptr;
-       struct pci1710_private *devpriv = dev->private;
 
-       /* Software trigger, CNT0=external */
-       devpriv->ctrl = PCI171X_CTRL_SW | PCI171X_CTRL_CNT0;
-       /* reset any operations */
-       outw(devpriv->ctrl, dev->iobase + PCI171X_CTRL_REG);
+       /*
+        * Disable A/D triggers and interrupt sources, set counter 0
+        * to use internal 1 MHz clock.
+        */
+       outw(0, dev->iobase + PCI171X_CTRL_REG);
+
+       /* clear A/D FIFO and any pending interrutps */
        outb(0, dev->iobase + PCI171X_CLRFIFO_REG);
        outb(0, dev->iobase + PCI171X_CLRINT_REG);
-       devpriv->da_ranges = 0;
+
        if (board->has_ao) {
                /* set DACs to 0..5V and outputs to 0V */
-               outb(devpriv->da_ranges, dev->iobase + PCI171X_DAREF_REG);
+               outb(0, dev->iobase + PCI171X_DAREF_REG);
                outw(0, dev->iobase + PCI171X_DA_REG(0));
                outw(0, dev->iobase + PCI171X_DA_REG(1));
        }
-       outw(0, dev->iobase + PCI171X_DO_REG);  /*  digital outputs to 0 */
-       outb(0, dev->iobase + PCI171X_CLRFIFO_REG);
-       outb(0, dev->iobase + PCI171X_CLRINT_REG);
 
-       return 0;
+       /* set digital outputs to 0 */
+       outw(0, dev->iobase + PCI171X_DO_REG);
 }
 
 static int pci1710_auto_attach(struct comedi_device *dev,