Skip to contentSkip to conversation

watchdog/aspeed: fix variable type to store reload value

PATCH Superseded Cédric Le Goater 2 participants 3 messages Sep 19, 2017 – Sep 20, 2017 Arm/Aspeed machine support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog/aspeed: fix variable type to store reload value

Initially from Anton D. Kachalov" <[email protected]> but the SoB was missing.

[clg: change commit log and subject]
---
 hw/watchdog/wdt_aspeed.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/watchdog/wdt_aspeed.c +2 -2
index 22bce364d7b5..b8e0e9a75999 100644
@@ -100,13 +100,13 @@ static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size)
 
 static void aspeed_wdt_reload(AspeedWDTState *s, bool pclk)
 {
-    uint32_t reload;
+    uint64_t reload;
 
     if (pclk) {
         reload = muldiv64(s->regs[WDT_RELOAD_VALUE], NANOSECONDS_PER_SECOND,
                           s->pclk_freq);
     } else {
-        reload = s->regs[WDT_RELOAD_VALUE] * 1000;
+        reload = s->regs[WDT_RELOAD_VALUE] * 1000UL;
     }
 
     if (aspeed_wdt_is_enabled(s)) {
Signature · 1 line
2.13.5
#1 lore raw

hw/watchdog/wdt_aspeed.c static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) · line 109

Quoted 8 lines · Cédric Le Goater
hw/watchdog/wdt_aspeed.c +2 -1
+    uint64_t reload;
 
     if (pclk) {
         reload = muldiv64(s->regs[WDT_RELOAD_VALUE], NANOSECONDS_PER_SECOND,
                           s->pclk_freq);
     } else {
-        reload = s->regs[WDT_RELOAD_VALUE] * 1000;
+        reload = s->regs[WDT_RELOAD_VALUE] * 1000UL;

UL does not help ilp32 hosts. Need ULL or an explicit cast.

r~

#2 lore raw
Quoted 11 lines · Richard Henderson

hw/watchdog/wdt_aspeed.c static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) · line 109

Quoted 8 lines · Cédric Le Goater
hw/watchdog/wdt_aspeed.c +2 -1
+    uint64_t reload;
 
     if (pclk) {
         reload = muldiv64(s->regs[WDT_RELOAD_VALUE], NANOSECONDS_PER_SECOND,
                           s->pclk_freq);
     } else {
-        reload = s->regs[WDT_RELOAD_VALUE] * 1000;
+        reload = s->regs[WDT_RELOAD_VALUE] * 1000UL;

UL does not help ilp32 hosts. Need ULL or an explicit cast.

ok. I will send a fix.

Thanks,

C.