Skip to contentSkip to conversation

clocksource: fsl: avoid harmless 64-bit warnings

PATCH In review Arnd Bergmann 4 participants 7 messages Nov 16, 2015 – Nov 17, 2015 Clocksource, clockevent drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: fsl: avoid harmless 64-bit warnings

The ftm_clockevent_init passes the value of "~0UL" into a function that takes a 32-bit argument, which drops the upper 32 bits, as gcc warns about on ARM64:

clocksource/fsl_ftm_timer.c: In function 'ftm_clockevent_init':
clocksource/fsl_ftm_timer.c:206:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]

This was obviously unintended behavior, and is easily avoided by using '~0u' as the integer literal, because that is 32-bit wide on all architectures.

drivers/clocksource/fsl_ftm_timer.c +2 -2
index 10202f1fdfd7..517e1c7624d4 100644
@@ -203,7 +203,7 @@ static int __init ftm_clockevent_init(unsigned long freq, int irq)
 	int err;
 
 	ftm_writel(0x00, priv->clkevt_base + FTM_CNTIN);
-	ftm_writel(~0UL, priv->clkevt_base + FTM_MOD);
+	ftm_writel(~0u, priv->clkevt_base + FTM_MOD);
 
 	ftm_reset_counter(priv->clkevt_base);
 
@@ -230,7 +230,7 @@ static int __init ftm_clocksource_init(unsigned long freq)
 	int err;
 
 	ftm_writel(0x00, priv->clksrc_base + FTM_CNTIN);
-	ftm_writel(~0UL, priv->clksrc_base + FTM_MOD);
+	ftm_writel(~0u, priv->clksrc_base + FTM_MOD);
 
 	ftm_reset_counter(priv->clksrc_base);
 
#1 lore raw
Quoted 4 lines · Arnd Bergmann

The ftm_clockevent_init passes the value of "~0UL" into a function that takes a 32-bit argument, which drops the upper 32 bits, as gcc warns about on ARM64:

Quoted 8 lines

clocksource/fsl_ftm_timer.c: In function 'ftm_clockevent_init':
clocksource/fsl_ftm_timer.c:206:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]

This was obviously unintended behavior, and is easily avoided by using '~0u' as the integer literal, because that is 32-bit wide on all architectures.

Thanks Arnd for the fix. I will apply it on top of branch.

#2 lore raw

[tip:timers/urgent] clocksource/fsl: Avoid harmless 64-bit warnings

In reply to Arnd Bergmann
clocksource/fsl: Avoid harmless 64-bit warnings
Commit-ID:  dde7632ed02382e4bac2b57c66ee2285764f2cd7
Gitweb:     http://git.kernel.org/tip/dde7632ed02382e4bac2b57c66ee2285764f2cd7
Author:     Arnd Bergmann <[email protected]>
AuthorDate: Mon, 16 Nov 2015 17:34:50 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 16 Nov 2015 19:07:08 +0100

clocksource/fsl: Avoid harmless 64-bit warnings

The ftm_clockevent_init passes the value of "~0UL" into a function that takes a 32-bit argument, which drops the upper 32 bits, as gcc warns about on ARM64:

clocksource/fsl_ftm_timer.c: In function 'ftm_clockevent_init':
clocksource/fsl_ftm_timer.c:206:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]

This was obviously unintended behavior, and is easily avoided by using '~0u' as the integer literal, because that is 32-bit wide on all architectures.

---
 drivers/clocksource/fsl_ftm_timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clocksource/fsl_ftm_timer.c +2 -2
index 10202f1..517e1c7 100644
@@ -203,7 +203,7 @@ static int __init ftm_clockevent_init(unsigned long freq, int irq)
 	int err;
 
 	ftm_writel(0x00, priv->clkevt_base + FTM_CNTIN);
-	ftm_writel(~0UL, priv->clkevt_base + FTM_MOD);
+	ftm_writel(~0u, priv->clkevt_base + FTM_MOD);
 
 	ftm_reset_counter(priv->clkevt_base);
 
@@ -230,7 +230,7 @@ static int __init ftm_clocksource_init(unsigned long freq)
 	int err;
 
 	ftm_writel(0x00, priv->clksrc_base + FTM_CNTIN);
-	ftm_writel(~0UL, priv->clksrc_base + FTM_MOD);
+	ftm_writel(~0u, priv->clksrc_base + FTM_MOD);
 
 	ftm_reset_counter(priv->clksrc_base);
 
#3 lore raw

Re: [tip:timers/urgent] clocksource/fsl: Avoid harmless 64-bit warnings

Quoted 30 lines · tip-bot for Arnd Bergmann
Commit-ID:  dde7632ed02382e4bac2b57c66ee2285764f2cd7
Gitweb:     http://git.kernel.org/tip/dde7632ed02382e4bac2b57c66ee2285764f2cd7
Author:     Arnd Bergmann <[email protected]>
AuthorDate: Mon, 16 Nov 2015 17:34:50 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 16 Nov 2015 19:07:08 +0100

clocksource/fsl: Avoid harmless 64-bit warnings

The ftm_clockevent_init passes the value of "~0UL" into a function that takes a 32-bit argument, which drops the upper 32 bits, as gcc warns about on ARM64:

clocksource/fsl_ftm_timer.c: In function 'ftm_clockevent_init':
clocksource/fsl_ftm_timer.c:206:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]

This was obviously unintended behavior, and is easily avoided by using '~0u' as the integer literal, because that is 32-bit wide on all architectures.

Quoted 1 line

---

Ok, I dropped the patch from my tree.

-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#4 lore raw

Re: [tip:timers/urgent] clocksource/fsl: Avoid harmless 64-bit warnings

Quoted 2 lines · Daniel Lezcano

Ok, I dropped the patch from my tree.

Had it already pushed when I saw your reply.

#5 lore raw

Re: [tip:timers/urgent] clocksource/fsl: Avoid harmless 64-bit warnings

Quoted 6 lines · Thomas Gleixner
Quoted 2 lines · Daniel Lezcano

Ok, I dropped the patch from my tree.

Had it already pushed when I saw your reply.

No problem. Better more than less :)

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#6 lore raw

Re: [tip:timers/urgent] clocksource/fsl: Avoid harmless 64-bit warnings

Quoted 9 lines · Daniel Lezcano
Quoted 6 lines · Thomas Gleixner
Quoted 2 lines · Daniel Lezcano

Ok, I dropped the patch from my tree.

Had it already pushed when I saw your reply.

No problem. Better more than less :)

Hum, I meant "Better to have too much than not enough".

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog