Commit b485fe5e authored by Wan ZongShun's avatar Wan ZongShun Committed by Linus Torvalds

rtc/m41t80: use rtc_valid_tm() to check returned tm

Use rtc_valid_tm() to check returned struct rtc_time *tm - it can avoid
returning wrong tm value.
Signed-off-by: default avatarWan ZongShun <mcuos.com@gmail.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 d6c7428f
...@@ -121,7 +121,7 @@ static int m41t80_get_datetime(struct i2c_client *client, ...@@ -121,7 +121,7 @@ static int m41t80_get_datetime(struct i2c_client *client,
/* assume 20YY not 19YY, and ignore the Century Bit */ /* assume 20YY not 19YY, and ignore the Century Bit */
tm->tm_year = bcd2bin(buf[M41T80_REG_YEAR]) + 100; tm->tm_year = bcd2bin(buf[M41T80_REG_YEAR]) + 100;
return 0; return rtc_valid_tm(tm);
} }
/* Sets the given date and time to the real time clock. */ /* Sets the given date and time to the real time clock. */
...@@ -364,7 +364,7 @@ static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t) ...@@ -364,7 +364,7 @@ static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t)
t->time.tm_isdst = -1; t->time.tm_isdst = -1;
t->enabled = !!(reg[M41T80_REG_ALARM_MON] & M41T80_ALMON_AFE); t->enabled = !!(reg[M41T80_REG_ALARM_MON] & M41T80_ALMON_AFE);
t->pending = !!(reg[M41T80_REG_FLAGS] & M41T80_FLAGS_AF); t->pending = !!(reg[M41T80_REG_FLAGS] & M41T80_FLAGS_AF);
return 0; return rtc_valid_tm(t);
} }
static struct rtc_class_ops m41t80_rtc_ops = { static struct rtc_class_ops m41t80_rtc_ops = {
......
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