[PATCH v11 10/33] counter: stm32-lptimer-cnt: Add const qualifier for functions_list array

Jonathan Cameron jic23 at kernel.org
Wed Jun 9 08:25:39 PDT 2021


On Wed,  9 Jun 2021 10:31:13 +0900
William Breathitt Gray <vilhelm.gray at gmail.com> wrote:

> The struct counter_count functions_list member expects a const enum
> counter_count_function array. This patch adds the const qualifier to the
> stm32_lptim_cnt_functions to match functions_list.
> 
> Reviewed-by: Fabrice Gasnier <fabrice.gasnier at foss.st.com>
> Signed-off-by: William Breathitt Gray <vilhelm.gray at gmail.com>
Applied.

btw a different reasoning for all of these is that static const is
read only and will let linker and compiler do various tricks that it can't
do otherwise.

Jonathan

> ---
>  drivers/counter/stm32-lptimer-cnt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c
> index 937439635d53..0f7d3f1ec1b6 100644
> --- a/drivers/counter/stm32-lptimer-cnt.c
> +++ b/drivers/counter/stm32-lptimer-cnt.c
> @@ -134,7 +134,7 @@ enum stm32_lptim_cnt_function {
>  	STM32_LPTIM_ENCODER_BOTH_EDGE,
>  };
>  
> -static enum counter_count_function stm32_lptim_cnt_functions[] = {
> +static const enum counter_count_function stm32_lptim_cnt_functions[] = {
>  	[STM32_LPTIM_COUNTER_INCREASE] = COUNTER_COUNT_FUNCTION_INCREASE,
>  	[STM32_LPTIM_ENCODER_BOTH_EDGE] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4,
>  };




More information about the linux-arm-kernel mailing list