staging: comedi: ni_tio: tidy up Gxx_Status_Bits
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 28 Jul 2014 17:26:53 +0000 (10:26 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Jul 2014 23:50:59 +0000 (16:50 -0700)
Convert this enum into defines and rename the CamelCase symbols.

For aesthetics, move the new defines so they are associated with
the register define.

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_tio.c
drivers/staging/comedi/drivers/ni_tio_internal.h
drivers/staging/comedi/drivers/ni_tiocmd.c

index 15364128c91f39ae7f97e1bf993580684f7ffc5d..ccdf96ed653919c5fac9104ed9e320b5e20b7eb4 100644 (file)
@@ -1200,9 +1200,9 @@ int ni_tio_insn_config(struct comedi_device *dev,
        case INSN_CONFIG_GET_COUNTER_STATUS:
                data[1] = 0;
                status = read_register(counter, NITIO_SHARED_STATUS_REG(cidx));
-               if (status & Gi_Armed_Bit(cidx)) {
+               if (status & GI_ARMED(cidx)) {
                        data[1] |= COMEDI_COUNTER_ARMED;
-                       if (status & Gi_Counting_Bit(cidx))
+                       if (status & GI_COUNTING(cidx))
                                data[1] |= COMEDI_COUNTER_COUNTING;
                }
                data[2] = COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
@@ -1289,7 +1289,7 @@ static unsigned ni_tio_next_load_register(struct ni_gpct *counter)
        const unsigned bits =
                read_register(counter, NITIO_SHARED_STATUS_REG(cidx));
 
-       return (bits & Gi_Next_Load_Source_Bit(cidx))
+       return (bits & GI_NEXT_LOAD_SRC(cidx))
                        ? NITIO_LOADB_REG(cidx)
                        : NITIO_LOADA_REG(cidx);
 }
index 889bd3063c27177cb9ed0ec931c783faeccb148e..37fde62b0d6e88a6940f586958c26f640d9a15bf 100644 (file)
 #define GI_GATE2_SUBSEL                        (1 << 14)
 #define GI_SRC_SUBSEL                  (1 << 15)
 #define NITIO_SHARED_STATUS_REG(x)     (NITIO_G01_STATUS + ((x) / 2))
+#define GI_SAVE(x)                     (((x) % 2) ? (1 << 1) : (1 << 0))
+#define GI_COUNTING(x)                 (((x) % 2) ? (1 << 3) : (1 << 2))
+#define GI_NEXT_LOAD_SRC(x)            (((x) % 2) ? (1 << 5) : (1 << 4))
+#define GI_STALE_DATA(x)               (((x) % 2) ? (1 << 7) : (1 << 6))
+#define GI_ARMED(x)                    (((x) % 2) ? (1 << 9) : (1 << 8))
+#define GI_NO_LOAD_BETWEEN_GATES(x)    (((x) % 2) ? (1 << 11) : (1 << 10))
+#define GI_TC_ERROR(x)                 (((x) % 2) ? (1 << 13) : (1 << 12))
+#define GI_GATE_ERROR(x)               (((x) % 2) ? (1 << 15) : (1 << 14))
 #define NITIO_RESET_REG(x)             (NITIO_G01_RESET + ((x) / 2))
 #define NITIO_STATUS1_REG(x)           (NITIO_G01_STATUS1 + ((x) / 2))
 #define NITIO_STATUS2_REG(x)           (NITIO_G01_STATUS2 + ((x) / 2))
 #define NITIO_STATUS_REG(x)            (NITIO_G0_STATUS + (x))
 #define NITIO_INT_ENA_REG(x)           (NITIO_G0_INT_ENA + (x))
 
-enum Gxx_Status_Bits {
-       G0_Save_Bit = 0x1,
-       G1_Save_Bit = 0x2,
-       G0_Counting_Bit = 0x4,
-       G1_Counting_Bit = 0x8,
-       G0_Next_Load_Source_Bit = 0x10,
-       G1_Next_Load_Source_Bit = 0x20,
-       G0_Stale_Data_Bit = 0x40,
-       G1_Stale_Data_Bit = 0x80,
-       G0_Armed_Bit = 0x100,
-       G1_Armed_Bit = 0x200,
-       G0_No_Load_Between_Gates_Bit = 0x400,
-       G1_No_Load_Between_Gates_Bit = 0x800,
-       G0_TC_Error_Bit = 0x1000,
-       G1_TC_Error_Bit = 0x2000,
-       G0_Gate_Error_Bit = 0x4000,
-       G1_Gate_Error_Bit = 0x8000
-};
-static inline enum Gxx_Status_Bits Gi_Counting_Bit(unsigned counter_index)
-{
-       if (counter_index % 2)
-               return G1_Counting_Bit;
-       return G0_Counting_Bit;
-}
-
-static inline enum Gxx_Status_Bits Gi_Armed_Bit(unsigned counter_index)
-{
-       if (counter_index % 2)
-               return G1_Armed_Bit;
-       return G0_Armed_Bit;
-}
-
-static inline enum Gxx_Status_Bits Gi_Next_Load_Source_Bit(unsigned
-                                                          counter_index)
-{
-       if (counter_index % 2)
-               return G1_Next_Load_Source_Bit;
-       return G0_Next_Load_Source_Bit;
-}
-
-static inline enum Gxx_Status_Bits Gi_Stale_Data_Bit(unsigned counter_index)
-{
-       if (counter_index % 2)
-               return G1_Stale_Data_Bit;
-       return G0_Stale_Data_Bit;
-}
-
-static inline enum Gxx_Status_Bits Gi_TC_Error_Bit(unsigned counter_index)
-{
-       if (counter_index % 2)
-               return G1_TC_Error_Bit;
-       return G0_TC_Error_Bit;
-}
-
-static inline enum Gxx_Status_Bits Gi_Gate_Error_Bit(unsigned counter_index)
-{
-       if (counter_index % 2)
-               return G1_Gate_Error_Bit;
-       return G0_Gate_Error_Bit;
-}
-
 /* joint reset register bits */
 static inline unsigned Gi_Reset_Bit(unsigned counter_index)
 {
index 16dba7fe7797f5a6faa83d0199b3735149e4b091..d628748ac5139a919b81ee7a846a7add898d42c8 100644 (file)
@@ -377,7 +377,7 @@ void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error,
        if (stale_data)
                *stale_data = 0;
 
-       if (gxx_status & Gi_Gate_Error_Bit(cidx)) {
+       if (gxx_status & GI_GATE_ERROR(cidx)) {
                ack |= Gi_Gate_Error_Confirm_Bit(cidx);
                if (gate_error) {
                        /*660x don't support automatic acknowledgement
@@ -389,7 +389,7 @@ void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error,
                        }
                }
        }
-       if (gxx_status & Gi_TC_Error_Bit(cidx)) {
+       if (gxx_status & GI_TC_ERROR(cidx)) {
                ack |= Gi_TC_Error_Confirm_Bit(cidx);
                if (tc_error)
                        *tc_error = 1;
@@ -404,7 +404,7 @@ void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, int *gate_error,
                write_register(counter, ack, NITIO_INT_ACK_REG(cidx));
        if (ni_tio_get_soft_copy(counter, NITIO_MODE_REG(cidx)) &
            GI_LOADING_ON_GATE) {
-               if (gxx_status & Gi_Stale_Data_Bit(cidx)) {
+               if (gxx_status & GI_STALE_DATA(cidx)) {
                        if (stale_data)
                                *stale_data = 1;
                }
This page took 0.028687 seconds and 5 git commands to generate.