[U-Boot] [PATCH v5 08/11] rtc: Don't allow setting unsuported years on s3c24x0_rtc
José Miguel Gonçalves
jose.goncalves at inov.pt
Fri Sep 21 20:47:45 CEST 2012
This RTC only supports a 100 years range so rtc_set() should not allow setting
years bellow 1970 or above 2069.
Signed-off-by: José Miguel Gonçalves <jose.goncalves at inov.pt>
---
Changes for v2:
- New patch
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
---
drivers/rtc/s3c24x0_rtc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/rtc/s3c24x0_rtc.c b/drivers/rtc/s3c24x0_rtc.c
index 3fd5cec..bcd6d44 100644
--- a/drivers/rtc/s3c24x0_rtc.c
+++ b/drivers/rtc/s3c24x0_rtc.c
@@ -139,6 +139,11 @@ int rtc_set(struct rtc_time *tmp)
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
#endif
+ if (tmp->tm_year < 1970 || tmp->tm_year > 2069) {
+ puts("ERROR: year should be between 1970 and 2069!\n");
+ return -1;
+ }
+
year = bin2bcd(tmp->tm_year % 100);
mon = bin2bcd(tmp->tm_mon);
wday = bin2bcd(tmp->tm_wday);
--
1.7.9.5
More information about the U-Boot
mailing list