2015-06-01 19:53:45

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH RESEND 3/3] drivers/rtc/sunxi: Replace deprecated rtc_tm_to_time()

On Friday 29 May 2015 23:04:37 Xunlei Pang wrote:
> }
>
> - rtc_tm_to_time(alrm_tm, &time_set);
> - rtc_tm_to_time(&tm_now, &time_now);
> + time_set = rtc_tm_to_time64(alrm_tm);
> + time_now = rtc_tm_to_time64(&tm_now);
> if (time_set <= time_now) {
> dev_err(dev, "Date to set in the past\n");
> return -EINVAL;
> }
>
> + if (time_set > time_now + 255 * SEC_IN_DAY) {
> + dev_err(dev, "Day must be in the range 0 - 255\n");
> + return -EINVAL;
> + }
> +
>

So this driver also uses the two values just to do a comparison
and to take the difference in seconds.

If we have a helper function that returns the difference between
two rtc_tm values as a time64_t, we can use that for both
this driver and isl1208.

Arnd


2015-06-02 03:21:38

by pang.xunlei

[permalink] [raw]
Subject: Re: [PATCH RESEND 3/3] drivers/rtc/sunxi: Replace deprecated rtc_tm_to_time()

Hi Arnd,

Arnd Bergmann <[email protected]> wrote 2015-06-02 AM 03:53:03:
> Re: [PATCH RESEND 3/3] drivers/rtc/sunxi: Replace deprecated
rtc_tm_to_time()
>
> On Friday 29 May 2015 23:04:37 Xunlei Pang wrote:
> > }
> >
> > - rtc_tm_to_time(alrm_tm, &time_set);
> > - rtc_tm_to_time(&tm_now, &time_now);
> > + time_set = rtc_tm_to_time64(alrm_tm);
> > + time_now = rtc_tm_to_time64(&tm_now);
> > if (time_set <= time_now) {
> > dev_err(dev, "Date to set in the past\n");
> > return -EINVAL;
> > }
> >
> > + if (time_set > time_now + 255 * SEC_IN_DAY) {
> > + dev_err(dev, "Day must be in the range 0 - 255\n");
> > + return -EINVAL;
> > + }
> > +
> >
>
> So this driver also uses the two values just to do a comparison
> and to take the difference in seconds.
>
> If we have a helper function that returns the difference between
> two rtc_tm values as a time64_t, we can use that for both
> this driver and isl1208.

Indeed, will do.

Thanks,
-Xunlei
--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s). If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited. If you have received this mail in error, please delete it and notify us immediately.