From 0c917a93654557dc2489ebacbeadc3851186e3ce Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 13 Nov 2015 11:11:22 -0700 Subject: [PATCH] staging: comedi: adv_pci1710: tidy up pci1710_reset() 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 737d40867d3b..8bd9edfca2f2 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -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, -- 2.20.1