staging: comedi: ni_tio: remove unnecessary ni_gpct_variant BUG() cases
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 24 Jul 2014 17:14:29 +0000 (10:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 27 Jul 2014 18:16:46 +0000 (11:16 -0700)
The enum ni_gpct_variant is used to handle hardware variations in the
gpct timers handled by this driver. This enum is defined as:

enum ni_gpct_variant {
ni_gpct_variant_e_series,
ni_gpct_variant_m_series,
ni_gpct_variant_660x
};

For all the switch statements where all three enum values are handled,
remove the unreachable BUG(). Move the default case so it is handled
the same as ni_gpct_variant_e_series.

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

index 49ffb508de000d25af839ef5434c2ce6ba26ddd6..c876273a80f49bffcaeed1d4edc4d92c64435757 100644 (file)
@@ -58,16 +58,13 @@ Gi_Alternate_Sync_Bit(enum ni_gpct_variant variant)
 {
        switch (variant) {
        case ni_gpct_variant_e_series:
+       default:
                return 0;
        case ni_gpct_variant_m_series:
                return Gi_M_Series_Alternate_Sync_Bit;
        case ni_gpct_variant_660x:
                return Gi_660x_Alternate_Sync_Bit;
-       default:
-               BUG();
-               break;
        }
-       return 0;
 }
 
 static inline enum Gi_Counting_Mode_Reg_Bits
@@ -75,16 +72,13 @@ Gi_Prescale_X2_Bit(enum ni_gpct_variant variant)
 {
        switch (variant) {
        case ni_gpct_variant_e_series:
+       default:
                return 0;
        case ni_gpct_variant_m_series:
                return Gi_M_Series_Prescale_X2_Bit;
        case ni_gpct_variant_660x:
                return Gi_660x_Prescale_X2_Bit;
-       default:
-               BUG();
-               break;
        }
-       return 0;
 }
 
 static inline enum Gi_Counting_Mode_Reg_Bits
@@ -92,16 +86,13 @@ Gi_Prescale_X8_Bit(enum ni_gpct_variant variant)
 {
        switch (variant) {
        case ni_gpct_variant_e_series:
+       default:
                return 0;
        case ni_gpct_variant_m_series:
                return Gi_M_Series_Prescale_X8_Bit;
        case ni_gpct_variant_660x:
                return Gi_660x_Prescale_X8_Bit;
-       default:
-               BUG();
-               break;
        }
-       return 0;
 }
 
 static inline enum Gi_Counting_Mode_Reg_Bits
@@ -109,16 +100,13 @@ Gi_HW_Arm_Select_Mask(enum ni_gpct_variant variant)
 {
        switch (variant) {
        case ni_gpct_variant_e_series:
+       default:
                return 0;
        case ni_gpct_variant_m_series:
                return Gi_M_Series_HW_Arm_Select_Mask;
        case ni_gpct_variant_660x:
                return Gi_660x_HW_Arm_Select_Mask;
-       default:
-               BUG();
-               break;
        }
-       return 0;
 }
 
 /* clock sources for ni_660x boards, get bits with Gi_Source_Select_Bits() */
@@ -304,15 +292,12 @@ ni_tio_second_gate_registers_present(const struct ni_gpct_device *counter_dev)
 {
        switch (counter_dev->variant) {
        case ni_gpct_variant_e_series:
+       default:
                return 0;
        case ni_gpct_variant_m_series:
        case ni_gpct_variant_660x:
                return 1;
-       default:
-               BUG();
-               break;
        }
-       return 0;
 }
 
 static void ni_tio_reset_count_and_disarm(struct ni_gpct *counter)
@@ -704,12 +689,10 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter,
                break;
        case ni_gpct_variant_e_series:
        case ni_gpct_variant_m_series:
+       default:
                input_select_bits |=
                    ni_m_series_source_select_bits(clock_source);
                break;
-       default:
-               BUG();
-               break;
        }
        if (clock_source & NI_GPCT_INVERT_CLOCK_SRC_BIT)
                input_select_bits |= Gi_Source_Polarity_Bit;
@@ -891,14 +874,11 @@ static unsigned ni_tio_generic_clock_src_select(const struct ni_gpct *counter)
        switch (counter->counter_dev->variant) {
        case ni_gpct_variant_e_series:
        case ni_gpct_variant_m_series:
+       default:
                return ni_m_series_clock_src_select(counter);
        case ni_gpct_variant_660x:
                return ni_660x_clock_src_select(counter);
-       default:
-               BUG();
-               break;
        }
-       return 0;
 }
 
 static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter,
@@ -1174,12 +1154,10 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index,
                switch (counter_dev->variant) {
                case ni_gpct_variant_e_series:
                case ni_gpct_variant_m_series:
+               default:
                        return ni_m_series_set_first_gate(counter, gate_source);
                case ni_gpct_variant_660x:
                        return ni_660x_set_first_gate(counter, gate_source);
-               default:
-                       BUG();
-                       break;
                }
                break;
        case 1:
@@ -1415,6 +1393,7 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index,
                switch (counter_dev->variant) {
                case ni_gpct_variant_e_series:
                case ni_gpct_variant_m_series:
+               default:
                        *gate_source =
                            ni_m_series_first_gate_to_generic_gate_source
                            (gate_select_bits);
@@ -1424,9 +1403,6 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index,
                            ni_660x_first_gate_to_generic_gate_source
                            (gate_select_bits);
                        break;
-               default:
-                       BUG();
-                       break;
                }
                if (mode_bits & Gi_Gate_Polarity_Bit)
                        *gate_source |= CR_INVERT;
@@ -1448,6 +1424,7 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index,
                switch (counter_dev->variant) {
                case ni_gpct_variant_e_series:
                case ni_gpct_variant_m_series:
+               default:
                        *gate_source =
                            ni_m_series_second_gate_to_generic_gate_source
                            (gate_select_bits);
@@ -1457,9 +1434,6 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index,
                            ni_660x_second_gate_to_generic_gate_source
                            (gate_select_bits);
                        break;
-               default:
-                       BUG();
-                       break;
                }
                if (counter_dev->regs[second_gate_reg] &
                    Gi_Second_Gate_Polarity_Bit) {