Skip to content

Commit 2027d97

Browse files
alvsunkartben
authored andcommitted
drivers: clock_control: add validation for SYS_CLOCK_HW_CYCLES_PER_SEC
Check whether the value of SYS_CLOCK_HW_CYCLES_PER_SEC is valid. Signed-off-by: Alvis Sun <yfsun@nuvoton.com>
1 parent d789d13 commit 2027d97

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/clock_control/clock_control_npcx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ static DEVICE_API(clock_control, npcx_clock_control_api) = {
161161
};
162162

163163
/* valid clock frequency check */
164+
BUILD_ASSERT(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC == OFMCLK / (APB2DIV_VAL + 1),
165+
"SYS_CLOCK_HW_CYCLES_PER_SEC must equal to OFMCLK/APB2DIV_VAL");
164166
BUILD_ASSERT(OFMCLK <= MAX_OFMCLK, "Exceed maximum OFMCLK setting");
165167
BUILD_ASSERT(CORE_CLK <= MAX_OFMCLK && CORE_CLK >= MHZ(4) &&
166168
OFMCLK % CORE_CLK == 0 &&

0 commit comments

Comments
 (0)