From fbca05d601a94d16912613d119f5b672a75a587f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 22 Mar 2013 09:54:16 -0700 Subject: [PATCH] staging: comedi: ni_labpc: cleanup labpc_counter_load() usage For aesthetic reasons, move the labpc_counter_load() function so it's by the labpc_counter_set_mode() function. Update all the labpc_counter_load() calls so that the I8254_MODE* enums are used instead of the open coded values. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 36 +++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index ba9c97d29398..5782b019697d 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -289,6 +289,20 @@ static const int dma_buffer_size = 0xff00; /* 2 bytes per sample */ static const int sample_size = 2; +static int labpc_counter_load(struct comedi_device *dev, + unsigned long base_address, + unsigned int counter_number, + unsigned int count, unsigned int mode) +{ + const struct labpc_boardinfo *board = comedi_board(dev); + + if (board->has_mmio) + return i8254_mm_load((void __iomem *)base_address, 0, + counter_number, count, mode); + else + return i8254_load(base_address, 0, counter_number, count, mode); +} + static int labpc_counter_set_mode(struct comedi_device *dev, unsigned long base_address, unsigned int counter_number, @@ -855,20 +869,6 @@ static int labpc_ai_cmdtest(struct comedi_device *dev, return 0; } -static int labpc_counter_load(struct comedi_device *dev, - unsigned long base_address, - unsigned int counter_number, - unsigned int count, unsigned int mode) -{ - const struct labpc_boardinfo *board = comedi_board(dev); - - if (board->has_mmio) - return i8254_mm_load((void __iomem *)base_address, 0, - counter_number, count, mode); - else - return i8254_load(base_address, 0, counter_number, count, mode); -} - static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { const struct labpc_boardinfo *board = comedi_board(dev); @@ -900,7 +900,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) * (pc+ manual says this is minimum allowed) using mode 0 */ ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG, - 1, 3, 0); + 1, 3, I8254_MODE0); if (ret < 0) { comedi_error(dev, "error loading counter a1"); return -1; @@ -961,7 +961,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) labpc_adc_timing(dev, cmd, mode); /* load counter b0 in mode 3 */ ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG, - 0, devpriv->divisor_b0, 3); + 0, devpriv->divisor_b0, I8254_MODE3); if (ret < 0) { comedi_error(dev, "error loading counter b0"); return -1; @@ -971,7 +971,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (labpc_ai_convert_period(cmd, mode)) { /* load counter a0 in mode 2 */ ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG, - 0, devpriv->divisor_a0, 2); + 0, devpriv->divisor_a0, I8254_MODE2); if (ret < 0) { comedi_error(dev, "error loading counter a0"); return -1; @@ -986,7 +986,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (labpc_ai_scan_period(cmd, mode)) { /* load counter b1 in mode 2 */ ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG, - 1, devpriv->divisor_b1, 2); + 1, devpriv->divisor_b1, I8254_MODE2); if (ret < 0) { comedi_error(dev, "error loading counter b1"); return -1; -- 2.30.2