aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/hctosys.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-04-29 19:53:17 -0400
committerH. Peter Anvin <hpa@zytor.com>2010-04-29 19:53:17 -0400
commitd9c5841e22231e4e49fd0a1004164e6fce59b7a6 (patch)
treee1f589c46b3ff79bbe7b1b2469f6362f94576da6 /drivers/rtc/hctosys.c
parentb701a47ba48b698976fb2fe05fb285b0edc1d26a (diff)
parent5967ed87ade85a421ef814296c3c7f182b08c225 (diff)
Merge branch 'x86/asm' into x86/atomic
Merge reason: Conflict between LOCK_PREFIX_HERE and relative alternatives pointers Resolved Conflicts: arch/x86/include/asm/alternative.h arch/x86/kernel/alternative.c Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'drivers/rtc/hctosys.c')
-rw-r--r--drivers/rtc/hctosys.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index 33c0e98243ee..bc90b091f195 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -22,48 +22,57 @@
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
25static int __init rtc_hctosys(void) 27static int __init rtc_hctosys(void)
26{ 28{
27 int err; 29 int err = -ENODEV;
28 struct rtc_time tm; 30 struct rtc_time tm;
31 struct timespec tv = {
32 .tv_nsec = NSEC_PER_SEC >> 1,
33 };
29 struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); 34 struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
30 35
31 if (rtc == NULL) { 36 if (rtc == NULL) {
32 printk("%s: unable to open rtc device (%s)\n", 37 pr_err("%s: unable to open rtc device (%s)\n",
33 __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); 38 __FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
34 return -ENODEV; 39 goto err_open;
35 } 40 }
36 41
37 err = rtc_read_time(rtc, &tm); 42 err = rtc_read_time(rtc, &tm);
38 if (err == 0) { 43 if (err) {
39 err = rtc_valid_tm(&tm); 44 dev_err(rtc->dev.parent,
40 if (err == 0) { 45 "hctosys: unable to read the hardware clock\n");
41 struct timespec tv; 46 goto err_read;
42 47
43 tv.tv_nsec = NSEC_PER_SEC >> 1; 48 }
44 49
45 rtc_tm_to_time(&tm, &tv.tv_sec); 50 err = rtc_valid_tm(&tm);
51 if (err) {
52 dev_err(rtc->dev.parent,
53 "hctosys: invalid date/time\n");
54 goto err_invalid;
55 }
46 56
47 do_settimeofday(&tv); 57 rtc_tm_to_time(&tm, &tv.tv_sec);
48 58
49 dev_info(rtc->dev.parent, 59 do_settimeofday(&tv);
50 "setting system clock to "
51 "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
52 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
53 tm.tm_hour, tm.tm_min, tm.tm_sec,
54 (unsigned int) tv.tv_sec);
55 }
56 else
57 dev_err(rtc->dev.parent,
58 "hctosys: invalid date/time\n");
59 }
60 else
61 dev_err(rtc->dev.parent,
62 "hctosys: unable to read the hardware clock\n");
63 60
61 dev_info(rtc->dev.parent,
62 "setting system clock to "
63 "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
64 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
65 tm.tm_hour, tm.tm_min, tm.tm_sec,
66 (unsigned int) tv.tv_sec);
67
68err_invalid:
69err_read:
64 rtc_class_close(rtc); 70 rtc_class_close(rtc);
65 71
66 return 0; 72err_open:
73 rtc_hctosys_ret = err;
74
75 return err;
67} 76}
68 77
69late_initcall(rtc_hctosys); 78late_initcall(rtc_hctosys);