aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 19:42:48 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 19:42:48 -0500
commit40ba587923ae67090d9f141c1d3c951be5c1420e (patch)
tree342a72fc0ee13a0d2496ef970b64dfeadf1355d2 /drivers/rtc
parent54c2c5761febcca46c8037d3a81612991e6c209a (diff)
parent6b550f9495947fc279d12c38feaf98500e8d0646 (diff)
Merge branch 'akpm' (aka "Andrew's patch-bomb")
Andrew elucidates: - First installmeant of MM. We have a HUGE number of MM patches this time. It's crazy. - MAINTAINERS updates - backlight updates - leds - checkpatch updates - misc ELF stuff - rtc updates - reiserfs - procfs - some misc other bits * akpm: (124 commits) user namespace: make signal.c respect user namespaces workqueue: make alloc_workqueue() take printf fmt and args for name procfs: add hidepid= and gid= mount options procfs: parse mount options procfs: introduce the /proc/<pid>/map_files/ directory procfs: make proc_get_link to use dentry instead of inode signal: add block_sigmask() for adding sigmask to current->blocked sparc: make SA_NOMASK a synonym of SA_NODEFER reiserfs: don't lock root inode searching reiserfs: don't lock journal_init() reiserfs: delay reiserfs lock until journal initialization reiserfs: delete comments referring to the BKL drivers/rtc/interface.c: fix alarm rollover when day or month is out-of-range drivers/rtc/rtc-twl.c: add DT support for RTC inside twl4030/twl6030 drivers/rtc/: remove redundant spi driver bus initialization drivers/rtc/rtc-jz4740.c: make jz4740_rtc_driver static drivers/rtc/rtc-mc13xxx.c: make mc13xxx_rtc_idtable static rtc: convert drivers/rtc/* to use module_platform_driver() drivers/rtc/rtc-wm831x.c: convert to devm_kzalloc() drivers/rtc/rtc-wm831x.c: remove unused period IRQ handler ...
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/interface.c4
-rw-r--r--drivers/rtc/rtc-88pm860x.c12
-rw-r--r--drivers/rtc/rtc-ab8500.c136
-rw-r--r--drivers/rtc/rtc-bfin.c13
-rw-r--r--drivers/rtc/rtc-bq4802.c13
-rw-r--r--drivers/rtc/rtc-cmos.c2
-rw-r--r--drivers/rtc/rtc-dm355evm.c12
-rw-r--r--drivers/rtc/rtc-ds1286.c13
-rw-r--r--drivers/rtc/rtc-ds1511.c15
-rw-r--r--drivers/rtc/rtc-ds1553.c13
-rw-r--r--drivers/rtc/rtc-ds1742.c13
-rw-r--r--drivers/rtc/rtc-jz4740.c14
-rw-r--r--drivers/rtc/rtc-lpc32xx.c12
-rw-r--r--drivers/rtc/rtc-m41t93.c1
-rw-r--r--drivers/rtc/rtc-m41t94.c1
-rw-r--r--drivers/rtc/rtc-m48t35.c13
-rw-r--r--drivers/rtc/rtc-m48t59.c13
-rw-r--r--drivers/rtc/rtc-m48t86.c13
-rw-r--r--drivers/rtc/rtc-max6902.c1
-rw-r--r--drivers/rtc/rtc-max8925.c12
-rw-r--r--drivers/rtc/rtc-max8998.c12
-rw-r--r--drivers/rtc/rtc-mc13xxx.c2
-rw-r--r--drivers/rtc/rtc-mpc5121.c12
-rw-r--r--drivers/rtc/rtc-mrst.c13
-rw-r--r--drivers/rtc/rtc-mxc.c123
-rw-r--r--drivers/rtc/rtc-pcf2123.c1
-rw-r--r--drivers/rtc/rtc-pcf50633.c12
-rw-r--r--drivers/rtc/rtc-pm8xxx.c12
-rw-r--r--drivers/rtc/rtc-rs5c348.c1
-rw-r--r--drivers/rtc/rtc-s3c.c16
-rw-r--r--drivers/rtc/rtc-sa1100.c13
-rw-r--r--drivers/rtc/rtc-spear.c12
-rw-r--r--drivers/rtc/rtc-stk17ta8.c13
-rw-r--r--drivers/rtc/rtc-stmp3xxx.c13
-rw-r--r--drivers/rtc/rtc-twl.c10
-rw-r--r--drivers/rtc/rtc-v3020.c13
-rw-r--r--drivers/rtc/rtc-vr41xx.c13
-rw-r--r--drivers/rtc/rtc-vt8500.c12
-rw-r--r--drivers/rtc/rtc-wm831x.c36
-rw-r--r--drivers/rtc/rtc-wm8350.c12
40 files changed, 233 insertions, 444 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 8e286259a007..8a1c031391d6 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -228,11 +228,11 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
228 alarm->time.tm_hour = now.tm_hour; 228 alarm->time.tm_hour = now.tm_hour;
229 229
230 /* For simplicity, only support date rollover for now */ 230 /* For simplicity, only support date rollover for now */
231 if (alarm->time.tm_mday == -1) { 231 if (alarm->time.tm_mday < 1 || alarm->time.tm_mday > 31) {
232 alarm->time.tm_mday = now.tm_mday; 232 alarm->time.tm_mday = now.tm_mday;
233 missing = day; 233 missing = day;
234 } 234 }
235 if (alarm->time.tm_mon == -1) { 235 if ((unsigned)alarm->time.tm_mon >= 12) {
236 alarm->time.tm_mon = now.tm_mon; 236 alarm->time.tm_mon = now.tm_mon;
237 if (missing == none) 237 if (missing == none)
238 missing = month; 238 missing = month;
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
index 64b847b7f970..f04761e6622d 100644
--- a/drivers/rtc/rtc-88pm860x.c
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -410,17 +410,7 @@ static struct platform_driver pm860x_rtc_driver = {
410 .remove = __devexit_p(pm860x_rtc_remove), 410 .remove = __devexit_p(pm860x_rtc_remove),
411}; 411};
412 412
413static int __init pm860x_rtc_init(void) 413module_platform_driver(pm860x_rtc_driver);
414{
415 return platform_driver_register(&pm860x_rtc_driver);
416}
417module_init(pm860x_rtc_init);
418
419static void __exit pm860x_rtc_exit(void)
420{
421 platform_driver_unregister(&pm860x_rtc_driver);
422}
423module_exit(pm860x_rtc_exit);
424 414
425MODULE_DESCRIPTION("Marvell 88PM860x RTC driver"); 415MODULE_DESCRIPTION("Marvell 88PM860x RTC driver");
426MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); 416MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index e346705aae92..a0a9810adf0b 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -90,7 +90,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
90 90
91 /* Early AB8500 chips will not clear the rtc read request bit */ 91 /* Early AB8500 chips will not clear the rtc read request bit */
92 if (abx500_get_chip_id(dev) == 0) { 92 if (abx500_get_chip_id(dev) == 0) {
93 msleep(1); 93 usleep_range(1000, 1000);
94 } else { 94 } else {
95 /* Wait for some cycles after enabling the rtc read in ab8500 */ 95 /* Wait for some cycles after enabling the rtc read in ab8500 */
96 while (time_before(jiffies, timeout)) { 96 while (time_before(jiffies, timeout)) {
@@ -102,7 +102,7 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
102 if (!(value & RTC_READ_REQUEST)) 102 if (!(value & RTC_READ_REQUEST))
103 break; 103 break;
104 104
105 msleep(1); 105 usleep_range(1000, 5000);
106 } 106 }
107 } 107 }
108 108
@@ -258,6 +258,109 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
258 return ab8500_rtc_irq_enable(dev, alarm->enabled); 258 return ab8500_rtc_irq_enable(dev, alarm->enabled);
259} 259}
260 260
261
262static int ab8500_rtc_set_calibration(struct device *dev, int calibration)
263{
264 int retval;
265 u8 rtccal = 0;
266
267 /*
268 * Check that the calibration value (which is in units of 0.5
269 * parts-per-million) is in the AB8500's range for RtcCalibration
270 * register. -128 (0x80) is not permitted because the AB8500 uses
271 * a sign-bit rather than two's complement, so 0x80 is just another
272 * representation of zero.
273 */
274 if ((calibration < -127) || (calibration > 127)) {
275 dev_err(dev, "RtcCalibration value outside permitted range\n");
276 return -EINVAL;
277 }
278
279 /*
280 * The AB8500 uses sign (in bit7) and magnitude (in bits0-7)
281 * so need to convert to this sort of representation before writing
282 * into RtcCalibration register...
283 */
284 if (calibration >= 0)
285 rtccal = 0x7F & calibration;
286 else
287 rtccal = ~(calibration - 1) | 0x80;
288
289 retval = abx500_set_register_interruptible(dev, AB8500_RTC,
290 AB8500_RTC_CALIB_REG, rtccal);
291
292 return retval;
293}
294
295static int ab8500_rtc_get_calibration(struct device *dev, int *calibration)
296{
297 int retval;
298 u8 rtccal = 0;
299
300 retval = abx500_get_register_interruptible(dev, AB8500_RTC,
301 AB8500_RTC_CALIB_REG, &rtccal);
302 if (retval >= 0) {
303 /*
304 * The AB8500 uses sign (in bit7) and magnitude (in bits0-7)
305 * so need to convert value from RtcCalibration register into
306 * a two's complement signed value...
307 */
308 if (rtccal & 0x80)
309 *calibration = 0 - (rtccal & 0x7F);
310 else
311 *calibration = 0x7F & rtccal;
312 }
313
314 return retval;
315}
316
317static ssize_t ab8500_sysfs_store_rtc_calibration(struct device *dev,
318 struct device_attribute *attr,
319 const char *buf, size_t count)
320{
321 int retval;
322 int calibration = 0;
323
324 if (sscanf(buf, " %i ", &calibration) != 1) {
325 dev_err(dev, "Failed to store RTC calibration attribute\n");
326 return -EINVAL;
327 }
328
329 retval = ab8500_rtc_set_calibration(dev, calibration);
330
331 return retval ? retval : count;
332}
333
334static ssize_t ab8500_sysfs_show_rtc_calibration(struct device *dev,
335 struct device_attribute *attr, char *buf)
336{
337 int retval = 0;
338 int calibration = 0;
339
340 retval = ab8500_rtc_get_calibration(dev, &calibration);
341 if (retval < 0) {
342 dev_err(dev, "Failed to read RTC calibration attribute\n");
343 sprintf(buf, "0\n");
344 return retval;
345 }
346
347 return sprintf(buf, "%d\n", calibration);
348}
349
350static DEVICE_ATTR(rtc_calibration, S_IRUGO | S_IWUSR,
351 ab8500_sysfs_show_rtc_calibration,
352 ab8500_sysfs_store_rtc_calibration);
353
354static int ab8500_sysfs_rtc_register(struct device *dev)
355{
356 return device_create_file(dev, &dev_attr_rtc_calibration);
357}
358
359static void ab8500_sysfs_rtc_unregister(struct device *dev)
360{
361 device_remove_file(dev, &dev_attr_rtc_calibration);
362}
363
261static irqreturn_t rtc_alarm_handler(int irq, void *data) 364static irqreturn_t rtc_alarm_handler(int irq, void *data)
262{ 365{
263 struct rtc_device *rtc = data; 366 struct rtc_device *rtc = data;
@@ -295,7 +398,7 @@ static int __devinit ab8500_rtc_probe(struct platform_device *pdev)
295 return err; 398 return err;
296 399
297 /* Wait for reset by the PorRtc */ 400 /* Wait for reset by the PorRtc */
298 msleep(1); 401 usleep_range(1000, 5000);
299 402
300 err = abx500_get_register_interruptible(&pdev->dev, AB8500_RTC, 403 err = abx500_get_register_interruptible(&pdev->dev, AB8500_RTC,
301 AB8500_RTC_STAT_REG, &rtc_ctrl); 404 AB8500_RTC_STAT_REG, &rtc_ctrl);
@@ -308,6 +411,8 @@ static int __devinit ab8500_rtc_probe(struct platform_device *pdev)
308 return -ENODEV; 411 return -ENODEV;
309 } 412 }
310 413
414 device_init_wakeup(&pdev->dev, true);
415
311 rtc = rtc_device_register("ab8500-rtc", &pdev->dev, &ab8500_rtc_ops, 416 rtc = rtc_device_register("ab8500-rtc", &pdev->dev, &ab8500_rtc_ops,
312 THIS_MODULE); 417 THIS_MODULE);
313 if (IS_ERR(rtc)) { 418 if (IS_ERR(rtc)) {
@@ -316,8 +421,8 @@ static int __devinit ab8500_rtc_probe(struct platform_device *pdev)
316 return err; 421 return err;
317 } 422 }
318 423
319 err = request_threaded_irq(irq, NULL, rtc_alarm_handler, 0, 424 err = request_threaded_irq(irq, NULL, rtc_alarm_handler,
320 "ab8500-rtc", rtc); 425 IRQF_NO_SUSPEND, "ab8500-rtc", rtc);
321 if (err < 0) { 426 if (err < 0) {
322 rtc_device_unregister(rtc); 427 rtc_device_unregister(rtc);
323 return err; 428 return err;
@@ -325,6 +430,13 @@ static int __devinit ab8500_rtc_probe(struct platform_device *pdev)
325 430
326 platform_set_drvdata(pdev, rtc); 431 platform_set_drvdata(pdev, rtc);
327 432
433
434 err = ab8500_sysfs_rtc_register(&pdev->dev);
435 if (err) {
436 dev_err(&pdev->dev, "sysfs RTC failed to register\n");
437 return err;
438 }
439
328 return 0; 440 return 0;
329} 441}
330 442
@@ -333,6 +445,8 @@ static int __devexit ab8500_rtc_remove(struct platform_device *pdev)
333 struct rtc_device *rtc = platform_get_drvdata(pdev); 445 struct rtc_device *rtc = platform_get_drvdata(pdev);
334 int irq = platform_get_irq_byname(pdev, "ALARM"); 446 int irq = platform_get_irq_byname(pdev, "ALARM");
335 447
448 ab8500_sysfs_rtc_unregister(&pdev->dev);
449
336 free_irq(irq, rtc); 450 free_irq(irq, rtc);
337 rtc_device_unregister(rtc); 451 rtc_device_unregister(rtc);
338 platform_set_drvdata(pdev, NULL); 452 platform_set_drvdata(pdev, NULL);
@@ -349,18 +463,8 @@ static struct platform_driver ab8500_rtc_driver = {
349 .remove = __devexit_p(ab8500_rtc_remove), 463 .remove = __devexit_p(ab8500_rtc_remove),
350}; 464};
351 465
352static int __init ab8500_rtc_init(void) 466module_platform_driver(ab8500_rtc_driver);
353{
354 return platform_driver_register(&ab8500_rtc_driver);
355}
356
357static void __exit ab8500_rtc_exit(void)
358{
359 platform_driver_unregister(&ab8500_rtc_driver);
360}
361 467
362module_init(ab8500_rtc_init);
363module_exit(ab8500_rtc_exit);
364MODULE_AUTHOR("Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>"); 468MODULE_AUTHOR("Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>");
365MODULE_DESCRIPTION("AB8500 RTC Driver"); 469MODULE_DESCRIPTION("AB8500 RTC Driver");
366MODULE_LICENSE("GPL v2"); 470MODULE_LICENSE("GPL v2");
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index 90d866272c8e..abfc1a0c07d9 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -456,18 +456,7 @@ static struct platform_driver bfin_rtc_driver = {
456 .resume = bfin_rtc_resume, 456 .resume = bfin_rtc_resume,
457}; 457};
458 458
459static int __init bfin_rtc_init(void) 459module_platform_driver(bfin_rtc_driver);
460{
461 return platform_driver_register(&bfin_rtc_driver);
462}
463
464static void __exit bfin_rtc_exit(void)
465{
466 platform_driver_unregister(&bfin_rtc_driver);
467}
468
469module_init(bfin_rtc_init);
470module_exit(bfin_rtc_exit);
471 460
472MODULE_DESCRIPTION("Blackfin On-Chip Real Time Clock Driver"); 461MODULE_DESCRIPTION("Blackfin On-Chip Real Time Clock Driver");
473MODULE_AUTHOR("Mike Frysinger <vapier@gentoo.org>"); 462MODULE_AUTHOR("Mike Frysinger <vapier@gentoo.org>");
diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c
index 128270ce355d..bf612ef22941 100644
--- a/drivers/rtc/rtc-bq4802.c
+++ b/drivers/rtc/rtc-bq4802.c
@@ -218,15 +218,4 @@ static struct platform_driver bq4802_driver = {
218 .remove = __devexit_p(bq4802_remove), 218 .remove = __devexit_p(bq4802_remove),
219}; 219};
220 220
221static int __init bq4802_init(void) 221module_platform_driver(bq4802_driver);
222{
223 return platform_driver_register(&bq4802_driver);
224}
225
226static void __exit bq4802_exit(void)
227{
228 platform_driver_unregister(&bq4802_driver);
229}
230
231module_init(bq4802_init);
232module_exit(bq4802_exit);
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 05beb6c1ca79..d7782aa09943 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -164,7 +164,7 @@ static inline unsigned char cmos_read_bank2(unsigned char addr)
164static inline void cmos_write_bank2(unsigned char val, unsigned char addr) 164static inline void cmos_write_bank2(unsigned char val, unsigned char addr)
165{ 165{
166 outb(addr, RTC_PORT(2)); 166 outb(addr, RTC_PORT(2));
167 outb(val, RTC_PORT(2)); 167 outb(val, RTC_PORT(3));
168} 168}
169 169
170#else 170#else
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c
index 2322c43af201..d4457afcba89 100644
--- a/drivers/rtc/rtc-dm355evm.c
+++ b/drivers/rtc/rtc-dm355evm.c
@@ -161,16 +161,6 @@ static struct platform_driver rtc_dm355evm_driver = {
161 }, 161 },
162}; 162};
163 163
164static int __init dm355evm_rtc_init(void) 164module_platform_driver(rtc_dm355evm_driver);
165{
166 return platform_driver_register(&rtc_dm355evm_driver);
167}
168module_init(dm355evm_rtc_init);
169
170static void __exit dm355evm_rtc_exit(void)
171{
172 platform_driver_unregister(&rtc_dm355evm_driver);
173}
174module_exit(dm355evm_rtc_exit);
175 165
176MODULE_LICENSE("GPL"); 166MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c
index 68e6caf25496..990c3ff489bf 100644
--- a/drivers/rtc/rtc-ds1286.c
+++ b/drivers/rtc/rtc-ds1286.c
@@ -396,21 +396,10 @@ static struct platform_driver ds1286_platform_driver = {
396 .remove = __devexit_p(ds1286_remove), 396 .remove = __devexit_p(ds1286_remove),
397}; 397};
398 398
399static int __init ds1286_init(void) 399module_platform_driver(ds1286_platform_driver);
400{
401 return platform_driver_register(&ds1286_platform_driver);
402}
403
404static void __exit ds1286_exit(void)
405{
406 platform_driver_unregister(&ds1286_platform_driver);
407}
408 400
409MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>"); 401MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>");
410MODULE_DESCRIPTION("DS1286 RTC driver"); 402MODULE_DESCRIPTION("DS1286 RTC driver");
411MODULE_LICENSE("GPL"); 403MODULE_LICENSE("GPL");
412MODULE_VERSION(DRV_VERSION); 404MODULE_VERSION(DRV_VERSION);
413MODULE_ALIAS("platform:rtc-ds1286"); 405MODULE_ALIAS("platform:rtc-ds1286");
414
415module_init(ds1286_init);
416module_exit(ds1286_exit);
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index 586c244a05d8..761f36bc83a9 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -580,20 +580,7 @@ static struct platform_driver ds1511_rtc_driver = {
580 }, 580 },
581}; 581};
582 582
583 static int __init 583module_platform_driver(ds1511_rtc_driver);
584ds1511_rtc_init(void)
585{
586 return platform_driver_register(&ds1511_rtc_driver);
587}
588
589 static void __exit
590ds1511_rtc_exit(void)
591{
592 platform_driver_unregister(&ds1511_rtc_driver);
593}
594
595module_init(ds1511_rtc_init);
596module_exit(ds1511_rtc_exit);
597 584
598MODULE_AUTHOR("Andrew Sharp <andy.sharp@lsi.com>"); 585MODULE_AUTHOR("Andrew Sharp <andy.sharp@lsi.com>");
599MODULE_DESCRIPTION("Dallas DS1511 RTC driver"); 586MODULE_DESCRIPTION("Dallas DS1511 RTC driver");
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index 1350029044e6..6f0a1b530f2e 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -361,18 +361,7 @@ static struct platform_driver ds1553_rtc_driver = {
361 }, 361 },
362}; 362};
363 363
364static __init int ds1553_init(void) 364module_platform_driver(ds1553_rtc_driver);
365{
366 return platform_driver_register(&ds1553_rtc_driver);
367}
368
369static __exit void ds1553_exit(void)
370{
371 platform_driver_unregister(&ds1553_rtc_driver);
372}
373
374module_init(ds1553_init);
375module_exit(ds1553_exit);
376 365
377MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); 366MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
378MODULE_DESCRIPTION("Dallas DS1553 RTC driver"); 367MODULE_DESCRIPTION("Dallas DS1553 RTC driver");
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index e3e0f92b60f0..76112667c507 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -240,18 +240,7 @@ static struct platform_driver ds1742_rtc_driver = {
240 }, 240 },
241}; 241};
242 242
243static __init int ds1742_init(void) 243module_platform_driver(ds1742_rtc_driver);
244{
245 return platform_driver_register(&ds1742_rtc_driver);
246}
247
248static __exit void ds1742_exit(void)
249{
250 platform_driver_unregister(&ds1742_rtc_driver);
251}
252
253module_init(ds1742_init);
254module_exit(ds1742_exit);
255 244
256MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); 245MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
257MODULE_DESCRIPTION("Dallas DS1742 RTC driver"); 246MODULE_DESCRIPTION("Dallas DS1742 RTC driver");
diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index b6473631d182..05ab227eeff7 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -345,7 +345,7 @@ static const struct dev_pm_ops jz4740_pm_ops = {
345#define JZ4740_RTC_PM_OPS NULL 345#define JZ4740_RTC_PM_OPS NULL
346#endif /* CONFIG_PM */ 346#endif /* CONFIG_PM */
347 347
348struct platform_driver jz4740_rtc_driver = { 348static struct platform_driver jz4740_rtc_driver = {
349 .probe = jz4740_rtc_probe, 349 .probe = jz4740_rtc_probe,
350 .remove = __devexit_p(jz4740_rtc_remove), 350 .remove = __devexit_p(jz4740_rtc_remove),
351 .driver = { 351 .driver = {
@@ -355,17 +355,7 @@ struct platform_driver jz4740_rtc_driver = {
355 }, 355 },
356}; 356};
357 357
358static int __init jz4740_rtc_init(void) 358module_platform_driver(jz4740_rtc_driver);
359{
360 return platform_driver_register(&jz4740_rtc_driver);
361}
362module_init(jz4740_rtc_init);
363
364static void __exit jz4740_rtc_exit(void)
365{
366 platform_driver_unregister(&jz4740_rtc_driver);
367}
368module_exit(jz4740_rtc_exit);
369 359
370MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 360MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
371MODULE_LICENSE("GPL"); 361MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c
index ae16250c762f..ecc1713b2b4f 100644
--- a/drivers/rtc/rtc-lpc32xx.c
+++ b/drivers/rtc/rtc-lpc32xx.c
@@ -396,17 +396,7 @@ static struct platform_driver lpc32xx_rtc_driver = {
396 }, 396 },
397}; 397};
398 398
399static int __init lpc32xx_rtc_init(void) 399module_platform_driver(lpc32xx_rtc_driver);
400{
401 return platform_driver_register(&lpc32xx_rtc_driver);
402}
403module_init(lpc32xx_rtc_init);
404
405static void __exit lpc32xx_rtc_exit(void)
406{
407 platform_driver_unregister(&lpc32xx_rtc_driver);
408}
409module_exit(lpc32xx_rtc_exit);
410 400
411MODULE_AUTHOR("Kevin Wells <wellsk40@gmail.com"); 401MODULE_AUTHOR("Kevin Wells <wellsk40@gmail.com");
412MODULE_DESCRIPTION("RTC driver for the LPC32xx SoC"); 402MODULE_DESCRIPTION("RTC driver for the LPC32xx SoC");
diff --git a/drivers/rtc/rtc-m41t93.c b/drivers/rtc/rtc-m41t93.c
index 7317d3b9a3d5..ef71132ff205 100644
--- a/drivers/rtc/rtc-m41t93.c
+++ b/drivers/rtc/rtc-m41t93.c
@@ -200,7 +200,6 @@ static int __devexit m41t93_remove(struct spi_device *spi)
200static struct spi_driver m41t93_driver = { 200static struct spi_driver m41t93_driver = {
201 .driver = { 201 .driver = {
202 .name = "rtc-m41t93", 202 .name = "rtc-m41t93",
203 .bus = &spi_bus_type,
204 .owner = THIS_MODULE, 203 .owner = THIS_MODULE,
205 }, 204 },
206 .probe = m41t93_probe, 205 .probe = m41t93_probe,
diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c
index e259ed76ae85..2a4721f61797 100644
--- a/drivers/rtc/rtc-m41t94.c
+++ b/drivers/rtc/rtc-m41t94.c
@@ -147,7 +147,6 @@ static int __devexit m41t94_remove(struct spi_device *spi)
147static struct spi_driver m41t94_driver = { 147static struct spi_driver m41t94_driver = {
148 .driver = { 148 .driver = {
149 .name = "rtc-m41t94", 149 .name = "rtc-m41t94",
150 .bus = &spi_bus_type,
151 .owner = THIS_MODULE, 150 .owner = THIS_MODULE,
152 }, 151 },
153 .probe = m41t94_probe, 152 .probe = m41t94_probe,
diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c
index 8e2a24e33ed6..f9e3b3583733 100644
--- a/drivers/rtc/rtc-m48t35.c
+++ b/drivers/rtc/rtc-m48t35.c
@@ -216,21 +216,10 @@ static struct platform_driver m48t35_platform_driver = {
216 .remove = __devexit_p(m48t35_remove), 216 .remove = __devexit_p(m48t35_remove),
217}; 217};
218 218
219static int __init m48t35_init(void) 219module_platform_driver(m48t35_platform_driver);
220{
221 return platform_driver_register(&m48t35_platform_driver);
222}
223
224static void __exit m48t35_exit(void)
225{
226 platform_driver_unregister(&m48t35_platform_driver);
227}
228 220
229MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>"); 221MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>");
230MODULE_DESCRIPTION("M48T35 RTC driver"); 222MODULE_DESCRIPTION("M48T35 RTC driver");
231MODULE_LICENSE("GPL"); 223MODULE_LICENSE("GPL");
232MODULE_VERSION(DRV_VERSION); 224MODULE_VERSION(DRV_VERSION);
233MODULE_ALIAS("platform:rtc-m48t35"); 225MODULE_ALIAS("platform:rtc-m48t35");
234
235module_init(m48t35_init);
236module_exit(m48t35_exit);
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index 28365388fb6c..30ebfec9fd2b 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -530,18 +530,7 @@ static struct platform_driver m48t59_rtc_driver = {
530 .remove = __devexit_p(m48t59_rtc_remove), 530 .remove = __devexit_p(m48t59_rtc_remove),
531}; 531};
532 532
533static int __init m48t59_rtc_init(void) 533module_platform_driver(m48t59_rtc_driver);
534{
535 return platform_driver_register(&m48t59_rtc_driver);
536}
537
538static void __exit m48t59_rtc_exit(void)
539{
540 platform_driver_unregister(&m48t59_rtc_driver);
541}
542
543module_init(m48t59_rtc_init);
544module_exit(m48t59_rtc_exit);
545 534
546MODULE_AUTHOR("Mark Zhan <rongkai.zhan@windriver.com>"); 535MODULE_AUTHOR("Mark Zhan <rongkai.zhan@windriver.com>");
547MODULE_DESCRIPTION("M48T59/M48T02/M48T08 RTC driver"); 536MODULE_DESCRIPTION("M48T59/M48T02/M48T08 RTC driver");
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c
index f981287d582b..863fb3363aa6 100644
--- a/drivers/rtc/rtc-m48t86.c
+++ b/drivers/rtc/rtc-m48t86.c
@@ -185,21 +185,10 @@ static struct platform_driver m48t86_rtc_platform_driver = {
185 .remove = __devexit_p(m48t86_rtc_remove), 185 .remove = __devexit_p(m48t86_rtc_remove),
186}; 186};
187 187
188static int __init m48t86_rtc_init(void) 188module_platform_driver(m48t86_rtc_platform_driver);
189{
190 return platform_driver_register(&m48t86_rtc_platform_driver);
191}
192
193static void __exit m48t86_rtc_exit(void)
194{
195 platform_driver_unregister(&m48t86_rtc_platform_driver);
196}
197 189
198MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 190MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
199MODULE_DESCRIPTION("M48T86 RTC driver"); 191MODULE_DESCRIPTION("M48T86 RTC driver");
200MODULE_LICENSE("GPL"); 192MODULE_LICENSE("GPL");
201MODULE_VERSION(DRV_VERSION); 193MODULE_VERSION(DRV_VERSION);
202MODULE_ALIAS("platform:rtc-m48t86"); 194MODULE_ALIAS("platform:rtc-m48t86");
203
204module_init(m48t86_rtc_init);
205module_exit(m48t86_rtc_exit);
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c
index 0ec3f588a255..1f6b3cc58e8a 100644
--- a/drivers/rtc/rtc-max6902.c
+++ b/drivers/rtc/rtc-max6902.c
@@ -154,7 +154,6 @@ static int __devexit max6902_remove(struct spi_device *spi)
154static struct spi_driver max6902_driver = { 154static struct spi_driver max6902_driver = {
155 .driver = { 155 .driver = {
156 .name = "rtc-max6902", 156 .name = "rtc-max6902",
157 .bus = &spi_bus_type,
158 .owner = THIS_MODULE, 157 .owner = THIS_MODULE,
159 }, 158 },
160 .probe = max6902_probe, 159 .probe = max6902_probe,
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
index 3bc046f427e0..4a5529346b47 100644
--- a/drivers/rtc/rtc-max8925.c
+++ b/drivers/rtc/rtc-max8925.c
@@ -299,17 +299,7 @@ static struct platform_driver max8925_rtc_driver = {
299 .remove = __devexit_p(max8925_rtc_remove), 299 .remove = __devexit_p(max8925_rtc_remove),
300}; 300};
301 301
302static int __init max8925_rtc_init(void) 302module_platform_driver(max8925_rtc_driver);
303{
304 return platform_driver_register(&max8925_rtc_driver);
305}
306module_init(max8925_rtc_init);
307
308static void __exit max8925_rtc_exit(void)
309{
310 platform_driver_unregister(&max8925_rtc_driver);
311}
312module_exit(max8925_rtc_exit);
313 303
314MODULE_DESCRIPTION("Maxim MAX8925 RTC driver"); 304MODULE_DESCRIPTION("Maxim MAX8925 RTC driver");
315MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); 305MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
diff --git a/drivers/rtc/rtc-max8998.c b/drivers/rtc/rtc-max8998.c
index 2e48aa604273..7196f438c089 100644
--- a/drivers/rtc/rtc-max8998.c
+++ b/drivers/rtc/rtc-max8998.c
@@ -327,17 +327,7 @@ static struct platform_driver max8998_rtc_driver = {
327 .id_table = max8998_rtc_id, 327 .id_table = max8998_rtc_id,
328}; 328};
329 329
330static int __init max8998_rtc_init(void) 330module_platform_driver(max8998_rtc_driver);
331{
332 return platform_driver_register(&max8998_rtc_driver);
333}
334module_init(max8998_rtc_init);
335
336static void __exit max8998_rtc_exit(void)
337{
338 platform_driver_unregister(&max8998_rtc_driver);
339}
340module_exit(max8998_rtc_exit);
341 331
342MODULE_AUTHOR("Minkyu Kang <mk7.kang@samsung.com>"); 332MODULE_AUTHOR("Minkyu Kang <mk7.kang@samsung.com>");
343MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); 333MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
index 9d0c3b478d55..546f6850bffb 100644
--- a/drivers/rtc/rtc-mc13xxx.c
+++ b/drivers/rtc/rtc-mc13xxx.c
@@ -399,7 +399,7 @@ static int __exit mc13xxx_rtc_remove(struct platform_device *pdev)
399 return 0; 399 return 0;
400} 400}
401 401
402const struct platform_device_id mc13xxx_rtc_idtable[] = { 402static const struct platform_device_id mc13xxx_rtc_idtable[] = {
403 { 403 {
404 .name = "mc13783-rtc", 404 .name = "mc13783-rtc",
405 }, { 405 }, {
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index da60915818b6..9d3caccfc250 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -418,17 +418,7 @@ static struct platform_driver mpc5121_rtc_driver = {
418 .remove = __devexit_p(mpc5121_rtc_remove), 418 .remove = __devexit_p(mpc5121_rtc_remove),
419}; 419};
420 420
421static int __init mpc5121_rtc_init(void) 421module_platform_driver(mpc5121_rtc_driver);
422{
423 return platform_driver_register(&mpc5121_rtc_driver);
424}
425module_init(mpc5121_rtc_init);
426
427static void __exit mpc5121_rtc_exit(void)
428{
429 platform_driver_unregister(&mpc5121_rtc_driver);
430}
431module_exit(mpc5121_rtc_exit);
432 422
433MODULE_LICENSE("GPL"); 423MODULE_LICENSE("GPL");
434MODULE_AUTHOR("John Rigby <jcrigby@gmail.com>"); 424MODULE_AUTHOR("John Rigby <jcrigby@gmail.com>");
diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c
index bb21f443fb70..6cd6c7235344 100644
--- a/drivers/rtc/rtc-mrst.c
+++ b/drivers/rtc/rtc-mrst.c
@@ -537,18 +537,7 @@ static struct platform_driver vrtc_mrst_platform_driver = {
537 } 537 }
538}; 538};
539 539
540static int __init vrtc_mrst_init(void) 540module_platform_driver(vrtc_mrst_platform_driver);
541{
542 return platform_driver_register(&vrtc_mrst_platform_driver);
543}
544
545static void __exit vrtc_mrst_exit(void)
546{
547 platform_driver_unregister(&vrtc_mrst_platform_driver);
548}
549
550module_init(vrtc_mrst_init);
551module_exit(vrtc_mrst_exit);
552 541
553MODULE_AUTHOR("Jacob Pan; Feng Tang"); 542MODULE_AUTHOR("Jacob Pan; Feng Tang");
554MODULE_DESCRIPTION("Driver for Moorestown virtual RTC"); 543MODULE_DESCRIPTION("Driver for Moorestown virtual RTC");
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 39e41fbdf08b..5e1d64ee5228 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -155,7 +155,6 @@ static int rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
155{ 155{
156 struct rtc_time alarm_tm, now_tm; 156 struct rtc_time alarm_tm, now_tm;
157 unsigned long now, time; 157 unsigned long now, time;
158 int ret;
159 struct platform_device *pdev = to_platform_device(dev); 158 struct platform_device *pdev = to_platform_device(dev);
160 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 159 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
161 void __iomem *ioaddr = pdata->ioaddr; 160 void __iomem *ioaddr = pdata->ioaddr;
@@ -168,21 +167,33 @@ static int rtc_update_alarm(struct device *dev, struct rtc_time *alrm)
168 alarm_tm.tm_hour = alrm->tm_hour; 167 alarm_tm.tm_hour = alrm->tm_hour;
169 alarm_tm.tm_min = alrm->tm_min; 168 alarm_tm.tm_min = alrm->tm_min;
170 alarm_tm.tm_sec = alrm->tm_sec; 169 alarm_tm.tm_sec = alrm->tm_sec;
171 rtc_tm_to_time(&now_tm, &now);
172 rtc_tm_to_time(&alarm_tm, &time); 170 rtc_tm_to_time(&alarm_tm, &time);
173 171
174 if (time < now) {
175 time += 60 * 60 * 24;
176 rtc_time_to_tm(time, &alarm_tm);
177 }
178
179 ret = rtc_tm_to_time(&alarm_tm, &time);
180
181 /* clear all the interrupt status bits */ 172 /* clear all the interrupt status bits */
182 writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR); 173 writew(readw(ioaddr + RTC_RTCISR), ioaddr + RTC_RTCISR);
183 set_alarm_or_time(dev, MXC_RTC_ALARM, time); 174 set_alarm_or_time(dev, MXC_RTC_ALARM, time);
184 175
185 return ret; 176 return 0;
177}
178
179static void mxc_rtc_irq_enable(struct device *dev, unsigned int bit,
180 unsigned int enabled)
181{
182 struct platform_device *pdev = to_platform_device(dev);
183 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
184 void __iomem *ioaddr = pdata->ioaddr;
185 u32 reg;
186
187 spin_lock_irq(&pdata->rtc->irq_lock);
188 reg = readw(ioaddr + RTC_RTCIENR);
189
190 if (enabled)
191 reg |= bit;
192 else
193 reg &= ~bit;
194
195 writew(reg, ioaddr + RTC_RTCIENR);
196 spin_unlock_irq(&pdata->rtc->irq_lock);
186} 197}
187 198
188/* This function is the RTC interrupt service routine. */ 199/* This function is the RTC interrupt service routine. */
@@ -199,13 +210,12 @@ static irqreturn_t mxc_rtc_interrupt(int irq, void *dev_id)
199 /* clear interrupt sources */ 210 /* clear interrupt sources */
200 writew(status, ioaddr + RTC_RTCISR); 211 writew(status, ioaddr + RTC_RTCISR);
201 212
202 /* clear alarm interrupt if it has occurred */
203 if (status & RTC_ALM_BIT)
204 status &= ~RTC_ALM_BIT;
205
206 /* update irq data & counter */ 213 /* update irq data & counter */
207 if (status & RTC_ALM_BIT) 214 if (status & RTC_ALM_BIT) {
208 events |= (RTC_AF | RTC_IRQF); 215 events |= (RTC_AF | RTC_IRQF);
216 /* RTC alarm should be one-shot */
217 mxc_rtc_irq_enable(&pdev->dev, RTC_ALM_BIT, 0);
218 }
209 219
210 if (status & RTC_1HZ_BIT) 220 if (status & RTC_1HZ_BIT)
211 events |= (RTC_UF | RTC_IRQF); 221 events |= (RTC_UF | RTC_IRQF);
@@ -213,9 +223,6 @@ static irqreturn_t mxc_rtc_interrupt(int irq, void *dev_id)
213 if (status & PIT_ALL_ON) 223 if (status & PIT_ALL_ON)
214 events |= (RTC_PF | RTC_IRQF); 224 events |= (RTC_PF | RTC_IRQF);
215 225
216 if ((status & RTC_ALM_BIT) && rtc_valid_tm(&pdata->g_rtc_alarm))
217 rtc_update_alarm(&pdev->dev, &pdata->g_rtc_alarm);
218
219 rtc_update_irq(pdata->rtc, 1, events); 226 rtc_update_irq(pdata->rtc, 1, events);
220 spin_unlock_irq(&pdata->rtc->irq_lock); 227 spin_unlock_irq(&pdata->rtc->irq_lock);
221 228
@@ -242,26 +249,6 @@ static void mxc_rtc_release(struct device *dev)
242 spin_unlock_irq(&pdata->rtc->irq_lock); 249 spin_unlock_irq(&pdata->rtc->irq_lock);
243} 250}
244 251
245static void mxc_rtc_irq_enable(struct device *dev, unsigned int bit,
246 unsigned int enabled)
247{
248 struct platform_device *pdev = to_platform_device(dev);
249 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
250 void __iomem *ioaddr = pdata->ioaddr;
251 u32 reg;
252
253 spin_lock_irq(&pdata->rtc->irq_lock);
254 reg = readw(ioaddr + RTC_RTCIENR);
255
256 if (enabled)
257 reg |= bit;
258 else
259 reg &= ~bit;
260
261 writew(reg, ioaddr + RTC_RTCIENR);
262 spin_unlock_irq(&pdata->rtc->irq_lock);
263}
264
265static int mxc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) 252static int mxc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
266{ 253{
267 mxc_rtc_irq_enable(dev, RTC_ALM_BIT, enabled); 254 mxc_rtc_irq_enable(dev, RTC_ALM_BIT, enabled);
@@ -290,6 +277,17 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
290 */ 277 */
291static int mxc_rtc_set_mmss(struct device *dev, unsigned long time) 278static int mxc_rtc_set_mmss(struct device *dev, unsigned long time)
292{ 279{
280 /*
281 * TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only
282 */
283 if (cpu_is_mx1()) {
284 struct rtc_time tm;
285
286 rtc_time_to_tm(time, &tm);
287 tm.tm_year = 70;
288 rtc_tm_to_time(&tm, &time);
289 }
290
293 /* Avoid roll-over from reading the different registers */ 291 /* Avoid roll-over from reading the different registers */
294 do { 292 do {
295 set_alarm_or_time(dev, MXC_RTC_TIME, time); 293 set_alarm_or_time(dev, MXC_RTC_TIME, time);
@@ -324,21 +322,7 @@ static int mxc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
324 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 322 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
325 int ret; 323 int ret;
326 324
327 if (rtc_valid_tm(&alrm->time)) { 325 ret = rtc_update_alarm(dev, &alrm->time);
328 if (alrm->time.tm_sec > 59 ||
329 alrm->time.tm_hour > 23 ||
330 alrm->time.tm_min > 59)
331 return -EINVAL;
332
333 ret = rtc_update_alarm(dev, &alrm->time);
334 } else {
335 ret = rtc_valid_tm(&alrm->time);
336 if (ret)
337 return ret;
338
339 ret = rtc_update_alarm(dev, &alrm->time);
340 }
341
342 if (ret) 326 if (ret)
343 return ret; 327 return ret;
344 328
@@ -424,6 +408,9 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
424 pdata->irq = -1; 408 pdata->irq = -1;
425 } 409 }
426 410
411 if (pdata->irq >=0)
412 device_init_wakeup(&pdev->dev, 1);
413
427 rtc = rtc_device_register(pdev->name, &pdev->dev, &mxc_rtc_ops, 414 rtc = rtc_device_register(pdev->name, &pdev->dev, &mxc_rtc_ops,
428 THIS_MODULE); 415 THIS_MODULE);
429 if (IS_ERR(rtc)) { 416 if (IS_ERR(rtc)) {
@@ -459,9 +446,39 @@ static int __exit mxc_rtc_remove(struct platform_device *pdev)
459 return 0; 446 return 0;
460} 447}
461 448
449#ifdef CONFIG_PM
450static int mxc_rtc_suspend(struct device *dev)
451{
452 struct rtc_plat_data *pdata = dev_get_drvdata(dev);
453
454 if (device_may_wakeup(dev))
455 enable_irq_wake(pdata->irq);
456
457 return 0;
458}
459
460static int mxc_rtc_resume(struct device *dev)
461{
462 struct rtc_plat_data *pdata = dev_get_drvdata(dev);
463
464 if (device_may_wakeup(dev))
465 disable_irq_wake(pdata->irq);
466
467 return 0;
468}
469
470static struct dev_pm_ops mxc_rtc_pm_ops = {
471 .suspend = mxc_rtc_suspend,
472 .resume = mxc_rtc_resume,
473};
474#endif
475
462static struct platform_driver mxc_rtc_driver = { 476static struct platform_driver mxc_rtc_driver = {
463 .driver = { 477 .driver = {
464 .name = "mxc_rtc", 478 .name = "mxc_rtc",
479#ifdef CONFIG_PM
480 .pm = &mxc_rtc_pm_ops,
481#endif
465 .owner = THIS_MODULE, 482 .owner = THIS_MODULE,
466 }, 483 },
467 .remove = __exit_p(mxc_rtc_remove), 484 .remove = __exit_p(mxc_rtc_remove),
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index 2ee3bbf7e5ea..b46c4004d8fe 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -340,7 +340,6 @@ static int __devexit pcf2123_remove(struct spi_device *spi)
340static struct spi_driver pcf2123_driver = { 340static struct spi_driver pcf2123_driver = {
341 .driver = { 341 .driver = {
342 .name = "rtc-pcf2123", 342 .name = "rtc-pcf2123",
343 .bus = &spi_bus_type,
344 .owner = THIS_MODULE, 343 .owner = THIS_MODULE,
345 }, 344 },
346 .probe = pcf2123_probe, 345 .probe = pcf2123_probe,
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c
index 0c423892923c..a20202f9ee57 100644
--- a/drivers/rtc/rtc-pcf50633.c
+++ b/drivers/rtc/rtc-pcf50633.c
@@ -294,17 +294,7 @@ static struct platform_driver pcf50633_rtc_driver = {
294 .remove = __devexit_p(pcf50633_rtc_remove), 294 .remove = __devexit_p(pcf50633_rtc_remove),
295}; 295};
296 296
297static int __init pcf50633_rtc_init(void) 297module_platform_driver(pcf50633_rtc_driver);
298{
299 return platform_driver_register(&pcf50633_rtc_driver);
300}
301module_init(pcf50633_rtc_init);
302
303static void __exit pcf50633_rtc_exit(void)
304{
305 platform_driver_unregister(&pcf50633_rtc_driver);
306}
307module_exit(pcf50633_rtc_exit);
308 298
309MODULE_DESCRIPTION("PCF50633 RTC driver"); 299MODULE_DESCRIPTION("PCF50633 RTC driver");
310MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>"); 300MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index d420e9d877e8..9f1d6bcbdf6c 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -532,17 +532,7 @@ static struct platform_driver pm8xxx_rtc_driver = {
532 }, 532 },
533}; 533};
534 534
535static int __init pm8xxx_rtc_init(void) 535module_platform_driver(pm8xxx_rtc_driver);
536{
537 return platform_driver_register(&pm8xxx_rtc_driver);
538}
539module_init(pm8xxx_rtc_init);
540
541static void __exit pm8xxx_rtc_exit(void)
542{
543 platform_driver_unregister(&pm8xxx_rtc_driver);
544}
545module_exit(pm8xxx_rtc_exit);
546 536
547MODULE_ALIAS("platform:rtc-pm8xxx"); 537MODULE_ALIAS("platform:rtc-pm8xxx");
548MODULE_DESCRIPTION("PMIC8xxx RTC driver"); 538MODULE_DESCRIPTION("PMIC8xxx RTC driver");
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
index 971bc8e08da6..ce2ca8523ddd 100644
--- a/drivers/rtc/rtc-rs5c348.c
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -229,7 +229,6 @@ static int __devexit rs5c348_remove(struct spi_device *spi)
229static struct spi_driver rs5c348_driver = { 229static struct spi_driver rs5c348_driver = {
230 .driver = { 230 .driver = {
231 .name = "rtc-rs5c348", 231 .name = "rtc-rs5c348",
232 .bus = &spi_bus_type,
233 .owner = THIS_MODULE, 232 .owner = THIS_MODULE,
234 }, 233 },
235 .probe = rs5c348_probe, 234 .probe = rs5c348_probe,
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 175067a17c46..aef40bd2957b 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -673,21 +673,7 @@ static struct platform_driver s3c_rtc_driver = {
673 }, 673 },
674}; 674};
675 675
676static char __initdata banner[] = "S3C24XX RTC, (c) 2004,2006 Simtec Electronics\n"; 676module_platform_driver(s3c_rtc_driver);
677
678static int __init s3c_rtc_init(void)
679{
680 printk(banner);
681 return platform_driver_register(&s3c_rtc_driver);
682}
683
684static void __exit s3c_rtc_exit(void)
685{
686 platform_driver_unregister(&s3c_rtc_driver);
687}
688
689module_init(s3c_rtc_init);
690module_exit(s3c_rtc_exit);
691 677
692MODULE_DESCRIPTION("Samsung S3C RTC Driver"); 678MODULE_DESCRIPTION("Samsung S3C RTC Driver");
693MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); 679MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index fc1ffe97fca1..4595d3e645a7 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -435,18 +435,7 @@ static struct platform_driver sa1100_rtc_driver = {
435 }, 435 },
436}; 436};
437 437
438static int __init sa1100_rtc_init(void) 438module_platform_driver(sa1100_rtc_driver);
439{
440 return platform_driver_register(&sa1100_rtc_driver);
441}
442
443static void __exit sa1100_rtc_exit(void)
444{
445 platform_driver_unregister(&sa1100_rtc_driver);
446}
447
448module_init(sa1100_rtc_init);
449module_exit(sa1100_rtc_exit);
450 439
451MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); 440MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
452MODULE_DESCRIPTION("SA11x0/PXA2xx Realtime Clock Driver (RTC)"); 441MODULE_DESCRIPTION("SA11x0/PXA2xx Realtime Clock Driver (RTC)");
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index 893bac2bb21b..19a28a671a8e 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -516,17 +516,7 @@ static struct platform_driver spear_rtc_driver = {
516 }, 516 },
517}; 517};
518 518
519static int __init rtc_init(void) 519module_platform_driver(spear_rtc_driver);
520{
521 return platform_driver_register(&spear_rtc_driver);
522}
523module_init(rtc_init);
524
525static void __exit rtc_exit(void)
526{
527 platform_driver_unregister(&spear_rtc_driver);
528}
529module_exit(rtc_exit);
530 520
531MODULE_ALIAS("platform:rtc-spear"); 521MODULE_ALIAS("platform:rtc-spear");
532MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>"); 522MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>");
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index ed3e9b599031..7621116bd20d 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -370,18 +370,7 @@ static struct platform_driver stk17ta8_rtc_driver = {
370 }, 370 },
371}; 371};
372 372
373static __init int stk17ta8_init(void) 373module_platform_driver(stk17ta8_rtc_driver);
374{
375 return platform_driver_register(&stk17ta8_rtc_driver);
376}
377
378static __exit void stk17ta8_exit(void)
379{
380 platform_driver_unregister(&stk17ta8_rtc_driver);
381}
382
383module_init(stk17ta8_init);
384module_exit(stk17ta8_exit);
385 374
386MODULE_AUTHOR("Thomas Hommel <thomas.hommel@ge.com>"); 375MODULE_AUTHOR("Thomas Hommel <thomas.hommel@ge.com>");
387MODULE_DESCRIPTION("Simtek STK17TA8 RTC driver"); 376MODULE_DESCRIPTION("Simtek STK17TA8 RTC driver");
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index 7315068daa59..10287865e330 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -276,18 +276,7 @@ static struct platform_driver stmp3xxx_rtcdrv = {
276 }, 276 },
277}; 277};
278 278
279static int __init stmp3xxx_rtc_init(void) 279module_platform_driver(stmp3xxx_rtcdrv);
280{
281 return platform_driver_register(&stmp3xxx_rtcdrv);
282}
283
284static void __exit stmp3xxx_rtc_exit(void)
285{
286 platform_driver_unregister(&stmp3xxx_rtcdrv);
287}
288
289module_init(stmp3xxx_rtc_init);
290module_exit(stmp3xxx_rtc_exit);
291 280
292MODULE_DESCRIPTION("STMP3xxx RTC Driver"); 281MODULE_DESCRIPTION("STMP3xxx RTC Driver");
293MODULE_AUTHOR("dmitry pervushin <dpervushin@embeddedalley.com> and " 282MODULE_AUTHOR("dmitry pervushin <dpervushin@embeddedalley.com> and "
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 20687d55e7a7..d43b4f6eb4e4 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -550,6 +550,11 @@ static int twl_rtc_resume(struct platform_device *pdev)
550#define twl_rtc_resume NULL 550#define twl_rtc_resume NULL
551#endif 551#endif
552 552
553static const struct of_device_id twl_rtc_of_match[] = {
554 {.compatible = "ti,twl4030-rtc", },
555 { },
556};
557MODULE_DEVICE_TABLE(of, twl_rtc_of_match);
553MODULE_ALIAS("platform:twl_rtc"); 558MODULE_ALIAS("platform:twl_rtc");
554 559
555static struct platform_driver twl4030rtc_driver = { 560static struct platform_driver twl4030rtc_driver = {
@@ -559,8 +564,9 @@ static struct platform_driver twl4030rtc_driver = {
559 .suspend = twl_rtc_suspend, 564 .suspend = twl_rtc_suspend,
560 .resume = twl_rtc_resume, 565 .resume = twl_rtc_resume,
561 .driver = { 566 .driver = {
562 .owner = THIS_MODULE, 567 .owner = THIS_MODULE,
563 .name = "twl_rtc", 568 .name = "twl_rtc",
569 .of_match_table = twl_rtc_of_match,
564 }, 570 },
565}; 571};
566 572
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index f71c3ce18036..bca5d677bc85 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -393,18 +393,7 @@ static struct platform_driver rtc_device_driver = {
393 }, 393 },
394}; 394};
395 395
396static __init int v3020_init(void) 396module_platform_driver(rtc_device_driver);
397{
398 return platform_driver_register(&rtc_device_driver);
399}
400
401static __exit void v3020_exit(void)
402{
403 platform_driver_unregister(&rtc_device_driver);
404}
405
406module_init(v3020_init);
407module_exit(v3020_exit);
408 397
409MODULE_DESCRIPTION("V3020 RTC"); 398MODULE_DESCRIPTION("V3020 RTC");
410MODULE_AUTHOR("Raphael Assenat"); 399MODULE_AUTHOR("Raphael Assenat");
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index c5698cda366a..fcbfdda2993b 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -405,15 +405,4 @@ static struct platform_driver rtc_platform_driver = {
405 }, 405 },
406}; 406};
407 407
408static int __init vr41xx_rtc_init(void) 408module_platform_driver(rtc_platform_driver);
409{
410 return platform_driver_register(&rtc_platform_driver);
411}
412
413static void __exit vr41xx_rtc_exit(void)
414{
415 platform_driver_unregister(&rtc_platform_driver);
416}
417
418module_init(vr41xx_rtc_init);
419module_exit(vr41xx_rtc_exit);
diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
index f93f412423c6..9e94fb147c26 100644
--- a/drivers/rtc/rtc-vt8500.c
+++ b/drivers/rtc/rtc-vt8500.c
@@ -311,17 +311,7 @@ static struct platform_driver vt8500_rtc_driver = {
311 }, 311 },
312}; 312};
313 313
314static int __init vt8500_rtc_init(void) 314module_platform_driver(vt8500_rtc_driver);
315{
316 return platform_driver_register(&vt8500_rtc_driver);
317}
318module_init(vt8500_rtc_init);
319
320static void __exit vt8500_rtc_exit(void)
321{
322 platform_driver_unregister(&vt8500_rtc_driver);
323}
324module_exit(vt8500_rtc_exit);
325 315
326MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com>"); 316MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com>");
327MODULE_DESCRIPTION("VIA VT8500 SoC Realtime Clock Driver (RTC)"); 317MODULE_DESCRIPTION("VIA VT8500 SoC Realtime Clock Driver (RTC)");
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c
index bdc909bd56da..3b6e6a67e765 100644
--- a/drivers/rtc/rtc-wm831x.c
+++ b/drivers/rtc/rtc-wm831x.c
@@ -324,15 +324,6 @@ static irqreturn_t wm831x_alm_irq(int irq, void *data)
324 return IRQ_HANDLED; 324 return IRQ_HANDLED;
325} 325}
326 326
327static irqreturn_t wm831x_per_irq(int irq, void *data)
328{
329 struct wm831x_rtc *wm831x_rtc = data;
330
331 rtc_update_irq(wm831x_rtc->rtc, 1, RTC_IRQF | RTC_UF);
332
333 return IRQ_HANDLED;
334}
335
336static const struct rtc_class_ops wm831x_rtc_ops = { 327static const struct rtc_class_ops wm831x_rtc_ops = {
337 .read_time = wm831x_rtc_readtime, 328 .read_time = wm831x_rtc_readtime,
338 .set_mmss = wm831x_rtc_set_mmss, 329 .set_mmss = wm831x_rtc_set_mmss,
@@ -405,11 +396,10 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
405{ 396{
406 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 397 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
407 struct wm831x_rtc *wm831x_rtc; 398 struct wm831x_rtc *wm831x_rtc;
408 int per_irq = platform_get_irq_byname(pdev, "PER");
409 int alm_irq = platform_get_irq_byname(pdev, "ALM"); 399 int alm_irq = platform_get_irq_byname(pdev, "ALM");
410 int ret = 0; 400 int ret = 0;
411 401
412 wm831x_rtc = kzalloc(sizeof(*wm831x_rtc), GFP_KERNEL); 402 wm831x_rtc = devm_kzalloc(&pdev->dev, sizeof(*wm831x_rtc), GFP_KERNEL);
413 if (wm831x_rtc == NULL) 403 if (wm831x_rtc == NULL)
414 return -ENOMEM; 404 return -ENOMEM;
415 405
@@ -433,14 +423,6 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
433 goto err; 423 goto err;
434 } 424 }
435 425
436 ret = request_threaded_irq(per_irq, NULL, wm831x_per_irq,
437 IRQF_TRIGGER_RISING, "RTC period",
438 wm831x_rtc);
439 if (ret != 0) {
440 dev_err(&pdev->dev, "Failed to request periodic IRQ %d: %d\n",
441 per_irq, ret);
442 }
443
444 ret = request_threaded_irq(alm_irq, NULL, wm831x_alm_irq, 426 ret = request_threaded_irq(alm_irq, NULL, wm831x_alm_irq,
445 IRQF_TRIGGER_RISING, "RTC alarm", 427 IRQF_TRIGGER_RISING, "RTC alarm",
446 wm831x_rtc); 428 wm831x_rtc);
@@ -452,20 +434,16 @@ static int wm831x_rtc_probe(struct platform_device *pdev)
452 return 0; 434 return 0;
453 435
454err: 436err:
455 kfree(wm831x_rtc);
456 return ret; 437 return ret;
457} 438}
458 439
459static int __devexit wm831x_rtc_remove(struct platform_device *pdev) 440static int __devexit wm831x_rtc_remove(struct platform_device *pdev)
460{ 441{
461 struct wm831x_rtc *wm831x_rtc = platform_get_drvdata(pdev); 442 struct wm831x_rtc *wm831x_rtc = platform_get_drvdata(pdev);
462 int per_irq = platform_get_irq_byname(pdev, "PER");
463 int alm_irq = platform_get_irq_byname(pdev, "ALM"); 443 int alm_irq = platform_get_irq_byname(pdev, "ALM");
464 444
465 free_irq(alm_irq, wm831x_rtc); 445 free_irq(alm_irq, wm831x_rtc);
466 free_irq(per_irq, wm831x_rtc);
467 rtc_device_unregister(wm831x_rtc->rtc); 446 rtc_device_unregister(wm831x_rtc->rtc);
468 kfree(wm831x_rtc);
469 447
470 return 0; 448 return 0;
471} 449}
@@ -490,17 +468,7 @@ static struct platform_driver wm831x_rtc_driver = {
490 }, 468 },
491}; 469};
492 470
493static int __init wm831x_rtc_init(void) 471module_platform_driver(wm831x_rtc_driver);
494{
495 return platform_driver_register(&wm831x_rtc_driver);
496}
497module_init(wm831x_rtc_init);
498
499static void __exit wm831x_rtc_exit(void)
500{
501 platform_driver_unregister(&wm831x_rtc_driver);
502}
503module_exit(wm831x_rtc_exit);
504 472
505MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 473MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
506MODULE_DESCRIPTION("RTC driver for the WM831x series PMICs"); 474MODULE_DESCRIPTION("RTC driver for the WM831x series PMICs");
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c
index 66421426e404..c2e52d15abb2 100644
--- a/drivers/rtc/rtc-wm8350.c
+++ b/drivers/rtc/rtc-wm8350.c
@@ -486,17 +486,7 @@ static struct platform_driver wm8350_rtc_driver = {
486 }, 486 },
487}; 487};
488 488
489static int __init wm8350_rtc_init(void) 489module_platform_driver(wm8350_rtc_driver);
490{
491 return platform_driver_register(&wm8350_rtc_driver);
492}
493module_init(wm8350_rtc_init);
494
495static void __exit wm8350_rtc_exit(void)
496{
497 platform_driver_unregister(&wm8350_rtc_driver);
498}
499module_exit(wm8350_rtc_exit);
500 490
501MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 491MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
502MODULE_DESCRIPTION("RTC driver for the WM8350"); 492MODULE_DESCRIPTION("RTC driver for the WM8350");