Skip to content

Commit

Permalink
Merge branch 'fortglx/3.9/time' of git://git.linaro.org/people/jstult…
Browse files Browse the repository at this point in the history
…z/linux into timers/core
  • Loading branch information
Thomas Gleixner committed Feb 14, 2013
2 parents 86c8ead + 84e345e commit 9f4646d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/linux/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ static inline bool has_persistent_clock(void)

extern void read_persistent_clock(struct timespec *ts);
extern void read_boot_clock(struct timespec *ts);
extern int persistent_clock_is_local;
extern int update_persistent_clock(struct timespec now);
void timekeeping_init(void);
extern int timekeeping_suspended;
Expand Down
8 changes: 8 additions & 0 deletions kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
return 0;
}

/*
* Indicates if there is an offset between the system clock and the hardware
* clock/persistent clock/rtc.
*/
int persistent_clock_is_local;

/*
* Adjust the time obtained from the CMOS to be UTC time instead of
* local time.
Expand All @@ -135,6 +141,8 @@ static inline void warp_clock(void)
struct timespec adjust;

adjust = current_kernel_time();
if (sys_tz.tz_minuteswest != 0)
persistent_clock_is_local = 1;
adjust.tv_sec += sys_tz.tz_minuteswest * 60;
do_settimeofday(&adjust);
}
Expand Down
8 changes: 6 additions & 2 deletions kernel/time/ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,17 @@ static void sync_cmos_clock(struct work_struct *work)

getnstimeofday(&now);
if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) {
struct timespec adjust = now;

fail = -ENODEV;
if (persistent_clock_is_local)
adjust.tv_sec -= (sys_tz.tz_minuteswest * 60);
#ifdef CONFIG_GENERIC_CMOS_UPDATE
fail = update_persistent_clock(now);
fail = update_persistent_clock(adjust);
#endif
#ifdef CONFIG_RTC_SYSTOHC
if (fail == -ENODEV)
fail = rtc_set_ntp_time(now);
fail = rtc_set_ntp_time(adjust);
#endif
}

Expand Down

0 comments on commit 9f4646d

Please sign in to comment.