summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaveen Kumar Chaudhary <[email protected]>2026-06-10 22:38:40 +0530
committerTom Rini <[email protected]>2026-06-29 15:29:23 -0600
commit1537ec5ceb7d80edaefb55743bb44e17f303285b (patch)
tree76e12b5bb405fa382811941b21d424bec9cb2826
parent835a18f80f25731dc818bf9b771bfa111ea3dbeb (diff)
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: 8e585f02f82 ("Added M5329AFEE and M5329BFEE Platforms") Signed-off-by: Naveen Kumar Chaudhary <[email protected]>
-rw-r--r--drivers/rtc/mcfrtc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/rtc/mcfrtc.c b/drivers/rtc/mcfrtc.c
index 9708971c5c4..23ffb2b31a1 100644
--- a/drivers/rtc/mcfrtc.c
+++ b/drivers/rtc/mcfrtc.c
@@ -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;