From 4eac3db1b97dd3b1665fec6fc6432d983701fd98 Mon Sep 17 00:00:00 2001 From: Johan Lafon Date: Mon, 11 Sep 2023 12:18:57 +0200 Subject: [PATCH] drivers: rtc: stm32: check if tm_wday is set tm/rtc_time structure allow for tm_wday to be set to -1 if unknown but RTC is expecting it Signed-off-by: Johan Lafon --- drivers/rtc/rtc_ll_stm32.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/rtc/rtc_ll_stm32.c b/drivers/rtc/rtc_ll_stm32.c index f8af22d00c5..c95c331ee97 100644 --- a/drivers/rtc/rtc_ll_stm32.c +++ b/drivers/rtc/rtc_ll_stm32.c @@ -138,6 +138,11 @@ static int rtc_stm32_set_time(const struct device *dev, const struct rtc_time *t return -EINVAL; } + if (timeptr->tm_wday == -1) { + /* day of the week is expected */ + return -EINVAL; + } + LOG_INF("Setting clock"); LL_RTC_DisableWriteProtection(RTC);