]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: ni_stc.h: tidy up the cs5529_command_bits
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 1 May 2015 22:00:10 +0000 (15:00 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 May 2015 17:05:19 +0000 (19:05 +0200)
For aesthetics, convert the enum into defines. Use the BIT() macro
to define the bits.

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
drivers/staging/comedi/drivers/ni_stc.h

index 8a484fb5ea8e8f80627d059244305a461e4cbe8c..33f01e1efb29b4131983620a0686a1510d33ddde 100644 (file)
@@ -4512,7 +4512,7 @@ static int cs5529_do_conversion(struct comedi_device *dev,
        int retval;
        unsigned short status;
 
-       cs5529_command(dev, CSCMD_COMMAND | CSCMD_SINGLE_CONVERSION);
+       cs5529_command(dev, CS5529_CMD_CB | CS5529_CMD_SINGLE_CONV);
        retval = cs5529_wait_for_idle(dev);
        if (retval) {
                dev_err(dev->class_dev,
@@ -4572,8 +4572,8 @@ static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
                       CAL_ADC_Config_Data_High_Word_67xx);
        ni_ao_win_outw(dev, (value & 0xffff),
                       CAL_ADC_Config_Data_Low_Word_67xx);
-       reg_select_bits &= CSCMD_REGISTER_SELECT_MASK;
-       cs5529_command(dev, CSCMD_COMMAND | reg_select_bits);
+       reg_select_bits &= CS5529_CMD_REG_MASK;
+       cs5529_command(dev, CS5529_CMD_CB | reg_select_bits);
        if (cs5529_wait_for_idle(dev))
                dev_err(dev->class_dev,
                        "timeout or signal in %s\n", __func__);
@@ -4587,14 +4587,14 @@ static int init_cs5529(struct comedi_device *dev)
 #if 1
        /* do self-calibration */
        cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_BOTH_SELF,
-                           CSCMD_CONFIG_REGISTER);
+                           CS5529_CFG_REG);
        /* need to force a conversion for calibration to run */
        cs5529_do_conversion(dev, NULL);
 #else
        /* force gain calibration to 1 */
-       cs5529_config_write(dev, 0x400000, CSCMD_GAIN_REGISTER);
+       cs5529_config_write(dev, 0x400000, CS5529_GAIN_REG);
        cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_OFFSET_SELF,
-                           CSCMD_CONFIG_REGISTER);
+                           CS5529_CFG_REG);
        if (cs5529_wait_for_idle(dev))
                dev_err(dev->class_dev,
                        "timeout or signal in %s\n", __func__);
index 3d1fd9b08684b134303b2354d0002d727cf3b1c7..0013e304ed563568868ee2c1541d13a1b00c7b09 100644 (file)
@@ -677,6 +677,20 @@ enum AO_Misc_611x_Bits {
        CLEAR_WG = 1,
 };
 
+#define CS5529_CMD_CB                  BIT(7)
+#define CS5529_CMD_SINGLE_CONV         BIT(6)
+#define CS5529_CMD_CONT_CONV           BIT(5)
+#define CS5529_CMD_READ                        BIT(4)
+#define CS5529_CMD_REG(x)              (((x) & 0x7) << 1)
+#define CS5529_CMD_REG_MASK            CS5529_CMD_REG(7)
+#define CS5529_CMD_PWR_SAVE            BIT(0)
+
+#define CS5529_OFFSET_REG              CS5529_CMD_REG(0)
+#define CS5529_GAIN_REG                        CS5529_CMD_REG(1)
+#define CS5529_CONV_DATA_REG           CS5529_CMD_REG(3)
+#define CS5529_SETUP_REG               CS5529_CMD_REG(4)
+
+#define CS5529_CFG_REG                 CS5529_CMD_REG(2)
 #define CS5529_CFG_AOUT(x)             BIT(22 + (x))
 #define CS5529_CFG_DOUT(x)             BIT(18 + (x))
 #define CS5529_CFG_LOW_PWR_MODE                BIT(16)
@@ -704,17 +718,6 @@ enum AO_Misc_611x_Bits {
 #define CS5529_CFG_CALIB_OFFSET_SYS    CS5529_CFG_CALIB(5)
 #define CS5529_CFG_CALIB_GAIN_SYS      CS5529_CFG_CALIB(6)
 
-enum cs5529_command_bits {
-       CSCMD_POWER_SAVE = 0x1,
-       CSCMD_REGISTER_SELECT_MASK = 0xe,
-       CSCMD_OFFSET_REGISTER = 0x0,
-       CSCMD_GAIN_REGISTER = 0x2,
-       CSCMD_CONFIG_REGISTER = 0x4,
-       CSCMD_READ = 0x10,
-       CSCMD_CONTINUOUS_CONVERSIONS = 0x20,
-       CSCMD_SINGLE_CONVERSION = 0x40,
-       CSCMD_COMMAND = 0x80,
-};
 enum cs5529_status_bits {
        CSS_ADC_BUSY = 0x1,
        CSS_OSC_DETECT = 0x2,   /* indicates adc error */