staging: comedi: ni_pcidio: factor board reset out of attach
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 5 Dec 2013 20:43:48 +0000 (13:43 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Dec 2013 21:07:17 +0000 (13:07 -0800)
Factor the code that resets the board and disables the interrupts out
of the attach.

Move the reset so it happens before the subdevices are initialized.

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/ni_pcidio.c

index 645a4d80e608dba9bad139298a80ba47077149e5..ef72fc79523ef5bb29765b8efdfd41b5b7eaea11 100644 (file)
@@ -949,6 +949,19 @@ static int pci_6534_upload_firmware(struct comedi_device *dev)
        return ret;
 }
 
+static void nidio_reset_board(struct comedi_device *dev)
+{
+       struct nidio96_private *devpriv = dev->private;
+       void __iomem *daq_mmio = devpriv->mite->daq_io_addr;
+
+       writel(0, daq_mmio + Port_IO(0));
+       writel(0, daq_mmio + Port_Pin_Directions(0));
+       writel(0, daq_mmio + Port_Pin_Mask(0));
+
+       /* disable interrupts on board */
+       writeb(0, daq_mmio + Master_DMA_And_Interrupt_Control);
+}
+
 static int nidio_auto_attach(struct comedi_device *dev,
                             unsigned long context)
 {
@@ -996,6 +1009,8 @@ static int nidio_auto_attach(struct comedi_device *dev,
                        return ret;
        }
 
+       nidio_reset_board(dev);
+
        ret = comedi_alloc_subdevices(dev, 1);
        if (ret)
                return ret;
@@ -1023,15 +1038,6 @@ static int nidio_auto_attach(struct comedi_device *dev,
        s->async_dma_dir = DMA_BIDIRECTIONAL;
        s->poll = &ni_pcidio_poll;
 
-       writel(0, devpriv->mite->daq_io_addr + Port_IO(0));
-       writel(0, devpriv->mite->daq_io_addr + Port_Pin_Directions(0));
-       writel(0, devpriv->mite->daq_io_addr + Port_Pin_Mask(0));
-
-       /* disable interrupts on board */
-       writeb(0x00,
-               devpriv->mite->daq_io_addr +
-               Master_DMA_And_Interrupt_Control);
-
        irq = mite_irq(devpriv->mite);
        if (irq) {
                ret = request_irq(irq, nidio_interrupt, IRQF_SHARED,