From 462a7262be4bb5d325c428a2ae4453b00cc8a87c Mon Sep 17 00:00:00 2001 From: Brett Witherspoon Date: Sat, 16 Sep 2023 15:44:43 -0400 Subject: [PATCH] drivers: rtc: stm32: add build assertion for source clock Assert the source clock is defined in the device tree to ensure the reference is valid. Signed-off-by: Brett Witherspoon --- drivers/rtc/rtc_ll_stm32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc_ll_stm32.c b/drivers/rtc/rtc_ll_stm32.c index cb7c85ad3a1..722a1552558 100644 --- a/drivers/rtc/rtc_ll_stm32.c +++ b/drivers/rtc/rtc_ll_stm32.c @@ -167,6 +167,8 @@ static int rtc_stm32_init(const struct device *dev) static const struct stm32_pclken rtc_clk[] = STM32_DT_INST_CLOCKS(0); +BUILD_ASSERT(DT_INST_CLOCKS_HAS_IDX(0, 1), "RTC source clock not defined in the device tree"); + static const struct rtc_stm32_config rtc_config = { #if DT_INST_CLOCKS_CELL_BY_IDX(0, 1, bus) == STM32_SRC_LSI /* prescaler values for LSI @ 32 KHz */