Re: [PATCH] clockevents: timer-stm32: Fix build warning spotted by kbuild test robot

From: Luc Van Oostenryck
Date: Wed May 27 2015 - 18:52:25 EST


On Wed, May 27, 2015 at 06:41:23PM +0200, Maxime Coquelin wrote:
> This patch fixes below warning spotted by kbuild test robot when building
> with ARCH=powerpc:
>
> drivers/clocksource/timer-stm32.c: In function 'stm32_clockevent_init':
> >> drivers/clocksource/timer-stm32.c:140:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
> writel_relaxed(~0UL, data->base + TIM_ARR);
>
> The fix consists in casting the value to u32.
>
> Reported-by: kbuild test robot <fengguang.wu@xxxxxxxxx>
> Signed-off-by: Maxime Coquelin <mcoquelin.stm32@xxxxxxxxx>
> ---
> drivers/clocksource/timer-stm32.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c
> index fad2e2e..c9578d8 100644
> --- a/drivers/clocksource/timer-stm32.c
> +++ b/drivers/clocksource/timer-stm32.c
> @@ -137,7 +137,7 @@ static void __init stm32_clockevent_init(struct device_node *np)
> }
>
> /* Detect whether the timer is 16 or 32 bits */
> - writel_relaxed(~0UL, data->base + TIM_ARR);
> + writel_relaxed((u32)~0UL, data->base + TIM_ARR);
> max_delta = readl_relaxed(data->base + TIM_ARR);
> if (max_delta == ~0UL) {
> prescaler = 1;


Since the warning come from using a unsigned long constant while
writel() expect an unsigned int, why not simply use ~0U ?


Luc Van Oostenryck
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/