[PATCH 14/17] staging: comedi: ni_65xx: factor input filter disable out of (*auto_attach)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For aesthetics, factor the code that disables the input filters out of
ni_65xx_auto_attach().

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregk@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_65xx.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index 8e5b30e..44d5c27 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -248,16 +248,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,
@@ -665,11 +678,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;
 }
-- 
1.9.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux