From: Ben Dooks <ben-linux@fluff.org>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org
Subject: [PATCH] rtc-s3c.c: fix time setting checks
Date: Tue, 15 Aug 2006 21:53:20 +0100 [thread overview]
Message-ID: <20060815205320.GE8907@home.fluff.org> (raw)
Fix the year check on setting the time with the S3C24XX
RTC driver. Also move the debug to before the set to see
what is going on if it does fail.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
diff -urpN -X ../dontdiff linux-2.6.18-rc4-rtc1/drivers/rtc/rtc-s3c.c linux-2.6.18-rc4-rtc2/drivers/rtc/rtc-s3c.c
--- linux-2.6.18-rc4-rtc1/drivers/rtc/rtc-s3c.c 2006-08-11 22:13:21.000000000 +0100
+++ linux-2.6.18-rc4-rtc2/drivers/rtc/rtc-s3c.c 2006-08-15 21:50:23.000000000 +0100
@@ -153,24 +153,25 @@ static int s3c_rtc_gettime(struct device
static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm)
{
void __iomem *base = s3c_rtc_base;
+ int year = tm->tm_year - 100;
- /* the rtc gets round the y2k problem by just not supporting it */
+ pr_debug("set time %02d.%02d.%02d %02d/%02d/%02d\n",
+ tm->tm_year, tm->tm_mon, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+ /* we get around y2k by simply not supporting it */
- if (tm->tm_year > 100) {
+ if (year < 0 || year >= 100) {
dev_err(dev, "rtc only supports 100 years\n");
return -EINVAL;
}
- pr_debug("set time %02d.%02d.%02d %02d/%02d/%02d\n",
- tm->tm_year, tm->tm_mon, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
-
writeb(BIN2BCD(tm->tm_sec), base + S3C2410_RTCSEC);
writeb(BIN2BCD(tm->tm_min), base + S3C2410_RTCMIN);
writeb(BIN2BCD(tm->tm_hour), base + S3C2410_RTCHOUR);
writeb(BIN2BCD(tm->tm_mday), base + S3C2410_RTCDATE);
writeb(BIN2BCD(tm->tm_mon + 1), base + S3C2410_RTCMON);
- writeb(BIN2BCD(tm->tm_year - 100), base + S3C2410_RTCYEAR);
+ writeb(BIN2BCD(year), base + S3C2410_RTCYEAR);
return 0;
}
next reply other threads:[~2006-08-15 20:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-15 20:53 Ben Dooks [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-08-15 9:24 [PATCH] rtc-s3c.c: fix time setting checks Ben Dooks
2006-08-15 10:27 ` Jiri Slaby
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=20060815205320.GE8907@home.fluff.org \
--to=ben-linux@fluff.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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