LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Adam Ward <adam.ward.opensource@diasemi.com>
To: Alessandro Zummo <a.zummo@towertech.it>
Cc: Support Opensource <support.opensource@diasemi.com>,
<rtc-linux@googlegroups.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v1 2/3] rtc: da9052: Add constraints to set valid year
Date: Wed, 4 Mar 2015 16:13:13 +0000 [thread overview]
Message-ID: <cb6d2528ac81589cd6d816ef1745daa6ca1e0610.1425490310.git.adam.ward.opensource@diasemi.com> (raw)
In-Reply-To: <cover.1425490310.git.adam.ward.opensource@diasemi.com>
Signed-off-by: Adam Ward <adam.ward.opensource@diasemi.com>
Tested-by: Adam Ward <adam.ward.opensource@diasemi.com>
---
drivers/rtc/rtc-da9052.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
index ead02fa..acc3e5a 100644
--- a/drivers/rtc/rtc-da9052.c
+++ b/drivers/rtc/rtc-da9052.c
@@ -206,6 +206,10 @@ static int da9052_rtc_set_time(struct device *dev, struct rtc_time *tm)
uint8_t v[6];
int ret;
+ /* DA9052 only has 6 bits for year - to represent 2000-2063 */
+ if ((tm->tm_year < 100) || (tm->tm_year > 163))
+ return -EINVAL;
+
rtc = dev_get_drvdata(dev);
v[0] = tm->tm_sec;
@@ -243,6 +247,10 @@ static int da9052_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
struct rtc_time *tm = &alrm->time;
struct da9052_rtc *rtc = dev_get_drvdata(dev);
+ /* DA9052 only has 6 bits for year - to represent 2000-2063 */
+ if ((tm->tm_year < 100) || (tm->tm_year > 163))
+ return -EINVAL;
+
ret = da9052_rtc_enable_alarm(rtc, 0);
if (ret < 0)
return ret;
--
end-of-patch for rtc: da9052: Corrections to access, validation and capability
next prev parent reply other threads:[~2015-03-04 17:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 17:31 [PATCH v1 0/3] rtc: da9052: Corrections to access, validation and capability Adam Ward
2015-03-04 16:13 ` [PATCH v1 1/3] rtc: da9052: Add extra reads with timeouts to avoid returning partially updated values Adam Ward
2015-03-04 16:13 ` Adam Ward [this message]
2015-03-04 16:13 ` [PATCH v1 3/3] rtc: da9052: Register ability of alarm to wake device from suspend Adam Ward
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=cb6d2528ac81589cd6d816ef1745daa6ca1e0610.1425490310.git.adam.ward.opensource@diasemi.com \
--to=adam.ward.opensource@diasemi.com \
--cc=a.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
--cc=support.opensource@diasemi.com \
--subject='Re: [PATCH v1 2/3] rtc: da9052: Add constraints to set valid year' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).