]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
rtc: mcfrtc: fix leap year calculation using wrong variable
authorNaveen Kumar Chaudhary <naveen.osdev@gmail.com>
Wed, 10 Jun 2026 17:08:40 +0000 (22:38 +0530)
committerTom Rini <trini@konsulko.com>
Mon, 29 Jun 2026 21:29:23 +0000 (15:29 -0600)
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 <naveen.osdev@gmail.com>
drivers/rtc/mcfrtc.c

index 9708971c5c435c2a0cc8ae0a74329ec91dbf6a61..23ffb2b31a147028a29067600223b87500c928a9 100644 (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;