]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: ni_65xx: factor input filter disable out of (*auto_attach)
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 14 Jul 2014 19:07:08 +0000 (12:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jul 2014 20:22:51 +0000 (13:22 -0700)
For aesthetics, factor the code that disables the input filters out of
ni_65xx_auto_attach().

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_65xx.c

index a0deb0159c3bad981c18c3141583587ccf910f3a..cad2c2890a27d3efc6ba8c082470bf236550244d 100644 (file)
@@ -278,16 +278,29 @@ static const struct ni_65xx_board ni_65xx_boards[] = {
        },
 };
 
-static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board
-                                              *board)
-{
-       return board->num_dio_ports + board->num_di_ports + board->num_do_ports;
-}
-
 struct ni_65xx_private {
        void __iomem *mmio;
 };
 
+static void ni_65xx_disable_input_filters(struct comedi_device *dev)
+{
+       const struct ni_65xx_board *board = comedi_board(dev);
+       struct ni_65xx_private *devpriv = dev->private;
+       unsigned num_ports;
+       int i;
+
+       num_ports = board->num_dio_ports +
+                   board->num_di_ports +
+                   board->num_do_ports;
+
+       /* disable input filtering on all ports */
+       for (i = 0; i < num_ports; ++i)
+               writeb(0x00, devpriv->mmio + NI_65XX_FILTER_ENA(i));
+
+       /* set filter interval to 0 (32bit reg) */
+       writel(0x00000000, devpriv->mmio + NI_65XX_FILTER_REG);
+}
+
 static int ni_65xx_dio_insn_config(struct comedi_device *dev,
                                   struct comedi_subdevice *s,
                                   struct comedi_insn *insn,
@@ -709,11 +722,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev,
                s->cancel       = ni_65xx_intr_cancel;
        }
 
-       for (i = 0; i < ni_65xx_total_num_ports(board); ++i)
-               writeb(0x00, devpriv->mmio + NI_65XX_FILTER_ENA(i));
-
-       /* Set filter interval to 0  (32bit reg) */
-       writel(0x00000000, devpriv->mmio + NI_65XX_FILTER_REG);
+       ni_65xx_disable_input_filters(dev);
 
        return 0;
 }