drivers/rtc/interface.c: check the validation of rtc_time in __rtc_read_time
PATCH 1/1 drivers/rtc/interface.c: check the validation of rtc_time in __rtc_read_time
Some of 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.
--- drivers/rtc/interface.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/rtc/interface.c +8 -0
@@ -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; }
Signature · 1 line
1.8.3.2
Quoted 3 lines · On Wed, 8 Oct 2014 11:05:29 +0900 Hyogi Gim <[email protected]> wrote:
Some of rtc devices always return '0' when rtc_class_ops.read_time is called. So if
rtc_timeisn't verified in callback, rtc interface cannot know whetherrtc_timeis valid.
We should fix the buggy .read_time() implementations...
Quoted 3 lines
Check
rtc_timeby using 'rtc_valid_tm' in '__rtc_read_time'. And add the message for debugging.
Quoted 8 lines · Andrew Morton
Quoted 3 lines · On Wed, 8 Oct 2014 11:05:29 +0900 Hyogi Gim <[email protected]> wrote:
Some of rtc devices always return '0' when rtc_class_ops.read_time is called. So if
rtc_timeisn't verified in callback, rtc interface cannot know whetherrtc_timeis valid.We should fix the buggy .read_time() implementations...
Thanks for comments.
I'm studying rtc framework and trying to find a problem. This is a minor bug. But, as you know, it can be a big problem for newbies like me.
Even though it was late, I send you reply because a question. If this patch is merged, rtc_valid_tm() in rtc_class_ops.read_time callback is not necessary anymore.
So, I think each rtc device driver should change the code. I can change the code. But, test is a little different.
In this case, how can I progress this modification?
Can I just send the notification for rtc_valid_tm() to the driver manufacturer? or, request test for the code that I've modified?
Signature · 1 line
Hyogi