Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer changes from Ingo Molnar: "Main changes: - ntp: Add CONFIG_RTC_SYSTOHC: a generic RTC driver facility complementing the existing CONFIG_RTC_HCTOSYS, which uses NTP to keep the hardware clock updated. - posix-timers: Fix clock_adjtime to always return timex data on success. This is changing the ABI, but no breakage was expected and found - caution is warranted nevertheless. - platform persistent clock improvements/cleanups. - clockevents: refactor timer broadcast handling to be more generic and less duplicated with matching architecture code (mostly ARM motivated.) - various fixes and cleanups" * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: timers/x86/hpet: Use HPET_COUNTER to specify the hpet counter in vread_hpet() posix-cpu-timers: Fix nanosleep task_struct leak clockevents: Fix generic broadcast for FEAT_C3STOP time, Fix setting of hardware clock in NTP code hrtimer: Prevent hrtimer_enqueue_reprogram race clockevents: Add generic timer broadcast function clockevents: Add generic timer broadcast receiver timekeeping: Switch HAS_PERSISTENT_CLOCK to ALWAYS_USE_PERSISTENT_CLOCK x86/time/rtc: Don't print extended CMOS year when reading RTC x86: Select HAS_PERSISTENT_CLOCK on x86 timekeeping: Add CONFIG_HAS_PERSISTENT_CLOCK option rtc: Skip the suspend/resume handling if persistent clock exist timekeeping: Add persistent_clock_exist flag posix-timers: Fix clock_adjtime to always return timex data on success Round the calculated scale factor in set_cyc2ns_scale() NTP: Add a CONFIG_RTC_SYSTOHC configuration MAINTAINERS: Update John Stultz's email time: create __getnstimeofday for WARNless calls
This commit is contained in:
@@ -20,14 +20,24 @@ if RTC_CLASS
|
||||
config RTC_HCTOSYS
|
||||
bool "Set system time from RTC on startup and resume"
|
||||
default y
|
||||
depends on !ALWAYS_USE_PERSISTENT_CLOCK
|
||||
help
|
||||
If you say yes here, the system time (wall clock) will be set using
|
||||
the value read from a specified RTC device. This is useful to avoid
|
||||
unnecessary fsck runs at boot time, and to network better.
|
||||
|
||||
config RTC_SYSTOHC
|
||||
bool "Set the RTC time based on NTP synchronization"
|
||||
default y
|
||||
depends on !ALWAYS_USE_PERSISTENT_CLOCK
|
||||
help
|
||||
If you say yes here, the system time (wall clock) will be stored
|
||||
in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11
|
||||
minutes if userspace reports synchronized NTP status.
|
||||
|
||||
config RTC_HCTOSYS_DEVICE
|
||||
string "RTC used to set the system time"
|
||||
depends on RTC_HCTOSYS = y
|
||||
depends on RTC_HCTOSYS = y || RTC_SYSTOHC = y
|
||||
default "rtc0"
|
||||
help
|
||||
The RTC device that will be used to (re)initialize the system
|
||||
|
@@ -6,6 +6,7 @@ ccflags-$(CONFIG_RTC_DEBUG) := -DDEBUG
|
||||
|
||||
obj-$(CONFIG_RTC_LIB) += rtc-lib.o
|
||||
obj-$(CONFIG_RTC_HCTOSYS) += hctosys.o
|
||||
obj-$(CONFIG_RTC_SYSTOHC) += systohc.o
|
||||
obj-$(CONFIG_RTC_CLASS) += rtc-core.o
|
||||
rtc-core-y := class.o interface.o
|
||||
|
||||
|
@@ -50,6 +50,10 @@ static int rtc_suspend(struct device *dev, pm_message_t mesg)
|
||||
struct rtc_device *rtc = to_rtc_device(dev);
|
||||
struct rtc_time tm;
|
||||
struct timespec delta, delta_delta;
|
||||
|
||||
if (has_persistent_clock())
|
||||
return 0;
|
||||
|
||||
if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0)
|
||||
return 0;
|
||||
|
||||
@@ -88,6 +92,9 @@ static int rtc_resume(struct device *dev)
|
||||
struct timespec new_system, new_rtc;
|
||||
struct timespec sleep_time;
|
||||
|
||||
if (has_persistent_clock())
|
||||
return 0;
|
||||
|
||||
rtc_hctosys_ret = -ENODEV;
|
||||
if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0)
|
||||
return 0;
|
||||
|
44
drivers/rtc/systohc.c
Normal file
44
drivers/rtc/systohc.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
#include <linux/rtc.h>
|
||||
#include <linux/time.h>
|
||||
|
||||
/**
|
||||
* rtc_set_ntp_time - Save NTP synchronized time to the RTC
|
||||
* @now: Current time of day
|
||||
*
|
||||
* Replacement for the NTP platform function update_persistent_clock
|
||||
* that stores time for later retrieval by rtc_hctosys.
|
||||
*
|
||||
* Returns 0 on successful RTC update, -ENODEV if a RTC update is not
|
||||
* possible at all, and various other -errno for specific temporary failure
|
||||
* cases.
|
||||
*
|
||||
* If temporary failure is indicated the caller should try again 'soon'
|
||||
*/
|
||||
int rtc_set_ntp_time(struct timespec now)
|
||||
{
|
||||
struct rtc_device *rtc;
|
||||
struct rtc_time tm;
|
||||
int err = -ENODEV;
|
||||
|
||||
if (now.tv_nsec < (NSEC_PER_SEC >> 1))
|
||||
rtc_time_to_tm(now.tv_sec, &tm);
|
||||
else
|
||||
rtc_time_to_tm(now.tv_sec + 1, &tm);
|
||||
|
||||
rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
|
||||
if (rtc) {
|
||||
/* rtc_hctosys exclusively uses UTC, so we call set_time here,
|
||||
* not set_mmss. */
|
||||
if (rtc->ops && (rtc->ops->set_time || rtc->ops->set_mmss))
|
||||
err = rtc_set_time(rtc, &tm);
|
||||
rtc_class_close(rtc);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
Reference in New Issue
Block a user