summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-da9052.c
diff options
context:
space:
mode:
authorAdam Ward <adam.ward.opensource@diasemi.com>2015-04-16 22:45:29 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-17 16:04:00 +0300
commitae824c484c85d77e3f272515aafb410bbade13fa (patch)
tree5df73c406852ff69c14b238046e1b67ad97948b6 /drivers/rtc/rtc-da9052.c
parent03cc1625e1f2e9fc6910af4174c942d56292f556 (diff)
downloadlinux-ae824c484c85d77e3f272515aafb410bbade13fa.tar.xz
drivers/rtc/rtc-da9052.c: add constraints to set valid year
Signed-off-by: Adam Ward <adam.ward.opensource@diasemi.com> Tested-by: Adam Ward <adam.ward.opensource@diasemi.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-da9052.c')
-rw-r--r--drivers/rtc/rtc-da9052.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
index ead02fad2de5..acc3e5a1f61a 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;