staging: comedi: cb_pcidda: cleanup DACCONTROL defines
authorH Hartley Sweeten <hartleys@visionengravers.com>
Wed, 24 Oct 2012 23:33:30 +0000 (16:33 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Oct 2012 02:35:50 +0000 (19:35 -0700)
Rename the defines used for the D/A Control register so that they
have namespace with this driver. Cleanup the use of these defines.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/cb_pcidda.c

index 2e2d00a60c9598f1ad5fd190d48267bcfcae6410..90930c801c8c7d2ceb18fece7f2b0d92ee9c64ef 100644 (file)
 #define CB_DDA_DIO1_8255_BASE          0x04
 
 /* DAC registers */
-#define DACONTROL      0       /*  D/A CONTROL REGISTER */
-#define        SU      0000001         /*  Simultaneous update enabled */
-#define NOSU   0000000         /*  Simultaneous update disabled */
-#define        ENABLEDAC       0000002 /*  Enable specified DAC */
-#define        DISABLEDAC      0000000 /*  Disable specified DAC */
-#define RANGE2V5       0000000 /*  2.5V */
-#define RANGE5V        0000200         /*  5V */
-#define RANGE10V       0000300 /*  10V */
-#define UNIP   0000400         /*  Unipolar outputs */
-#define BIP    0000000         /*  Bipolar outputs */
+#define CB_DDA_DA_CTRL_REG             0x00       /* D/A Control Register  */
+#define CB_DDA_DA_CTRL_SU              (1 << 0)   /*  Simultaneous update  */
+#define CB_DDA_DA_CTRL_EN              (1 << 1)   /*  Enable specified DAC */
+#define CB_DDA_DA_CTRL_DAC(x)          ((x) << 2) /*  Specify DAC channel  */
+#define CB_DDA_DA_CTRL_RANGE2V5                (0 << 6)   /*  2.5V range           */
+#define CB_DDA_DA_CTRL_RANGE5V         (2 << 6)   /*  5V range             */
+#define CB_DDA_DA_CTRL_RANGE10V                (3 << 6)   /*  10V range            */
+#define CB_DDA_DA_CTRL_UNIP            (1 << 8)   /*  Unipolar range       */
 
 #define DACALIBRATION1 4       /*  D/A CALIBRATION REGISTER 1 */
 /* write bits */
@@ -364,44 +362,35 @@ static int cb_pcidda_ao_winsn(struct comedi_device *dev,
                              struct comedi_insn *insn, unsigned int *data)
 {
        struct cb_pcidda_private *devpriv = dev->private;
-       unsigned int command;
-       unsigned int channel, range;
-
-       channel = CR_CHAN(insn->chanspec);
-       range = CR_RANGE(insn->chanspec);
+       unsigned int channel = CR_CHAN(insn->chanspec);
+       unsigned int range = CR_RANGE(insn->chanspec);
+       unsigned int ctrl;
 
        /*  adjust calibration dacs if range has changed */
        if (range != devpriv->ao_range[channel])
                cb_pcidda_calibrate(dev, channel, range);
 
-       /* output channel configuration */
-       command = NOSU | ENABLEDAC;
+       ctrl = CB_DDA_DA_CTRL_EN | CB_DDA_DA_CTRL_DAC(channel);
 
-       /* output channel range */
        switch (range) {
        case 0:
-               command |= BIP | RANGE10V;
-               break;
-       case 1:
-               command |= BIP | RANGE5V;
-               break;
-       case 2:
-               command |= BIP | RANGE2V5;
-               break;
        case 3:
-               command |= UNIP | RANGE10V;
+               ctrl |= CB_DDA_DA_CTRL_RANGE10V;
                break;
+       case 1:
        case 4:
-               command |= UNIP | RANGE5V;
+               ctrl |= CB_DDA_DA_CTRL_RANGE5V;
                break;
+       case 2:
        case 5:
-               command |= UNIP | RANGE2V5;
+               ctrl |= CB_DDA_DA_CTRL_RANGE2V5;
                break;
        }
 
-       /* output channel specification */
-       command |= channel << 2;
-       outw(command, dev->iobase + DACONTROL);
+       if (range > 2)
+               ctrl |= CB_DDA_DA_CTRL_UNIP;
+
+       outw(ctrl, dev->iobase + CB_DDA_DA_CTRL_REG);
 
        /* write data */
        outw(data[0], dev->iobase + DADATA + channel * 2);