staging: comedi: ni_mio_common: remove forward declaration 3
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 28 May 2014 23:26:26 +0000 (16:26 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jun 2014 21:33:51 +0000 (14:33 -0700)
Move the pwm config functions to remove the need for the forward
declarations.

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

index aa1f1938b8fbd89d59c44864d4615e9a090c62b4..b63c793afebedf341a119922c0b8fc19a37a7518 100644 (file)
@@ -278,13 +278,6 @@ static int cs5529_ai_insn_read(struct comedi_device *dev,
 static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
                                unsigned int reg_select_bits);
 
-static int ni_m_series_pwm_config(struct comedi_device *dev,
-                                 struct comedi_subdevice *s,
-                                 struct comedi_insn *insn, unsigned int *data);
-static int ni_6143_pwm_config(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn, unsigned int *data);
-
 static int ni_set_master_clock(struct comedi_device *dev, unsigned source,
                               unsigned period_ns);
 static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status);
@@ -4161,6 +4154,151 @@ static int ni_8255_callback(int dir, int port, int data, unsigned long arg)
        }
 }
 
+static int ni_get_pwm_config(struct comedi_device *dev, unsigned int *data)
+{
+       struct ni_private *devpriv = dev->private;
+
+       data[1] = devpriv->pwm_up_count * devpriv->clock_ns;
+       data[2] = devpriv->pwm_down_count * devpriv->clock_ns;
+       return 3;
+}
+
+static int ni_m_series_pwm_config(struct comedi_device *dev,
+                                 struct comedi_subdevice *s,
+                                 struct comedi_insn *insn,
+                                 unsigned int *data)
+{
+       struct ni_private *devpriv = dev->private;
+       unsigned up_count, down_count;
+
+       switch (data[0]) {
+       case INSN_CONFIG_PWM_OUTPUT:
+               switch (data[1]) {
+               case TRIG_ROUND_NEAREST:
+                       up_count =
+                           (data[2] +
+                            devpriv->clock_ns / 2) / devpriv->clock_ns;
+                       break;
+               case TRIG_ROUND_DOWN:
+                       up_count = data[2] / devpriv->clock_ns;
+                       break;
+               case TRIG_ROUND_UP:
+                       up_count =
+                           (data[2] + devpriv->clock_ns -
+                            1) / devpriv->clock_ns;
+                       break;
+               default:
+                       return -EINVAL;
+                       break;
+               }
+               switch (data[3]) {
+               case TRIG_ROUND_NEAREST:
+                       down_count =
+                           (data[4] +
+                            devpriv->clock_ns / 2) / devpriv->clock_ns;
+                       break;
+               case TRIG_ROUND_DOWN:
+                       down_count = data[4] / devpriv->clock_ns;
+                       break;
+               case TRIG_ROUND_UP:
+                       down_count =
+                           (data[4] + devpriv->clock_ns -
+                            1) / devpriv->clock_ns;
+                       break;
+               default:
+                       return -EINVAL;
+                       break;
+               }
+               if (up_count * devpriv->clock_ns != data[2] ||
+                   down_count * devpriv->clock_ns != data[4]) {
+                       data[2] = up_count * devpriv->clock_ns;
+                       data[4] = down_count * devpriv->clock_ns;
+                       return -EAGAIN;
+               }
+               ni_writel(MSeries_Cal_PWM_High_Time_Bits(up_count) |
+                         MSeries_Cal_PWM_Low_Time_Bits(down_count),
+                         M_Offset_Cal_PWM);
+               devpriv->pwm_up_count = up_count;
+               devpriv->pwm_down_count = down_count;
+               return 5;
+               break;
+       case INSN_CONFIG_GET_PWM_OUTPUT:
+               return ni_get_pwm_config(dev, data);
+               break;
+       default:
+               return -EINVAL;
+               break;
+       }
+       return 0;
+}
+
+static int ni_6143_pwm_config(struct comedi_device *dev,
+                             struct comedi_subdevice *s,
+                             struct comedi_insn *insn,
+                             unsigned int *data)
+{
+       struct ni_private *devpriv = dev->private;
+       unsigned up_count, down_count;
+
+       switch (data[0]) {
+       case INSN_CONFIG_PWM_OUTPUT:
+               switch (data[1]) {
+               case TRIG_ROUND_NEAREST:
+                       up_count =
+                           (data[2] +
+                            devpriv->clock_ns / 2) / devpriv->clock_ns;
+                       break;
+               case TRIG_ROUND_DOWN:
+                       up_count = data[2] / devpriv->clock_ns;
+                       break;
+               case TRIG_ROUND_UP:
+                       up_count =
+                           (data[2] + devpriv->clock_ns -
+                            1) / devpriv->clock_ns;
+                       break;
+               default:
+                       return -EINVAL;
+                       break;
+               }
+               switch (data[3]) {
+               case TRIG_ROUND_NEAREST:
+                       down_count =
+                           (data[4] +
+                            devpriv->clock_ns / 2) / devpriv->clock_ns;
+                       break;
+               case TRIG_ROUND_DOWN:
+                       down_count = data[4] / devpriv->clock_ns;
+                       break;
+               case TRIG_ROUND_UP:
+                       down_count =
+                           (data[4] + devpriv->clock_ns -
+                            1) / devpriv->clock_ns;
+                       break;
+               default:
+                       return -EINVAL;
+                       break;
+               }
+               if (up_count * devpriv->clock_ns != data[2] ||
+                   down_count * devpriv->clock_ns != data[4]) {
+                       data[2] = up_count * devpriv->clock_ns;
+                       data[4] = down_count * devpriv->clock_ns;
+                       return -EAGAIN;
+               }
+               ni_writel(up_count, Calibration_HighTime_6143);
+               devpriv->pwm_up_count = up_count;
+               ni_writel(down_count, Calibration_LowTime_6143);
+               devpriv->pwm_down_count = down_count;
+               return 5;
+               break;
+       case INSN_CONFIG_GET_PWM_OUTPUT:
+               return ni_get_pwm_config(dev, data);
+       default:
+               return -EINVAL;
+               break;
+       }
+       return 0;
+}
+
 static int ni_read_eeprom(struct comedi_device *dev, int addr)
 {
        struct ni_private *devpriv __maybe_unused = dev->private;
@@ -4538,149 +4676,6 @@ static int ni_E_init(struct comedi_device *dev)
        return 0;
 }
 
-static int ni_get_pwm_config(struct comedi_device *dev, unsigned int *data)
-{
-       struct ni_private *devpriv = dev->private;
-
-       data[1] = devpriv->pwm_up_count * devpriv->clock_ns;
-       data[2] = devpriv->pwm_down_count * devpriv->clock_ns;
-       return 3;
-}
-
-static int ni_m_series_pwm_config(struct comedi_device *dev,
-                                 struct comedi_subdevice *s,
-                                 struct comedi_insn *insn, unsigned int *data)
-{
-       struct ni_private *devpriv = dev->private;
-       unsigned up_count, down_count;
-
-       switch (data[0]) {
-       case INSN_CONFIG_PWM_OUTPUT:
-               switch (data[1]) {
-               case TRIG_ROUND_NEAREST:
-                       up_count =
-                           (data[2] +
-                            devpriv->clock_ns / 2) / devpriv->clock_ns;
-                       break;
-               case TRIG_ROUND_DOWN:
-                       up_count = data[2] / devpriv->clock_ns;
-                       break;
-               case TRIG_ROUND_UP:
-                       up_count =
-                           (data[2] + devpriv->clock_ns -
-                            1) / devpriv->clock_ns;
-                       break;
-               default:
-                       return -EINVAL;
-                       break;
-               }
-               switch (data[3]) {
-               case TRIG_ROUND_NEAREST:
-                       down_count =
-                           (data[4] +
-                            devpriv->clock_ns / 2) / devpriv->clock_ns;
-                       break;
-               case TRIG_ROUND_DOWN:
-                       down_count = data[4] / devpriv->clock_ns;
-                       break;
-               case TRIG_ROUND_UP:
-                       down_count =
-                           (data[4] + devpriv->clock_ns -
-                            1) / devpriv->clock_ns;
-                       break;
-               default:
-                       return -EINVAL;
-                       break;
-               }
-               if (up_count * devpriv->clock_ns != data[2] ||
-                   down_count * devpriv->clock_ns != data[4]) {
-                       data[2] = up_count * devpriv->clock_ns;
-                       data[4] = down_count * devpriv->clock_ns;
-                       return -EAGAIN;
-               }
-               ni_writel(MSeries_Cal_PWM_High_Time_Bits(up_count) |
-                         MSeries_Cal_PWM_Low_Time_Bits(down_count),
-                         M_Offset_Cal_PWM);
-               devpriv->pwm_up_count = up_count;
-               devpriv->pwm_down_count = down_count;
-               return 5;
-               break;
-       case INSN_CONFIG_GET_PWM_OUTPUT:
-               return ni_get_pwm_config(dev, data);
-               break;
-       default:
-               return -EINVAL;
-               break;
-       }
-       return 0;
-}
-
-static int ni_6143_pwm_config(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn, unsigned int *data)
-{
-       struct ni_private *devpriv = dev->private;
-       unsigned up_count, down_count;
-
-       switch (data[0]) {
-       case INSN_CONFIG_PWM_OUTPUT:
-               switch (data[1]) {
-               case TRIG_ROUND_NEAREST:
-                       up_count =
-                           (data[2] +
-                            devpriv->clock_ns / 2) / devpriv->clock_ns;
-                       break;
-               case TRIG_ROUND_DOWN:
-                       up_count = data[2] / devpriv->clock_ns;
-                       break;
-               case TRIG_ROUND_UP:
-                       up_count =
-                           (data[2] + devpriv->clock_ns -
-                            1) / devpriv->clock_ns;
-                       break;
-               default:
-                       return -EINVAL;
-                       break;
-               }
-               switch (data[3]) {
-               case TRIG_ROUND_NEAREST:
-                       down_count =
-                           (data[4] +
-                            devpriv->clock_ns / 2) / devpriv->clock_ns;
-                       break;
-               case TRIG_ROUND_DOWN:
-                       down_count = data[4] / devpriv->clock_ns;
-                       break;
-               case TRIG_ROUND_UP:
-                       down_count =
-                           (data[4] + devpriv->clock_ns -
-                            1) / devpriv->clock_ns;
-                       break;
-               default:
-                       return -EINVAL;
-                       break;
-               }
-               if (up_count * devpriv->clock_ns != data[2] ||
-                   down_count * devpriv->clock_ns != data[4]) {
-                       data[2] = up_count * devpriv->clock_ns;
-                       data[4] = down_count * devpriv->clock_ns;
-                       return -EAGAIN;
-               }
-               ni_writel(up_count, Calibration_HighTime_6143);
-               devpriv->pwm_up_count = up_count;
-               ni_writel(down_count, Calibration_LowTime_6143);
-               devpriv->pwm_down_count = down_count;
-               return 5;
-               break;
-       case INSN_CONFIG_GET_PWM_OUTPUT:
-               return ni_get_pwm_config(dev, data);
-       default:
-               return -EINVAL;
-               break;
-       }
-       return 0;
-}
-
 static void ni_write_caldac(struct comedi_device *dev, int addr, int val);
 /*
        calibration subdevice