Subject: Re: [PATCHv9 2/5] irqchip/tegra: Fix overflow implicit truncation warnings

From: Marc Zyngier <[email-masked]>
Date: Tue, 25 Jan 2022 09:30:34 +0000

On Mon, 24 Jan 2022 06:33:31 +0000,
Sai Prakash Ranjan <[email-masked]> wrote:
> 
> Fix -Woverflow warnings for tegra irqchip driver which is a result
> of moving arm64 custom MMIO accessor macros to asm-generic function
> implementations giving a bonus type-checking now and uncovering these
> overflow warnings.
> 
> drivers/irqchip/irq-tegra.c: In function ‘tegra_ictlr_suspend’:
> drivers/irqchip/irq-tegra.c:151:18: warning: large integer implicitly truncated to unsigned type [-Woverflow]
>    writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR);
>                   ^
> 
> Cc: Marc Zyngier <[email-masked]>
> Reviewed-by: Arnd Bergmann <[email-masked]>
> Signed-off-by: Sai Prakash Ranjan <[email-masked]>
> ---
>  drivers/irqchip/irq-tegra.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-tegra.c b/drivers/irqchip/irq-tegra.c
> index e1f771c72fc4..9e4e5b39c701 100644
> --- a/drivers/irqchip/irq-tegra.c
> +++ b/drivers/irqchip/irq-tegra.c
> @@ -148,10 +148,10 @@ static int tegra_ictlr_suspend(void)
>  		lic->cop_iep[i] = readl_relaxed(ictlr + ICTLR_COP_IEP_CLASS);
>  
>  		/* Disable COP interrupts */
> -		writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR);
> +		writel_relaxed(~0u, ictlr + ICTLR_COP_IER_CLR);

Aside from the 'l' in writel really meaning 'long' (a historical
artefact), it would probably be better to lift the ambiguity entirely
and write this as GENMASK(31, 0), making it clear what is being set,
no matter what the revision of the architecture is (this driver also
works on 32bit machines).

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel