aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/class.c8
-rw-r--r--drivers/rtc/hctosys.c4
-rw-r--r--drivers/rtc/rtc-sysfs.c6
3 files changed, 14 insertions, 4 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 37b1d82fda08..f8a0aab218cb 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -31,8 +31,12 @@ static void rtc_device_release(struct device *dev)
31 kfree(rtc); 31 kfree(rtc);
32} 32}
33 33
34#if defined(CONFIG_PM) && defined(CONFIG_RTC_HCTOSYS_DEVICE) 34#ifdef CONFIG_RTC_HCTOSYS_DEVICE
35/* Result of the last RTC to system clock attempt. */
36int rtc_hctosys_ret = -ENODEV;
37#endif
35 38
39#if defined(CONFIG_PM) && defined(CONFIG_RTC_HCTOSYS_DEVICE)
36/* 40/*
37 * On suspend(), measure the delta between one RTC and the 41 * On suspend(), measure the delta between one RTC and the
38 * system's wall clock; restore it on resume(). 42 * system's wall clock; restore it on resume().
@@ -84,6 +88,7 @@ static int rtc_resume(struct device *dev)
84 struct timespec new_system, new_rtc; 88 struct timespec new_system, new_rtc;
85 struct timespec sleep_time; 89 struct timespec sleep_time;
86 90
91 rtc_hctosys_ret = -ENODEV;
87 if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0) 92 if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0)
88 return 0; 93 return 0;
89 94
@@ -117,6 +122,7 @@ static int rtc_resume(struct device *dev)
117 122
118 if (sleep_time.tv_sec >= 0) 123 if (sleep_time.tv_sec >= 0)
119 timekeeping_inject_sleeptime(&sleep_time); 124 timekeeping_inject_sleeptime(&sleep_time);
125 rtc_hctosys_ret = 0;
120 return 0; 126 return 0;
121} 127}
122 128
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index bc90b091f195..4aa60d74004e 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -22,8 +22,6 @@
22 * the best guess is to add 0.5s. 22 * the best guess is to add 0.5s.
23 */ 23 */
24 24
25int rtc_hctosys_ret = -ENODEV;
26
27static int __init rtc_hctosys(void) 25static int __init rtc_hctosys(void)
28{ 26{
29 int err = -ENODEV; 27 int err = -ENODEV;
@@ -56,7 +54,7 @@ static int __init rtc_hctosys(void)
56 54
57 rtc_tm_to_time(&tm, &tv.tv_sec); 55 rtc_tm_to_time(&tm, &tv.tv_sec);
58 56
59 do_settimeofday(&tv); 57 err = do_settimeofday(&tv);
60 58
61 dev_info(rtc->dev.parent, 59 dev_info(rtc->dev.parent,
62 "setting system clock to " 60 "setting system clock to "
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 380083ca572f..b70e2bb63645 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -102,6 +102,12 @@ rtc_sysfs_set_max_user_freq(struct device *dev, struct device_attribute *attr,
102 return n; 102 return n;
103} 103}
104 104
105/**
106 * rtc_sysfs_show_hctosys - indicate if the given RTC set the system time
107 *
108 * Returns 1 if the system clock was set by this RTC at the last
109 * boot or resume event.
110 */
105static ssize_t 111static ssize_t
106rtc_sysfs_show_hctosys(struct device *dev, struct device_attribute *attr, 112rtc_sysfs_show_hctosys(struct device *dev, struct device_attribute *attr,
107 char *buf) 113 char *buf)