aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/counter/stm32-lptimer-cnt.c
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2021-08-03 21:06:12 +0900
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-08-09 20:17:36 +0100
commitb11eed1554e8ea33b748094ea73d8b42fa2bbe3b (patch)
tree9fef0018387c91f35cf29b9d8386da362814239f /drivers/counter/stm32-lptimer-cnt.c
parentcounter: 104-quad-8: Return error when invalid mode during ceiling_write (diff)
downloadlinux-dev-b11eed1554e8ea33b748094ea73d8b42fa2bbe3b.tar.xz
linux-dev-b11eed1554e8ea33b748094ea73d8b42fa2bbe3b.zip
counter: Return error code on invalid modes
Only a select set of modes (function, action, etc.) are valid for a given device configuration. This patch ensures that invalid modes result in a return -EINVAL. Such a situation should never occur in reality, but it's good to define a default switch case for the sake of making the intent of the code clear. Cc: Kamel Bouhara <kamel.bouhara@bootlin.com> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Alexandre Torgue <alexandre.torgue@st.com> Acked-by: David Lechner <david@lechnology.com> Acked-by: Syed Nayyar Waris <syednwaris@gmail.com> Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Link: https://lore.kernel.org/r/7af82d4e39610da11edce0ee370285fe1cb1eac8.1627990337.git.vilhelm.gray@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/counter/stm32-lptimer-cnt.c')
-rw-r--r--drivers/counter/stm32-lptimer-cnt.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c
index c19d998df5ba..78f383b77bd2 100644
--- a/drivers/counter/stm32-lptimer-cnt.c
+++ b/drivers/counter/stm32-lptimer-cnt.c
@@ -206,9 +206,10 @@ static int stm32_lptim_cnt_function_set(struct counter_device *counter,
priv->quadrature_mode = 1;
priv->polarity = STM32_LPTIM_SYNAPSE_ACTION_BOTH_EDGES;
return 0;
+ default:
+ /* should never reach this path */
+ return -EINVAL;
}
-
- return -EINVAL;
}
static ssize_t stm32_lptim_cnt_enable_read(struct counter_device *counter,
@@ -326,9 +327,10 @@ static int stm32_lptim_cnt_action_get(struct counter_device *counter,
case STM32_LPTIM_ENCODER_BOTH_EDGE:
*action = priv->polarity;
return 0;
+ default:
+ /* should never reach this path */
+ return -EINVAL;
}
-
- return -EINVAL;
}
static int stm32_lptim_cnt_action_set(struct counter_device *counter,