rtc: mcfrtc: fix leap year calculation using wrong variable

The leap year check in rtc_set() passes the loop variable 'i' (month
index, always 1 when the condition is true) to isleap() instead of the
actual year. Since isleap(1) is always false, February 29th is never
accounted for when computing the day count, resulting in the RTC being
set one day behind for any date after February in a leap year.

Pass tmp->tm_year to isleap() so the leap day is correctly included.

Fixes: 8e585f02f8 ("Added M5329AFEE and M5329BFEE Platforms")
Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev@gmail.com>
This commit is contained in:
Naveen Kumar Chaudhary
2026-06-29 15:29:23 -06:00
committed by Tom Rini
parent 835a18f80f
commit 1537ec5ceb
+1 -1
View File
@@ -73,7 +73,7 @@ int rtc_set(struct rtc_time *tmp)
days += month_days[i];
if (i == 1)
days += isleap(i);
days += isleap(tmp->tm_year);
}
days += tmp->tm_mday - 1;