mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonghwa Lee <jonghwa3.lee@samsung.com>
To: linux-kernel@vger.kernel.org
Cc: a.zummo@towertech.it, Andrew Morton <akpm@linux-foundation.org>,
	rtc-linux@googlegroups.com,
	Jonghwa Lee <jonghwa3.lee@samsung.com>
Subject: [PATCH] rtc: Modify leap year test for more simpler way
Date: Wed, 06 Feb 2013 20:22:55 +0900	[thread overview]
Message-ID: <1360149775-19606-1-git-send-email-jonghwa3.lee@samsung.com> (raw)

Leap year which is multiple of 4, just needed 2 LSB for verifying.
A year with zero for all thease two bits means that it is leap year.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
---
 include/linux/rtc.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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
-- 
1.7.9.5


             reply	other threads:[~2013-02-06 11:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-06 11:22 Jonghwa Lee [this message]
2013-02-06 11:42 ` Venu Byravarasu
2013-02-06 12:43   ` jonghwa3.lee
2013-02-06 12:53     ` jonghwa3.lee
2013-02-06 13:00     ` Haojian Zhuang
2013-02-06 18:11       ` Stephen Warren
2013-02-07  1:15         ` jonghwa3.lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360149775-19606-1-git-send-email-jonghwa3.lee@samsung.com \
    --to=jonghwa3.lee@samsung.com \
    --cc=a.zummo@towertech.it \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®