From: H Hartley Sweeten Date: Mon, 14 Jul 2014 19:07:08 +0000 (-0700) Subject: staging: comedi: ni_65xx: factor input filter disable out of (*auto_attach) X-Git-Tag: v3.17-rc1~123^2~695 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9233c8db355e70550298f493ec7c30b3e6425868;p=karo-tx-linux.git staging: comedi: ni_65xx: factor input filter disable out of (*auto_attach) For aesthetics, factor the code that disables the input filters out of ni_65xx_auto_attach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index a0deb0159c3b..cad2c2890a27 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -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; }