diff options
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/Kconfig | 2 | ||||
-rw-r--r-- | drivers/rtc/class.c | 42 | ||||
-rw-r--r-- | drivers/rtc/interface.c | 51 | ||||
-rw-r--r-- | drivers/rtc/rtc-dm355evm.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1305.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 27 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1511.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1553.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1672.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1742.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-em3027.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-isl12022.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-m41t80.c | 9 | ||||
-rw-r--r-- | drivers/rtc/rtc-mc13xxx.c | 6 | ||||
-rw-r--r-- | drivers/rtc/rtc-mrst.c | 19 | ||||
-rw-r--r-- | drivers/rtc/rtc-mv.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-pcf2123.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-pcf8563.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-puv3.c | 4 | ||||
-rw-r--r-- | drivers/rtc/rtc-rs5c348.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-rs5c372.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-stk17ta8.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-tx4939.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-x1205.c | 1 |
25 files changed, 125 insertions, 53 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 5a538fc1cc85..53eb4e55b289 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -8,7 +8,7 @@ config RTC_LIB | |||
8 | menuconfig RTC_CLASS | 8 | menuconfig RTC_CLASS |
9 | bool "Real Time Clock" | 9 | bool "Real Time Clock" |
10 | default n | 10 | default n |
11 | depends on !S390 | 11 | depends on !S390 && !UML |
12 | select RTC_LIB | 12 | select RTC_LIB |
13 | help | 13 | help |
14 | Generic RTC class support. If you say yes here, you will | 14 | Generic RTC class support. If you say yes here, you will |
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 01a7df5317c1..dc4c2748bbc3 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -21,16 +21,13 @@ | |||
21 | #include "rtc-core.h" | 21 | #include "rtc-core.h" |
22 | 22 | ||
23 | 23 | ||
24 | static DEFINE_IDR(rtc_idr); | 24 | static DEFINE_IDA(rtc_ida); |
25 | static DEFINE_MUTEX(idr_lock); | ||
26 | struct class *rtc_class; | 25 | struct class *rtc_class; |
27 | 26 | ||
28 | static void rtc_device_release(struct device *dev) | 27 | static void rtc_device_release(struct device *dev) |
29 | { | 28 | { |
30 | struct rtc_device *rtc = to_rtc_device(dev); | 29 | struct rtc_device *rtc = to_rtc_device(dev); |
31 | mutex_lock(&idr_lock); | 30 | ida_simple_remove(&rtc_ida, rtc->id); |
32 | idr_remove(&rtc_idr, rtc->id); | ||
33 | mutex_unlock(&idr_lock); | ||
34 | kfree(rtc); | 31 | kfree(rtc); |
35 | } | 32 | } |
36 | 33 | ||
@@ -66,7 +63,7 @@ static int rtc_suspend(struct device *dev, pm_message_t mesg) | |||
66 | */ | 63 | */ |
67 | delta = timespec_sub(old_system, old_rtc); | 64 | delta = timespec_sub(old_system, old_rtc); |
68 | delta_delta = timespec_sub(delta, old_delta); | 65 | delta_delta = timespec_sub(delta, old_delta); |
69 | if (abs(delta_delta.tv_sec) >= 2) { | 66 | if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { |
70 | /* | 67 | /* |
71 | * if delta_delta is too large, assume time correction | 68 | * if delta_delta is too large, assume time correction |
72 | * has occured and set old_delta to the current delta. | 69 | * has occured and set old_delta to the current delta. |
@@ -100,9 +97,8 @@ static int rtc_resume(struct device *dev) | |||
100 | rtc_tm_to_time(&tm, &new_rtc.tv_sec); | 97 | rtc_tm_to_time(&tm, &new_rtc.tv_sec); |
101 | new_rtc.tv_nsec = 0; | 98 | new_rtc.tv_nsec = 0; |
102 | 99 | ||
103 | if (new_rtc.tv_sec <= old_rtc.tv_sec) { | 100 | if (new_rtc.tv_sec < old_rtc.tv_sec) { |
104 | if (new_rtc.tv_sec < old_rtc.tv_sec) | 101 | pr_debug("%s: time travel!\n", dev_name(&rtc->dev)); |
105 | pr_debug("%s: time travel!\n", dev_name(&rtc->dev)); | ||
106 | return 0; | 102 | return 0; |
107 | } | 103 | } |
108 | 104 | ||
@@ -119,7 +115,8 @@ static int rtc_resume(struct device *dev) | |||
119 | sleep_time = timespec_sub(sleep_time, | 115 | sleep_time = timespec_sub(sleep_time, |
120 | timespec_sub(new_system, old_system)); | 116 | timespec_sub(new_system, old_system)); |
121 | 117 | ||
122 | timekeeping_inject_sleeptime(&sleep_time); | 118 | if (sleep_time.tv_sec >= 0) |
119 | timekeeping_inject_sleeptime(&sleep_time); | ||
123 | return 0; | 120 | return 0; |
124 | } | 121 | } |
125 | 122 | ||
@@ -146,25 +143,16 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
146 | struct rtc_wkalrm alrm; | 143 | struct rtc_wkalrm alrm; |
147 | int id, err; | 144 | int id, err; |
148 | 145 | ||
149 | if (idr_pre_get(&rtc_idr, GFP_KERNEL) == 0) { | 146 | id = ida_simple_get(&rtc_ida, 0, 0, GFP_KERNEL); |
150 | err = -ENOMEM; | 147 | if (id < 0) { |
148 | err = id; | ||
151 | goto exit; | 149 | goto exit; |
152 | } | 150 | } |
153 | 151 | ||
154 | |||
155 | mutex_lock(&idr_lock); | ||
156 | err = idr_get_new(&rtc_idr, NULL, &id); | ||
157 | mutex_unlock(&idr_lock); | ||
158 | |||
159 | if (err < 0) | ||
160 | goto exit; | ||
161 | |||
162 | id = id & MAX_ID_MASK; | ||
163 | |||
164 | rtc = kzalloc(sizeof(struct rtc_device), GFP_KERNEL); | 152 | rtc = kzalloc(sizeof(struct rtc_device), GFP_KERNEL); |
165 | if (rtc == NULL) { | 153 | if (rtc == NULL) { |
166 | err = -ENOMEM; | 154 | err = -ENOMEM; |
167 | goto exit_idr; | 155 | goto exit_ida; |
168 | } | 156 | } |
169 | 157 | ||
170 | rtc->id = id; | 158 | rtc->id = id; |
@@ -222,10 +210,8 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
222 | exit_kfree: | 210 | exit_kfree: |
223 | kfree(rtc); | 211 | kfree(rtc); |
224 | 212 | ||
225 | exit_idr: | 213 | exit_ida: |
226 | mutex_lock(&idr_lock); | 214 | ida_simple_remove(&rtc_ida, id); |
227 | idr_remove(&rtc_idr, id); | ||
228 | mutex_unlock(&idr_lock); | ||
229 | 215 | ||
230 | exit: | 216 | exit: |
231 | dev_err(dev, "rtc core: unable to register %s, err = %d\n", | 217 | dev_err(dev, "rtc core: unable to register %s, err = %d\n", |
@@ -276,7 +262,7 @@ static void __exit rtc_exit(void) | |||
276 | { | 262 | { |
277 | rtc_dev_exit(); | 263 | rtc_dev_exit(); |
278 | class_destroy(rtc_class); | 264 | class_destroy(rtc_class); |
279 | idr_destroy(&rtc_idr); | 265 | ida_destroy(&rtc_ida); |
280 | } | 266 | } |
281 | 267 | ||
282 | subsys_initcall(rtc_init); | 268 | subsys_initcall(rtc_init); |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 44e91e598f8d..3bcc7cfcaba7 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/module.h> | ||
16 | #include <linux/log2.h> | 17 | #include <linux/log2.h> |
17 | #include <linux/workqueue.h> | 18 | #include <linux/workqueue.h> |
18 | 19 | ||
@@ -72,6 +73,8 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) | |||
72 | err = -EINVAL; | 73 | err = -EINVAL; |
73 | 74 | ||
74 | mutex_unlock(&rtc->ops_lock); | 75 | mutex_unlock(&rtc->ops_lock); |
76 | /* A timer might have just expired */ | ||
77 | schedule_work(&rtc->irqwork); | ||
75 | return err; | 78 | return err; |
76 | } | 79 | } |
77 | EXPORT_SYMBOL_GPL(rtc_set_time); | 80 | EXPORT_SYMBOL_GPL(rtc_set_time); |
@@ -111,6 +114,8 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) | |||
111 | err = -EINVAL; | 114 | err = -EINVAL; |
112 | 115 | ||
113 | mutex_unlock(&rtc->ops_lock); | 116 | mutex_unlock(&rtc->ops_lock); |
117 | /* A timer might have just expired */ | ||
118 | schedule_work(&rtc->irqwork); | ||
114 | 119 | ||
115 | return err; | 120 | return err; |
116 | } | 121 | } |
@@ -318,6 +323,20 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
318 | } | 323 | } |
319 | EXPORT_SYMBOL_GPL(rtc_read_alarm); | 324 | EXPORT_SYMBOL_GPL(rtc_read_alarm); |
320 | 325 | ||
326 | static int ___rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | ||
327 | { | ||
328 | int err; | ||
329 | |||
330 | if (!rtc->ops) | ||
331 | err = -ENODEV; | ||
332 | else if (!rtc->ops->set_alarm) | ||
333 | err = -EINVAL; | ||
334 | else | ||
335 | err = rtc->ops->set_alarm(rtc->dev.parent, alarm); | ||
336 | |||
337 | return err; | ||
338 | } | ||
339 | |||
321 | static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 340 | static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
322 | { | 341 | { |
323 | struct rtc_time tm; | 342 | struct rtc_time tm; |
@@ -341,14 +360,7 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
341 | * over right here, before we set the alarm. | 360 | * over right here, before we set the alarm. |
342 | */ | 361 | */ |
343 | 362 | ||
344 | if (!rtc->ops) | 363 | return ___rtc_set_alarm(rtc, alarm); |
345 | err = -ENODEV; | ||
346 | else if (!rtc->ops->set_alarm) | ||
347 | err = -EINVAL; | ||
348 | else | ||
349 | err = rtc->ops->set_alarm(rtc->dev.parent, alarm); | ||
350 | |||
351 | return err; | ||
352 | } | 364 | } |
353 | 365 | ||
354 | int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 366 | int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
@@ -395,6 +407,8 @@ int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
395 | timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); | 407 | timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); |
396 | } | 408 | } |
397 | mutex_unlock(&rtc->ops_lock); | 409 | mutex_unlock(&rtc->ops_lock); |
410 | /* maybe that was in the past.*/ | ||
411 | schedule_work(&rtc->irqwork); | ||
398 | return err; | 412 | return err; |
399 | } | 413 | } |
400 | EXPORT_SYMBOL_GPL(rtc_initialize_alarm); | 414 | EXPORT_SYMBOL_GPL(rtc_initialize_alarm); |
@@ -762,6 +776,20 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) | |||
762 | return 0; | 776 | return 0; |
763 | } | 777 | } |
764 | 778 | ||
779 | static void rtc_alarm_disable(struct rtc_device *rtc) | ||
780 | { | ||
781 | struct rtc_wkalrm alarm; | ||
782 | struct rtc_time tm; | ||
783 | |||
784 | __rtc_read_time(rtc, &tm); | ||
785 | |||
786 | alarm.time = rtc_ktime_to_tm(ktime_add(rtc_tm_to_ktime(tm), | ||
787 | ktime_set(300, 0))); | ||
788 | alarm.enabled = 0; | ||
789 | |||
790 | ___rtc_set_alarm(rtc, &alarm); | ||
791 | } | ||
792 | |||
765 | /** | 793 | /** |
766 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue | 794 | * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue |
767 | * @rtc rtc device | 795 | * @rtc rtc device |
@@ -783,8 +811,10 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) | |||
783 | struct rtc_wkalrm alarm; | 811 | struct rtc_wkalrm alarm; |
784 | int err; | 812 | int err; |
785 | next = timerqueue_getnext(&rtc->timerqueue); | 813 | next = timerqueue_getnext(&rtc->timerqueue); |
786 | if (!next) | 814 | if (!next) { |
815 | rtc_alarm_disable(rtc); | ||
787 | return; | 816 | return; |
817 | } | ||
788 | alarm.time = rtc_ktime_to_tm(next->expires); | 818 | alarm.time = rtc_ktime_to_tm(next->expires); |
789 | alarm.enabled = 1; | 819 | alarm.enabled = 1; |
790 | err = __rtc_set_alarm(rtc, &alarm); | 820 | err = __rtc_set_alarm(rtc, &alarm); |
@@ -846,7 +876,8 @@ again: | |||
846 | err = __rtc_set_alarm(rtc, &alarm); | 876 | err = __rtc_set_alarm(rtc, &alarm); |
847 | if (err == -ETIME) | 877 | if (err == -ETIME) |
848 | goto again; | 878 | goto again; |
849 | } | 879 | } else |
880 | rtc_alarm_disable(rtc); | ||
850 | 881 | ||
851 | mutex_unlock(&rtc->ops_lock); | 882 | mutex_unlock(&rtc->ops_lock); |
852 | } | 883 | } |
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c index 58d4e18530da..2322c43af201 100644 --- a/drivers/rtc/rtc-dm355evm.c +++ b/drivers/rtc/rtc-dm355evm.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | 15 | ||
16 | #include <linux/i2c/dm355evm_msp.h> | 16 | #include <linux/i2c/dm355evm_msp.h> |
17 | #include <linux/module.h> | ||
17 | 18 | ||
18 | 19 | ||
19 | /* | 20 | /* |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 57fbcc149ba7..3a33b1fdbe0f 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | #include <linux/spi/spi.h> | 18 | #include <linux/spi/spi.h> |
19 | #include <linux/spi/ds1305.h> | 19 | #include <linux/spi/ds1305.h> |
20 | #include <linux/module.h> | ||
20 | 21 | ||
21 | 22 | ||
22 | /* | 23 | /* |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index b2005b44e4f7..62b0763b7b9a 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -34,6 +34,7 @@ enum ds_type { | |||
34 | ds_1388, | 34 | ds_1388, |
35 | ds_3231, | 35 | ds_3231, |
36 | m41t00, | 36 | m41t00, |
37 | mcp7941x, | ||
37 | rx_8025, | 38 | rx_8025, |
38 | // rs5c372 too? different address... | 39 | // rs5c372 too? different address... |
39 | }; | 40 | }; |
@@ -43,6 +44,7 @@ enum ds_type { | |||
43 | #define DS1307_REG_SECS 0x00 /* 00-59 */ | 44 | #define DS1307_REG_SECS 0x00 /* 00-59 */ |
44 | # define DS1307_BIT_CH 0x80 | 45 | # define DS1307_BIT_CH 0x80 |
45 | # define DS1340_BIT_nEOSC 0x80 | 46 | # define DS1340_BIT_nEOSC 0x80 |
47 | # define MCP7941X_BIT_ST 0x80 | ||
46 | #define DS1307_REG_MIN 0x01 /* 00-59 */ | 48 | #define DS1307_REG_MIN 0x01 /* 00-59 */ |
47 | #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ | 49 | #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ |
48 | # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ | 50 | # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ |
@@ -50,6 +52,7 @@ enum ds_type { | |||
50 | # define DS1340_BIT_CENTURY_EN 0x80 /* in REG_HOUR */ | 52 | # define DS1340_BIT_CENTURY_EN 0x80 /* in REG_HOUR */ |
51 | # define DS1340_BIT_CENTURY 0x40 /* in REG_HOUR */ | 53 | # define DS1340_BIT_CENTURY 0x40 /* in REG_HOUR */ |
52 | #define DS1307_REG_WDAY 0x03 /* 01-07 */ | 54 | #define DS1307_REG_WDAY 0x03 /* 01-07 */ |
55 | # define MCP7941X_BIT_VBATEN 0x08 | ||
53 | #define DS1307_REG_MDAY 0x04 /* 01-31 */ | 56 | #define DS1307_REG_MDAY 0x04 /* 01-31 */ |
54 | #define DS1307_REG_MONTH 0x05 /* 01-12 */ | 57 | #define DS1307_REG_MONTH 0x05 /* 01-12 */ |
55 | # define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ | 58 | # define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ |
@@ -137,6 +140,8 @@ static const struct chip_desc chips[] = { | |||
137 | }, | 140 | }, |
138 | [m41t00] = { | 141 | [m41t00] = { |
139 | }, | 142 | }, |
143 | [mcp7941x] = { | ||
144 | }, | ||
140 | [rx_8025] = { | 145 | [rx_8025] = { |
141 | }, }; | 146 | }, }; |
142 | 147 | ||
@@ -149,6 +154,7 @@ static const struct i2c_device_id ds1307_id[] = { | |||
149 | { "ds1340", ds_1340 }, | 154 | { "ds1340", ds_1340 }, |
150 | { "ds3231", ds_3231 }, | 155 | { "ds3231", ds_3231 }, |
151 | { "m41t00", m41t00 }, | 156 | { "m41t00", m41t00 }, |
157 | { "mcp7941x", mcp7941x }, | ||
152 | { "pt7c4338", ds_1307 }, | 158 | { "pt7c4338", ds_1307 }, |
153 | { "rx8025", rx_8025 }, | 159 | { "rx8025", rx_8025 }, |
154 | { } | 160 | { } |
@@ -365,6 +371,10 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) | |||
365 | buf[DS1307_REG_HOUR] |= DS1340_BIT_CENTURY_EN | 371 | buf[DS1307_REG_HOUR] |= DS1340_BIT_CENTURY_EN |
366 | | DS1340_BIT_CENTURY; | 372 | | DS1340_BIT_CENTURY; |
367 | break; | 373 | break; |
374 | case mcp7941x: | ||
375 | buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; | ||
376 | buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; | ||
377 | break; | ||
368 | default: | 378 | default: |
369 | break; | 379 | break; |
370 | } | 380 | } |
@@ -809,6 +819,23 @@ read_rtc: | |||
809 | dev_warn(&client->dev, "SET TIME!\n"); | 819 | dev_warn(&client->dev, "SET TIME!\n"); |
810 | } | 820 | } |
811 | break; | 821 | break; |
822 | case mcp7941x: | ||
823 | /* make sure that the backup battery is enabled */ | ||
824 | if (!(ds1307->regs[DS1307_REG_WDAY] & MCP7941X_BIT_VBATEN)) { | ||
825 | i2c_smbus_write_byte_data(client, DS1307_REG_WDAY, | ||
826 | ds1307->regs[DS1307_REG_WDAY] | ||
827 | | MCP7941X_BIT_VBATEN); | ||
828 | } | ||
829 | |||
830 | /* clock halted? turn it on, so clock can tick. */ | ||
831 | if (!(tmp & MCP7941X_BIT_ST)) { | ||
832 | i2c_smbus_write_byte_data(client, DS1307_REG_SECS, | ||
833 | MCP7941X_BIT_ST); | ||
834 | dev_warn(&client->dev, "SET TIME!\n"); | ||
835 | goto read_rtc; | ||
836 | } | ||
837 | |||
838 | break; | ||
812 | case rx_8025: | 839 | case rx_8025: |
813 | case ds_1337: | 840 | case ds_1337: |
814 | case ds_1339: | 841 | case ds_1339: |
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 568ad30617e7..586c244a05d8 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/rtc.h> | 23 | #include <linux/rtc.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/module.h> | ||
26 | 27 | ||
27 | #define DRV_VERSION "0.6" | 28 | #define DRV_VERSION "0.6" |
28 | 29 | ||
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index fee41b97c9e8..1350029044e6 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/module.h> | ||
21 | 22 | ||
22 | #define DRV_VERSION "0.3" | 23 | #define DRV_VERSION "0.3" |
23 | 24 | ||
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index 06dfb54f99b6..a319402a5447 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/i2c.h> | 12 | #include <linux/i2c.h> |
13 | #include <linux/rtc.h> | 13 | #include <linux/rtc.h> |
14 | #include <linux/module.h> | ||
14 | 15 | ||
15 | #define DRV_VERSION "0.4" | 16 | #define DRV_VERSION "0.4" |
16 | 17 | ||
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c index d84a448dd754..e3e0f92b60f0 100644 --- a/drivers/rtc/rtc-ds1742.c +++ b/drivers/rtc/rtc-ds1742.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/rtc.h> | 21 | #include <linux/rtc.h> |
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/module.h> | ||
24 | 25 | ||
25 | #define DRV_VERSION "0.4" | 26 | #define DRV_VERSION "0.4" |
26 | 27 | ||
diff --git a/drivers/rtc/rtc-em3027.c b/drivers/rtc/rtc-em3027.c index d8e1c2578553..8414dea5fb14 100644 --- a/drivers/rtc/rtc-em3027.c +++ b/drivers/rtc/rtc-em3027.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/i2c.h> | 14 | #include <linux/i2c.h> |
15 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
16 | #include <linux/bcd.h> | 16 | #include <linux/bcd.h> |
17 | #include <linux/module.h> | ||
17 | 18 | ||
18 | /* Registers */ | 19 | /* Registers */ |
19 | #define EM3027_REG_ON_OFF_CTRL 0x00 | 20 | #define EM3027_REG_ON_OFF_CTRL 0x00 |
diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index ddbc797ea6cd..6186833973ee 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/bcd.h> | 15 | #include <linux/bcd.h> |
16 | #include <linux/rtc.h> | 16 | #include <linux/rtc.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/module.h> | ||
18 | 19 | ||
19 | #define DRV_VERSION "0.1" | 20 | #define DRV_VERSION "0.1" |
20 | 21 | ||
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index eda128fc1d38..64aedd8cc095 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -357,10 +357,19 @@ static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
357 | static struct rtc_class_ops m41t80_rtc_ops = { | 357 | static struct rtc_class_ops m41t80_rtc_ops = { |
358 | .read_time = m41t80_rtc_read_time, | 358 | .read_time = m41t80_rtc_read_time, |
359 | .set_time = m41t80_rtc_set_time, | 359 | .set_time = m41t80_rtc_set_time, |
360 | /* | ||
361 | * XXX - m41t80 alarm functionality is reported broken. | ||
362 | * until it is fixed, don't register alarm functions. | ||
363 | * | ||
360 | .read_alarm = m41t80_rtc_read_alarm, | 364 | .read_alarm = m41t80_rtc_read_alarm, |
361 | .set_alarm = m41t80_rtc_set_alarm, | 365 | .set_alarm = m41t80_rtc_set_alarm, |
366 | */ | ||
362 | .proc = m41t80_rtc_proc, | 367 | .proc = m41t80_rtc_proc, |
368 | /* | ||
369 | * See above comment on broken alarm | ||
370 | * | ||
363 | .alarm_irq_enable = m41t80_rtc_alarm_irq_enable, | 371 | .alarm_irq_enable = m41t80_rtc_alarm_irq_enable, |
372 | */ | ||
364 | }; | 373 | }; |
365 | 374 | ||
366 | #if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) | 375 | #if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) |
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index a1a278bc340d..9d0c3b478d55 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c | |||
@@ -309,7 +309,7 @@ static irqreturn_t mc13xxx_rtc_reset_handler(int irq, void *dev) | |||
309 | return IRQ_HANDLED; | 309 | return IRQ_HANDLED; |
310 | } | 310 | } |
311 | 311 | ||
312 | static int __devinit mc13xxx_rtc_probe(struct platform_device *pdev) | 312 | static int __init mc13xxx_rtc_probe(struct platform_device *pdev) |
313 | { | 313 | { |
314 | int ret; | 314 | int ret; |
315 | struct mc13xxx_rtc *priv; | 315 | struct mc13xxx_rtc *priv; |
@@ -378,7 +378,7 @@ err_reset_irq_request: | |||
378 | return ret; | 378 | return ret; |
379 | } | 379 | } |
380 | 380 | ||
381 | static int __devexit mc13xxx_rtc_remove(struct platform_device *pdev) | 381 | static int __exit mc13xxx_rtc_remove(struct platform_device *pdev) |
382 | { | 382 | { |
383 | struct mc13xxx_rtc *priv = platform_get_drvdata(pdev); | 383 | struct mc13xxx_rtc *priv = platform_get_drvdata(pdev); |
384 | 384 | ||
@@ -410,7 +410,7 @@ const struct platform_device_id mc13xxx_rtc_idtable[] = { | |||
410 | 410 | ||
411 | static struct platform_driver mc13xxx_rtc_driver = { | 411 | static struct platform_driver mc13xxx_rtc_driver = { |
412 | .id_table = mc13xxx_rtc_idtable, | 412 | .id_table = mc13xxx_rtc_idtable, |
413 | .remove = __devexit_p(mc13xxx_rtc_remove), | 413 | .remove = __exit_p(mc13xxx_rtc_remove), |
414 | .driver = { | 414 | .driver = { |
415 | .name = DRIVER_NAME, | 415 | .name = DRIVER_NAME, |
416 | .owner = THIS_MODULE, | 416 | .owner = THIS_MODULE, |
diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index d33544802a2e..bb21f443fb70 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c | |||
@@ -76,12 +76,15 @@ static inline unsigned char vrtc_is_updating(void) | |||
76 | /* | 76 | /* |
77 | * rtc_time's year contains the increment over 1900, but vRTC's YEAR | 77 | * rtc_time's year contains the increment over 1900, but vRTC's YEAR |
78 | * register can't be programmed to value larger than 0x64, so vRTC | 78 | * register can't be programmed to value larger than 0x64, so vRTC |
79 | * driver chose to use 1960 (1970 is UNIX time start point) as the base, | 79 | * driver chose to use 1972 (1970 is UNIX time start point) as the base, |
80 | * and does the translation at read/write time. | 80 | * and does the translation at read/write time. |
81 | * | 81 | * |
82 | * Why not just use 1970 as the offset? it's because using 1960 will | 82 | * Why not just use 1970 as the offset? it's because using 1972 will |
83 | * make it consistent in leap year setting for both vrtc and low-level | 83 | * make it consistent in leap year setting for both vrtc and low-level |
84 | * physical rtc devices. | 84 | * physical rtc devices. Then why not use 1960 as the offset? If we use |
85 | * 1960, for a device's first use, its YEAR register is 0 and the system | ||
86 | * year will be parsed as 1960 which is not a valid UNIX time and will | ||
87 | * cause many applications to fail mysteriously. | ||
85 | */ | 88 | */ |
86 | static int mrst_read_time(struct device *dev, struct rtc_time *time) | 89 | static int mrst_read_time(struct device *dev, struct rtc_time *time) |
87 | { | 90 | { |
@@ -99,10 +102,10 @@ static int mrst_read_time(struct device *dev, struct rtc_time *time) | |||
99 | time->tm_year = vrtc_cmos_read(RTC_YEAR); | 102 | time->tm_year = vrtc_cmos_read(RTC_YEAR); |
100 | spin_unlock_irqrestore(&rtc_lock, flags); | 103 | spin_unlock_irqrestore(&rtc_lock, flags); |
101 | 104 | ||
102 | /* Adjust for the 1960/1900 */ | 105 | /* Adjust for the 1972/1900 */ |
103 | time->tm_year += 60; | 106 | time->tm_year += 72; |
104 | time->tm_mon--; | 107 | time->tm_mon--; |
105 | return RTC_24H; | 108 | return rtc_valid_tm(time); |
106 | } | 109 | } |
107 | 110 | ||
108 | static int mrst_set_time(struct device *dev, struct rtc_time *time) | 111 | static int mrst_set_time(struct device *dev, struct rtc_time *time) |
@@ -119,9 +122,9 @@ static int mrst_set_time(struct device *dev, struct rtc_time *time) | |||
119 | min = time->tm_min; | 122 | min = time->tm_min; |
120 | sec = time->tm_sec; | 123 | sec = time->tm_sec; |
121 | 124 | ||
122 | if (yrs < 70 || yrs > 138) | 125 | if (yrs < 72 || yrs > 138) |
123 | return -EINVAL; | 126 | return -EINVAL; |
124 | yrs -= 60; | 127 | yrs -= 72; |
125 | 128 | ||
126 | spin_lock_irqsave(&rtc_lock, flags); | 129 | spin_lock_irqsave(&rtc_lock, flags); |
127 | 130 | ||
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index 60627a764514..768e2edb9678 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/gfp.h> | 16 | #include <linux/gfp.h> |
17 | #include <linux/module.h> | ||
17 | 18 | ||
18 | 19 | ||
19 | #define RTC_TIME_REG_OFFS 0 | 20 | #define RTC_TIME_REG_OFFS 0 |
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c index 71bab0ef5443..2ee3bbf7e5ea 100644 --- a/drivers/rtc/rtc-pcf2123.c +++ b/drivers/rtc/rtc-pcf2123.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
43 | #include <linux/rtc.h> | 43 | #include <linux/rtc.h> |
44 | #include <linux/spi/spi.h> | 44 | #include <linux/spi/spi.h> |
45 | #include <linux/module.h> | ||
45 | 46 | ||
46 | #define DRV_VERSION "0.6" | 47 | #define DRV_VERSION "0.6" |
47 | 48 | ||
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index b42c0c679266..606fdfab34e2 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/bcd.h> | 18 | #include <linux/bcd.h> |
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/module.h> | ||
21 | 22 | ||
22 | #define DRV_VERSION "0.4.3" | 23 | #define DRV_VERSION "0.4.3" |
23 | 24 | ||
diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c index b3eba3cddd42..e4b6880aabd0 100644 --- a/drivers/rtc/rtc-puv3.c +++ b/drivers/rtc/rtc-puv3.c | |||
@@ -220,7 +220,7 @@ static void puv3_rtc_enable(struct platform_device *pdev, int en) | |||
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | static int puv3_rtc_remove(struct platform_device *dev) | 223 | static int __devexit puv3_rtc_remove(struct platform_device *dev) |
224 | { | 224 | { |
225 | struct rtc_device *rtc = platform_get_drvdata(dev); | 225 | struct rtc_device *rtc = platform_get_drvdata(dev); |
226 | 226 | ||
@@ -236,7 +236,7 @@ static int puv3_rtc_remove(struct platform_device *dev) | |||
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | 238 | ||
239 | static int puv3_rtc_probe(struct platform_device *pdev) | 239 | static int __devinit puv3_rtc_probe(struct platform_device *pdev) |
240 | { | 240 | { |
241 | struct rtc_device *rtc; | 241 | struct rtc_device *rtc; |
242 | struct resource *res; | 242 | struct resource *res; |
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index 368d0e63cf83..971bc8e08da6 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/rtc.h> | 23 | #include <linux/rtc.h> |
24 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
25 | #include <linux/spi/spi.h> | 25 | #include <linux/spi/spi.h> |
26 | #include <linux/module.h> | ||
26 | 27 | ||
27 | #define DRV_VERSION "0.2" | 28 | #define DRV_VERSION "0.2" |
28 | 29 | ||
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index 85c1b848dd72..d29f5432c6e8 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
15 | #include <linux/bcd.h> | 15 | #include <linux/bcd.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/module.h> | ||
17 | 18 | ||
18 | #define DRV_VERSION "0.6" | 19 | #define DRV_VERSION "0.6" |
19 | 20 | ||
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 7639ab906f02..5b979d9cc332 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -202,7 +202,6 @@ static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
202 | void __iomem *base = s3c_rtc_base; | 202 | void __iomem *base = s3c_rtc_base; |
203 | int year = tm->tm_year - 100; | 203 | int year = tm->tm_year - 100; |
204 | 204 | ||
205 | clk_enable(rtc_clk); | ||
206 | pr_debug("set time %04d.%02d.%02d %02d:%02d:%02d\n", | 205 | pr_debug("set time %04d.%02d.%02d %02d:%02d:%02d\n", |
207 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, | 206 | 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, |
208 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 207 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
@@ -214,6 +213,7 @@ static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
214 | return -EINVAL; | 213 | return -EINVAL; |
215 | } | 214 | } |
216 | 215 | ||
216 | clk_enable(rtc_clk); | ||
217 | writeb(bin2bcd(tm->tm_sec), base + S3C2410_RTCSEC); | 217 | writeb(bin2bcd(tm->tm_sec), base + S3C2410_RTCSEC); |
218 | writeb(bin2bcd(tm->tm_min), base + S3C2410_RTCMIN); | 218 | writeb(bin2bcd(tm->tm_min), base + S3C2410_RTCMIN); |
219 | writeb(bin2bcd(tm->tm_hour), base + S3C2410_RTCHOUR); | 219 | writeb(bin2bcd(tm->tm_hour), base + S3C2410_RTCHOUR); |
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c index 3b943673cd3e..ed3e9b599031 100644 --- a/drivers/rtc/rtc-stk17ta8.c +++ b/drivers/rtc/rtc-stk17ta8.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/rtc.h> | 21 | #include <linux/rtc.h> |
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/module.h> | ||
24 | 25 | ||
25 | #define DRV_VERSION "0.1" | 26 | #define DRV_VERSION "0.1" |
26 | 27 | ||
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c index ec6313d15359..aac0ffed4345 100644 --- a/drivers/rtc/rtc-tx4939.c +++ b/drivers/rtc/rtc-tx4939.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/rtc.h> | 11 | #include <linux/rtc.h> |
12 | #include <linux/platform_device.h> | 12 | #include <linux/platform_device.h> |
13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
14 | #include <linux/module.h> | ||
14 | #include <linux/io.h> | 15 | #include <linux/io.h> |
15 | #include <linux/gfp.h> | 16 | #include <linux/gfp.h> |
16 | #include <asm/txx9/tx4939.h> | 17 | #include <asm/txx9/tx4939.h> |
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index b00aad2620d4..8c051d3179db 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/bcd.h> | 21 | #include <linux/bcd.h> |
22 | #include <linux/rtc.h> | 22 | #include <linux/rtc.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/module.h> | ||
24 | 25 | ||
25 | #define DRV_VERSION "1.0.8" | 26 | #define DRV_VERSION "1.0.8" |
26 | 27 | ||