From patchwork Wed Feb 6 11:39:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: rtc: Modify leap year test for more simpler way Date: Wed, 06 Feb 2013 01:39:51 -0000 From: venu X-Patchwork-Id: 218562 Message-Id: <1360150791.5912.YahooMailNeo@web192506.mail.sg3.yahoo.com> To: "rtc-linux@googlegroups.com" , "linux-kernel@vger.kernel.org" Cc: "a.zummo@towertech.it" , Andrew Morton , Jonghwa Lee By definition of Leap year, If a year is multiple of 100 and not 400, then that should not be a leap year. Your logic does not take care of this condition. Hence I feel this patch is not correct. Thanks, Venu diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 9531845..d662b8d 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -181,7 +181,7 @@ void rtc_timer_do_work(struct work_struct *work); static inline bool is_leap_year(unsigned int year) { -    return (!(year % 4) && (year % 100)) || !(year % 400); +    return !(year & 0x3); } #ifdef CONFIG_RTC_HCTOSYS_DEVICE