This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch releases/13.1 in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 54309cc738dd9d491f52088a37d3368aab67c581 Author: ouyangxiangzhen <[email protected]> AuthorDate: Wed May 20 09:51:02 2026 +0800 timers/clkcnt: Round-up when converting nsec to cnt Use round-up logic in clkcnt_delta_time2cnt() to prevent timer sleep duration being too short due to truncation. Signed-off-by: ouyangxiangzhen <[email protected]> --- include/nuttx/timers/clkcnt.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/nuttx/timers/clkcnt.h b/include/nuttx/timers/clkcnt.h index e9ed6487936..b835ea03249 100644 --- a/include/nuttx/timers/clkcnt.h +++ b/include/nuttx/timers/clkcnt.h @@ -178,7 +178,9 @@ clkcnt_t clkcnt_delta_time2cnt(uint64_t time, uint32_t freq, uint32_t scale) DEBUGASSERT(time <= CLKCNT_MAX / freq); - return div_const(time * freq, scale); + /* Round-up to the scale. */ + + return div_const(time * freq + (scale - 1u), scale); } /****************************************************************************
