diff --git a/include/zephyr/sys_clock.h b/include/zephyr/sys_clock.h index eab5df34d07..e43b539fb8f 100644 --- a/include/zephyr/sys_clock.h +++ b/include/zephyr/sys_clock.h @@ -146,9 +146,9 @@ typedef struct { /** @endcond */ -#if defined(CONFIG_SYS_CLOCK_EXISTS) && !defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME) -BUILD_ASSERT(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC != 0, - "SYS_CLOCK_HW_CYCLES_PER_SEC must be non-zero!"); +#if defined(CONFIG_SYS_CLOCK_EXISTS) && \ + (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC == 0) +#error "SYS_CLOCK_HW_CYCLES_PER_SEC must be non-zero!" #endif @@ -164,7 +164,7 @@ BUILD_ASSERT(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC != 0, * @{ */ -#if defined(CONFIG_SYS_CLOCK_EXISTS) && !defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME) +#ifdef CONFIG_SYS_CLOCK_EXISTS #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME) || \ (MSEC_PER_SEC % CONFIG_SYS_CLOCK_TICKS_PER_SEC) || \ diff --git a/kernel/Kconfig b/kernel/Kconfig index c237a5af48a..af51267edbf 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -799,7 +799,6 @@ config SYS_CLOCK_TICKS_PER_SEC config SYS_CLOCK_HW_CYCLES_PER_SEC int "System clock's h/w timer frequency" - depends on !TIMER_READS_ITS_FREQUENCY_AT_RUNTIME help This option specifies the frequency of the hardware timer used for the system clock (in Hz). This option is set by the SOC's or board's Kconfig file diff --git a/kernel/timeout.c b/kernel/timeout.c index 55ba6dd3d2f..8c727e204f9 100644 --- a/kernel/timeout.c +++ b/kernel/timeout.c @@ -25,7 +25,7 @@ static struct k_spinlock timeout_lock; static int announce_remaining; #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME) -int z_clock_hw_cycles_per_sec; +int z_clock_hw_cycles_per_sec = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC; #ifdef CONFIG_USERSPACE static inline int z_vrfy_sys_clock_hw_cycles_per_sec_runtime_get(void)