From bbb8fafdcf11dacaaefea8c11a82616aee4f7ac4 Mon Sep 17 00:00:00 2001 From: Emilio Bottoni Date: Tue, 23 Jun 2026 15:02:03 -0300 Subject: [PATCH] drivers: rtc: mchp_g1: initialize unsupported rtc_time fields The get_alarm_time and get_clock_time functions were leaving tm_wday, tm_yday, tm_isdst, and tm_nsec uninitialized after populating the rtc_time struct. These fields are not backed by hardware registers, so callers would read indeterminate values. Set tm_wday, tm_yday, and tm_isdst to -1 (unsupported/unknown) and tm_nsec to 0, matching the convention used by other RTC drivers in Zephyr. Signed-off-by: Emilio Bottoni --- drivers/rtc/rtc_mchp_g1.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/rtc/rtc_mchp_g1.c b/drivers/rtc/rtc_mchp_g1.c index 841549cfae0..291bb86f76c 100644 --- a/drivers/rtc/rtc_mchp_g1.c +++ b/drivers/rtc/rtc_mchp_g1.c @@ -642,6 +642,11 @@ static int rtc_mchp_get_alarm_time(const struct device *dev, uint16_t alarm_id, timeptr->tm_mday = (int)rtc_alarm_time.date_of_month; timeptr->tm_year = (int)rtc_alarm_time.year; + timeptr->tm_wday = -1; + timeptr->tm_yday = -1; + timeptr->tm_isdst = -1; + timeptr->tm_nsec = 0; + return 0; } @@ -733,6 +738,11 @@ static int rtc_mchp_get_clock_time(const struct device *dev, struct rtc_time *ti timeptr->tm_mday = (int)rtc_current_time.date_of_month; timeptr->tm_year = (int)rtc_current_time.year; + timeptr->tm_wday = -1; + timeptr->tm_yday = -1; + timeptr->tm_isdst = -1; + timeptr->tm_nsec = 0; + return 0; }