staging: comedi: ni_tio: tidy up Gxx_Status_Bits

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>
This commit is contained in:
H Hartley Sweeten
2014-07-28 10:26:53 -07:00
committed by Greg Kroah-Hartman
parent 4359dcf356
commit 24a675c513
3 changed files with 14 additions and 67 deletions

View 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);
}

View File

@@ -117,6 +117,14 @@
#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))
@@ -127,67 +135,6 @@
#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)
{

View 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;
}