summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorHyogi Gim <ciogenis@gmail.com>2014-12-11 02:52:27 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-11 04:41:13 +0300
commit16682c86d2fb68cc78c6cc0af51c2a78809dc5b0 (patch)
tree99297da840e40be5c9a98a1e3c1fb4ed038a1bad /drivers/rtc
parent0e95325525c4383565cea4f402f15a3113162d05 (diff)
downloadlinux-16682c86d2fb68cc78c6cc0af51c2a78809dc5b0.tar.xz
drivers/rtc/interface.c: check the validation of rtc_time in __rtc_read_time
Some rtc devices always return '0' when rtc_class_ops.read_time is called. So if rtc_time isn't verified in callback, rtc interface cannot know whether rtc_time is valid. Check rtc_time by using 'rtc_valid_tm' in '__rtc_read_time'. And add the message for debugging. Signed-off-by: Hyogi Gim <hyogi.gim@lge.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: John Stultz <john.stultz@linaro.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/interface.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 5b2717f5dafa..818ea97f403c 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -30,6 +30,14 @@ static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
else {
memset(tm, 0, sizeof(struct rtc_time));
err = rtc->ops->read_time(rtc->dev.parent, tm);
+ if (err < 0) {
+ dev_err(&rtc->dev, "read_time: fail to read\n");
+ return err;
+ }
+
+ err = rtc_valid_tm(tm);
+ if (err < 0)
+ dev_err(&rtc->dev, "read_time: rtc_time isn't valid\n");
}
return err;
}