Skip to content

Commit 49fd6f9

Browse files
iwamatsualexandrebelloni
authored andcommitted
rtc: rtc-mc146818-lib: Use is_leap_year instead of calculate leap years
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 <[email protected]> Acked-by: Maciej W. Rozycki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent b6cd7ad commit 49fd6f9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/rtc/rtc-mc146818-lib.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int mc146818_set_time(struct rtc_time *time)
216216
unsigned char save_control, save_freq_select;
217217
unsigned int yrs;
218218
#ifdef CONFIG_MACH_DECSTATION
219-
unsigned int real_yrs, leap_yr;
219+
unsigned int real_yrs;
220220
#endif
221221
unsigned char century = 0;
222222

@@ -232,16 +232,14 @@ int mc146818_set_time(struct rtc_time *time)
232232

233233
#ifdef CONFIG_MACH_DECSTATION
234234
real_yrs = yrs;
235-
leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) ||
236-
!((yrs + 1900) % 400));
237235
yrs = 72;
238236

239237
/*
240238
* We want to keep the year set to 73 until March
241239
* for non-leap years, so that Feb, 29th is handled
242240
* correctly.
243241
*/
244-
if (!leap_yr && mon < 3) {
242+
if (!is_leap_year(real_yrs + 1900) && mon < 3) {
245243
real_yrs--;
246244
yrs = 73;
247245
}

0 commit comments

Comments
 (0)