diff options
Diffstat (limited to 'kernel/time/ntp.c')
-rw-r--r-- | kernel/time/ntp.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 24174b4d669b..b10a42bb0165 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/time.h> | 15 | #include <linux/time.h> |
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/rtc.h> | ||
18 | 19 | ||
19 | #include "tick-internal.h" | 20 | #include "tick-internal.h" |
20 | 21 | ||
@@ -483,8 +484,7 @@ out: | |||
483 | return leap; | 484 | return leap; |
484 | } | 485 | } |
485 | 486 | ||
486 | #ifdef CONFIG_GENERIC_CMOS_UPDATE | 487 | #if defined(CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC) |
487 | |||
488 | static void sync_cmos_clock(struct work_struct *work); | 488 | static void sync_cmos_clock(struct work_struct *work); |
489 | 489 | ||
490 | static DECLARE_DELAYED_WORK(sync_cmos_work, sync_cmos_clock); | 490 | static DECLARE_DELAYED_WORK(sync_cmos_work, sync_cmos_clock); |
@@ -510,14 +510,26 @@ static void sync_cmos_clock(struct work_struct *work) | |||
510 | } | 510 | } |
511 | 511 | ||
512 | getnstimeofday(&now); | 512 | getnstimeofday(&now); |
513 | if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) | 513 | if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2) { |
514 | fail = update_persistent_clock(now); | 514 | struct timespec adjust = now; |
515 | |||
516 | fail = -ENODEV; | ||
517 | if (persistent_clock_is_local) | ||
518 | adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); | ||
519 | #ifdef CONFIG_GENERIC_CMOS_UPDATE | ||
520 | fail = update_persistent_clock(adjust); | ||
521 | #endif | ||
522 | #ifdef CONFIG_RTC_SYSTOHC | ||
523 | if (fail == -ENODEV) | ||
524 | fail = rtc_set_ntp_time(adjust); | ||
525 | #endif | ||
526 | } | ||
515 | 527 | ||
516 | next.tv_nsec = (NSEC_PER_SEC / 2) - now.tv_nsec - (TICK_NSEC / 2); | 528 | next.tv_nsec = (NSEC_PER_SEC / 2) - now.tv_nsec - (TICK_NSEC / 2); |
517 | if (next.tv_nsec <= 0) | 529 | if (next.tv_nsec <= 0) |
518 | next.tv_nsec += NSEC_PER_SEC; | 530 | next.tv_nsec += NSEC_PER_SEC; |
519 | 531 | ||
520 | if (!fail) | 532 | if (!fail || fail == -ENODEV) |
521 | next.tv_sec = 659; | 533 | next.tv_sec = 659; |
522 | else | 534 | else |
523 | next.tv_sec = 0; | 535 | next.tv_sec = 0; |