summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-lib.c
diff options
context:
space:
mode:
authorZhenyu Wang <zhenyuw@linux.intel.com>2018-04-17 10:43:57 +0800
committerZhenyu Wang <zhenyuw@linux.intel.com>2018-04-17 10:45:23 +0800
commit30596ec32e2cd141d73ee8701386887def9e98c0 (patch)
treec8b0d725c46fd8fa504ec0bf41c92c6ff680b406 /drivers/rtc/rtc-lib.c
parentd54e79340ff8d65b6c63ac278158add2fe211fd0 (diff)
parent60cc43fc888428bb2f18f08997432d426a243338 (diff)
Back merge 'drm-intel-fixes' into gvt-fixes
Need for 4.17-rc1 Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Diffstat (limited to 'drivers/rtc/rtc-lib.c')
-rw-r--r--drivers/rtc/rtc-lib.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index 1ae7da5cfc60..4a3c0f3aab14 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -52,13 +52,11 @@ EXPORT_SYMBOL(rtc_year_days);
*/
void rtc_time64_to_tm(time64_t time, struct rtc_time *tm)
{
- unsigned int month, year;
- unsigned long secs;
+ unsigned int month, year, secs;
int days;
/* time must be positive */
- days = div_s64(time, 86400);
- secs = time - (unsigned int) days * 86400;
+ days = div_s64_rem(time, 86400, &secs);
/* day of the week, 1970-01-01 was a Thursday */
tm->tm_wday = (days + 4) % 7;
@@ -67,7 +65,7 @@ void rtc_time64_to_tm(time64_t time, struct rtc_time *tm)
days -= (year - 1970) * 365
+ LEAPS_THRU_END_OF(year - 1)
- LEAPS_THRU_END_OF(1970 - 1);
- if (days < 0) {
+ while (days < 0) {
year -= 1;
days += 365 + is_leap_year(year);
}