Skip to content

Commit 4323243

Browse files
Flavio Ceolinandrewboie
authored andcommitted
sys_clock: Change function signature
__ticks_to_ms always return an unsigned value, changing the function to reflect it. Signed-off-by: Flavio Ceolin <[email protected]>
1 parent f1f82a8 commit 4323243

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

include/sys_clock.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,21 @@ static ALWAYS_INLINE s32_t _ms_to_ticks(s32_t ms)
125125
#endif
126126
}
127127

128-
static inline s64_t __ticks_to_ms(s64_t ticks)
128+
static inline u64_t __ticks_to_ms(s64_t ticks)
129129
{
130130
#ifdef CONFIG_SYS_CLOCK_EXISTS
131131

132132
#ifdef _NEED_PRECISE_TICK_MS_CONVERSION
133133
/* use 64-bit math to keep precision */
134-
return (u64_t)ticks * MSEC_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
134+
return (u64_t)ticks * MSEC_PER_SEC / (u64_t)CONFIG_SYS_CLOCK_TICKS_PER_SEC;
135135
#else
136136
/* simple multiplication keeps precision */
137-
u32_t ms_per_tick = MSEC_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
138-
139-
return (u64_t)ticks * ms_per_tick;
137+
return (u64_t)ticks * MSEC_PER_SEC / (u64_t)CONFIG_SYS_CLOCK_TICKS_PER_SEC;
140138
#endif
141139

142140
#else
143141
__ASSERT(ticks == 0, "ticks not zero");
144-
return 0;
142+
return 0ULL;
145143
#endif
146144
}
147145

0 commit comments

Comments
 (0)