Commit ae824c48 authored by Adam Ward's avatar Adam Ward Committed by Linus Torvalds

drivers/rtc/rtc-da9052.c: add constraints to set valid year

Signed-off-by: default avatarAdam Ward <adam.ward.opensource@diasemi.com>
Tested-by: default avatarAdam Ward <adam.ward.opensource@diasemi.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 03cc1625
...@@ -206,6 +206,10 @@ static int da9052_rtc_set_time(struct device *dev, struct rtc_time *tm) ...@@ -206,6 +206,10 @@ static int da9052_rtc_set_time(struct device *dev, struct rtc_time *tm)
uint8_t v[6]; uint8_t v[6];
int ret; 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); rtc = dev_get_drvdata(dev);
v[0] = tm->tm_sec; v[0] = tm->tm_sec;
...@@ -243,6 +247,10 @@ static int da9052_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) ...@@ -243,6 +247,10 @@ static int da9052_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
struct rtc_time *tm = &alrm->time; struct rtc_time *tm = &alrm->time;
struct da9052_rtc *rtc = dev_get_drvdata(dev); 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); ret = da9052_rtc_enable_alarm(rtc, 0);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment