lkml.org 
[lkml]   [2014]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] driver/rtc/class.c: check the error after rtc_read_time()
Date
On Wednesday, July 23, 2014 02:56:34 PM Andrew Morton wrote:
> On Tue, 15 Jul 2014 17:25:23 +0900 Hyogi Gim <hyogi.gim@lge.com> wrote:
>
> > In rtc_suspend() and rtc_resume(), the error after rtc_read_time() is not
> > checked. If rtc device fail to read time, we cannot guarantee the following
> > process.
> >
> > Add the verification code for returned rtc_read_time() error.
> >
> > ...
> >
> > --- a/drivers/rtc/class.c
> > +++ b/drivers/rtc/class.c
> > @@ -53,6 +53,7 @@ static int rtc_suspend(struct device *dev)
> > struct rtc_device *rtc = to_rtc_device(dev);
> > struct rtc_time tm;
> > struct timespec delta, delta_delta;
> > + int err;
> >
> > if (has_persistent_clock())
> > return 0;
> > @@ -61,7 +62,12 @@ static int rtc_suspend(struct device *dev)
> > return 0;
> >
> > /* snapshot the current RTC and system time at suspend*/
> > - rtc_read_time(rtc, &tm);
> > + err = rtc_read_time(rtc, &tm);
> > + if (err < 0) {
> > + pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev));
> > + return 0;
> > + }
>
> OK, it makes no sense to go ahead and set the system time from a
> garbage rtc_time.
>
> But I'm wondering if we should propagate the error back to the
> rtc_suspend() caller. What does the PM core do if a particular
> device's ->suspend or ->resume fails?

It aborts the suspend.

Rafael



\
 
 \ /
  Last update: 2014-07-24 02:21    [W:0.039 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site