]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years
authorNobuhiro Iwamatsu <iwamatsu@nigauri.org>
Mon, 7 Oct 2024 23:36:18 +0000 (08:36 +0900)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Sun, 10 Nov 2024 22:02:43 +0000 (23:02 +0100)
The is_leap_year() for determining leap year is provided in rtc lib.
This uses is_leap_year() instead of its own leap year determination
routine.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>
Link: https://lore.kernel.org/r/20241007233618.1442937-1-nobuhiro1.iwamatsu@toshiba.co.jp
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-mc146818-lib.c

index 651bf3c279c7462151096cf8565a56fffab9052d..dbd2d5835f002c746ff08e3535a1f01adaa67150 100644 (file)
@@ -216,7 +216,7 @@ int mc146818_set_time(struct rtc_time *time)
        unsigned char save_control, save_freq_select;
        unsigned int yrs;
 #ifdef CONFIG_MACH_DECSTATION
-       unsigned int real_yrs, leap_yr;
+       unsigned int real_yrs;
 #endif
        unsigned char century = 0;
 
@@ -232,8 +232,6 @@ int mc146818_set_time(struct rtc_time *time)
 
 #ifdef CONFIG_MACH_DECSTATION
        real_yrs = yrs;
-       leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
-                       !((yrs + 1900) % 400));
        yrs = 72;
 
        /*
@@ -241,7 +239,7 @@ int mc146818_set_time(struct rtc_time *time)
         * for non-leap years, so that Feb, 29th is handled
         * correctly.
         */
-       if (!leap_yr && mon < 3) {
+       if (!is_leap_year(real_yrs + 1900) && mon < 3) {
                real_yrs--;
                yrs = 73;
        }