counter: Return error code on invalid modes
[linux-2.6-microblaze.git] / drivers / counter / ti-eqep.c
index 65df9ef..c303eb1 100644 (file)
@@ -157,7 +157,7 @@ static int ti_eqep_action_get(struct counter_device *counter,
                 * QEPA and QEPB trigger QCLK.
                 */
                *action = TI_EQEP_SYNAPSE_ACTION_BOTH_EDGES;
-               break;
+               return 0;
        case TI_EQEP_COUNT_FUNC_DIR_COUNT:
                /* In direction-count mode only rising edge of QEPA is counted
                 * and QEPB gives direction.
@@ -165,12 +165,14 @@ static int ti_eqep_action_get(struct counter_device *counter,
                switch (synapse->signal->id) {
                case TI_EQEP_SIGNAL_QEPA:
                        *action = TI_EQEP_SYNAPSE_ACTION_RISING_EDGE;
-                       break;
-               default:
+                       return 0;
+               case TI_EQEP_SIGNAL_QEPB:
                        *action = TI_EQEP_SYNAPSE_ACTION_NONE;
-                       break;
+                       return 0;
+               default:
+                       /* should never reach this path */
+                       return -EINVAL;
                }
-               break;
        case TI_EQEP_COUNT_FUNC_UP_COUNT:
        case TI_EQEP_COUNT_FUNC_DOWN_COUNT:
                /* In up/down-count modes only QEPA is counted and QEPB is not
@@ -186,15 +188,18 @@ static int ti_eqep_action_get(struct counter_device *counter,
                                *action = TI_EQEP_SYNAPSE_ACTION_BOTH_EDGES;
                        else
                                *action = TI_EQEP_SYNAPSE_ACTION_RISING_EDGE;
-                       break;
-               default:
+                       return 0;
+               case TI_EQEP_SIGNAL_QEPB:
                        *action = TI_EQEP_SYNAPSE_ACTION_NONE;
-                       break;
+                       return 0;
+               default:
+                       /* should never reach this path */
+                       return -EINVAL;
                }
-               break;
+       default:
+               /* should never reach this path */
+               return -EINVAL;
        }
-
-       return 0;
 }
 
 static const struct counter_ops ti_eqep_counter_ops = {