diff options
Diffstat (limited to 'drivers/rtc')
98 files changed, 1216 insertions, 933 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index b9838130a7b0..9e3498bf302b 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -313,6 +313,15 @@ config RTC_DRV_PALMAS | |||
313 | This driver can also be built as a module. If so, the module | 313 | This driver can also be built as a module. If so, the module |
314 | will be called rtc-palma. | 314 | will be called rtc-palma. |
315 | 315 | ||
316 | config RTC_DRV_PCF2127 | ||
317 | tristate "NXP PCF2127" | ||
318 | help | ||
319 | If you say yes here you get support for the NXP PCF2127/29 RTC | ||
320 | chips. | ||
321 | |||
322 | This driver can also be built as a module. If so, the module | ||
323 | will be called rtc-pcf2127. | ||
324 | |||
316 | config RTC_DRV_PCF8523 | 325 | config RTC_DRV_PCF8523 |
317 | tristate "NXP PCF8523" | 326 | tristate "NXP PCF8523" |
318 | help | 327 | help |
@@ -1233,6 +1242,13 @@ config RTC_DRV_SNVS | |||
1233 | This driver can also be built as a module, if so, the module | 1242 | This driver can also be built as a module, if so, the module |
1234 | will be called "rtc-snvs". | 1243 | will be called "rtc-snvs". |
1235 | 1244 | ||
1245 | config RTC_DRV_SIRFSOC | ||
1246 | tristate "SiRFSOC RTC" | ||
1247 | depends on ARCH_SIRF | ||
1248 | help | ||
1249 | Say "yes" here to support the real time clock on SiRF SOC chips. | ||
1250 | This driver can also be built as a module called rtc-sirfsoc. | ||
1251 | |||
1236 | comment "HID Sensor RTC drivers" | 1252 | comment "HID Sensor RTC drivers" |
1237 | 1253 | ||
1238 | config RTC_DRV_HID_SENSOR_TIME | 1254 | config RTC_DRV_HID_SENSOR_TIME |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index c33f86f1a69b..d3b4488f48f2 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -83,6 +83,7 @@ obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o | |||
83 | obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o | 83 | obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o |
84 | obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o | 84 | obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o |
85 | obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o | 85 | obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o |
86 | obj-$(CONFIG_RTC_DRV_PCF2127) += rtc-pcf2127.o | ||
86 | obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o | 87 | obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o |
87 | obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o | 88 | obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o |
88 | obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o | 89 | obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o |
@@ -128,3 +129,4 @@ obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o | |||
128 | obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o | 129 | obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o |
129 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o | 130 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o |
130 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o | 131 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o |
132 | obj-$(CONFIG_RTC_DRV_SIRFSOC) += rtc-sirfsoc.o | ||
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 66385402d20e..02426812bebc 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -38,7 +38,7 @@ static void rtc_device_release(struct device *dev) | |||
38 | int rtc_hctosys_ret = -ENODEV; | 38 | int rtc_hctosys_ret = -ENODEV; |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #if defined(CONFIG_PM) && defined(CONFIG_RTC_HCTOSYS_DEVICE) | 41 | #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_RTC_HCTOSYS_DEVICE) |
42 | /* | 42 | /* |
43 | * On suspend(), measure the delta between one RTC and the | 43 | * On suspend(), measure the delta between one RTC and the |
44 | * system's wall clock; restore it on resume(). | 44 | * system's wall clock; restore it on resume(). |
@@ -47,7 +47,7 @@ int rtc_hctosys_ret = -ENODEV; | |||
47 | static struct timespec old_rtc, old_system, old_delta; | 47 | static struct timespec old_rtc, old_system, old_delta; |
48 | 48 | ||
49 | 49 | ||
50 | static int rtc_suspend(struct device *dev, pm_message_t mesg) | 50 | static int rtc_suspend(struct device *dev) |
51 | { | 51 | { |
52 | struct rtc_device *rtc = to_rtc_device(dev); | 52 | struct rtc_device *rtc = to_rtc_device(dev); |
53 | struct rtc_time tm; | 53 | struct rtc_time tm; |
@@ -135,9 +135,10 @@ static int rtc_resume(struct device *dev) | |||
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |
137 | 137 | ||
138 | static SIMPLE_DEV_PM_OPS(rtc_class_dev_pm_ops, rtc_suspend, rtc_resume); | ||
139 | #define RTC_CLASS_DEV_PM_OPS (&rtc_class_dev_pm_ops) | ||
138 | #else | 140 | #else |
139 | #define rtc_suspend NULL | 141 | #define RTC_CLASS_DEV_PM_OPS NULL |
140 | #define rtc_resume NULL | ||
141 | #endif | 142 | #endif |
142 | 143 | ||
143 | 144 | ||
@@ -336,8 +337,7 @@ static int __init rtc_init(void) | |||
336 | pr_err("couldn't create class\n"); | 337 | pr_err("couldn't create class\n"); |
337 | return PTR_ERR(rtc_class); | 338 | return PTR_ERR(rtc_class); |
338 | } | 339 | } |
339 | rtc_class->suspend = rtc_suspend; | 340 | rtc_class->pm = RTC_CLASS_DEV_PM_OPS; |
340 | rtc_class->resume = rtc_resume; | ||
341 | rtc_dev_init(); | 341 | rtc_dev_init(); |
342 | rtc_sysfs_init(rtc_class); | 342 | rtc_sysfs_init(rtc_class); |
343 | return 0; | 343 | return 0; |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 42bd57da239d..72c5cdbe0791 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -109,9 +109,9 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) | |||
109 | err = rtc->ops->set_time(rtc->dev.parent, | 109 | err = rtc->ops->set_time(rtc->dev.parent, |
110 | &new); | 110 | &new); |
111 | } | 111 | } |
112 | } | 112 | } else { |
113 | else | ||
114 | err = -EINVAL; | 113 | err = -EINVAL; |
114 | } | ||
115 | 115 | ||
116 | mutex_unlock(&rtc->ops_lock); | 116 | mutex_unlock(&rtc->ops_lock); |
117 | /* A timer might have just expired */ | 117 | /* A timer might have just expired */ |
@@ -367,14 +367,14 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
367 | err = mutex_lock_interruptible(&rtc->ops_lock); | 367 | err = mutex_lock_interruptible(&rtc->ops_lock); |
368 | if (err) | 368 | if (err) |
369 | return err; | 369 | return err; |
370 | if (rtc->aie_timer.enabled) { | 370 | if (rtc->aie_timer.enabled) |
371 | rtc_timer_remove(rtc, &rtc->aie_timer); | 371 | rtc_timer_remove(rtc, &rtc->aie_timer); |
372 | } | 372 | |
373 | rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); | 373 | rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); |
374 | rtc->aie_timer.period = ktime_set(0, 0); | 374 | rtc->aie_timer.period = ktime_set(0, 0); |
375 | if (alarm->enabled) { | 375 | if (alarm->enabled) |
376 | err = rtc_timer_enqueue(rtc, &rtc->aie_timer); | 376 | err = rtc_timer_enqueue(rtc, &rtc->aie_timer); |
377 | } | 377 | |
378 | mutex_unlock(&rtc->ops_lock); | 378 | mutex_unlock(&rtc->ops_lock); |
379 | return err; | 379 | return err; |
380 | } | 380 | } |
@@ -698,9 +698,9 @@ retry: | |||
698 | spin_lock_irqsave(&rtc->irq_task_lock, flags); | 698 | spin_lock_irqsave(&rtc->irq_task_lock, flags); |
699 | if (rtc->irq_task != NULL && task == NULL) | 699 | if (rtc->irq_task != NULL && task == NULL) |
700 | err = -EBUSY; | 700 | err = -EBUSY; |
701 | if (rtc->irq_task != task) | 701 | else if (rtc->irq_task != task) |
702 | err = -EACCES; | 702 | err = -EACCES; |
703 | if (!err) { | 703 | else { |
704 | if (rtc_update_hrtimer(rtc, enabled) < 0) { | 704 | if (rtc_update_hrtimer(rtc, enabled) < 0) { |
705 | spin_unlock_irqrestore(&rtc->irq_task_lock, flags); | 705 | spin_unlock_irqrestore(&rtc->irq_task_lock, flags); |
706 | cpu_relax(); | 706 | cpu_relax(); |
@@ -734,9 +734,9 @@ retry: | |||
734 | spin_lock_irqsave(&rtc->irq_task_lock, flags); | 734 | spin_lock_irqsave(&rtc->irq_task_lock, flags); |
735 | if (rtc->irq_task != NULL && task == NULL) | 735 | if (rtc->irq_task != NULL && task == NULL) |
736 | err = -EBUSY; | 736 | err = -EBUSY; |
737 | if (rtc->irq_task != task) | 737 | else if (rtc->irq_task != task) |
738 | err = -EACCES; | 738 | err = -EACCES; |
739 | if (!err) { | 739 | else { |
740 | rtc->irq_freq = freq; | 740 | rtc->irq_freq = freq; |
741 | if (rtc->pie_enabled && rtc_update_hrtimer(rtc, 1) < 0) { | 741 | if (rtc->pie_enabled && rtc_update_hrtimer(rtc, 1) < 0) { |
742 | spin_unlock_irqrestore(&rtc->irq_task_lock, flags); | 742 | spin_unlock_irqrestore(&rtc->irq_task_lock, flags); |
@@ -891,7 +891,7 @@ again: | |||
891 | * | 891 | * |
892 | * Kernel interface to initializing an rtc_timer. | 892 | * Kernel interface to initializing an rtc_timer. |
893 | */ | 893 | */ |
894 | void rtc_timer_init(struct rtc_timer *timer, void (*f)(void* p), void* data) | 894 | void rtc_timer_init(struct rtc_timer *timer, void (*f)(void *p), void *data) |
895 | { | 895 | { |
896 | timerqueue_init(&timer->node); | 896 | timerqueue_init(&timer->node); |
897 | timer->enabled = 0; | 897 | timer->enabled = 0; |
@@ -907,7 +907,7 @@ void rtc_timer_init(struct rtc_timer *timer, void (*f)(void* p), void* data) | |||
907 | * | 907 | * |
908 | * Kernel interface to set an rtc_timer | 908 | * Kernel interface to set an rtc_timer |
909 | */ | 909 | */ |
910 | int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer* timer, | 910 | int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer *timer, |
911 | ktime_t expires, ktime_t period) | 911 | ktime_t expires, ktime_t period) |
912 | { | 912 | { |
913 | int ret = 0; | 913 | int ret = 0; |
@@ -930,7 +930,7 @@ int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer* timer, | |||
930 | * | 930 | * |
931 | * Kernel interface to cancel an rtc_timer | 931 | * Kernel interface to cancel an rtc_timer |
932 | */ | 932 | */ |
933 | int rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer* timer) | 933 | int rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer *timer) |
934 | { | 934 | { |
935 | int ret = 0; | 935 | int ret = 0; |
936 | mutex_lock(&rtc->ops_lock); | 936 | mutex_lock(&rtc->ops_lock); |
diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c index f3742f364eb8..354c937a5866 100644 --- a/drivers/rtc/rtc-88pm80x.c +++ b/drivers/rtc/rtc-88pm80x.c | |||
@@ -345,7 +345,6 @@ out: | |||
345 | static int pm80x_rtc_remove(struct platform_device *pdev) | 345 | static int pm80x_rtc_remove(struct platform_device *pdev) |
346 | { | 346 | { |
347 | struct pm80x_rtc_info *info = platform_get_drvdata(pdev); | 347 | struct pm80x_rtc_info *info = platform_get_drvdata(pdev); |
348 | platform_set_drvdata(pdev, NULL); | ||
349 | pm80x_free_irq(info->chip, info->irq, info); | 348 | pm80x_free_irq(info->chip, info->irq, info); |
350 | return 0; | 349 | return 0; |
351 | } | 350 | } |
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c index 0f2b91bfee37..4e30c85728e5 100644 --- a/drivers/rtc/rtc-88pm860x.c +++ b/drivers/rtc/rtc-88pm860x.c | |||
@@ -418,7 +418,6 @@ static int pm860x_rtc_remove(struct platform_device *pdev) | |||
418 | pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0); | 418 | pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0); |
419 | #endif /* VRTC_CALIBRATION */ | 419 | #endif /* VRTC_CALIBRATION */ |
420 | 420 | ||
421 | platform_set_drvdata(pdev, NULL); | ||
422 | return 0; | 421 | return 0; |
423 | } | 422 | } |
424 | 423 | ||
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c index 47a4f2c4d30e..ff435343ba9f 100644 --- a/drivers/rtc/rtc-ab3100.c +++ b/drivers/rtc/rtc-ab3100.c | |||
@@ -240,18 +240,11 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev) | |||
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | 242 | ||
243 | static int __exit ab3100_rtc_remove(struct platform_device *pdev) | ||
244 | { | ||
245 | platform_set_drvdata(pdev, NULL); | ||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | static struct platform_driver ab3100_rtc_driver = { | 243 | static struct platform_driver ab3100_rtc_driver = { |
250 | .driver = { | 244 | .driver = { |
251 | .name = "ab3100-rtc", | 245 | .name = "ab3100-rtc", |
252 | .owner = THIS_MODULE, | 246 | .owner = THIS_MODULE, |
253 | }, | 247 | }, |
254 | .remove = __exit_p(ab3100_rtc_remove), | ||
255 | }; | 248 | }; |
256 | 249 | ||
257 | module_platform_driver_probe(ab3100_rtc_driver, ab3100_rtc_probe); | 250 | module_platform_driver_probe(ab3100_rtc_driver, ab3100_rtc_probe); |
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index 63cfa314a39f..727e2f5d14d9 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c | |||
@@ -35,6 +35,10 @@ | |||
35 | #define AB8500_RTC_FORCE_BKUP_REG 0x0D | 35 | #define AB8500_RTC_FORCE_BKUP_REG 0x0D |
36 | #define AB8500_RTC_CALIB_REG 0x0E | 36 | #define AB8500_RTC_CALIB_REG 0x0E |
37 | #define AB8500_RTC_SWITCH_STAT_REG 0x0F | 37 | #define AB8500_RTC_SWITCH_STAT_REG 0x0F |
38 | #define AB8540_RTC_ALRM_SEC 0x22 | ||
39 | #define AB8540_RTC_ALRM_MIN_LOW_REG 0x23 | ||
40 | #define AB8540_RTC_ALRM_MIN_MID_REG 0x24 | ||
41 | #define AB8540_RTC_ALRM_MIN_HI_REG 0x25 | ||
38 | 42 | ||
39 | /* RtcReadRequest bits */ | 43 | /* RtcReadRequest bits */ |
40 | #define RTC_READ_REQUEST 0x01 | 44 | #define RTC_READ_REQUEST 0x01 |
@@ -58,6 +62,11 @@ static const u8 ab8500_rtc_alarm_regs[] = { | |||
58 | AB8500_RTC_ALRM_MIN_LOW_REG | 62 | AB8500_RTC_ALRM_MIN_LOW_REG |
59 | }; | 63 | }; |
60 | 64 | ||
65 | static const u8 ab8540_rtc_alarm_regs[] = { | ||
66 | AB8540_RTC_ALRM_MIN_HI_REG, AB8540_RTC_ALRM_MIN_MID_REG, | ||
67 | AB8540_RTC_ALRM_MIN_LOW_REG, AB8540_RTC_ALRM_SEC | ||
68 | }; | ||
69 | |||
61 | /* Calculate the seconds from 1970 to 01-01-2000 00:00:00 */ | 70 | /* Calculate the seconds from 1970 to 01-01-2000 00:00:00 */ |
62 | static unsigned long get_elapsed_seconds(int year) | 71 | static unsigned long get_elapsed_seconds(int year) |
63 | { | 72 | { |
@@ -267,6 +276,42 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
267 | return ab8500_rtc_irq_enable(dev, alarm->enabled); | 276 | return ab8500_rtc_irq_enable(dev, alarm->enabled); |
268 | } | 277 | } |
269 | 278 | ||
279 | static int ab8540_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | ||
280 | { | ||
281 | int retval, i; | ||
282 | unsigned char buf[ARRAY_SIZE(ab8540_rtc_alarm_regs)]; | ||
283 | unsigned long mins, secs = 0; | ||
284 | |||
285 | if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { | ||
286 | dev_dbg(dev, "year should be equal to or greater than %d\n", | ||
287 | AB8500_RTC_EPOCH); | ||
288 | return -EINVAL; | ||
289 | } | ||
290 | |||
291 | /* Get the number of seconds since 1970 */ | ||
292 | rtc_tm_to_time(&alarm->time, &secs); | ||
293 | |||
294 | /* | ||
295 | * Convert it to the number of seconds since 01-01-2000 00:00:00 | ||
296 | */ | ||
297 | secs -= get_elapsed_seconds(AB8500_RTC_EPOCH); | ||
298 | mins = secs / 60; | ||
299 | |||
300 | buf[3] = secs % 60; | ||
301 | buf[2] = mins & 0xFF; | ||
302 | buf[1] = (mins >> 8) & 0xFF; | ||
303 | buf[0] = (mins >> 16) & 0xFF; | ||
304 | |||
305 | /* Set the alarm time */ | ||
306 | for (i = 0; i < ARRAY_SIZE(ab8540_rtc_alarm_regs); i++) { | ||
307 | retval = abx500_set_register_interruptible(dev, AB8500_RTC, | ||
308 | ab8540_rtc_alarm_regs[i], buf[i]); | ||
309 | if (retval < 0) | ||
310 | return retval; | ||
311 | } | ||
312 | |||
313 | return ab8500_rtc_irq_enable(dev, alarm->enabled); | ||
314 | } | ||
270 | 315 | ||
271 | static int ab8500_rtc_set_calibration(struct device *dev, int calibration) | 316 | static int ab8500_rtc_set_calibration(struct device *dev, int calibration) |
272 | { | 317 | { |
@@ -389,8 +434,22 @@ static const struct rtc_class_ops ab8500_rtc_ops = { | |||
389 | .alarm_irq_enable = ab8500_rtc_irq_enable, | 434 | .alarm_irq_enable = ab8500_rtc_irq_enable, |
390 | }; | 435 | }; |
391 | 436 | ||
437 | static const struct rtc_class_ops ab8540_rtc_ops = { | ||
438 | .read_time = ab8500_rtc_read_time, | ||
439 | .set_time = ab8500_rtc_set_time, | ||
440 | .read_alarm = ab8500_rtc_read_alarm, | ||
441 | .set_alarm = ab8540_rtc_set_alarm, | ||
442 | .alarm_irq_enable = ab8500_rtc_irq_enable, | ||
443 | }; | ||
444 | |||
445 | static struct platform_device_id ab85xx_rtc_ids[] = { | ||
446 | { "ab8500-rtc", (kernel_ulong_t)&ab8500_rtc_ops, }, | ||
447 | { "ab8540-rtc", (kernel_ulong_t)&ab8540_rtc_ops, }, | ||
448 | }; | ||
449 | |||
392 | static int ab8500_rtc_probe(struct platform_device *pdev) | 450 | static int ab8500_rtc_probe(struct platform_device *pdev) |
393 | { | 451 | { |
452 | const struct platform_device_id *platid = platform_get_device_id(pdev); | ||
394 | int err; | 453 | int err; |
395 | struct rtc_device *rtc; | 454 | struct rtc_device *rtc; |
396 | u8 rtc_ctrl; | 455 | u8 rtc_ctrl; |
@@ -423,7 +482,8 @@ static int ab8500_rtc_probe(struct platform_device *pdev) | |||
423 | device_init_wakeup(&pdev->dev, true); | 482 | device_init_wakeup(&pdev->dev, true); |
424 | 483 | ||
425 | rtc = devm_rtc_device_register(&pdev->dev, "ab8500-rtc", | 484 | rtc = devm_rtc_device_register(&pdev->dev, "ab8500-rtc", |
426 | &ab8500_rtc_ops, THIS_MODULE); | 485 | (struct rtc_class_ops *)platid->driver_data, |
486 | THIS_MODULE); | ||
427 | if (IS_ERR(rtc)) { | 487 | if (IS_ERR(rtc)) { |
428 | dev_err(&pdev->dev, "Registration failed\n"); | 488 | dev_err(&pdev->dev, "Registration failed\n"); |
429 | err = PTR_ERR(rtc); | 489 | err = PTR_ERR(rtc); |
@@ -451,8 +511,6 @@ static int ab8500_rtc_remove(struct platform_device *pdev) | |||
451 | { | 511 | { |
452 | ab8500_sysfs_rtc_unregister(&pdev->dev); | 512 | ab8500_sysfs_rtc_unregister(&pdev->dev); |
453 | 513 | ||
454 | platform_set_drvdata(pdev, NULL); | ||
455 | |||
456 | return 0; | 514 | return 0; |
457 | } | 515 | } |
458 | 516 | ||
@@ -463,6 +521,7 @@ static struct platform_driver ab8500_rtc_driver = { | |||
463 | }, | 521 | }, |
464 | .probe = ab8500_rtc_probe, | 522 | .probe = ab8500_rtc_probe, |
465 | .remove = ab8500_rtc_remove, | 523 | .remove = ab8500_rtc_remove, |
524 | .id_table = ab85xx_rtc_ids, | ||
466 | }; | 525 | }; |
467 | 526 | ||
468 | module_platform_driver(ab8500_rtc_driver); | 527 | module_platform_driver(ab8500_rtc_driver); |
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index f47fbb5eee8b..3161ab5263ed 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c | |||
@@ -141,7 +141,7 @@ static int at32_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
141 | 141 | ||
142 | spin_lock_irq(&rtc->lock); | 142 | spin_lock_irq(&rtc->lock); |
143 | 143 | ||
144 | if(enabled) { | 144 | if (enabled) { |
145 | if (rtc_readl(rtc, VAL) > rtc->alarm_time) { | 145 | if (rtc_readl(rtc, VAL) > rtc->alarm_time) { |
146 | ret = -EINVAL; | 146 | ret = -EINVAL; |
147 | goto out; | 147 | goto out; |
@@ -212,23 +212,20 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
212 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 212 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
213 | if (!regs) { | 213 | if (!regs) { |
214 | dev_dbg(&pdev->dev, "no mmio resource defined\n"); | 214 | dev_dbg(&pdev->dev, "no mmio resource defined\n"); |
215 | ret = -ENXIO; | 215 | return -ENXIO; |
216 | goto out; | ||
217 | } | 216 | } |
218 | 217 | ||
219 | irq = platform_get_irq(pdev, 0); | 218 | irq = platform_get_irq(pdev, 0); |
220 | if (irq <= 0) { | 219 | if (irq <= 0) { |
221 | dev_dbg(&pdev->dev, "could not get irq\n"); | 220 | dev_dbg(&pdev->dev, "could not get irq\n"); |
222 | ret = -ENXIO; | 221 | return -ENXIO; |
223 | goto out; | ||
224 | } | 222 | } |
225 | 223 | ||
226 | rtc->irq = irq; | 224 | rtc->irq = irq; |
227 | rtc->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); | 225 | rtc->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); |
228 | if (!rtc->regs) { | 226 | if (!rtc->regs) { |
229 | ret = -ENOMEM; | ||
230 | dev_dbg(&pdev->dev, "could not map I/O memory\n"); | 227 | dev_dbg(&pdev->dev, "could not map I/O memory\n"); |
231 | goto out; | 228 | return -ENOMEM; |
232 | } | 229 | } |
233 | spin_lock_init(&rtc->lock); | 230 | spin_lock_init(&rtc->lock); |
234 | 231 | ||
@@ -249,7 +246,7 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
249 | "rtc", rtc); | 246 | "rtc", rtc); |
250 | if (ret) { | 247 | if (ret) { |
251 | dev_dbg(&pdev->dev, "could not request irq %d\n", irq); | 248 | dev_dbg(&pdev->dev, "could not request irq %d\n", irq); |
252 | goto out; | 249 | return ret; |
253 | } | 250 | } |
254 | 251 | ||
255 | platform_set_drvdata(pdev, rtc); | 252 | platform_set_drvdata(pdev, rtc); |
@@ -258,8 +255,7 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
258 | &at32_rtc_ops, THIS_MODULE); | 255 | &at32_rtc_ops, THIS_MODULE); |
259 | if (IS_ERR(rtc->rtc)) { | 256 | if (IS_ERR(rtc->rtc)) { |
260 | dev_dbg(&pdev->dev, "could not register rtc device\n"); | 257 | dev_dbg(&pdev->dev, "could not register rtc device\n"); |
261 | ret = PTR_ERR(rtc->rtc); | 258 | return PTR_ERR(rtc->rtc); |
262 | goto out; | ||
263 | } | 259 | } |
264 | 260 | ||
265 | device_init_wakeup(&pdev->dev, 1); | 261 | device_init_wakeup(&pdev->dev, 1); |
@@ -268,18 +264,12 @@ static int __init at32_rtc_probe(struct platform_device *pdev) | |||
268 | (unsigned long)rtc->regs, rtc->irq); | 264 | (unsigned long)rtc->regs, rtc->irq); |
269 | 265 | ||
270 | return 0; | 266 | return 0; |
271 | |||
272 | out: | ||
273 | platform_set_drvdata(pdev, NULL); | ||
274 | return ret; | ||
275 | } | 267 | } |
276 | 268 | ||
277 | static int __exit at32_rtc_remove(struct platform_device *pdev) | 269 | static int __exit at32_rtc_remove(struct platform_device *pdev) |
278 | { | 270 | { |
279 | device_init_wakeup(&pdev->dev, 0); | 271 | device_init_wakeup(&pdev->dev, 0); |
280 | 272 | ||
281 | platform_set_drvdata(pdev, NULL); | ||
282 | |||
283 | return 0; | 273 | return 0; |
284 | } | 274 | } |
285 | 275 | ||
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index f296f3f7db9b..741892632ae0 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -31,8 +31,7 @@ | |||
31 | #include <linux/io.h> | 31 | #include <linux/io.h> |
32 | #include <linux/of.h> | 32 | #include <linux/of.h> |
33 | #include <linux/of_device.h> | 33 | #include <linux/of_device.h> |
34 | 34 | #include <linux/uaccess.h> | |
35 | #include <asm/uaccess.h> | ||
36 | 35 | ||
37 | #include "rtc-at91rm9200.h" | 36 | #include "rtc-at91rm9200.h" |
38 | 37 | ||
@@ -439,7 +438,6 @@ static int __exit at91_rtc_remove(struct platform_device *pdev) | |||
439 | 438 | ||
440 | rtc_device_unregister(rtc); | 439 | rtc_device_unregister(rtc); |
441 | iounmap(at91_rtc_regs); | 440 | iounmap(at91_rtc_regs); |
442 | platform_set_drvdata(pdev, NULL); | ||
443 | 441 | ||
444 | return 0; | 442 | return 0; |
445 | } | 443 | } |
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index b60a34cb145a..309b8b342d9c 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
@@ -324,16 +324,14 @@ static int at91_rtc_probe(struct platform_device *pdev) | |||
324 | rtc->rtt = devm_ioremap(&pdev->dev, r->start, resource_size(r)); | 324 | rtc->rtt = devm_ioremap(&pdev->dev, r->start, resource_size(r)); |
325 | if (!rtc->rtt) { | 325 | if (!rtc->rtt) { |
326 | dev_err(&pdev->dev, "failed to map registers, aborting.\n"); | 326 | dev_err(&pdev->dev, "failed to map registers, aborting.\n"); |
327 | ret = -ENOMEM; | 327 | return -ENOMEM; |
328 | goto fail; | ||
329 | } | 328 | } |
330 | 329 | ||
331 | rtc->gpbr = devm_ioremap(&pdev->dev, r_gpbr->start, | 330 | rtc->gpbr = devm_ioremap(&pdev->dev, r_gpbr->start, |
332 | resource_size(r_gpbr)); | 331 | resource_size(r_gpbr)); |
333 | if (!rtc->gpbr) { | 332 | if (!rtc->gpbr) { |
334 | dev_err(&pdev->dev, "failed to map gpbr registers, aborting.\n"); | 333 | dev_err(&pdev->dev, "failed to map gpbr registers, aborting.\n"); |
335 | ret = -ENOMEM; | 334 | return -ENOMEM; |
336 | goto fail; | ||
337 | } | 335 | } |
338 | 336 | ||
339 | mr = rtt_readl(rtc, MR); | 337 | mr = rtt_readl(rtc, MR); |
@@ -350,17 +348,15 @@ static int at91_rtc_probe(struct platform_device *pdev) | |||
350 | 348 | ||
351 | rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name, | 349 | rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name, |
352 | &at91_rtc_ops, THIS_MODULE); | 350 | &at91_rtc_ops, THIS_MODULE); |
353 | if (IS_ERR(rtc->rtcdev)) { | 351 | if (IS_ERR(rtc->rtcdev)) |
354 | ret = PTR_ERR(rtc->rtcdev); | 352 | return PTR_ERR(rtc->rtcdev); |
355 | goto fail; | ||
356 | } | ||
357 | 353 | ||
358 | /* register irq handler after we know what name we'll use */ | 354 | /* register irq handler after we know what name we'll use */ |
359 | ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt, | 355 | ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt, |
360 | IRQF_SHARED, dev_name(&rtc->rtcdev->dev), rtc); | 356 | IRQF_SHARED, dev_name(&rtc->rtcdev->dev), rtc); |
361 | if (ret) { | 357 | if (ret) { |
362 | dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq); | 358 | dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq); |
363 | goto fail; | 359 | return ret; |
364 | } | 360 | } |
365 | 361 | ||
366 | /* NOTE: sam9260 rev A silicon has a ROM bug which resets the | 362 | /* NOTE: sam9260 rev A silicon has a ROM bug which resets the |
@@ -374,10 +370,6 @@ static int at91_rtc_probe(struct platform_device *pdev) | |||
374 | dev_name(&rtc->rtcdev->dev)); | 370 | dev_name(&rtc->rtcdev->dev)); |
375 | 371 | ||
376 | return 0; | 372 | return 0; |
377 | |||
378 | fail: | ||
379 | platform_set_drvdata(pdev, NULL); | ||
380 | return ret; | ||
381 | } | 373 | } |
382 | 374 | ||
383 | /* | 375 | /* |
@@ -391,7 +383,6 @@ static int at91_rtc_remove(struct platform_device *pdev) | |||
391 | /* disable all interrupts */ | 383 | /* disable all interrupts */ |
392 | rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)); | 384 | rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)); |
393 | 385 | ||
394 | platform_set_drvdata(pdev, NULL); | ||
395 | return 0; | 386 | return 0; |
396 | } | 387 | } |
397 | 388 | ||
diff --git a/drivers/rtc/rtc-au1xxx.c b/drivers/rtc/rtc-au1xxx.c index 7995abc391fc..ed526a192ce0 100644 --- a/drivers/rtc/rtc-au1xxx.c +++ b/drivers/rtc/rtc-au1xxx.c | |||
@@ -116,19 +116,11 @@ out_err: | |||
116 | return ret; | 116 | return ret; |
117 | } | 117 | } |
118 | 118 | ||
119 | static int au1xtoy_rtc_remove(struct platform_device *pdev) | ||
120 | { | ||
121 | platform_set_drvdata(pdev, NULL); | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | static struct platform_driver au1xrtc_driver = { | 119 | static struct platform_driver au1xrtc_driver = { |
127 | .driver = { | 120 | .driver = { |
128 | .name = "rtc-au1xxx", | 121 | .name = "rtc-au1xxx", |
129 | .owner = THIS_MODULE, | 122 | .owner = THIS_MODULE, |
130 | }, | 123 | }, |
131 | .remove = au1xtoy_rtc_remove, | ||
132 | }; | 124 | }; |
133 | 125 | ||
134 | module_platform_driver_probe(au1xrtc_driver, au1xtoy_rtc_probe); | 126 | module_platform_driver_probe(au1xrtc_driver, au1xtoy_rtc_probe); |
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index ad44ec5dc29a..0c53f452849d 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
@@ -391,7 +391,6 @@ static int bfin_rtc_remove(struct platform_device *pdev) | |||
391 | struct device *dev = &pdev->dev; | 391 | struct device *dev = &pdev->dev; |
392 | 392 | ||
393 | bfin_rtc_reset(dev, 0); | 393 | bfin_rtc_reset(dev, 0); |
394 | platform_set_drvdata(pdev, NULL); | ||
395 | 394 | ||
396 | return 0; | 395 | return 0; |
397 | } | 396 | } |
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c index fea78bc713ca..c74bf0dc52cc 100644 --- a/drivers/rtc/rtc-bq32k.c +++ b/drivers/rtc/rtc-bq32k.c | |||
@@ -163,11 +163,6 @@ static int bq32k_probe(struct i2c_client *client, | |||
163 | return 0; | 163 | return 0; |
164 | } | 164 | } |
165 | 165 | ||
166 | static int bq32k_remove(struct i2c_client *client) | ||
167 | { | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | static const struct i2c_device_id bq32k_id[] = { | 166 | static const struct i2c_device_id bq32k_id[] = { |
172 | { "bq32000", 0 }, | 167 | { "bq32000", 0 }, |
173 | { } | 168 | { } |
@@ -180,7 +175,6 @@ static struct i2c_driver bq32k_driver = { | |||
180 | .owner = THIS_MODULE, | 175 | .owner = THIS_MODULE, |
181 | }, | 176 | }, |
182 | .probe = bq32k_probe, | 177 | .probe = bq32k_probe, |
183 | .remove = bq32k_remove, | ||
184 | .id_table = bq32k_id, | 178 | .id_table = bq32k_id, |
185 | }; | 179 | }; |
186 | 180 | ||
diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c index af2886784a7b..fc0ff87aa5df 100644 --- a/drivers/rtc/rtc-bq4802.c +++ b/drivers/rtc/rtc-bq4802.c | |||
@@ -186,13 +186,6 @@ out: | |||
186 | 186 | ||
187 | } | 187 | } |
188 | 188 | ||
189 | static int bq4802_remove(struct platform_device *pdev) | ||
190 | { | ||
191 | platform_set_drvdata(pdev, NULL); | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | /* work with hotplug and coldplug */ | 189 | /* work with hotplug and coldplug */ |
197 | MODULE_ALIAS("platform:rtc-bq4802"); | 190 | MODULE_ALIAS("platform:rtc-bq4802"); |
198 | 191 | ||
@@ -202,7 +195,6 @@ static struct platform_driver bq4802_driver = { | |||
202 | .owner = THIS_MODULE, | 195 | .owner = THIS_MODULE, |
203 | }, | 196 | }, |
204 | .probe = bq4802_probe, | 197 | .probe = bq4802_probe, |
205 | .remove = bq4802_remove, | ||
206 | }; | 198 | }; |
207 | 199 | ||
208 | module_platform_driver(bq4802_driver); | 200 | module_platform_driver(bq4802_driver); |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index f1cb706445c7..be06d7150de5 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -326,7 +326,7 @@ static void cmos_irq_disable(struct cmos_rtc *cmos, unsigned char mask) | |||
326 | static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | 326 | static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) |
327 | { | 327 | { |
328 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 328 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
329 | unsigned char mon, mday, hrs, min, sec, rtc_control; | 329 | unsigned char mon, mday, hrs, min, sec, rtc_control; |
330 | 330 | ||
331 | if (!is_valid_irq(cmos->irq)) | 331 | if (!is_valid_irq(cmos->irq)) |
332 | return -EIO; | 332 | return -EIO; |
@@ -556,17 +556,24 @@ static irqreturn_t cmos_interrupt(int irq, void *p) | |||
556 | rtc_control = CMOS_READ(RTC_CONTROL); | 556 | rtc_control = CMOS_READ(RTC_CONTROL); |
557 | if (is_hpet_enabled()) | 557 | if (is_hpet_enabled()) |
558 | irqstat = (unsigned long)irq & 0xF0; | 558 | irqstat = (unsigned long)irq & 0xF0; |
559 | irqstat &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | 559 | |
560 | /* If we were suspended, RTC_CONTROL may not be accurate since the | ||
561 | * bios may have cleared it. | ||
562 | */ | ||
563 | if (!cmos_rtc.suspend_ctrl) | ||
564 | irqstat &= (rtc_control & RTC_IRQMASK) | RTC_IRQF; | ||
565 | else | ||
566 | irqstat &= (cmos_rtc.suspend_ctrl & RTC_IRQMASK) | RTC_IRQF; | ||
560 | 567 | ||
561 | /* All Linux RTC alarms should be treated as if they were oneshot. | 568 | /* All Linux RTC alarms should be treated as if they were oneshot. |
562 | * Similar code may be needed in system wakeup paths, in case the | 569 | * Similar code may be needed in system wakeup paths, in case the |
563 | * alarm woke the system. | 570 | * alarm woke the system. |
564 | */ | 571 | */ |
565 | if (irqstat & RTC_AIE) { | 572 | if (irqstat & RTC_AIE) { |
573 | cmos_rtc.suspend_ctrl &= ~RTC_AIE; | ||
566 | rtc_control &= ~RTC_AIE; | 574 | rtc_control &= ~RTC_AIE; |
567 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 575 | CMOS_WRITE(rtc_control, RTC_CONTROL); |
568 | hpet_mask_rtc_irq_bit(RTC_AIE); | 576 | hpet_mask_rtc_irq_bit(RTC_AIE); |
569 | |||
570 | CMOS_READ(RTC_INTR_FLAGS); | 577 | CMOS_READ(RTC_INTR_FLAGS); |
571 | } | 578 | } |
572 | spin_unlock(&rtc_lock); | 579 | spin_unlock(&rtc_lock); |
@@ -691,7 +698,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) | |||
691 | /* FIXME: | 698 | /* FIXME: |
692 | * <asm-generic/rtc.h> doesn't know 12-hour mode either. | 699 | * <asm-generic/rtc.h> doesn't know 12-hour mode either. |
693 | */ | 700 | */ |
694 | if (is_valid_irq(rtc_irq) && !(rtc_control & RTC_24H)) { | 701 | if (is_valid_irq(rtc_irq) && !(rtc_control & RTC_24H)) { |
695 | dev_warn(dev, "only 24-hr supported\n"); | 702 | dev_warn(dev, "only 24-hr supported\n"); |
696 | retval = -ENXIO; | 703 | retval = -ENXIO; |
697 | goto cleanup1; | 704 | goto cleanup1; |
@@ -839,21 +846,23 @@ static inline int cmos_poweroff(struct device *dev) | |||
839 | static int cmos_resume(struct device *dev) | 846 | static int cmos_resume(struct device *dev) |
840 | { | 847 | { |
841 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 848 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
842 | unsigned char tmp = cmos->suspend_ctrl; | 849 | unsigned char tmp; |
850 | |||
851 | if (cmos->enabled_wake) { | ||
852 | if (cmos->wake_off) | ||
853 | cmos->wake_off(dev); | ||
854 | else | ||
855 | disable_irq_wake(cmos->irq); | ||
856 | cmos->enabled_wake = 0; | ||
857 | } | ||
843 | 858 | ||
859 | spin_lock_irq(&rtc_lock); | ||
860 | tmp = cmos->suspend_ctrl; | ||
861 | cmos->suspend_ctrl = 0; | ||
844 | /* re-enable any irqs previously active */ | 862 | /* re-enable any irqs previously active */ |
845 | if (tmp & RTC_IRQMASK) { | 863 | if (tmp & RTC_IRQMASK) { |
846 | unsigned char mask; | 864 | unsigned char mask; |
847 | 865 | ||
848 | if (cmos->enabled_wake) { | ||
849 | if (cmos->wake_off) | ||
850 | cmos->wake_off(dev); | ||
851 | else | ||
852 | disable_irq_wake(cmos->irq); | ||
853 | cmos->enabled_wake = 0; | ||
854 | } | ||
855 | |||
856 | spin_lock_irq(&rtc_lock); | ||
857 | if (device_may_wakeup(dev)) | 866 | if (device_may_wakeup(dev)) |
858 | hpet_rtc_timer_init(); | 867 | hpet_rtc_timer_init(); |
859 | 868 | ||
@@ -873,8 +882,8 @@ static int cmos_resume(struct device *dev) | |||
873 | tmp &= ~RTC_AIE; | 882 | tmp &= ~RTC_AIE; |
874 | hpet_mask_rtc_irq_bit(RTC_AIE); | 883 | hpet_mask_rtc_irq_bit(RTC_AIE); |
875 | } while (mask & RTC_AIE); | 884 | } while (mask & RTC_AIE); |
876 | spin_unlock_irq(&rtc_lock); | ||
877 | } | 885 | } |
886 | spin_unlock_irq(&rtc_lock); | ||
878 | 887 | ||
879 | dev_dbg(dev, "resume, ctrl %02x\n", tmp); | 888 | dev_dbg(dev, "resume, ctrl %02x\n", tmp); |
880 | 889 | ||
@@ -991,7 +1000,7 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) | |||
991 | { | 1000 | { |
992 | cmos_wake_setup(&pnp->dev); | 1001 | cmos_wake_setup(&pnp->dev); |
993 | 1002 | ||
994 | if (pnp_port_start(pnp,0) == 0x70 && !pnp_irq_valid(pnp,0)) | 1003 | if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0)) |
995 | /* Some machines contain a PNP entry for the RTC, but | 1004 | /* Some machines contain a PNP entry for the RTC, but |
996 | * don't define the IRQ. It should always be safe to | 1005 | * don't define the IRQ. It should always be safe to |
997 | * hardcode it in these cases | 1006 | * hardcode it in these cases |
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index ad6863a76af9..73f157519dff 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c | |||
@@ -152,12 +152,10 @@ static struct rtc_class_ops coh901331_ops = { | |||
152 | 152 | ||
153 | static int __exit coh901331_remove(struct platform_device *pdev) | 153 | static int __exit coh901331_remove(struct platform_device *pdev) |
154 | { | 154 | { |
155 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 155 | struct coh901331_port *rtap = platform_get_drvdata(pdev); |
156 | 156 | ||
157 | if (rtap) { | 157 | if (rtap) |
158 | clk_unprepare(rtap->clk); | 158 | clk_unprepare(rtap->clk); |
159 | platform_set_drvdata(pdev, NULL); | ||
160 | } | ||
161 | 159 | ||
162 | return 0; | 160 | return 0; |
163 | } | 161 | } |
@@ -220,7 +218,6 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
220 | return 0; | 218 | return 0; |
221 | 219 | ||
222 | out_no_rtc: | 220 | out_no_rtc: |
223 | platform_set_drvdata(pdev, NULL); | ||
224 | clk_unprepare(rtap->clk); | 221 | clk_unprepare(rtap->clk); |
225 | return ret; | 222 | return ret; |
226 | } | 223 | } |
@@ -267,7 +264,7 @@ static SIMPLE_DEV_PM_OPS(coh901331_pm_ops, coh901331_suspend, coh901331_resume); | |||
267 | 264 | ||
268 | static void coh901331_shutdown(struct platform_device *pdev) | 265 | static void coh901331_shutdown(struct platform_device *pdev) |
269 | { | 266 | { |
270 | struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev); | 267 | struct coh901331_port *rtap = platform_get_drvdata(pdev); |
271 | 268 | ||
272 | clk_enable(rtap->clk); | 269 | clk_enable(rtap->clk); |
273 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); | 270 | writel(0, rtap->virtbase + COH901331_IRQ_MASK); |
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c index 7286b279cf2d..9c8c19441cc6 100644 --- a/drivers/rtc/rtc-da9052.c +++ b/drivers/rtc/rtc-da9052.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/rtc.h> | 17 | #include <linux/rtc.h> |
18 | #include <linux/err.h> | ||
18 | 19 | ||
19 | #include <linux/mfd/da9052/da9052.h> | 20 | #include <linux/mfd/da9052/da9052.h> |
20 | #include <linux/mfd/da9052/reg.h> | 21 | #include <linux/mfd/da9052/reg.h> |
@@ -249,22 +250,11 @@ static int da9052_rtc_probe(struct platform_device *pdev) | |||
249 | 250 | ||
250 | rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, | 251 | rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
251 | &da9052_rtc_ops, THIS_MODULE); | 252 | &da9052_rtc_ops, THIS_MODULE); |
252 | if (IS_ERR(rtc->rtc)) | 253 | return PTR_RET(rtc->rtc); |
253 | return PTR_ERR(rtc->rtc); | ||
254 | |||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | static int da9052_rtc_remove(struct platform_device *pdev) | ||
259 | { | ||
260 | platform_set_drvdata(pdev, NULL); | ||
261 | |||
262 | return 0; | ||
263 | } | 254 | } |
264 | 255 | ||
265 | static struct platform_driver da9052_rtc_driver = { | 256 | static struct platform_driver da9052_rtc_driver = { |
266 | .probe = da9052_rtc_probe, | 257 | .probe = da9052_rtc_probe, |
267 | .remove = da9052_rtc_remove, | ||
268 | .driver = { | 258 | .driver = { |
269 | .name = "da9052-rtc", | 259 | .name = "da9052-rtc", |
270 | .owner = THIS_MODULE, | 260 | .owner = THIS_MODULE, |
diff --git a/drivers/rtc/rtc-da9055.c b/drivers/rtc/rtc-da9055.c index 73858ca9709a..e00642b61076 100644 --- a/drivers/rtc/rtc-da9055.c +++ b/drivers/rtc/rtc-da9055.c | |||
@@ -315,13 +315,6 @@ err_rtc: | |||
315 | 315 | ||
316 | } | 316 | } |
317 | 317 | ||
318 | static int da9055_rtc_remove(struct platform_device *pdev) | ||
319 | { | ||
320 | platform_set_drvdata(pdev, NULL); | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | #ifdef CONFIG_PM | 318 | #ifdef CONFIG_PM |
326 | /* Turn off the alarm if it should not be a wake source. */ | 319 | /* Turn off the alarm if it should not be a wake source. */ |
327 | static int da9055_rtc_suspend(struct device *dev) | 320 | static int da9055_rtc_suspend(struct device *dev) |
@@ -394,7 +387,6 @@ static const struct dev_pm_ops da9055_rtc_pm_ops = { | |||
394 | 387 | ||
395 | static struct platform_driver da9055_rtc_driver = { | 388 | static struct platform_driver da9055_rtc_driver = { |
396 | .probe = da9055_rtc_probe, | 389 | .probe = da9055_rtc_probe, |
397 | .remove = da9055_rtc_remove, | ||
398 | .driver = { | 390 | .driver = { |
399 | .name = "da9055-rtc", | 391 | .name = "da9055-rtc", |
400 | .owner = THIS_MODULE, | 392 | .owner = THIS_MODULE, |
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index a55048c3e26f..24677ef8c39a 100644 --- a/drivers/rtc/rtc-davinci.c +++ b/drivers/rtc/rtc-davinci.c | |||
@@ -117,7 +117,7 @@ | |||
117 | static DEFINE_SPINLOCK(davinci_rtc_lock); | 117 | static DEFINE_SPINLOCK(davinci_rtc_lock); |
118 | 118 | ||
119 | struct davinci_rtc { | 119 | struct davinci_rtc { |
120 | struct rtc_device *rtc; | 120 | struct rtc_device *rtc; |
121 | void __iomem *base; | 121 | void __iomem *base; |
122 | resource_size_t pbase; | 122 | resource_size_t pbase; |
123 | size_t base_size; | 123 | size_t base_size; |
@@ -526,10 +526,9 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
526 | davinci_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, | 526 | davinci_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
527 | &davinci_rtc_ops, THIS_MODULE); | 527 | &davinci_rtc_ops, THIS_MODULE); |
528 | if (IS_ERR(davinci_rtc->rtc)) { | 528 | if (IS_ERR(davinci_rtc->rtc)) { |
529 | ret = PTR_ERR(davinci_rtc->rtc); | ||
530 | dev_err(dev, "unable to register RTC device, err %d\n", | 529 | dev_err(dev, "unable to register RTC device, err %d\n", |
531 | ret); | 530 | ret); |
532 | goto fail1; | 531 | return PTR_ERR(davinci_rtc->rtc); |
533 | } | 532 | } |
534 | 533 | ||
535 | rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, PRTCIF_INTFLG); | 534 | rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, PRTCIF_INTFLG); |
@@ -543,7 +542,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
543 | 0, "davinci_rtc", davinci_rtc); | 542 | 0, "davinci_rtc", davinci_rtc); |
544 | if (ret < 0) { | 543 | if (ret < 0) { |
545 | dev_err(dev, "unable to register davinci RTC interrupt\n"); | 544 | dev_err(dev, "unable to register davinci RTC interrupt\n"); |
546 | goto fail1; | 545 | return ret; |
547 | } | 546 | } |
548 | 547 | ||
549 | /* Enable interrupts */ | 548 | /* Enable interrupts */ |
@@ -556,10 +555,6 @@ static int __init davinci_rtc_probe(struct platform_device *pdev) | |||
556 | device_init_wakeup(&pdev->dev, 0); | 555 | device_init_wakeup(&pdev->dev, 0); |
557 | 556 | ||
558 | return 0; | 557 | return 0; |
559 | |||
560 | fail1: | ||
561 | platform_set_drvdata(pdev, NULL); | ||
562 | return ret; | ||
563 | } | 558 | } |
564 | 559 | ||
565 | static int __exit davinci_rtc_remove(struct platform_device *pdev) | 560 | static int __exit davinci_rtc_remove(struct platform_device *pdev) |
@@ -570,8 +565,6 @@ static int __exit davinci_rtc_remove(struct platform_device *pdev) | |||
570 | 565 | ||
571 | rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); | 566 | rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); |
572 | 567 | ||
573 | platform_set_drvdata(pdev, NULL); | ||
574 | |||
575 | return 0; | 568 | return 0; |
576 | } | 569 | } |
577 | 570 | ||
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c index 1e1ca63d58a9..1aca08394c47 100644 --- a/drivers/rtc/rtc-dm355evm.c +++ b/drivers/rtc/rtc-dm355evm.c | |||
@@ -139,19 +139,12 @@ static int dm355evm_rtc_probe(struct platform_device *pdev) | |||
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | static int dm355evm_rtc_remove(struct platform_device *pdev) | ||
143 | { | ||
144 | platform_set_drvdata(pdev, NULL); | ||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | /* | 142 | /* |
149 | * I2C is used to talk to the MSP430, but this platform device is | 143 | * I2C is used to talk to the MSP430, but this platform device is |
150 | * exposed by an MFD driver that manages I2C communications. | 144 | * exposed by an MFD driver that manages I2C communications. |
151 | */ | 145 | */ |
152 | static struct platform_driver rtc_dm355evm_driver = { | 146 | static struct platform_driver rtc_dm355evm_driver = { |
153 | .probe = dm355evm_rtc_probe, | 147 | .probe = dm355evm_rtc_probe, |
154 | .remove = dm355evm_rtc_remove, | ||
155 | .driver = { | 148 | .driver = { |
156 | .owner = THIS_MODULE, | 149 | .owner = THIS_MODULE, |
157 | .name = "rtc-dm355evm", | 150 | .name = "rtc-dm355evm", |
diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c index c7702b7269f7..9c04fd2bc209 100644 --- a/drivers/rtc/rtc-ds1216.c +++ b/drivers/rtc/rtc-ds1216.c | |||
@@ -167,34 +167,17 @@ static int __init ds1216_rtc_probe(struct platform_device *pdev) | |||
167 | return 0; | 167 | return 0; |
168 | } | 168 | } |
169 | 169 | ||
170 | static int __exit ds1216_rtc_remove(struct platform_device *pdev) | ||
171 | { | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static struct platform_driver ds1216_rtc_platform_driver = { | 170 | static struct platform_driver ds1216_rtc_platform_driver = { |
176 | .driver = { | 171 | .driver = { |
177 | .name = "rtc-ds1216", | 172 | .name = "rtc-ds1216", |
178 | .owner = THIS_MODULE, | 173 | .owner = THIS_MODULE, |
179 | }, | 174 | }, |
180 | .remove = __exit_p(ds1216_rtc_remove), | ||
181 | }; | 175 | }; |
182 | 176 | ||
183 | static int __init ds1216_rtc_init(void) | 177 | module_platform_driver_probe(ds1216_rtc_platform_driver, ds1216_rtc_probe); |
184 | { | ||
185 | return platform_driver_probe(&ds1216_rtc_platform_driver, ds1216_rtc_probe); | ||
186 | } | ||
187 | |||
188 | static void __exit ds1216_rtc_exit(void) | ||
189 | { | ||
190 | platform_driver_unregister(&ds1216_rtc_platform_driver); | ||
191 | } | ||
192 | 178 | ||
193 | MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>"); | 179 | MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>"); |
194 | MODULE_DESCRIPTION("DS1216 RTC driver"); | 180 | MODULE_DESCRIPTION("DS1216 RTC driver"); |
195 | MODULE_LICENSE("GPL"); | 181 | MODULE_LICENSE("GPL"); |
196 | MODULE_VERSION(DRV_VERSION); | 182 | MODULE_VERSION(DRV_VERSION); |
197 | MODULE_ALIAS("platform:rtc-ds1216"); | 183 | MODULE_ALIAS("platform:rtc-ds1216"); |
198 | |||
199 | module_init(ds1216_rtc_init); | ||
200 | module_exit(ds1216_rtc_exit); | ||
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index 398c96a98fc4..50e109b78252 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c | |||
@@ -353,18 +353,12 @@ static int ds1286_probe(struct platform_device *pdev) | |||
353 | return 0; | 353 | return 0; |
354 | } | 354 | } |
355 | 355 | ||
356 | static int ds1286_remove(struct platform_device *pdev) | ||
357 | { | ||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | static struct platform_driver ds1286_platform_driver = { | 356 | static struct platform_driver ds1286_platform_driver = { |
362 | .driver = { | 357 | .driver = { |
363 | .name = "rtc-ds1286", | 358 | .name = "rtc-ds1286", |
364 | .owner = THIS_MODULE, | 359 | .owner = THIS_MODULE, |
365 | }, | 360 | }, |
366 | .probe = ds1286_probe, | 361 | .probe = ds1286_probe, |
367 | .remove = ds1286_remove, | ||
368 | }; | 362 | }; |
369 | 363 | ||
370 | module_platform_driver(ds1286_platform_driver); | 364 | module_platform_driver(ds1286_platform_driver); |
diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index d13954346286..07e8d79b4a09 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c | |||
@@ -23,8 +23,12 @@ | |||
23 | #define RTC_CMD_READ 0x81 /* Read command */ | 23 | #define RTC_CMD_READ 0x81 /* Read command */ |
24 | #define RTC_CMD_WRITE 0x80 /* Write command */ | 24 | #define RTC_CMD_WRITE 0x80 /* Write command */ |
25 | 25 | ||
26 | #define RTC_CMD_WRITE_ENABLE 0x00 /* Write enable */ | ||
27 | #define RTC_CMD_WRITE_DISABLE 0x80 /* Write disable */ | ||
28 | |||
26 | #define RTC_ADDR_RAM0 0x20 /* Address of RAM0 */ | 29 | #define RTC_ADDR_RAM0 0x20 /* Address of RAM0 */ |
27 | #define RTC_ADDR_TCR 0x08 /* Address of trickle charge register */ | 30 | #define RTC_ADDR_TCR 0x08 /* Address of trickle charge register */ |
31 | #define RTC_ADDR_CTRL 0x07 /* Address of control register */ | ||
28 | #define RTC_ADDR_YEAR 0x06 /* Address of year register */ | 32 | #define RTC_ADDR_YEAR 0x06 /* Address of year register */ |
29 | #define RTC_ADDR_DAY 0x05 /* Address of day of week register */ | 33 | #define RTC_ADDR_DAY 0x05 /* Address of day of week register */ |
30 | #define RTC_ADDR_MON 0x04 /* Address of month register */ | 34 | #define RTC_ADDR_MON 0x04 /* Address of month register */ |
@@ -161,6 +165,7 @@ static int ds1302_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
161 | 165 | ||
162 | static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) | 166 | static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) |
163 | { | 167 | { |
168 | ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_ENABLE); | ||
164 | /* Stop RTC */ | 169 | /* Stop RTC */ |
165 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); | 170 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); |
166 | 171 | ||
@@ -175,6 +180,8 @@ static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
175 | /* Start RTC */ | 180 | /* Start RTC */ |
176 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80); | 181 | ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80); |
177 | 182 | ||
183 | ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_DISABLE); | ||
184 | |||
178 | return 0; | 185 | return 0; |
179 | } | 186 | } |
180 | 187 | ||
@@ -234,19 +241,11 @@ static int __init ds1302_rtc_probe(struct platform_device *pdev) | |||
234 | return 0; | 241 | return 0; |
235 | } | 242 | } |
236 | 243 | ||
237 | static int __exit ds1302_rtc_remove(struct platform_device *pdev) | ||
238 | { | ||
239 | platform_set_drvdata(pdev, NULL); | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | |||
244 | static struct platform_driver ds1302_platform_driver = { | 244 | static struct platform_driver ds1302_platform_driver = { |
245 | .driver = { | 245 | .driver = { |
246 | .name = DRV_NAME, | 246 | .name = DRV_NAME, |
247 | .owner = THIS_MODULE, | 247 | .owner = THIS_MODULE, |
248 | }, | 248 | }, |
249 | .remove = __exit_p(ds1302_rtc_remove), | ||
250 | }; | 249 | }; |
251 | 250 | ||
252 | module_platform_driver_probe(ds1302_platform_driver, ds1302_rtc_probe); | 251 | module_platform_driver_probe(ds1302_platform_driver, ds1302_rtc_probe); |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index bb5f13f63630..dd6170acde95 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -158,7 +158,7 @@ static int ds1305_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
158 | goto done; | 158 | goto done; |
159 | buf[1] &= ~DS1305_AEI0; | 159 | buf[1] &= ~DS1305_AEI0; |
160 | } | 160 | } |
161 | err = spi_write_then_read(ds1305->spi, buf, sizeof buf, NULL, 0); | 161 | err = spi_write_then_read(ds1305->spi, buf, sizeof(buf), NULL, 0); |
162 | if (err >= 0) | 162 | if (err >= 0) |
163 | ds1305->ctrl[0] = buf[1]; | 163 | ds1305->ctrl[0] = buf[1]; |
164 | done: | 164 | done: |
@@ -181,8 +181,8 @@ static int ds1305_get_time(struct device *dev, struct rtc_time *time) | |||
181 | /* Use write-then-read to get all the date/time registers | 181 | /* Use write-then-read to get all the date/time registers |
182 | * since dma from stack is nonportable | 182 | * since dma from stack is nonportable |
183 | */ | 183 | */ |
184 | status = spi_write_then_read(ds1305->spi, &addr, sizeof addr, | 184 | status = spi_write_then_read(ds1305->spi, &addr, sizeof(addr), |
185 | buf, sizeof buf); | 185 | buf, sizeof(buf)); |
186 | if (status < 0) | 186 | if (status < 0) |
187 | return status; | 187 | return status; |
188 | 188 | ||
@@ -237,7 +237,7 @@ static int ds1305_set_time(struct device *dev, struct rtc_time *time) | |||
237 | buf[4], buf[5], buf[6], buf[7]); | 237 | buf[4], buf[5], buf[6], buf[7]); |
238 | 238 | ||
239 | /* use write-then-read since dma from stack is nonportable */ | 239 | /* use write-then-read since dma from stack is nonportable */ |
240 | return spi_write_then_read(ds1305->spi, buf, sizeof buf, | 240 | return spi_write_then_read(ds1305->spi, buf, sizeof(buf), |
241 | NULL, 0); | 241 | NULL, 0); |
242 | } | 242 | } |
243 | 243 | ||
@@ -286,8 +286,8 @@ static int ds1305_get_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
286 | * of EFI status is at best fragile anyway (given IRQ handlers). | 286 | * of EFI status is at best fragile anyway (given IRQ handlers). |
287 | */ | 287 | */ |
288 | addr = DS1305_CONTROL; | 288 | addr = DS1305_CONTROL; |
289 | status = spi_write_then_read(spi, &addr, sizeof addr, | 289 | status = spi_write_then_read(spi, &addr, sizeof(addr), |
290 | ds1305->ctrl, sizeof ds1305->ctrl); | 290 | ds1305->ctrl, sizeof(ds1305->ctrl)); |
291 | if (status < 0) | 291 | if (status < 0) |
292 | return status; | 292 | return status; |
293 | 293 | ||
@@ -296,8 +296,8 @@ static int ds1305_get_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
296 | 296 | ||
297 | /* get and check ALM0 registers */ | 297 | /* get and check ALM0 registers */ |
298 | addr = DS1305_ALM0(DS1305_SEC); | 298 | addr = DS1305_ALM0(DS1305_SEC); |
299 | status = spi_write_then_read(spi, &addr, sizeof addr, | 299 | status = spi_write_then_read(spi, &addr, sizeof(addr), |
300 | buf, sizeof buf); | 300 | buf, sizeof(buf)); |
301 | if (status < 0) | 301 | if (status < 0) |
302 | return status; | 302 | return status; |
303 | 303 | ||
@@ -381,7 +381,7 @@ static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
381 | "alm0 write", buf[1 + DS1305_SEC], buf[1 + DS1305_MIN], | 381 | "alm0 write", buf[1 + DS1305_SEC], buf[1 + DS1305_MIN], |
382 | buf[1 + DS1305_HOUR], buf[1 + DS1305_WDAY]); | 382 | buf[1 + DS1305_HOUR], buf[1 + DS1305_WDAY]); |
383 | 383 | ||
384 | status = spi_write_then_read(spi, buf, sizeof buf, NULL, 0); | 384 | status = spi_write_then_read(spi, buf, sizeof(buf), NULL, 0); |
385 | if (status < 0) | 385 | if (status < 0) |
386 | return status; | 386 | return status; |
387 | 387 | ||
@@ -474,7 +474,7 @@ static void ds1305_work(struct work_struct *work) | |||
474 | buf[1] = ds1305->ctrl[0]; | 474 | buf[1] = ds1305->ctrl[0]; |
475 | buf[2] = 0; | 475 | buf[2] = 0; |
476 | 476 | ||
477 | status = spi_write_then_read(spi, buf, sizeof buf, | 477 | status = spi_write_then_read(spi, buf, sizeof(buf), |
478 | NULL, 0); | 478 | NULL, 0); |
479 | if (status < 0) | 479 | if (status < 0) |
480 | dev_dbg(&spi->dev, "clear irq --> %d\n", status); | 480 | dev_dbg(&spi->dev, "clear irq --> %d\n", status); |
@@ -627,8 +627,8 @@ static int ds1305_probe(struct spi_device *spi) | |||
627 | 627 | ||
628 | /* read and cache control registers */ | 628 | /* read and cache control registers */ |
629 | addr = DS1305_CONTROL; | 629 | addr = DS1305_CONTROL; |
630 | status = spi_write_then_read(spi, &addr, sizeof addr, | 630 | status = spi_write_then_read(spi, &addr, sizeof(addr), |
631 | ds1305->ctrl, sizeof ds1305->ctrl); | 631 | ds1305->ctrl, sizeof(ds1305->ctrl)); |
632 | if (status < 0) { | 632 | if (status < 0) { |
633 | dev_dbg(&spi->dev, "can't %s, %d\n", | 633 | dev_dbg(&spi->dev, "can't %s, %d\n", |
634 | "read", status); | 634 | "read", status); |
@@ -659,7 +659,7 @@ static int ds1305_probe(struct spi_device *spi) | |||
659 | 659 | ||
660 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | 660 | buf[0] = DS1305_WRITE | DS1305_CONTROL; |
661 | buf[1] = ds1305->ctrl[0]; | 661 | buf[1] = ds1305->ctrl[0]; |
662 | status = spi_write_then_read(spi, buf, sizeof buf, NULL, 0); | 662 | status = spi_write_then_read(spi, buf, sizeof(buf), NULL, 0); |
663 | 663 | ||
664 | dev_dbg(&spi->dev, "clear WP --> %d\n", status); | 664 | dev_dbg(&spi->dev, "clear WP --> %d\n", status); |
665 | if (status < 0) | 665 | if (status < 0) |
@@ -713,7 +713,7 @@ static int ds1305_probe(struct spi_device *spi) | |||
713 | buf[1] = ds1305->ctrl[0]; | 713 | buf[1] = ds1305->ctrl[0]; |
714 | buf[2] = ds1305->ctrl[1]; | 714 | buf[2] = ds1305->ctrl[1]; |
715 | buf[3] = ds1305->ctrl[2]; | 715 | buf[3] = ds1305->ctrl[2]; |
716 | status = spi_write_then_read(spi, buf, sizeof buf, NULL, 0); | 716 | status = spi_write_then_read(spi, buf, sizeof(buf), NULL, 0); |
717 | if (status < 0) { | 717 | if (status < 0) { |
718 | dev_dbg(&spi->dev, "can't %s, %d\n", | 718 | dev_dbg(&spi->dev, "can't %s, %d\n", |
719 | "write", status); | 719 | "write", status); |
@@ -725,8 +725,8 @@ static int ds1305_probe(struct spi_device *spi) | |||
725 | 725 | ||
726 | /* see if non-Linux software set up AM/PM mode */ | 726 | /* see if non-Linux software set up AM/PM mode */ |
727 | addr = DS1305_HOUR; | 727 | addr = DS1305_HOUR; |
728 | status = spi_write_then_read(spi, &addr, sizeof addr, | 728 | status = spi_write_then_read(spi, &addr, sizeof(addr), |
729 | &value, sizeof value); | 729 | &value, sizeof(value)); |
730 | if (status < 0) { | 730 | if (status < 0) { |
731 | dev_dbg(&spi->dev, "read HOUR --> %d\n", status); | 731 | dev_dbg(&spi->dev, "read HOUR --> %d\n", status); |
732 | return status; | 732 | return status; |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index b53992ab3090..ca18fd1433b3 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -683,7 +683,7 @@ static int ds1307_probe(struct i2c_client *client, | |||
683 | && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) | 683 | && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) |
684 | return -EIO; | 684 | return -EIO; |
685 | 685 | ||
686 | ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL); | 686 | ds1307 = devm_kzalloc(&client->dev, sizeof(struct ds1307), GFP_KERNEL); |
687 | if (!ds1307) | 687 | if (!ds1307) |
688 | return -ENOMEM; | 688 | return -ENOMEM; |
689 | 689 | ||
@@ -715,7 +715,7 @@ static int ds1307_probe(struct i2c_client *client, | |||
715 | if (tmp != 2) { | 715 | if (tmp != 2) { |
716 | dev_dbg(&client->dev, "read error %d\n", tmp); | 716 | dev_dbg(&client->dev, "read error %d\n", tmp); |
717 | err = -EIO; | 717 | err = -EIO; |
718 | goto exit_free; | 718 | goto exit; |
719 | } | 719 | } |
720 | 720 | ||
721 | /* oscillator off? turn it on, so clock can tick. */ | 721 | /* oscillator off? turn it on, so clock can tick. */ |
@@ -754,7 +754,7 @@ static int ds1307_probe(struct i2c_client *client, | |||
754 | if (tmp != 2) { | 754 | if (tmp != 2) { |
755 | dev_dbg(&client->dev, "read error %d\n", tmp); | 755 | dev_dbg(&client->dev, "read error %d\n", tmp); |
756 | err = -EIO; | 756 | err = -EIO; |
757 | goto exit_free; | 757 | goto exit; |
758 | } | 758 | } |
759 | 759 | ||
760 | /* oscillator off? turn it on, so clock can tick. */ | 760 | /* oscillator off? turn it on, so clock can tick. */ |
@@ -798,7 +798,7 @@ static int ds1307_probe(struct i2c_client *client, | |||
798 | if (tmp != 2) { | 798 | if (tmp != 2) { |
799 | dev_dbg(&client->dev, "read error %d\n", tmp); | 799 | dev_dbg(&client->dev, "read error %d\n", tmp); |
800 | err = -EIO; | 800 | err = -EIO; |
801 | goto exit_free; | 801 | goto exit; |
802 | } | 802 | } |
803 | 803 | ||
804 | /* correct hour */ | 804 | /* correct hour */ |
@@ -826,7 +826,7 @@ read_rtc: | |||
826 | if (tmp != 8) { | 826 | if (tmp != 8) { |
827 | dev_dbg(&client->dev, "read error %d\n", tmp); | 827 | dev_dbg(&client->dev, "read error %d\n", tmp); |
828 | err = -EIO; | 828 | err = -EIO; |
829 | goto exit_free; | 829 | goto exit; |
830 | } | 830 | } |
831 | 831 | ||
832 | /* | 832 | /* |
@@ -868,7 +868,7 @@ read_rtc: | |||
868 | if (tmp < 0) { | 868 | if (tmp < 0) { |
869 | dev_dbg(&client->dev, "read error %d\n", tmp); | 869 | dev_dbg(&client->dev, "read error %d\n", tmp); |
870 | err = -EIO; | 870 | err = -EIO; |
871 | goto exit_free; | 871 | goto exit; |
872 | } | 872 | } |
873 | 873 | ||
874 | /* oscillator fault? clear flag, and warn */ | 874 | /* oscillator fault? clear flag, and warn */ |
@@ -927,13 +927,13 @@ read_rtc: | |||
927 | bin2bcd(tmp)); | 927 | bin2bcd(tmp)); |
928 | } | 928 | } |
929 | 929 | ||
930 | ds1307->rtc = rtc_device_register(client->name, &client->dev, | 930 | ds1307->rtc = devm_rtc_device_register(&client->dev, client->name, |
931 | &ds13xx_rtc_ops, THIS_MODULE); | 931 | &ds13xx_rtc_ops, THIS_MODULE); |
932 | if (IS_ERR(ds1307->rtc)) { | 932 | if (IS_ERR(ds1307->rtc)) { |
933 | err = PTR_ERR(ds1307->rtc); | 933 | err = PTR_ERR(ds1307->rtc); |
934 | dev_err(&client->dev, | 934 | dev_err(&client->dev, |
935 | "unable to register the class device\n"); | 935 | "unable to register the class device\n"); |
936 | goto exit_free; | 936 | goto exit; |
937 | } | 937 | } |
938 | 938 | ||
939 | if (want_irq) { | 939 | if (want_irq) { |
@@ -942,7 +942,7 @@ read_rtc: | |||
942 | if (err) { | 942 | if (err) { |
943 | dev_err(&client->dev, | 943 | dev_err(&client->dev, |
944 | "unable to request IRQ!\n"); | 944 | "unable to request IRQ!\n"); |
945 | goto exit_irq; | 945 | goto exit; |
946 | } | 946 | } |
947 | 947 | ||
948 | device_set_wakeup_capable(&client->dev, 1); | 948 | device_set_wakeup_capable(&client->dev, 1); |
@@ -951,11 +951,12 @@ read_rtc: | |||
951 | } | 951 | } |
952 | 952 | ||
953 | if (chip->nvram_size) { | 953 | if (chip->nvram_size) { |
954 | ds1307->nvram = kzalloc(sizeof(struct bin_attribute), | 954 | ds1307->nvram = devm_kzalloc(&client->dev, |
955 | GFP_KERNEL); | 955 | sizeof(struct bin_attribute), |
956 | GFP_KERNEL); | ||
956 | if (!ds1307->nvram) { | 957 | if (!ds1307->nvram) { |
957 | err = -ENOMEM; | 958 | err = -ENOMEM; |
958 | goto exit_nvram; | 959 | goto exit; |
959 | } | 960 | } |
960 | ds1307->nvram->attr.name = "nvram"; | 961 | ds1307->nvram->attr.name = "nvram"; |
961 | ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR; | 962 | ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR; |
@@ -965,21 +966,15 @@ read_rtc: | |||
965 | ds1307->nvram->size = chip->nvram_size; | 966 | ds1307->nvram->size = chip->nvram_size; |
966 | ds1307->nvram_offset = chip->nvram_offset; | 967 | ds1307->nvram_offset = chip->nvram_offset; |
967 | err = sysfs_create_bin_file(&client->dev.kobj, ds1307->nvram); | 968 | err = sysfs_create_bin_file(&client->dev.kobj, ds1307->nvram); |
968 | if (err) { | 969 | if (err) |
969 | kfree(ds1307->nvram); | 970 | goto exit; |
970 | goto exit_nvram; | ||
971 | } | ||
972 | set_bit(HAS_NVRAM, &ds1307->flags); | 971 | set_bit(HAS_NVRAM, &ds1307->flags); |
973 | dev_info(&client->dev, "%zu bytes nvram\n", ds1307->nvram->size); | 972 | dev_info(&client->dev, "%zu bytes nvram\n", ds1307->nvram->size); |
974 | } | 973 | } |
975 | 974 | ||
976 | return 0; | 975 | return 0; |
977 | 976 | ||
978 | exit_nvram: | 977 | exit: |
979 | exit_irq: | ||
980 | rtc_device_unregister(ds1307->rtc); | ||
981 | exit_free: | ||
982 | kfree(ds1307); | ||
983 | return err; | 978 | return err; |
984 | } | 979 | } |
985 | 980 | ||
@@ -992,13 +987,9 @@ static int ds1307_remove(struct i2c_client *client) | |||
992 | cancel_work_sync(&ds1307->work); | 987 | cancel_work_sync(&ds1307->work); |
993 | } | 988 | } |
994 | 989 | ||
995 | if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) { | 990 | if (test_and_clear_bit(HAS_NVRAM, &ds1307->flags)) |
996 | sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram); | 991 | sysfs_remove_bin_file(&client->dev.kobj, ds1307->nvram); |
997 | kfree(ds1307->nvram); | ||
998 | } | ||
999 | 992 | ||
1000 | rtc_device_unregister(ds1307->rtc); | ||
1001 | kfree(ds1307); | ||
1002 | return 0; | 993 | return 0; |
1003 | } | 994 | } |
1004 | 995 | ||
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 94366e12f40f..9e6e14fb53d7 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -65,7 +65,7 @@ struct ds1374 { | |||
65 | static struct i2c_driver ds1374_driver; | 65 | static struct i2c_driver ds1374_driver; |
66 | 66 | ||
67 | static int ds1374_read_rtc(struct i2c_client *client, u32 *time, | 67 | static int ds1374_read_rtc(struct i2c_client *client, u32 *time, |
68 | int reg, int nbytes) | 68 | int reg, int nbytes) |
69 | { | 69 | { |
70 | u8 buf[4]; | 70 | u8 buf[4]; |
71 | int ret; | 71 | int ret; |
@@ -90,7 +90,7 @@ static int ds1374_read_rtc(struct i2c_client *client, u32 *time, | |||
90 | } | 90 | } |
91 | 91 | ||
92 | static int ds1374_write_rtc(struct i2c_client *client, u32 time, | 92 | static int ds1374_write_rtc(struct i2c_client *client, u32 time, |
93 | int reg, int nbytes) | 93 | int reg, int nbytes) |
94 | { | 94 | { |
95 | u8 buf[4]; | 95 | u8 buf[4]; |
96 | int i; | 96 | int i; |
@@ -119,8 +119,7 @@ static int ds1374_check_rtc_status(struct i2c_client *client) | |||
119 | 119 | ||
120 | if (stat & DS1374_REG_SR_OSF) | 120 | if (stat & DS1374_REG_SR_OSF) |
121 | dev_warn(&client->dev, | 121 | dev_warn(&client->dev, |
122 | "oscillator discontinuity flagged, " | 122 | "oscillator discontinuity flagged, time unreliable\n"); |
123 | "time unreliable\n"); | ||
124 | 123 | ||
125 | stat &= ~(DS1374_REG_SR_OSF | DS1374_REG_SR_AF); | 124 | stat &= ~(DS1374_REG_SR_OSF | DS1374_REG_SR_AF); |
126 | 125 | ||
@@ -363,7 +362,7 @@ static int ds1374_probe(struct i2c_client *client, | |||
363 | 362 | ||
364 | if (client->irq > 0) { | 363 | if (client->irq > 0) { |
365 | ret = devm_request_irq(&client->dev, client->irq, ds1374_irq, 0, | 364 | ret = devm_request_irq(&client->dev, client->irq, ds1374_irq, 0, |
366 | "ds1374", client); | 365 | "ds1374", client); |
367 | if (ret) { | 366 | if (ret) { |
368 | dev_err(&client->dev, "unable to request IRQ\n"); | 367 | dev_err(&client->dev, "unable to request IRQ\n"); |
369 | return ret; | 368 | return ret; |
@@ -373,7 +372,7 @@ static int ds1374_probe(struct i2c_client *client, | |||
373 | } | 372 | } |
374 | 373 | ||
375 | ds1374->rtc = devm_rtc_device_register(&client->dev, client->name, | 374 | ds1374->rtc = devm_rtc_device_register(&client->dev, client->name, |
376 | &ds1374_rtc_ops, THIS_MODULE); | 375 | &ds1374_rtc_ops, THIS_MODULE); |
377 | if (IS_ERR(ds1374->rtc)) { | 376 | if (IS_ERR(ds1374->rtc)) { |
378 | dev_err(&client->dev, "unable to register the class device\n"); | 377 | dev_err(&client->dev, "unable to register the class device\n"); |
379 | return PTR_ERR(ds1374->rtc); | 378 | return PTR_ERR(ds1374->rtc); |
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c index 289af419dff4..be9d8c0a7e3a 100644 --- a/drivers/rtc/rtc-ds1390.c +++ b/drivers/rtc/rtc-ds1390.c | |||
@@ -154,18 +154,12 @@ static int ds1390_probe(struct spi_device *spi) | |||
154 | return res; | 154 | return res; |
155 | } | 155 | } |
156 | 156 | ||
157 | static int ds1390_remove(struct spi_device *spi) | ||
158 | { | ||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | static struct spi_driver ds1390_driver = { | 157 | static struct spi_driver ds1390_driver = { |
163 | .driver = { | 158 | .driver = { |
164 | .name = "rtc-ds1390", | 159 | .name = "rtc-ds1390", |
165 | .owner = THIS_MODULE, | 160 | .owner = THIS_MODULE, |
166 | }, | 161 | }, |
167 | .probe = ds1390_probe, | 162 | .probe = ds1390_probe, |
168 | .remove = ds1390_remove, | ||
169 | }; | 163 | }; |
170 | 164 | ||
171 | module_spi_driver(ds1390_driver); | 165 | module_spi_driver(ds1390_driver); |
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 6ce8a997cf51..308a8fefe76f 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -104,31 +104,31 @@ static DEFINE_SPINLOCK(ds1511_lock); | |||
104 | static __iomem char *ds1511_base; | 104 | static __iomem char *ds1511_base; |
105 | static u32 reg_spacing = 1; | 105 | static u32 reg_spacing = 1; |
106 | 106 | ||
107 | static noinline void | 107 | static noinline void |
108 | rtc_write(uint8_t val, uint32_t reg) | 108 | rtc_write(uint8_t val, uint32_t reg) |
109 | { | 109 | { |
110 | writeb(val, ds1511_base + (reg * reg_spacing)); | 110 | writeb(val, ds1511_base + (reg * reg_spacing)); |
111 | } | 111 | } |
112 | 112 | ||
113 | static inline void | 113 | static inline void |
114 | rtc_write_alarm(uint8_t val, enum ds1511reg reg) | 114 | rtc_write_alarm(uint8_t val, enum ds1511reg reg) |
115 | { | 115 | { |
116 | rtc_write((val | 0x80), reg); | 116 | rtc_write((val | 0x80), reg); |
117 | } | 117 | } |
118 | 118 | ||
119 | static noinline uint8_t | 119 | static noinline uint8_t |
120 | rtc_read(enum ds1511reg reg) | 120 | rtc_read(enum ds1511reg reg) |
121 | { | 121 | { |
122 | return readb(ds1511_base + (reg * reg_spacing)); | 122 | return readb(ds1511_base + (reg * reg_spacing)); |
123 | } | 123 | } |
124 | 124 | ||
125 | static inline void | 125 | static inline void |
126 | rtc_disable_update(void) | 126 | rtc_disable_update(void) |
127 | { | 127 | { |
128 | rtc_write((rtc_read(RTC_CMD) & ~RTC_TE), RTC_CMD); | 128 | rtc_write((rtc_read(RTC_CMD) & ~RTC_TE), RTC_CMD); |
129 | } | 129 | } |
130 | 130 | ||
131 | static void | 131 | static void |
132 | rtc_enable_update(void) | 132 | rtc_enable_update(void) |
133 | { | 133 | { |
134 | rtc_write((rtc_read(RTC_CMD) | RTC_TE), RTC_CMD); | 134 | rtc_write((rtc_read(RTC_CMD) | RTC_TE), RTC_CMD); |
@@ -145,7 +145,7 @@ rtc_enable_update(void) | |||
145 | * just enough code to set the watchdog timer so that it | 145 | * just enough code to set the watchdog timer so that it |
146 | * will reboot the system | 146 | * will reboot the system |
147 | */ | 147 | */ |
148 | void | 148 | void |
149 | ds1511_wdog_set(unsigned long deciseconds) | 149 | ds1511_wdog_set(unsigned long deciseconds) |
150 | { | 150 | { |
151 | /* | 151 | /* |
@@ -163,7 +163,7 @@ ds1511_wdog_set(unsigned long deciseconds) | |||
163 | rtc_write(DS1511_WDE | DS1511_WDS, RTC_CMD); | 163 | rtc_write(DS1511_WDE | DS1511_WDS, RTC_CMD); |
164 | } | 164 | } |
165 | 165 | ||
166 | void | 166 | void |
167 | ds1511_wdog_disable(void) | 167 | ds1511_wdog_disable(void) |
168 | { | 168 | { |
169 | /* | 169 | /* |
@@ -191,13 +191,12 @@ static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm) | |||
191 | /* | 191 | /* |
192 | * won't have to change this for a while | 192 | * won't have to change this for a while |
193 | */ | 193 | */ |
194 | if (rtc_tm->tm_year < 1900) { | 194 | if (rtc_tm->tm_year < 1900) |
195 | rtc_tm->tm_year += 1900; | 195 | rtc_tm->tm_year += 1900; |
196 | } | ||
197 | 196 | ||
198 | if (rtc_tm->tm_year < 1970) { | 197 | if (rtc_tm->tm_year < 1970) |
199 | return -EINVAL; | 198 | return -EINVAL; |
200 | } | 199 | |
201 | yrs = rtc_tm->tm_year % 100; | 200 | yrs = rtc_tm->tm_year % 100; |
202 | cen = rtc_tm->tm_year / 100; | 201 | cen = rtc_tm->tm_year / 100; |
203 | mon = rtc_tm->tm_mon + 1; /* tm_mon starts at zero */ | 202 | mon = rtc_tm->tm_mon + 1; /* tm_mon starts at zero */ |
@@ -207,17 +206,14 @@ static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm) | |||
207 | min = rtc_tm->tm_min; | 206 | min = rtc_tm->tm_min; |
208 | sec = rtc_tm->tm_sec; | 207 | sec = rtc_tm->tm_sec; |
209 | 208 | ||
210 | if ((mon > 12) || (day == 0)) { | 209 | if ((mon > 12) || (day == 0)) |
211 | return -EINVAL; | 210 | return -EINVAL; |
212 | } | ||
213 | 211 | ||
214 | if (day > rtc_month_days(rtc_tm->tm_mon, rtc_tm->tm_year)) { | 212 | if (day > rtc_month_days(rtc_tm->tm_mon, rtc_tm->tm_year)) |
215 | return -EINVAL; | 213 | return -EINVAL; |
216 | } | ||
217 | 214 | ||
218 | if ((hrs >= 24) || (min >= 60) || (sec >= 60)) { | 215 | if ((hrs >= 24) || (min >= 60) || (sec >= 60)) |
219 | return -EINVAL; | 216 | return -EINVAL; |
220 | } | ||
221 | 217 | ||
222 | /* | 218 | /* |
223 | * each register is a different number of valid bits | 219 | * each register is a different number of valid bits |
@@ -299,7 +295,7 @@ static int ds1511_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) | |||
299 | * date/hours/mins/secs matches. the ds1511 has many more | 295 | * date/hours/mins/secs matches. the ds1511 has many more |
300 | * permutations, but the kernel doesn't. | 296 | * permutations, but the kernel doesn't. |
301 | */ | 297 | */ |
302 | static void | 298 | static void |
303 | ds1511_rtc_update_alarm(struct rtc_plat_data *pdata) | 299 | ds1511_rtc_update_alarm(struct rtc_plat_data *pdata) |
304 | { | 300 | { |
305 | unsigned long flags; | 301 | unsigned long flags; |
@@ -322,7 +318,7 @@ ds1511_rtc_update_alarm(struct rtc_plat_data *pdata) | |||
322 | spin_unlock_irqrestore(&pdata->lock, flags); | 318 | spin_unlock_irqrestore(&pdata->lock, flags); |
323 | } | 319 | } |
324 | 320 | ||
325 | static int | 321 | static int |
326 | ds1511_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 322 | ds1511_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
327 | { | 323 | { |
328 | struct platform_device *pdev = to_platform_device(dev); | 324 | struct platform_device *pdev = to_platform_device(dev); |
@@ -335,14 +331,14 @@ ds1511_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
335 | pdata->alrm_hour = alrm->time.tm_hour; | 331 | pdata->alrm_hour = alrm->time.tm_hour; |
336 | pdata->alrm_min = alrm->time.tm_min; | 332 | pdata->alrm_min = alrm->time.tm_min; |
337 | pdata->alrm_sec = alrm->time.tm_sec; | 333 | pdata->alrm_sec = alrm->time.tm_sec; |
338 | if (alrm->enabled) { | 334 | if (alrm->enabled) |
339 | pdata->irqen |= RTC_AF; | 335 | pdata->irqen |= RTC_AF; |
340 | } | 336 | |
341 | ds1511_rtc_update_alarm(pdata); | 337 | ds1511_rtc_update_alarm(pdata); |
342 | return 0; | 338 | return 0; |
343 | } | 339 | } |
344 | 340 | ||
345 | static int | 341 | static int |
346 | ds1511_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 342 | ds1511_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
347 | { | 343 | { |
348 | struct platform_device *pdev = to_platform_device(dev); | 344 | struct platform_device *pdev = to_platform_device(dev); |
@@ -359,7 +355,7 @@ ds1511_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
359 | return 0; | 355 | return 0; |
360 | } | 356 | } |
361 | 357 | ||
362 | static irqreturn_t | 358 | static irqreturn_t |
363 | ds1511_interrupt(int irq, void *dev_id) | 359 | ds1511_interrupt(int irq, void *dev_id) |
364 | { | 360 | { |
365 | struct platform_device *pdev = dev_id; | 361 | struct platform_device *pdev = dev_id; |
@@ -406,7 +402,7 @@ static const struct rtc_class_ops ds1511_rtc_ops = { | |||
406 | .alarm_irq_enable = ds1511_rtc_alarm_irq_enable, | 402 | .alarm_irq_enable = ds1511_rtc_alarm_irq_enable, |
407 | }; | 403 | }; |
408 | 404 | ||
409 | static ssize_t | 405 | static ssize_t |
410 | ds1511_nvram_read(struct file *filp, struct kobject *kobj, | 406 | ds1511_nvram_read(struct file *filp, struct kobject *kobj, |
411 | struct bin_attribute *ba, | 407 | struct bin_attribute *ba, |
412 | char *buf, loff_t pos, size_t size) | 408 | char *buf, loff_t pos, size_t size) |
@@ -417,26 +413,26 @@ ds1511_nvram_read(struct file *filp, struct kobject *kobj, | |||
417 | * if count is more than one, turn on "burst" mode | 413 | * if count is more than one, turn on "burst" mode |
418 | * turn it off when you're done | 414 | * turn it off when you're done |
419 | */ | 415 | */ |
420 | if (size > 1) { | 416 | if (size > 1) |
421 | rtc_write((rtc_read(RTC_CMD) | DS1511_BME), RTC_CMD); | 417 | rtc_write((rtc_read(RTC_CMD) | DS1511_BME), RTC_CMD); |
422 | } | 418 | |
423 | if (pos > DS1511_RAM_MAX) { | 419 | if (pos > DS1511_RAM_MAX) |
424 | pos = DS1511_RAM_MAX; | 420 | pos = DS1511_RAM_MAX; |
425 | } | 421 | |
426 | if (size + pos > DS1511_RAM_MAX + 1) { | 422 | if (size + pos > DS1511_RAM_MAX + 1) |
427 | size = DS1511_RAM_MAX - pos + 1; | 423 | size = DS1511_RAM_MAX - pos + 1; |
428 | } | 424 | |
429 | rtc_write(pos, DS1511_RAMADDR_LSB); | 425 | rtc_write(pos, DS1511_RAMADDR_LSB); |
430 | for (count = 0; size > 0; count++, size--) { | 426 | for (count = 0; size > 0; count++, size--) |
431 | *buf++ = rtc_read(DS1511_RAMDATA); | 427 | *buf++ = rtc_read(DS1511_RAMDATA); |
432 | } | 428 | |
433 | if (count > 1) { | 429 | if (count > 1) |
434 | rtc_write((rtc_read(RTC_CMD) & ~DS1511_BME), RTC_CMD); | 430 | rtc_write((rtc_read(RTC_CMD) & ~DS1511_BME), RTC_CMD); |
435 | } | 431 | |
436 | return count; | 432 | return count; |
437 | } | 433 | } |
438 | 434 | ||
439 | static ssize_t | 435 | static ssize_t |
440 | ds1511_nvram_write(struct file *filp, struct kobject *kobj, | 436 | ds1511_nvram_write(struct file *filp, struct kobject *kobj, |
441 | struct bin_attribute *bin_attr, | 437 | struct bin_attribute *bin_attr, |
442 | char *buf, loff_t pos, size_t size) | 438 | char *buf, loff_t pos, size_t size) |
@@ -447,22 +443,22 @@ ds1511_nvram_write(struct file *filp, struct kobject *kobj, | |||
447 | * if count is more than one, turn on "burst" mode | 443 | * if count is more than one, turn on "burst" mode |
448 | * turn it off when you're done | 444 | * turn it off when you're done |
449 | */ | 445 | */ |
450 | if (size > 1) { | 446 | if (size > 1) |
451 | rtc_write((rtc_read(RTC_CMD) | DS1511_BME), RTC_CMD); | 447 | rtc_write((rtc_read(RTC_CMD) | DS1511_BME), RTC_CMD); |
452 | } | 448 | |
453 | if (pos > DS1511_RAM_MAX) { | 449 | if (pos > DS1511_RAM_MAX) |
454 | pos = DS1511_RAM_MAX; | 450 | pos = DS1511_RAM_MAX; |
455 | } | 451 | |
456 | if (size + pos > DS1511_RAM_MAX + 1) { | 452 | if (size + pos > DS1511_RAM_MAX + 1) |
457 | size = DS1511_RAM_MAX - pos + 1; | 453 | size = DS1511_RAM_MAX - pos + 1; |
458 | } | 454 | |
459 | rtc_write(pos, DS1511_RAMADDR_LSB); | 455 | rtc_write(pos, DS1511_RAMADDR_LSB); |
460 | for (count = 0; size > 0; count++, size--) { | 456 | for (count = 0; size > 0; count++, size--) |
461 | rtc_write(*buf++, DS1511_RAMDATA); | 457 | rtc_write(*buf++, DS1511_RAMDATA); |
462 | } | 458 | |
463 | if (count > 1) { | 459 | if (count > 1) |
464 | rtc_write((rtc_read(RTC_CMD) & ~DS1511_BME), RTC_CMD); | 460 | rtc_write((rtc_read(RTC_CMD) & ~DS1511_BME), RTC_CMD); |
465 | } | 461 | |
466 | return count; | 462 | return count; |
467 | } | 463 | } |
468 | 464 | ||
@@ -484,9 +480,9 @@ static int ds1511_rtc_probe(struct platform_device *pdev) | |||
484 | int ret = 0; | 480 | int ret = 0; |
485 | 481 | ||
486 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 482 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
487 | if (!res) { | 483 | if (!res) |
488 | return -ENODEV; | 484 | return -ENODEV; |
489 | } | 485 | |
490 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | 486 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
491 | if (!pdata) | 487 | if (!pdata) |
492 | return -ENOMEM; | 488 | return -ENOMEM; |
@@ -518,9 +514,8 @@ static int ds1511_rtc_probe(struct platform_device *pdev) | |||
518 | /* | 514 | /* |
519 | * check for a dying bat-tree | 515 | * check for a dying bat-tree |
520 | */ | 516 | */ |
521 | if (rtc_read(RTC_CMD1) & DS1511_BLF1) { | 517 | if (rtc_read(RTC_CMD1) & DS1511_BLF1) |
522 | dev_warn(&pdev->dev, "voltage-low detected.\n"); | 518 | dev_warn(&pdev->dev, "voltage-low detected.\n"); |
523 | } | ||
524 | 519 | ||
525 | spin_lock_init(&pdata->lock); | 520 | spin_lock_init(&pdata->lock); |
526 | platform_set_drvdata(pdev, pdata); | 521 | platform_set_drvdata(pdev, pdata); |
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index 3fc2a4738027..18e2d8471472 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c | |||
@@ -153,11 +153,6 @@ static const struct rtc_class_ops ds1672_rtc_ops = { | |||
153 | .set_mmss = ds1672_rtc_set_mmss, | 153 | .set_mmss = ds1672_rtc_set_mmss, |
154 | }; | 154 | }; |
155 | 155 | ||
156 | static int ds1672_remove(struct i2c_client *client) | ||
157 | { | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static int ds1672_probe(struct i2c_client *client, | 156 | static int ds1672_probe(struct i2c_client *client, |
162 | const struct i2c_device_id *id) | 157 | const struct i2c_device_id *id) |
163 | { | 158 | { |
@@ -210,7 +205,6 @@ static struct i2c_driver ds1672_driver = { | |||
210 | .name = "rtc-ds1672", | 205 | .name = "rtc-ds1672", |
211 | }, | 206 | }, |
212 | .probe = &ds1672_probe, | 207 | .probe = &ds1672_probe, |
213 | .remove = &ds1672_remove, | ||
214 | .id_table = ds1672_id, | 208 | .id_table = ds1672_id, |
215 | }; | 209 | }; |
216 | 210 | ||
diff --git a/drivers/rtc/rtc-ds3234.c b/drivers/rtc/rtc-ds3234.c index ba98c0e9580d..4c9ba5368464 100644 --- a/drivers/rtc/rtc-ds3234.c +++ b/drivers/rtc/rtc-ds3234.c | |||
@@ -73,7 +73,7 @@ static int ds3234_read_time(struct device *dev, struct rtc_time *dt) | |||
73 | dt->tm_wday = bcd2bin(buf[3]) - 1; /* 0 = Sun */ | 73 | dt->tm_wday = bcd2bin(buf[3]) - 1; /* 0 = Sun */ |
74 | dt->tm_mday = bcd2bin(buf[4]); | 74 | dt->tm_mday = bcd2bin(buf[4]); |
75 | dt->tm_mon = bcd2bin(buf[5] & 0x1f) - 1; /* 0 = Jan */ | 75 | dt->tm_mon = bcd2bin(buf[5] & 0x1f) - 1; /* 0 = Jan */ |
76 | dt->tm_year = bcd2bin(buf[6] & 0xff) + 100; /* Assume 20YY */ | 76 | dt->tm_year = bcd2bin(buf[6] & 0xff) + 100; /* Assume 20YY */ |
77 | 77 | ||
78 | return rtc_valid_tm(dt); | 78 | return rtc_valid_tm(dt); |
79 | } | 79 | } |
@@ -156,18 +156,12 @@ static int ds3234_probe(struct spi_device *spi) | |||
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | static int ds3234_remove(struct spi_device *spi) | ||
160 | { | ||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static struct spi_driver ds3234_driver = { | 159 | static struct spi_driver ds3234_driver = { |
165 | .driver = { | 160 | .driver = { |
166 | .name = "ds3234", | 161 | .name = "ds3234", |
167 | .owner = THIS_MODULE, | 162 | .owner = THIS_MODULE, |
168 | }, | 163 | }, |
169 | .probe = ds3234_probe, | 164 | .probe = ds3234_probe, |
170 | .remove = ds3234_remove, | ||
171 | }; | 165 | }; |
172 | 166 | ||
173 | module_spi_driver(ds3234_driver); | 167 | module_spi_driver(ds3234_driver); |
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c index b3c8c0b1709d..797aa0252ba9 100644 --- a/drivers/rtc/rtc-efi.c +++ b/drivers/rtc/rtc-efi.c | |||
@@ -201,17 +201,11 @@ static int __init efi_rtc_probe(struct platform_device *dev) | |||
201 | return 0; | 201 | return 0; |
202 | } | 202 | } |
203 | 203 | ||
204 | static int __exit efi_rtc_remove(struct platform_device *dev) | ||
205 | { | ||
206 | return 0; | ||
207 | } | ||
208 | |||
209 | static struct platform_driver efi_rtc_driver = { | 204 | static struct platform_driver efi_rtc_driver = { |
210 | .driver = { | 205 | .driver = { |
211 | .name = "rtc-efi", | 206 | .name = "rtc-efi", |
212 | .owner = THIS_MODULE, | 207 | .owner = THIS_MODULE, |
213 | }, | 208 | }, |
214 | .remove = __exit_p(efi_rtc_remove), | ||
215 | }; | 209 | }; |
216 | 210 | ||
217 | module_platform_driver_probe(efi_rtc_driver, efi_rtc_probe); | 211 | module_platform_driver_probe(efi_rtc_driver, efi_rtc_probe); |
diff --git a/drivers/rtc/rtc-em3027.c b/drivers/rtc/rtc-em3027.c index 3f9eb57d0486..fccf36699245 100644 --- a/drivers/rtc/rtc-em3027.c +++ b/drivers/rtc/rtc-em3027.c | |||
@@ -131,11 +131,6 @@ static int em3027_probe(struct i2c_client *client, | |||
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | 133 | ||
134 | static int em3027_remove(struct i2c_client *client) | ||
135 | { | ||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | static struct i2c_device_id em3027_id[] = { | 134 | static struct i2c_device_id em3027_id[] = { |
140 | { "em3027", 0 }, | 135 | { "em3027", 0 }, |
141 | { } | 136 | { } |
@@ -146,7 +141,6 @@ static struct i2c_driver em3027_driver = { | |||
146 | .name = "rtc-em3027", | 141 | .name = "rtc-em3027", |
147 | }, | 142 | }, |
148 | .probe = &em3027_probe, | 143 | .probe = &em3027_probe, |
149 | .remove = &em3027_remove, | ||
150 | .id_table = em3027_id, | 144 | .id_table = em3027_id, |
151 | }; | 145 | }; |
152 | 146 | ||
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 5807b77c444a..549b3c3792d2 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
@@ -167,7 +167,6 @@ static int ep93xx_rtc_probe(struct platform_device *pdev) | |||
167 | return 0; | 167 | return 0; |
168 | 168 | ||
169 | exit: | 169 | exit: |
170 | platform_set_drvdata(pdev, NULL); | ||
171 | pdev->dev.platform_data = NULL; | 170 | pdev->dev.platform_data = NULL; |
172 | return err; | 171 | return err; |
173 | } | 172 | } |
@@ -175,7 +174,6 @@ exit: | |||
175 | static int ep93xx_rtc_remove(struct platform_device *pdev) | 174 | static int ep93xx_rtc_remove(struct platform_device *pdev) |
176 | { | 175 | { |
177 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); | 176 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); |
178 | platform_set_drvdata(pdev, NULL); | ||
179 | pdev->dev.platform_data = NULL; | 177 | pdev->dev.platform_data = NULL; |
180 | 178 | ||
181 | return 0; | 179 | return 0; |
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c index 2835fb6c1965..83c3b3029fa7 100644 --- a/drivers/rtc/rtc-fm3130.c +++ b/drivers/rtc/rtc-fm3130.c | |||
@@ -47,7 +47,7 @@ | |||
47 | 47 | ||
48 | struct fm3130 { | 48 | struct fm3130 { |
49 | u8 reg_addr_time; | 49 | u8 reg_addr_time; |
50 | u8 reg_addr_alarm; | 50 | u8 reg_addr_alarm; |
51 | u8 regs[15]; | 51 | u8 regs[15]; |
52 | struct i2c_msg msg[4]; | 52 | struct i2c_msg msg[4]; |
53 | struct i2c_client *client; | 53 | struct i2c_client *client; |
@@ -520,18 +520,12 @@ exit_free: | |||
520 | return err; | 520 | return err; |
521 | } | 521 | } |
522 | 522 | ||
523 | static int fm3130_remove(struct i2c_client *client) | ||
524 | { | ||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | static struct i2c_driver fm3130_driver = { | 523 | static struct i2c_driver fm3130_driver = { |
529 | .driver = { | 524 | .driver = { |
530 | .name = "rtc-fm3130", | 525 | .name = "rtc-fm3130", |
531 | .owner = THIS_MODULE, | 526 | .owner = THIS_MODULE, |
532 | }, | 527 | }, |
533 | .probe = fm3130_probe, | 528 | .probe = fm3130_probe, |
534 | .remove = fm3130_remove, | ||
535 | .id_table = fm3130_id, | 529 | .id_table = fm3130_id, |
536 | }; | 530 | }; |
537 | 531 | ||
diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index 06279ce6bff2..9b6725ebbfb2 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c | |||
@@ -48,17 +48,11 @@ static int __init generic_rtc_probe(struct platform_device *dev) | |||
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | static int __exit generic_rtc_remove(struct platform_device *dev) | ||
52 | { | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | static struct platform_driver generic_rtc_driver = { | 51 | static struct platform_driver generic_rtc_driver = { |
57 | .driver = { | 52 | .driver = { |
58 | .name = "rtc-generic", | 53 | .name = "rtc-generic", |
59 | .owner = THIS_MODULE, | 54 | .owner = THIS_MODULE, |
60 | }, | 55 | }, |
61 | .remove = __exit_p(generic_rtc_remove), | ||
62 | }; | 56 | }; |
63 | 57 | ||
64 | module_platform_driver_probe(generic_rtc_driver, generic_rtc_probe); | 58 | module_platform_driver_probe(generic_rtc_driver, generic_rtc_probe); |
diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c index 63024505dddc..7273b0139e5c 100644 --- a/drivers/rtc/rtc-hid-sensor-time.c +++ b/drivers/rtc/rtc-hid-sensor-time.c | |||
@@ -76,6 +76,20 @@ static int hid_time_proc_event(struct hid_sensor_hub_device *hsdev, | |||
76 | return 0; | 76 | return 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | static u32 hid_time_value(size_t raw_len, char *raw_data) | ||
80 | { | ||
81 | switch (raw_len) { | ||
82 | case 1: | ||
83 | return *(u8 *)raw_data; | ||
84 | case 2: | ||
85 | return *(u16 *)raw_data; | ||
86 | case 4: | ||
87 | return *(u32 *)raw_data; | ||
88 | default: | ||
89 | return (u32)(~0U); /* 0xff... or -1 to denote an error */ | ||
90 | } | ||
91 | } | ||
92 | |||
79 | static int hid_time_capture_sample(struct hid_sensor_hub_device *hsdev, | 93 | static int hid_time_capture_sample(struct hid_sensor_hub_device *hsdev, |
80 | unsigned usage_id, size_t raw_len, | 94 | unsigned usage_id, size_t raw_len, |
81 | char *raw_data, void *priv) | 95 | char *raw_data, void *priv) |
@@ -85,26 +99,35 @@ static int hid_time_capture_sample(struct hid_sensor_hub_device *hsdev, | |||
85 | 99 | ||
86 | switch (usage_id) { | 100 | switch (usage_id) { |
87 | case HID_USAGE_SENSOR_TIME_YEAR: | 101 | case HID_USAGE_SENSOR_TIME_YEAR: |
88 | time_buf->tm_year = *(u8 *)raw_data; | 102 | /* |
89 | if (time_buf->tm_year < 70) | 103 | * The draft for HID-sensors (HUTRR39) currently doesn't define |
90 | /* assume we are in 1970...2069 */ | 104 | * the range for the year attribute. Therefor we support |
91 | time_buf->tm_year += 100; | 105 | * 8 bit (0-99) and 16 or 32 bits (full) as size for the year. |
106 | */ | ||
107 | if (raw_len == 1) { | ||
108 | time_buf->tm_year = *(u8 *)raw_data; | ||
109 | if (time_buf->tm_year < 70) | ||
110 | /* assume we are in 1970...2069 */ | ||
111 | time_buf->tm_year += 100; | ||
112 | } else | ||
113 | time_buf->tm_year = | ||
114 | (int)hid_time_value(raw_len, raw_data)-1900; | ||
92 | break; | 115 | break; |
93 | case HID_USAGE_SENSOR_TIME_MONTH: | 116 | case HID_USAGE_SENSOR_TIME_MONTH: |
94 | /* sensor sending the month as 1-12, we need 0-11 */ | 117 | /* sensors are sending the month as 1-12, we need 0-11 */ |
95 | time_buf->tm_mon = *(u8 *)raw_data-1; | 118 | time_buf->tm_mon = (int)hid_time_value(raw_len, raw_data)-1; |
96 | break; | 119 | break; |
97 | case HID_USAGE_SENSOR_TIME_DAY: | 120 | case HID_USAGE_SENSOR_TIME_DAY: |
98 | time_buf->tm_mday = *(u8 *)raw_data; | 121 | time_buf->tm_mday = (int)hid_time_value(raw_len, raw_data); |
99 | break; | 122 | break; |
100 | case HID_USAGE_SENSOR_TIME_HOUR: | 123 | case HID_USAGE_SENSOR_TIME_HOUR: |
101 | time_buf->tm_hour = *(u8 *)raw_data; | 124 | time_buf->tm_hour = (int)hid_time_value(raw_len, raw_data); |
102 | break; | 125 | break; |
103 | case HID_USAGE_SENSOR_TIME_MINUTE: | 126 | case HID_USAGE_SENSOR_TIME_MINUTE: |
104 | time_buf->tm_min = *(u8 *)raw_data; | 127 | time_buf->tm_min = (int)hid_time_value(raw_len, raw_data); |
105 | break; | 128 | break; |
106 | case HID_USAGE_SENSOR_TIME_SECOND: | 129 | case HID_USAGE_SENSOR_TIME_SECOND: |
107 | time_buf->tm_sec = *(u8 *)raw_data; | 130 | time_buf->tm_sec = (int)hid_time_value(raw_len, raw_data); |
108 | break; | 131 | break; |
109 | default: | 132 | default: |
110 | return -EINVAL; | 133 | return -EINVAL; |
@@ -150,9 +173,10 @@ static int hid_time_parse_report(struct platform_device *pdev, | |||
150 | "not all needed attributes inside the same report!\n"); | 173 | "not all needed attributes inside the same report!\n"); |
151 | return -EINVAL; | 174 | return -EINVAL; |
152 | } | 175 | } |
153 | if (time_state->info[i].size != 1) { | 176 | if (time_state->info[i].size == 3 || |
177 | time_state->info[i].size > 4) { | ||
154 | dev_err(&pdev->dev, | 178 | dev_err(&pdev->dev, |
155 | "attribute '%s' not 8 bits wide!\n", | 179 | "attribute '%s' not 8, 16 or 32 bits wide!\n", |
156 | hid_time_attrib_name( | 180 | hid_time_attrib_name( |
157 | time_state->info[i].attrib_id)); | 181 | time_state->info[i].attrib_id)); |
158 | return -EINVAL; | 182 | return -EINVAL; |
diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index a1bbbb8de029..5dbdc4405718 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c | |||
@@ -16,6 +16,7 @@ | |||
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 | #include <linux/module.h> |
19 | #include <linux/err.h> | ||
19 | 20 | ||
20 | #define DRV_VERSION "0.1" | 21 | #define DRV_VERSION "0.1" |
21 | 22 | ||
@@ -267,15 +268,7 @@ static int isl12022_probe(struct i2c_client *client, | |||
267 | isl12022->rtc = devm_rtc_device_register(&client->dev, | 268 | isl12022->rtc = devm_rtc_device_register(&client->dev, |
268 | isl12022_driver.driver.name, | 269 | isl12022_driver.driver.name, |
269 | &isl12022_rtc_ops, THIS_MODULE); | 270 | &isl12022_rtc_ops, THIS_MODULE); |
270 | if (IS_ERR(isl12022->rtc)) | 271 | return PTR_RET(isl12022->rtc); |
271 | return PTR_ERR(isl12022->rtc); | ||
272 | |||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | static int isl12022_remove(struct i2c_client *client) | ||
277 | { | ||
278 | return 0; | ||
279 | } | 272 | } |
280 | 273 | ||
281 | static const struct i2c_device_id isl12022_id[] = { | 274 | static const struct i2c_device_id isl12022_id[] = { |
@@ -289,7 +282,6 @@ static struct i2c_driver isl12022_driver = { | |||
289 | .name = "rtc-isl12022", | 282 | .name = "rtc-isl12022", |
290 | }, | 283 | }, |
291 | .probe = isl12022_probe, | 284 | .probe = isl12022_probe, |
292 | .remove = isl12022_remove, | ||
293 | .id_table = isl12022_id, | 285 | .id_table = isl12022_id, |
294 | }; | 286 | }; |
295 | 287 | ||
diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c index 1e48686ca6d2..1b126d2513de 100644 --- a/drivers/rtc/rtc-jz4740.c +++ b/drivers/rtc/rtc-jz4740.c | |||
@@ -14,6 +14,7 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/io.h> | ||
17 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
18 | #include <linux/module.h> | 19 | #include <linux/module.h> |
19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
@@ -216,37 +217,34 @@ static int jz4740_rtc_probe(struct platform_device *pdev) | |||
216 | struct jz4740_rtc *rtc; | 217 | struct jz4740_rtc *rtc; |
217 | uint32_t scratchpad; | 218 | uint32_t scratchpad; |
218 | 219 | ||
219 | rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); | 220 | rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); |
220 | if (!rtc) | 221 | if (!rtc) |
221 | return -ENOMEM; | 222 | return -ENOMEM; |
222 | 223 | ||
223 | rtc->irq = platform_get_irq(pdev, 0); | 224 | rtc->irq = platform_get_irq(pdev, 0); |
224 | if (rtc->irq < 0) { | 225 | if (rtc->irq < 0) { |
225 | ret = -ENOENT; | ||
226 | dev_err(&pdev->dev, "Failed to get platform irq\n"); | 226 | dev_err(&pdev->dev, "Failed to get platform irq\n"); |
227 | goto err_free; | 227 | return -ENOENT; |
228 | } | 228 | } |
229 | 229 | ||
230 | rtc->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 230 | rtc->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
231 | if (!rtc->mem) { | 231 | if (!rtc->mem) { |
232 | ret = -ENOENT; | ||
233 | dev_err(&pdev->dev, "Failed to get platform mmio memory\n"); | 232 | dev_err(&pdev->dev, "Failed to get platform mmio memory\n"); |
234 | goto err_free; | 233 | return -ENOENT; |
235 | } | 234 | } |
236 | 235 | ||
237 | rtc->mem = request_mem_region(rtc->mem->start, resource_size(rtc->mem), | 236 | rtc->mem = devm_request_mem_region(&pdev->dev, rtc->mem->start, |
238 | pdev->name); | 237 | resource_size(rtc->mem), pdev->name); |
239 | if (!rtc->mem) { | 238 | if (!rtc->mem) { |
240 | ret = -EBUSY; | ||
241 | dev_err(&pdev->dev, "Failed to request mmio memory region\n"); | 239 | dev_err(&pdev->dev, "Failed to request mmio memory region\n"); |
242 | goto err_free; | 240 | return -EBUSY; |
243 | } | 241 | } |
244 | 242 | ||
245 | rtc->base = ioremap_nocache(rtc->mem->start, resource_size(rtc->mem)); | 243 | rtc->base = devm_ioremap_nocache(&pdev->dev, rtc->mem->start, |
244 | resource_size(rtc->mem)); | ||
246 | if (!rtc->base) { | 245 | if (!rtc->base) { |
247 | ret = -EBUSY; | ||
248 | dev_err(&pdev->dev, "Failed to ioremap mmio memory\n"); | 246 | dev_err(&pdev->dev, "Failed to ioremap mmio memory\n"); |
249 | goto err_release_mem_region; | 247 | return -EBUSY; |
250 | } | 248 | } |
251 | 249 | ||
252 | spin_lock_init(&rtc->lock); | 250 | spin_lock_init(&rtc->lock); |
@@ -255,19 +253,19 @@ static int jz4740_rtc_probe(struct platform_device *pdev) | |||
255 | 253 | ||
256 | device_init_wakeup(&pdev->dev, 1); | 254 | device_init_wakeup(&pdev->dev, 1); |
257 | 255 | ||
258 | rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, &jz4740_rtc_ops, | 256 | rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
259 | THIS_MODULE); | 257 | &jz4740_rtc_ops, THIS_MODULE); |
260 | if (IS_ERR(rtc->rtc)) { | 258 | if (IS_ERR(rtc->rtc)) { |
261 | ret = PTR_ERR(rtc->rtc); | 259 | ret = PTR_ERR(rtc->rtc); |
262 | dev_err(&pdev->dev, "Failed to register rtc device: %d\n", ret); | 260 | dev_err(&pdev->dev, "Failed to register rtc device: %d\n", ret); |
263 | goto err_iounmap; | 261 | return ret; |
264 | } | 262 | } |
265 | 263 | ||
266 | ret = request_irq(rtc->irq, jz4740_rtc_irq, 0, | 264 | ret = devm_request_irq(&pdev->dev, rtc->irq, jz4740_rtc_irq, 0, |
267 | pdev->name, rtc); | 265 | pdev->name, rtc); |
268 | if (ret) { | 266 | if (ret) { |
269 | dev_err(&pdev->dev, "Failed to request rtc irq: %d\n", ret); | 267 | dev_err(&pdev->dev, "Failed to request rtc irq: %d\n", ret); |
270 | goto err_unregister_rtc; | 268 | return ret; |
271 | } | 269 | } |
272 | 270 | ||
273 | scratchpad = jz4740_rtc_reg_read(rtc, JZ_REG_RTC_SCRATCHPAD); | 271 | scratchpad = jz4740_rtc_reg_read(rtc, JZ_REG_RTC_SCRATCHPAD); |
@@ -276,46 +274,13 @@ static int jz4740_rtc_probe(struct platform_device *pdev) | |||
276 | ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC, 0); | 274 | ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC, 0); |
277 | if (ret) { | 275 | if (ret) { |
278 | dev_err(&pdev->dev, "Could not write write to RTC registers\n"); | 276 | dev_err(&pdev->dev, "Could not write write to RTC registers\n"); |
279 | goto err_free_irq; | 277 | return ret; |
280 | } | 278 | } |
281 | } | 279 | } |
282 | 280 | ||
283 | return 0; | 281 | return 0; |
284 | |||
285 | err_free_irq: | ||
286 | free_irq(rtc->irq, rtc); | ||
287 | err_unregister_rtc: | ||
288 | rtc_device_unregister(rtc->rtc); | ||
289 | err_iounmap: | ||
290 | platform_set_drvdata(pdev, NULL); | ||
291 | iounmap(rtc->base); | ||
292 | err_release_mem_region: | ||
293 | release_mem_region(rtc->mem->start, resource_size(rtc->mem)); | ||
294 | err_free: | ||
295 | kfree(rtc); | ||
296 | |||
297 | return ret; | ||
298 | } | ||
299 | |||
300 | static int jz4740_rtc_remove(struct platform_device *pdev) | ||
301 | { | ||
302 | struct jz4740_rtc *rtc = platform_get_drvdata(pdev); | ||
303 | |||
304 | free_irq(rtc->irq, rtc); | ||
305 | |||
306 | rtc_device_unregister(rtc->rtc); | ||
307 | |||
308 | iounmap(rtc->base); | ||
309 | release_mem_region(rtc->mem->start, resource_size(rtc->mem)); | ||
310 | |||
311 | kfree(rtc); | ||
312 | |||
313 | platform_set_drvdata(pdev, NULL); | ||
314 | |||
315 | return 0; | ||
316 | } | 282 | } |
317 | 283 | ||
318 | |||
319 | #ifdef CONFIG_PM | 284 | #ifdef CONFIG_PM |
320 | static int jz4740_rtc_suspend(struct device *dev) | 285 | static int jz4740_rtc_suspend(struct device *dev) |
321 | { | 286 | { |
@@ -347,7 +312,6 @@ static const struct dev_pm_ops jz4740_pm_ops = { | |||
347 | 312 | ||
348 | static struct platform_driver jz4740_rtc_driver = { | 313 | static struct platform_driver jz4740_rtc_driver = { |
349 | .probe = jz4740_rtc_probe, | 314 | .probe = jz4740_rtc_probe, |
350 | .remove = jz4740_rtc_remove, | ||
351 | .driver = { | 315 | .driver = { |
352 | .name = "jz4740-rtc", | 316 | .name = "jz4740-rtc", |
353 | .owner = THIS_MODULE, | 317 | .owner = THIS_MODULE, |
diff --git a/drivers/rtc/rtc-lp8788.c b/drivers/rtc/rtc-lp8788.c index 9853ac15b296..4ff6c73253b3 100644 --- a/drivers/rtc/rtc-lp8788.c +++ b/drivers/rtc/rtc-lp8788.c | |||
@@ -312,16 +312,8 @@ static int lp8788_rtc_probe(struct platform_device *pdev) | |||
312 | return 0; | 312 | return 0; |
313 | } | 313 | } |
314 | 314 | ||
315 | static int lp8788_rtc_remove(struct platform_device *pdev) | ||
316 | { | ||
317 | platform_set_drvdata(pdev, NULL); | ||
318 | |||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | static struct platform_driver lp8788_rtc_driver = { | 315 | static struct platform_driver lp8788_rtc_driver = { |
323 | .probe = lp8788_rtc_probe, | 316 | .probe = lp8788_rtc_probe, |
324 | .remove = lp8788_rtc_remove, | ||
325 | .driver = { | 317 | .driver = { |
326 | .name = LP8788_DEV_RTC, | 318 | .name = LP8788_DEV_RTC, |
327 | .owner = THIS_MODULE, | 319 | .owner = THIS_MODULE, |
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c index 787550d756e9..8276ae94a2a9 100644 --- a/drivers/rtc/rtc-lpc32xx.c +++ b/drivers/rtc/rtc-lpc32xx.c | |||
@@ -277,7 +277,6 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev) | |||
277 | &lpc32xx_rtc_ops, THIS_MODULE); | 277 | &lpc32xx_rtc_ops, THIS_MODULE); |
278 | if (IS_ERR(rtc->rtc)) { | 278 | if (IS_ERR(rtc->rtc)) { |
279 | dev_err(&pdev->dev, "Can't get RTC\n"); | 279 | dev_err(&pdev->dev, "Can't get RTC\n"); |
280 | platform_set_drvdata(pdev, NULL); | ||
281 | return PTR_ERR(rtc->rtc); | 280 | return PTR_ERR(rtc->rtc); |
282 | } | 281 | } |
283 | 282 | ||
@@ -306,8 +305,6 @@ static int lpc32xx_rtc_remove(struct platform_device *pdev) | |||
306 | if (rtc->irq >= 0) | 305 | if (rtc->irq >= 0) |
307 | device_init_wakeup(&pdev->dev, 0); | 306 | device_init_wakeup(&pdev->dev, 0); |
308 | 307 | ||
309 | platform_set_drvdata(pdev, NULL); | ||
310 | |||
311 | return 0; | 308 | return 0; |
312 | } | 309 | } |
313 | 310 | ||
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c index db82f91f4562..682ecb094839 100644 --- a/drivers/rtc/rtc-ls1x.c +++ b/drivers/rtc/rtc-ls1x.c | |||
@@ -185,19 +185,11 @@ err: | |||
185 | return ret; | 185 | return ret; |
186 | } | 186 | } |
187 | 187 | ||
188 | static int ls1x_rtc_remove(struct platform_device *pdev) | ||
189 | { | ||
190 | platform_set_drvdata(pdev, NULL); | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static struct platform_driver ls1x_rtc_driver = { | 188 | static struct platform_driver ls1x_rtc_driver = { |
196 | .driver = { | 189 | .driver = { |
197 | .name = "ls1x-rtc", | 190 | .name = "ls1x-rtc", |
198 | .owner = THIS_MODULE, | 191 | .owner = THIS_MODULE, |
199 | }, | 192 | }, |
200 | .remove = ls1x_rtc_remove, | ||
201 | .probe = ls1x_rtc_probe, | 193 | .probe = ls1x_rtc_probe, |
202 | }; | 194 | }; |
203 | 195 | ||
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 89674b5e6efd..a5248aa1abf1 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -168,7 +168,7 @@ static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm) | |||
168 | buf[M41T80_REG_MIN] = | 168 | buf[M41T80_REG_MIN] = |
169 | bin2bcd(tm->tm_min) | (buf[M41T80_REG_MIN] & ~0x7f); | 169 | bin2bcd(tm->tm_min) | (buf[M41T80_REG_MIN] & ~0x7f); |
170 | buf[M41T80_REG_HOUR] = | 170 | buf[M41T80_REG_HOUR] = |
171 | bin2bcd(tm->tm_hour) | (buf[M41T80_REG_HOUR] & ~0x3f) ; | 171 | bin2bcd(tm->tm_hour) | (buf[M41T80_REG_HOUR] & ~0x3f); |
172 | buf[M41T80_REG_WDAY] = | 172 | buf[M41T80_REG_WDAY] = |
173 | (tm->tm_wday & 0x07) | (buf[M41T80_REG_WDAY] & ~0x07); | 173 | (tm->tm_wday & 0x07) | (buf[M41T80_REG_WDAY] & ~0x07); |
174 | buf[M41T80_REG_DAY] = | 174 | buf[M41T80_REG_DAY] = |
diff --git a/drivers/rtc/rtc-m41t93.c b/drivers/rtc/rtc-m41t93.c index 9707d36e8b15..4698c7e344e4 100644 --- a/drivers/rtc/rtc-m41t93.c +++ b/drivers/rtc/rtc-m41t93.c | |||
@@ -194,19 +194,12 @@ static int m41t93_probe(struct spi_device *spi) | |||
194 | return 0; | 194 | return 0; |
195 | } | 195 | } |
196 | 196 | ||
197 | |||
198 | static int m41t93_remove(struct spi_device *spi) | ||
199 | { | ||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static struct spi_driver m41t93_driver = { | 197 | static struct spi_driver m41t93_driver = { |
204 | .driver = { | 198 | .driver = { |
205 | .name = "rtc-m41t93", | 199 | .name = "rtc-m41t93", |
206 | .owner = THIS_MODULE, | 200 | .owner = THIS_MODULE, |
207 | }, | 201 | }, |
208 | .probe = m41t93_probe, | 202 | .probe = m41t93_probe, |
209 | .remove = m41t93_remove, | ||
210 | }; | 203 | }; |
211 | 204 | ||
212 | module_spi_driver(m41t93_driver); | 205 | module_spi_driver(m41t93_driver); |
diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c index 7454ef0a4cfa..8d800b1bf87b 100644 --- a/drivers/rtc/rtc-m41t94.c +++ b/drivers/rtc/rtc-m41t94.c | |||
@@ -134,18 +134,12 @@ static int m41t94_probe(struct spi_device *spi) | |||
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | static int m41t94_remove(struct spi_device *spi) | ||
138 | { | ||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | static struct spi_driver m41t94_driver = { | 137 | static struct spi_driver m41t94_driver = { |
143 | .driver = { | 138 | .driver = { |
144 | .name = "rtc-m41t94", | 139 | .name = "rtc-m41t94", |
145 | .owner = THIS_MODULE, | 140 | .owner = THIS_MODULE, |
146 | }, | 141 | }, |
147 | .probe = m41t94_probe, | 142 | .probe = m41t94_probe, |
148 | .remove = m41t94_remove, | ||
149 | }; | 143 | }; |
150 | 144 | ||
151 | module_spi_driver(m41t94_driver); | 145 | module_spi_driver(m41t94_driver); |
diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c index 37444246e5e4..23c3779a5f2b 100644 --- a/drivers/rtc/rtc-m48t35.c +++ b/drivers/rtc/rtc-m48t35.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/bcd.h> | 21 | #include <linux/bcd.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/err.h> | ||
23 | 24 | ||
24 | #define DRV_VERSION "1.0" | 25 | #define DRV_VERSION "1.0" |
25 | 26 | ||
@@ -174,15 +175,7 @@ static int m48t35_probe(struct platform_device *pdev) | |||
174 | 175 | ||
175 | priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35", | 176 | priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35", |
176 | &m48t35_ops, THIS_MODULE); | 177 | &m48t35_ops, THIS_MODULE); |
177 | if (IS_ERR(priv->rtc)) | 178 | return PTR_RET(priv->rtc); |
178 | return PTR_ERR(priv->rtc); | ||
179 | |||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | static int m48t35_remove(struct platform_device *pdev) | ||
184 | { | ||
185 | return 0; | ||
186 | } | 179 | } |
187 | 180 | ||
188 | static struct platform_driver m48t35_platform_driver = { | 181 | static struct platform_driver m48t35_platform_driver = { |
@@ -191,7 +184,6 @@ static struct platform_driver m48t35_platform_driver = { | |||
191 | .owner = THIS_MODULE, | 184 | .owner = THIS_MODULE, |
192 | }, | 185 | }, |
193 | .probe = m48t35_probe, | 186 | .probe = m48t35_probe, |
194 | .remove = m48t35_remove, | ||
195 | }; | 187 | }; |
196 | 188 | ||
197 | module_platform_driver(m48t35_platform_driver); | 189 | module_platform_driver(m48t35_platform_driver); |
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index 130f29af3869..fcb03291f145 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c | |||
@@ -409,7 +409,8 @@ static int m48t59_rtc_probe(struct platform_device *pdev) | |||
409 | } else if (res->flags & IORESOURCE_MEM) { | 409 | } else if (res->flags & IORESOURCE_MEM) { |
410 | /* we are memory-mapped */ | 410 | /* we are memory-mapped */ |
411 | if (!pdata) { | 411 | if (!pdata) { |
412 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | 412 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), |
413 | GFP_KERNEL); | ||
413 | if (!pdata) | 414 | if (!pdata) |
414 | return -ENOMEM; | 415 | return -ENOMEM; |
415 | /* Ensure we only kmalloc platform data once */ | 416 | /* Ensure we only kmalloc platform data once */ |
@@ -425,7 +426,7 @@ static int m48t59_rtc_probe(struct platform_device *pdev) | |||
425 | pdata->read_byte = m48t59_mem_readb; | 426 | pdata->read_byte = m48t59_mem_readb; |
426 | } | 427 | } |
427 | 428 | ||
428 | m48t59 = kzalloc(sizeof(*m48t59), GFP_KERNEL); | 429 | m48t59 = devm_kzalloc(&pdev->dev, sizeof(*m48t59), GFP_KERNEL); |
429 | if (!m48t59) | 430 | if (!m48t59) |
430 | return -ENOMEM; | 431 | return -ENOMEM; |
431 | 432 | ||
@@ -433,9 +434,10 @@ static int m48t59_rtc_probe(struct platform_device *pdev) | |||
433 | 434 | ||
434 | if (!m48t59->ioaddr) { | 435 | if (!m48t59->ioaddr) { |
435 | /* ioaddr not mapped externally */ | 436 | /* ioaddr not mapped externally */ |
436 | m48t59->ioaddr = ioremap(res->start, resource_size(res)); | 437 | m48t59->ioaddr = devm_ioremap(&pdev->dev, res->start, |
438 | resource_size(res)); | ||
437 | if (!m48t59->ioaddr) | 439 | if (!m48t59->ioaddr) |
438 | goto out; | 440 | return ret; |
439 | } | 441 | } |
440 | 442 | ||
441 | /* Try to get irq number. We also can work in | 443 | /* Try to get irq number. We also can work in |
@@ -446,10 +448,11 @@ static int m48t59_rtc_probe(struct platform_device *pdev) | |||
446 | m48t59->irq = NO_IRQ; | 448 | m48t59->irq = NO_IRQ; |
447 | 449 | ||
448 | if (m48t59->irq != NO_IRQ) { | 450 | if (m48t59->irq != NO_IRQ) { |
449 | ret = request_irq(m48t59->irq, m48t59_rtc_interrupt, | 451 | ret = devm_request_irq(&pdev->dev, m48t59->irq, |
450 | IRQF_SHARED, "rtc-m48t59", &pdev->dev); | 452 | m48t59_rtc_interrupt, IRQF_SHARED, |
453 | "rtc-m48t59", &pdev->dev); | ||
451 | if (ret) | 454 | if (ret) |
452 | goto out; | 455 | return ret; |
453 | } | 456 | } |
454 | switch (pdata->type) { | 457 | switch (pdata->type) { |
455 | case M48T59RTC_TYPE_M48T59: | 458 | case M48T59RTC_TYPE_M48T59: |
@@ -469,52 +472,29 @@ static int m48t59_rtc_probe(struct platform_device *pdev) | |||
469 | break; | 472 | break; |
470 | default: | 473 | default: |
471 | dev_err(&pdev->dev, "Unknown RTC type\n"); | 474 | dev_err(&pdev->dev, "Unknown RTC type\n"); |
472 | ret = -ENODEV; | 475 | return -ENODEV; |
473 | goto out; | ||
474 | } | 476 | } |
475 | 477 | ||
476 | spin_lock_init(&m48t59->lock); | 478 | spin_lock_init(&m48t59->lock); |
477 | platform_set_drvdata(pdev, m48t59); | 479 | platform_set_drvdata(pdev, m48t59); |
478 | 480 | ||
479 | m48t59->rtc = rtc_device_register(name, &pdev->dev, ops, THIS_MODULE); | 481 | m48t59->rtc = devm_rtc_device_register(&pdev->dev, name, ops, |
480 | if (IS_ERR(m48t59->rtc)) { | 482 | THIS_MODULE); |
481 | ret = PTR_ERR(m48t59->rtc); | 483 | if (IS_ERR(m48t59->rtc)) |
482 | goto out; | 484 | return PTR_ERR(m48t59->rtc); |
483 | } | ||
484 | 485 | ||
485 | m48t59_nvram_attr.size = pdata->offset; | 486 | m48t59_nvram_attr.size = pdata->offset; |
486 | 487 | ||
487 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr); | 488 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr); |
488 | if (ret) { | 489 | if (ret) |
489 | rtc_device_unregister(m48t59->rtc); | 490 | return ret; |
490 | goto out; | ||
491 | } | ||
492 | 491 | ||
493 | return 0; | 492 | return 0; |
494 | |||
495 | out: | ||
496 | if (m48t59->irq != NO_IRQ) | ||
497 | free_irq(m48t59->irq, &pdev->dev); | ||
498 | if (m48t59->ioaddr) | ||
499 | iounmap(m48t59->ioaddr); | ||
500 | kfree(m48t59); | ||
501 | return ret; | ||
502 | } | 493 | } |
503 | 494 | ||
504 | static int m48t59_rtc_remove(struct platform_device *pdev) | 495 | static int m48t59_rtc_remove(struct platform_device *pdev) |
505 | { | 496 | { |
506 | struct m48t59_private *m48t59 = platform_get_drvdata(pdev); | ||
507 | struct m48t59_plat_data *pdata = pdev->dev.platform_data; | ||
508 | |||
509 | sysfs_remove_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr); | 497 | sysfs_remove_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr); |
510 | if (!IS_ERR(m48t59->rtc)) | ||
511 | rtc_device_unregister(m48t59->rtc); | ||
512 | if (m48t59->ioaddr && !pdata->ioaddr) | ||
513 | iounmap(m48t59->ioaddr); | ||
514 | if (m48t59->irq != NO_IRQ) | ||
515 | free_irq(m48t59->irq, &pdev->dev); | ||
516 | platform_set_drvdata(pdev, NULL); | ||
517 | kfree(m48t59); | ||
518 | return 0; | 498 | return 0; |
519 | } | 499 | } |
520 | 500 | ||
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c index 33a91c484533..2d30314fa07f 100644 --- a/drivers/rtc/rtc-m48t86.c +++ b/drivers/rtc/rtc-m48t86.c | |||
@@ -166,20 +166,12 @@ static int m48t86_rtc_probe(struct platform_device *dev) | |||
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | static int m48t86_rtc_remove(struct platform_device *dev) | ||
170 | { | ||
171 | platform_set_drvdata(dev, NULL); | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static struct platform_driver m48t86_rtc_platform_driver = { | 169 | static struct platform_driver m48t86_rtc_platform_driver = { |
177 | .driver = { | 170 | .driver = { |
178 | .name = "rtc-m48t86", | 171 | .name = "rtc-m48t86", |
179 | .owner = THIS_MODULE, | 172 | .owner = THIS_MODULE, |
180 | }, | 173 | }, |
181 | .probe = m48t86_rtc_probe, | 174 | .probe = m48t86_rtc_probe, |
182 | .remove = m48t86_rtc_remove, | ||
183 | }; | 175 | }; |
184 | 176 | ||
185 | module_platform_driver(m48t86_rtc_platform_driver); | 177 | module_platform_driver(m48t86_rtc_platform_driver); |
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c index 8669d6d09a00..55969b1b771a 100644 --- a/drivers/rtc/rtc-max6900.c +++ b/drivers/rtc/rtc-max6900.c | |||
@@ -212,11 +212,6 @@ static int max6900_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
212 | return max6900_i2c_set_time(to_i2c_client(dev), tm); | 212 | return max6900_i2c_set_time(to_i2c_client(dev), tm); |
213 | } | 213 | } |
214 | 214 | ||
215 | static int max6900_remove(struct i2c_client *client) | ||
216 | { | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static const struct rtc_class_ops max6900_rtc_ops = { | 215 | static const struct rtc_class_ops max6900_rtc_ops = { |
221 | .read_time = max6900_rtc_read_time, | 216 | .read_time = max6900_rtc_read_time, |
222 | .set_time = max6900_rtc_set_time, | 217 | .set_time = max6900_rtc_set_time, |
@@ -252,7 +247,6 @@ static struct i2c_driver max6900_driver = { | |||
252 | .name = "rtc-max6900", | 247 | .name = "rtc-max6900", |
253 | }, | 248 | }, |
254 | .probe = max6900_probe, | 249 | .probe = max6900_probe, |
255 | .remove = max6900_remove, | ||
256 | .id_table = max6900_id, | 250 | .id_table = max6900_id, |
257 | }; | 251 | }; |
258 | 252 | ||
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c index e3aea00c3145..ac3f4191864f 100644 --- a/drivers/rtc/rtc-max6902.c +++ b/drivers/rtc/rtc-max6902.c | |||
@@ -143,23 +143,17 @@ static int max6902_probe(struct spi_device *spi) | |||
143 | return 0; | 143 | return 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | static int max6902_remove(struct spi_device *spi) | ||
147 | { | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static struct spi_driver max6902_driver = { | 146 | static struct spi_driver max6902_driver = { |
152 | .driver = { | 147 | .driver = { |
153 | .name = "rtc-max6902", | 148 | .name = "rtc-max6902", |
154 | .owner = THIS_MODULE, | 149 | .owner = THIS_MODULE, |
155 | }, | 150 | }, |
156 | .probe = max6902_probe, | 151 | .probe = max6902_probe, |
157 | .remove = max6902_remove, | ||
158 | }; | 152 | }; |
159 | 153 | ||
160 | module_spi_driver(max6902_driver); | 154 | module_spi_driver(max6902_driver); |
161 | 155 | ||
162 | MODULE_DESCRIPTION ("max6902 spi RTC driver"); | 156 | MODULE_DESCRIPTION("max6902 spi RTC driver"); |
163 | MODULE_AUTHOR ("Raphael Assenat"); | 157 | MODULE_AUTHOR("Raphael Assenat"); |
164 | MODULE_LICENSE ("GPL"); | 158 | MODULE_LICENSE("GPL"); |
165 | MODULE_ALIAS("spi:rtc-max6902"); | 159 | MODULE_ALIAS("spi:rtc-max6902"); |
diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c index 771812d62e6b..9915cb96014b 100644 --- a/drivers/rtc/rtc-max77686.c +++ b/drivers/rtc/rtc-max77686.c | |||
@@ -119,7 +119,7 @@ static int max77686_rtc_tm_to_data(struct rtc_time *tm, u8 *data) | |||
119 | data[RTC_WEEKDAY] = 1 << tm->tm_wday; | 119 | data[RTC_WEEKDAY] = 1 << tm->tm_wday; |
120 | data[RTC_DATE] = tm->tm_mday; | 120 | data[RTC_DATE] = tm->tm_mday; |
121 | data[RTC_MONTH] = tm->tm_mon + 1; | 121 | data[RTC_MONTH] = tm->tm_mon + 1; |
122 | data[RTC_YEAR] = tm->tm_year > 100 ? (tm->tm_year - 100) : 0 ; | 122 | data[RTC_YEAR] = tm->tm_year > 100 ? (tm->tm_year - 100) : 0; |
123 | 123 | ||
124 | if (tm->tm_year < 100) { | 124 | if (tm->tm_year < 100) { |
125 | pr_warn("%s: MAX77686 RTC cannot handle the year %d." | 125 | pr_warn("%s: MAX77686 RTC cannot handle the year %d." |
@@ -567,11 +567,6 @@ err_rtc: | |||
567 | return ret; | 567 | return ret; |
568 | } | 568 | } |
569 | 569 | ||
570 | static int max77686_rtc_remove(struct platform_device *pdev) | ||
571 | { | ||
572 | return 0; | ||
573 | } | ||
574 | |||
575 | static void max77686_rtc_shutdown(struct platform_device *pdev) | 570 | static void max77686_rtc_shutdown(struct platform_device *pdev) |
576 | { | 571 | { |
577 | #ifdef MAX77686_RTC_WTSR_SMPL | 572 | #ifdef MAX77686_RTC_WTSR_SMPL |
@@ -610,7 +605,6 @@ static struct platform_driver max77686_rtc_driver = { | |||
610 | .owner = THIS_MODULE, | 605 | .owner = THIS_MODULE, |
611 | }, | 606 | }, |
612 | .probe = max77686_rtc_probe, | 607 | .probe = max77686_rtc_probe, |
613 | .remove = max77686_rtc_remove, | ||
614 | .shutdown = max77686_rtc_shutdown, | 608 | .shutdown = max77686_rtc_shutdown, |
615 | .id_table = rtc_id, | 609 | .id_table = rtc_id, |
616 | }; | 610 | }; |
diff --git a/drivers/rtc/rtc-max8907.c b/drivers/rtc/rtc-max8907.c index 86afb797125d..8e45b3c4aa2f 100644 --- a/drivers/rtc/rtc-max8907.c +++ b/drivers/rtc/rtc-max8907.c | |||
@@ -213,18 +213,12 @@ static int max8907_rtc_probe(struct platform_device *pdev) | |||
213 | return ret; | 213 | return ret; |
214 | } | 214 | } |
215 | 215 | ||
216 | static int max8907_rtc_remove(struct platform_device *pdev) | ||
217 | { | ||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | static struct platform_driver max8907_rtc_driver = { | 216 | static struct platform_driver max8907_rtc_driver = { |
222 | .driver = { | 217 | .driver = { |
223 | .name = "max8907-rtc", | 218 | .name = "max8907-rtc", |
224 | .owner = THIS_MODULE, | 219 | .owner = THIS_MODULE, |
225 | }, | 220 | }, |
226 | .probe = max8907_rtc_probe, | 221 | .probe = max8907_rtc_probe, |
227 | .remove = max8907_rtc_remove, | ||
228 | }; | 222 | }; |
229 | module_platform_driver(max8907_rtc_driver); | 223 | module_platform_driver(max8907_rtc_driver); |
230 | 224 | ||
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index 7c90f4e45e27..951d1a78e190 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c | |||
@@ -268,7 +268,7 @@ static int max8925_rtc_probe(struct platform_device *pdev) | |||
268 | if (ret < 0) { | 268 | if (ret < 0) { |
269 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", | 269 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", |
270 | info->irq, ret); | 270 | info->irq, ret); |
271 | goto err; | 271 | return ret; |
272 | } | 272 | } |
273 | 273 | ||
274 | dev_set_drvdata(&pdev->dev, info); | 274 | dev_set_drvdata(&pdev->dev, info); |
@@ -282,18 +282,10 @@ static int max8925_rtc_probe(struct platform_device *pdev) | |||
282 | ret = PTR_ERR(info->rtc_dev); | 282 | ret = PTR_ERR(info->rtc_dev); |
283 | if (IS_ERR(info->rtc_dev)) { | 283 | if (IS_ERR(info->rtc_dev)) { |
284 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); | 284 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); |
285 | goto err; | 285 | return ret; |
286 | } | 286 | } |
287 | 287 | ||
288 | return 0; | 288 | return 0; |
289 | err: | ||
290 | platform_set_drvdata(pdev, NULL); | ||
291 | return ret; | ||
292 | } | ||
293 | |||
294 | static int max8925_rtc_remove(struct platform_device *pdev) | ||
295 | { | ||
296 | return 0; | ||
297 | } | 289 | } |
298 | 290 | ||
299 | #ifdef CONFIG_PM_SLEEP | 291 | #ifdef CONFIG_PM_SLEEP |
@@ -326,7 +318,6 @@ static struct platform_driver max8925_rtc_driver = { | |||
326 | .pm = &max8925_rtc_pm_ops, | 318 | .pm = &max8925_rtc_pm_ops, |
327 | }, | 319 | }, |
328 | .probe = max8925_rtc_probe, | 320 | .probe = max8925_rtc_probe, |
329 | .remove = max8925_rtc_remove, | ||
330 | }; | 321 | }; |
331 | 322 | ||
332 | module_platform_driver(max8925_rtc_driver); | 323 | module_platform_driver(max8925_rtc_driver); |
diff --git a/drivers/rtc/rtc-max8997.c b/drivers/rtc/rtc-max8997.c index dacf48db7925..0777c01b58e0 100644 --- a/drivers/rtc/rtc-max8997.c +++ b/drivers/rtc/rtc-max8997.c | |||
@@ -104,7 +104,7 @@ static int max8997_rtc_tm_to_data(struct rtc_time *tm, u8 *data) | |||
104 | data[RTC_WEEKDAY] = 1 << tm->tm_wday; | 104 | data[RTC_WEEKDAY] = 1 << tm->tm_wday; |
105 | data[RTC_DATE] = tm->tm_mday; | 105 | data[RTC_DATE] = tm->tm_mday; |
106 | data[RTC_MONTH] = tm->tm_mon + 1; | 106 | data[RTC_MONTH] = tm->tm_mon + 1; |
107 | data[RTC_YEAR] = tm->tm_year > 100 ? (tm->tm_year - 100) : 0 ; | 107 | data[RTC_YEAR] = tm->tm_year > 100 ? (tm->tm_year - 100) : 0; |
108 | 108 | ||
109 | if (tm->tm_year < 100) { | 109 | if (tm->tm_year < 100) { |
110 | pr_warn("%s: MAX8997 RTC cannot handle the year %d." | 110 | pr_warn("%s: MAX8997 RTC cannot handle the year %d." |
@@ -507,11 +507,6 @@ err_out: | |||
507 | return ret; | 507 | return ret; |
508 | } | 508 | } |
509 | 509 | ||
510 | static int max8997_rtc_remove(struct platform_device *pdev) | ||
511 | { | ||
512 | return 0; | ||
513 | } | ||
514 | |||
515 | static void max8997_rtc_shutdown(struct platform_device *pdev) | 510 | static void max8997_rtc_shutdown(struct platform_device *pdev) |
516 | { | 511 | { |
517 | struct max8997_rtc_info *info = platform_get_drvdata(pdev); | 512 | struct max8997_rtc_info *info = platform_get_drvdata(pdev); |
@@ -531,7 +526,6 @@ static struct platform_driver max8997_rtc_driver = { | |||
531 | .owner = THIS_MODULE, | 526 | .owner = THIS_MODULE, |
532 | }, | 527 | }, |
533 | .probe = max8997_rtc_probe, | 528 | .probe = max8997_rtc_probe, |
534 | .remove = max8997_rtc_remove, | ||
535 | .shutdown = max8997_rtc_shutdown, | 529 | .shutdown = max8997_rtc_shutdown, |
536 | .id_table = rtc_id, | 530 | .id_table = rtc_id, |
537 | }; | 531 | }; |
diff --git a/drivers/rtc/rtc-max8998.c b/drivers/rtc/rtc-max8998.c index d5af7baa48b5..5388336a2c4c 100644 --- a/drivers/rtc/rtc-max8998.c +++ b/drivers/rtc/rtc-max8998.c | |||
@@ -274,7 +274,7 @@ static int max8998_rtc_probe(struct platform_device *pdev) | |||
274 | if (IS_ERR(info->rtc_dev)) { | 274 | if (IS_ERR(info->rtc_dev)) { |
275 | ret = PTR_ERR(info->rtc_dev); | 275 | ret = PTR_ERR(info->rtc_dev); |
276 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); | 276 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); |
277 | goto out_rtc; | 277 | return ret; |
278 | } | 278 | } |
279 | 279 | ||
280 | ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, | 280 | ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, |
@@ -292,15 +292,6 @@ static int max8998_rtc_probe(struct platform_device *pdev) | |||
292 | } | 292 | } |
293 | 293 | ||
294 | return 0; | 294 | return 0; |
295 | |||
296 | out_rtc: | ||
297 | platform_set_drvdata(pdev, NULL); | ||
298 | return ret; | ||
299 | } | ||
300 | |||
301 | static int max8998_rtc_remove(struct platform_device *pdev) | ||
302 | { | ||
303 | return 0; | ||
304 | } | 295 | } |
305 | 296 | ||
306 | static const struct platform_device_id max8998_rtc_id[] = { | 297 | static const struct platform_device_id max8998_rtc_id[] = { |
@@ -315,7 +306,6 @@ static struct platform_driver max8998_rtc_driver = { | |||
315 | .owner = THIS_MODULE, | 306 | .owner = THIS_MODULE, |
316 | }, | 307 | }, |
317 | .probe = max8998_rtc_probe, | 308 | .probe = max8998_rtc_probe, |
318 | .remove = max8998_rtc_remove, | ||
319 | .id_table = max8998_rtc_id, | 309 | .id_table = max8998_rtc_id, |
320 | }; | 310 | }; |
321 | 311 | ||
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index 7a8ed27a5f2e..77ea9896b5ba 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c | |||
@@ -370,8 +370,6 @@ err_reset_irq_status: | |||
370 | err_reset_irq_request: | 370 | err_reset_irq_request: |
371 | 371 | ||
372 | mc13xxx_unlock(mc13xxx); | 372 | mc13xxx_unlock(mc13xxx); |
373 | |||
374 | platform_set_drvdata(pdev, NULL); | ||
375 | } | 373 | } |
376 | 374 | ||
377 | return ret; | 375 | return ret; |
@@ -389,8 +387,6 @@ static int __exit mc13xxx_rtc_remove(struct platform_device *pdev) | |||
389 | 387 | ||
390 | mc13xxx_unlock(priv->mc13xxx); | 388 | mc13xxx_unlock(priv->mc13xxx); |
391 | 389 | ||
392 | platform_set_drvdata(pdev, NULL); | ||
393 | |||
394 | return 0; | 390 | return 0; |
395 | } | 391 | } |
396 | 392 | ||
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c index bdcc60830aec..9c8f60903799 100644 --- a/drivers/rtc/rtc-mpc5121.c +++ b/drivers/rtc/rtc-mpc5121.c | |||
@@ -68,7 +68,7 @@ struct mpc5121_rtc_regs { | |||
68 | u32 target_time; /* RTC + 0x20 */ | 68 | u32 target_time; /* RTC + 0x20 */ |
69 | /* | 69 | /* |
70 | * actual_time: | 70 | * actual_time: |
71 | * readonly time since VBAT_RTC was last connected | 71 | * readonly time since VBAT_RTC was last connected |
72 | */ | 72 | */ |
73 | u32 actual_time; /* RTC + 0x24 */ | 73 | u32 actual_time; /* RTC + 0x24 */ |
74 | u32 keep_alive; /* RTC + 0x28 */ | 74 | u32 keep_alive; /* RTC + 0x28 */ |
@@ -312,20 +312,19 @@ static int mpc5121_rtc_probe(struct platform_device *op) | |||
312 | struct mpc5121_rtc_data *rtc; | 312 | struct mpc5121_rtc_data *rtc; |
313 | int err = 0; | 313 | int err = 0; |
314 | 314 | ||
315 | rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); | 315 | rtc = devm_kzalloc(&op->dev, sizeof(*rtc), GFP_KERNEL); |
316 | if (!rtc) | 316 | if (!rtc) |
317 | return -ENOMEM; | 317 | return -ENOMEM; |
318 | 318 | ||
319 | rtc->regs = of_iomap(op->dev.of_node, 0); | 319 | rtc->regs = of_iomap(op->dev.of_node, 0); |
320 | if (!rtc->regs) { | 320 | if (!rtc->regs) { |
321 | dev_err(&op->dev, "%s: couldn't map io space\n", __func__); | 321 | dev_err(&op->dev, "%s: couldn't map io space\n", __func__); |
322 | err = -ENOSYS; | 322 | return -ENOSYS; |
323 | goto out_free; | ||
324 | } | 323 | } |
325 | 324 | ||
326 | device_init_wakeup(&op->dev, 1); | 325 | device_init_wakeup(&op->dev, 1); |
327 | 326 | ||
328 | dev_set_drvdata(&op->dev, rtc); | 327 | platform_set_drvdata(op, rtc); |
329 | 328 | ||
330 | rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1); | 329 | rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1); |
331 | err = request_irq(rtc->irq, mpc5121_rtc_handler, 0, | 330 | err = request_irq(rtc->irq, mpc5121_rtc_handler, 0, |
@@ -354,10 +353,10 @@ static int mpc5121_rtc_probe(struct platform_device *op) | |||
354 | out_be32(&rtc->regs->keep_alive, ka); | 353 | out_be32(&rtc->regs->keep_alive, ka); |
355 | } | 354 | } |
356 | 355 | ||
357 | rtc->rtc = rtc_device_register("mpc5121-rtc", &op->dev, | 356 | rtc->rtc = devm_rtc_device_register(&op->dev, "mpc5121-rtc", |
358 | &mpc5121_rtc_ops, THIS_MODULE); | 357 | &mpc5121_rtc_ops, THIS_MODULE); |
359 | } else { | 358 | } else { |
360 | rtc->rtc = rtc_device_register("mpc5200-rtc", &op->dev, | 359 | rtc->rtc = devm_rtc_device_register(&op->dev, "mpc5200-rtc", |
361 | &mpc5200_rtc_ops, THIS_MODULE); | 360 | &mpc5200_rtc_ops, THIS_MODULE); |
362 | } | 361 | } |
363 | 362 | ||
@@ -377,29 +376,24 @@ out_dispose2: | |||
377 | out_dispose: | 376 | out_dispose: |
378 | irq_dispose_mapping(rtc->irq); | 377 | irq_dispose_mapping(rtc->irq); |
379 | iounmap(rtc->regs); | 378 | iounmap(rtc->regs); |
380 | out_free: | ||
381 | kfree(rtc); | ||
382 | 379 | ||
383 | return err; | 380 | return err; |
384 | } | 381 | } |
385 | 382 | ||
386 | static int mpc5121_rtc_remove(struct platform_device *op) | 383 | static int mpc5121_rtc_remove(struct platform_device *op) |
387 | { | 384 | { |
388 | struct mpc5121_rtc_data *rtc = dev_get_drvdata(&op->dev); | 385 | struct mpc5121_rtc_data *rtc = platform_get_drvdata(op); |
389 | struct mpc5121_rtc_regs __iomem *regs = rtc->regs; | 386 | struct mpc5121_rtc_regs __iomem *regs = rtc->regs; |
390 | 387 | ||
391 | /* disable interrupt, so there are no nasty surprises */ | 388 | /* disable interrupt, so there are no nasty surprises */ |
392 | out_8(®s->alm_enable, 0); | 389 | out_8(®s->alm_enable, 0); |
393 | out_8(®s->int_enable, in_8(®s->int_enable) & ~0x1); | 390 | out_8(®s->int_enable, in_8(®s->int_enable) & ~0x1); |
394 | 391 | ||
395 | rtc_device_unregister(rtc->rtc); | ||
396 | iounmap(rtc->regs); | 392 | iounmap(rtc->regs); |
397 | free_irq(rtc->irq, &op->dev); | 393 | free_irq(rtc->irq, &op->dev); |
398 | free_irq(rtc->irq_periodic, &op->dev); | 394 | free_irq(rtc->irq_periodic, &op->dev); |
399 | irq_dispose_mapping(rtc->irq); | 395 | irq_dispose_mapping(rtc->irq); |
400 | irq_dispose_mapping(rtc->irq_periodic); | 396 | irq_dispose_mapping(rtc->irq_periodic); |
401 | dev_set_drvdata(&op->dev, NULL); | ||
402 | kfree(rtc); | ||
403 | 397 | ||
404 | return 0; | 398 | return 0; |
405 | } | 399 | } |
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c index 771f86a05d14..426cb5189daa 100644 --- a/drivers/rtc/rtc-msm6242.c +++ b/drivers/rtc/rtc-msm6242.c | |||
@@ -111,8 +111,8 @@ static void msm6242_lock(struct msm6242_priv *priv) | |||
111 | } | 111 | } |
112 | 112 | ||
113 | if (!cnt) | 113 | if (!cnt) |
114 | pr_warning("msm6242: timed out waiting for RTC (0x%x)\n", | 114 | pr_warn("msm6242: timed out waiting for RTC (0x%x)\n", |
115 | msm6242_read(priv, MSM6242_CD)); | 115 | msm6242_read(priv, MSM6242_CD)); |
116 | } | 116 | } |
117 | 117 | ||
118 | static void msm6242_unlock(struct msm6242_priv *priv) | 118 | static void msm6242_unlock(struct msm6242_priv *priv) |
@@ -199,7 +199,6 @@ static int __init msm6242_rtc_probe(struct platform_device *pdev) | |||
199 | struct resource *res; | 199 | struct resource *res; |
200 | struct msm6242_priv *priv; | 200 | struct msm6242_priv *priv; |
201 | struct rtc_device *rtc; | 201 | struct rtc_device *rtc; |
202 | int error; | ||
203 | 202 | ||
204 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 203 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
205 | if (!res) | 204 | if (!res) |
@@ -216,22 +215,11 @@ static int __init msm6242_rtc_probe(struct platform_device *pdev) | |||
216 | 215 | ||
217 | rtc = devm_rtc_device_register(&pdev->dev, "rtc-msm6242", | 216 | rtc = devm_rtc_device_register(&pdev->dev, "rtc-msm6242", |
218 | &msm6242_rtc_ops, THIS_MODULE); | 217 | &msm6242_rtc_ops, THIS_MODULE); |
219 | if (IS_ERR(rtc)) { | 218 | if (IS_ERR(rtc)) |
220 | error = PTR_ERR(rtc); | 219 | return PTR_ERR(rtc); |
221 | goto out_unmap; | ||
222 | } | ||
223 | 220 | ||
224 | priv->rtc = rtc; | 221 | priv->rtc = rtc; |
225 | return 0; | 222 | return 0; |
226 | |||
227 | out_unmap: | ||
228 | platform_set_drvdata(pdev, NULL); | ||
229 | return error; | ||
230 | } | ||
231 | |||
232 | static int __exit msm6242_rtc_remove(struct platform_device *pdev) | ||
233 | { | ||
234 | return 0; | ||
235 | } | 223 | } |
236 | 224 | ||
237 | static struct platform_driver msm6242_rtc_driver = { | 225 | static struct platform_driver msm6242_rtc_driver = { |
@@ -239,7 +227,6 @@ static struct platform_driver msm6242_rtc_driver = { | |||
239 | .name = "rtc-msm6242", | 227 | .name = "rtc-msm6242", |
240 | .owner = THIS_MODULE, | 228 | .owner = THIS_MODULE, |
241 | }, | 229 | }, |
242 | .remove = __exit_p(msm6242_rtc_remove), | ||
243 | }; | 230 | }; |
244 | 231 | ||
245 | module_platform_driver_probe(msm6242_rtc_driver, msm6242_rtc_probe); | 232 | module_platform_driver_probe(msm6242_rtc_driver, msm6242_rtc_probe); |
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 9a3895bc4f4d..ab87bacb8f88 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -436,22 +436,20 @@ static int mxc_rtc_probe(struct platform_device *pdev) | |||
436 | pdata->irq = -1; | 436 | pdata->irq = -1; |
437 | } | 437 | } |
438 | 438 | ||
439 | if (pdata->irq >=0) | 439 | if (pdata->irq >= 0) |
440 | device_init_wakeup(&pdev->dev, 1); | 440 | device_init_wakeup(&pdev->dev, 1); |
441 | 441 | ||
442 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &mxc_rtc_ops, | 442 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &mxc_rtc_ops, |
443 | THIS_MODULE); | 443 | THIS_MODULE); |
444 | if (IS_ERR(rtc)) { | 444 | if (IS_ERR(rtc)) { |
445 | ret = PTR_ERR(rtc); | 445 | ret = PTR_ERR(rtc); |
446 | goto exit_clr_drvdata; | 446 | goto exit_put_clk; |
447 | } | 447 | } |
448 | 448 | ||
449 | pdata->rtc = rtc; | 449 | pdata->rtc = rtc; |
450 | 450 | ||
451 | return 0; | 451 | return 0; |
452 | 452 | ||
453 | exit_clr_drvdata: | ||
454 | platform_set_drvdata(pdev, NULL); | ||
455 | exit_put_clk: | 453 | exit_put_clk: |
456 | clk_disable_unprepare(pdata->clk); | 454 | clk_disable_unprepare(pdata->clk); |
457 | 455 | ||
@@ -465,7 +463,6 @@ static int mxc_rtc_remove(struct platform_device *pdev) | |||
465 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 463 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
466 | 464 | ||
467 | clk_disable_unprepare(pdata->clk); | 465 | clk_disable_unprepare(pdata->clk); |
468 | platform_set_drvdata(pdev, NULL); | ||
469 | 466 | ||
470 | return 0; | 467 | return 0; |
471 | } | 468 | } |
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c index d592e2fe43f7..22861c5e0c59 100644 --- a/drivers/rtc/rtc-nuc900.c +++ b/drivers/rtc/rtc-nuc900.c | |||
@@ -260,15 +260,7 @@ static int __init nuc900_rtc_probe(struct platform_device *pdev) | |||
260 | return 0; | 260 | return 0; |
261 | } | 261 | } |
262 | 262 | ||
263 | static int __exit nuc900_rtc_remove(struct platform_device *pdev) | ||
264 | { | ||
265 | platform_set_drvdata(pdev, NULL); | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | static struct platform_driver nuc900_rtc_driver = { | 263 | static struct platform_driver nuc900_rtc_driver = { |
271 | .remove = __exit_p(nuc900_rtc_remove), | ||
272 | .driver = { | 264 | .driver = { |
273 | .name = "nuc900-rtc", | 265 | .name = "nuc900-rtc", |
274 | .owner = THIS_MODULE, | 266 | .owner = THIS_MODULE, |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index b0ba3fc991ea..c6ffbaec32a4 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -23,9 +23,7 @@ | |||
23 | #include <linux/of.h> | 23 | #include <linux/of.h> |
24 | #include <linux/of_device.h> | 24 | #include <linux/of_device.h> |
25 | #include <linux/pm_runtime.h> | 25 | #include <linux/pm_runtime.h> |
26 | 26 | #include <linux/io.h> | |
27 | #include <asm/io.h> | ||
28 | |||
29 | 27 | ||
30 | /* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock | 28 | /* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock |
31 | * with century-range alarm matching, driven by the 32kHz clock. | 29 | * with century-range alarm matching, driven by the 32kHz clock. |
@@ -423,6 +421,8 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
423 | * is write-only, and always reads as zero...) | 421 | * is write-only, and always reads as zero...) |
424 | */ | 422 | */ |
425 | 423 | ||
424 | device_init_wakeup(&pdev->dev, true); | ||
425 | |||
426 | if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT) | 426 | if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT) |
427 | pr_info("%s: split power mode\n", pdev->name); | 427 | pr_info("%s: split power mode\n", pdev->name); |
428 | 428 | ||
diff --git a/drivers/rtc/rtc-palmas.c b/drivers/rtc/rtc-palmas.c index 50204d474eb7..a1fecc8d97fc 100644 --- a/drivers/rtc/rtc-palmas.c +++ b/drivers/rtc/rtc-palmas.c | |||
@@ -265,6 +265,7 @@ static int palmas_rtc_probe(struct platform_device *pdev) | |||
265 | 265 | ||
266 | palmas_rtc->irq = platform_get_irq(pdev, 0); | 266 | palmas_rtc->irq = platform_get_irq(pdev, 0); |
267 | 267 | ||
268 | device_init_wakeup(&pdev->dev, 1); | ||
268 | palmas_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, | 269 | palmas_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
269 | &palmas_rtc_ops, THIS_MODULE); | 270 | &palmas_rtc_ops, THIS_MODULE); |
270 | if (IS_ERR(palmas_rtc->rtc)) { | 271 | if (IS_ERR(palmas_rtc->rtc)) { |
@@ -283,7 +284,6 @@ static int palmas_rtc_probe(struct platform_device *pdev) | |||
283 | return ret; | 284 | return ret; |
284 | } | 285 | } |
285 | 286 | ||
286 | device_set_wakeup_capable(&pdev->dev, 1); | ||
287 | return 0; | 287 | return 0; |
288 | } | 288 | } |
289 | 289 | ||
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index 539a90b98bc5..40b5c630bc7d 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c | |||
@@ -156,10 +156,8 @@ static int __init pcap_rtc_probe(struct platform_device *pdev) | |||
156 | 156 | ||
157 | pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap", | 157 | pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap", |
158 | &pcap_rtc_ops, THIS_MODULE); | 158 | &pcap_rtc_ops, THIS_MODULE); |
159 | if (IS_ERR(pcap_rtc->rtc)) { | 159 | if (IS_ERR(pcap_rtc->rtc)) |
160 | err = PTR_ERR(pcap_rtc->rtc); | 160 | return PTR_ERR(pcap_rtc->rtc); |
161 | goto fail; | ||
162 | } | ||
163 | 161 | ||
164 | timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); | 162 | timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); |
165 | alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); | 163 | alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); |
@@ -167,17 +165,14 @@ static int __init pcap_rtc_probe(struct platform_device *pdev) | |||
167 | err = devm_request_irq(&pdev->dev, timer_irq, pcap_rtc_irq, 0, | 165 | err = devm_request_irq(&pdev->dev, timer_irq, pcap_rtc_irq, 0, |
168 | "RTC Timer", pcap_rtc); | 166 | "RTC Timer", pcap_rtc); |
169 | if (err) | 167 | if (err) |
170 | goto fail; | 168 | return err; |
171 | 169 | ||
172 | err = devm_request_irq(&pdev->dev, alarm_irq, pcap_rtc_irq, 0, | 170 | err = devm_request_irq(&pdev->dev, alarm_irq, pcap_rtc_irq, 0, |
173 | "RTC Alarm", pcap_rtc); | 171 | "RTC Alarm", pcap_rtc); |
174 | if (err) | 172 | if (err) |
175 | goto fail; | 173 | return err; |
176 | 174 | ||
177 | return 0; | 175 | return 0; |
178 | fail: | ||
179 | platform_set_drvdata(pdev, NULL); | ||
180 | return err; | ||
181 | } | 176 | } |
182 | 177 | ||
183 | static int __exit pcap_rtc_remove(struct platform_device *pdev) | 178 | static int __exit pcap_rtc_remove(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c index 796a6c5067dd..1725b5090e33 100644 --- a/drivers/rtc/rtc-pcf2123.c +++ b/drivers/rtc/rtc-pcf2123.c | |||
@@ -18,11 +18,11 @@ | |||
18 | * should look something like: | 18 | * should look something like: |
19 | * | 19 | * |
20 | * static struct spi_board_info ek_spi_devices[] = { | 20 | * static struct spi_board_info ek_spi_devices[] = { |
21 | * ... | 21 | * ... |
22 | * { | 22 | * { |
23 | * .modalias = "rtc-pcf2123", | 23 | * .modalias = "rtc-pcf2123", |
24 | * .chip_select = 1, | 24 | * .chip_select = 1, |
25 | * .controller_data = (void *)AT91_PIN_PA10, | 25 | * .controller_data = (void *)AT91_PIN_PA10, |
26 | * .max_speed_hz = 1000 * 1000, | 26 | * .max_speed_hz = 1000 * 1000, |
27 | * .mode = SPI_CS_HIGH, | 27 | * .mode = SPI_CS_HIGH, |
28 | * .bus_num = 0, | 28 | * .bus_num = 0, |
@@ -94,8 +94,9 @@ static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr, | |||
94 | 94 | ||
95 | r = container_of(attr, struct pcf2123_sysfs_reg, attr); | 95 | r = container_of(attr, struct pcf2123_sysfs_reg, attr); |
96 | 96 | ||
97 | if (strict_strtoul(r->name, 16, ®)) | 97 | ret = kstrtoul(r->name, 16, ®); |
98 | return -EINVAL; | 98 | if (ret) |
99 | return ret; | ||
99 | 100 | ||
100 | txbuf[0] = PCF2123_READ | reg; | 101 | txbuf[0] = PCF2123_READ | reg; |
101 | ret = spi_write_then_read(spi, txbuf, 1, rxbuf, 1); | 102 | ret = spi_write_then_read(spi, txbuf, 1, rxbuf, 1); |
@@ -117,9 +118,13 @@ static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr, | |||
117 | 118 | ||
118 | r = container_of(attr, struct pcf2123_sysfs_reg, attr); | 119 | r = container_of(attr, struct pcf2123_sysfs_reg, attr); |
119 | 120 | ||
120 | if (strict_strtoul(r->name, 16, ®) | 121 | ret = kstrtoul(r->name, 16, ®); |
121 | || strict_strtoul(buffer, 10, &val)) | 122 | if (ret) |
122 | return -EINVAL; | 123 | return ret; |
124 | |||
125 | ret = kstrtoul(buffer, 10, &val); | ||
126 | if (ret) | ||
127 | return ret; | ||
123 | 128 | ||
124 | txbuf[0] = PCF2123_WRITE | reg; | 129 | txbuf[0] = PCF2123_WRITE | reg; |
125 | txbuf[1] = val; | 130 | txbuf[1] = val; |
diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c new file mode 100644 index 000000000000..205b9f7da1b8 --- /dev/null +++ b/drivers/rtc/rtc-pcf2127.c | |||
@@ -0,0 +1,241 @@ | |||
1 | /* | ||
2 | * An I2C driver for the NXP PCF2127 RTC | ||
3 | * Copyright 2013 Til-Technologies | ||
4 | * | ||
5 | * Author: Renaud Cerrato <r.cerrato@til-technologies.fr> | ||
6 | * | ||
7 | * based on the other drivers in this same directory. | ||
8 | * | ||
9 | * http://www.nxp.com/documents/data_sheet/PCF2127AT.pdf | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/i2c.h> | ||
17 | #include <linux/bcd.h> | ||
18 | #include <linux/rtc.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/of.h> | ||
22 | |||
23 | #define DRV_VERSION "0.0.1" | ||
24 | |||
25 | #define PCF2127_REG_CTRL1 (0x00) /* Control Register 1 */ | ||
26 | #define PCF2127_REG_CTRL2 (0x01) /* Control Register 2 */ | ||
27 | #define PCF2127_REG_CTRL3 (0x02) /* Control Register 3 */ | ||
28 | #define PCF2127_REG_SC (0x03) /* datetime */ | ||
29 | #define PCF2127_REG_MN (0x04) | ||
30 | #define PCF2127_REG_HR (0x05) | ||
31 | #define PCF2127_REG_DM (0x06) | ||
32 | #define PCF2127_REG_DW (0x07) | ||
33 | #define PCF2127_REG_MO (0x08) | ||
34 | #define PCF2127_REG_YR (0x09) | ||
35 | |||
36 | static struct i2c_driver pcf2127_driver; | ||
37 | |||
38 | struct pcf2127 { | ||
39 | struct rtc_device *rtc; | ||
40 | int voltage_low; /* indicates if a low_voltage was detected */ | ||
41 | }; | ||
42 | |||
43 | /* | ||
44 | * In the routines that deal directly with the pcf2127 hardware, we use | ||
45 | * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch. | ||
46 | */ | ||
47 | static int pcf2127_get_datetime(struct i2c_client *client, struct rtc_time *tm) | ||
48 | { | ||
49 | struct pcf2127 *pcf2127 = i2c_get_clientdata(client); | ||
50 | unsigned char buf[10] = { PCF2127_REG_CTRL1 }; | ||
51 | |||
52 | /* read registers */ | ||
53 | if (i2c_master_send(client, buf, 1) != 1 || | ||
54 | i2c_master_recv(client, buf, sizeof(buf)) != sizeof(buf)) { | ||
55 | dev_err(&client->dev, "%s: read error\n", __func__); | ||
56 | return -EIO; | ||
57 | } | ||
58 | |||
59 | if (buf[PCF2127_REG_CTRL3] & 0x04) { | ||
60 | pcf2127->voltage_low = 1; | ||
61 | dev_info(&client->dev, | ||
62 | "low voltage detected, date/time is not reliable.\n"); | ||
63 | } | ||
64 | |||
65 | dev_dbg(&client->dev, | ||
66 | "%s: raw data is cr1=%02x, cr2=%02x, cr3=%02x, " | ||
67 | "sec=%02x, min=%02x, hr=%02x, " | ||
68 | "mday=%02x, wday=%02x, mon=%02x, year=%02x\n", | ||
69 | __func__, | ||
70 | buf[0], buf[1], buf[2], | ||
71 | buf[3], buf[4], buf[5], | ||
72 | buf[6], buf[7], buf[8], buf[9]); | ||
73 | |||
74 | |||
75 | tm->tm_sec = bcd2bin(buf[PCF2127_REG_SC] & 0x7F); | ||
76 | tm->tm_min = bcd2bin(buf[PCF2127_REG_MN] & 0x7F); | ||
77 | tm->tm_hour = bcd2bin(buf[PCF2127_REG_HR] & 0x3F); /* rtc hr 0-23 */ | ||
78 | tm->tm_mday = bcd2bin(buf[PCF2127_REG_DM] & 0x3F); | ||
79 | tm->tm_wday = buf[PCF2127_REG_DW] & 0x07; | ||
80 | tm->tm_mon = bcd2bin(buf[PCF2127_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ | ||
81 | tm->tm_year = bcd2bin(buf[PCF2127_REG_YR]); | ||
82 | if (tm->tm_year < 70) | ||
83 | tm->tm_year += 100; /* assume we are in 1970...2069 */ | ||
84 | |||
85 | dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " | ||
86 | "mday=%d, mon=%d, year=%d, wday=%d\n", | ||
87 | __func__, | ||
88 | tm->tm_sec, tm->tm_min, tm->tm_hour, | ||
89 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
90 | |||
91 | /* the clock can give out invalid datetime, but we cannot return | ||
92 | * -EINVAL otherwise hwclock will refuse to set the time on bootup. | ||
93 | */ | ||
94 | if (rtc_valid_tm(tm) < 0) | ||
95 | dev_err(&client->dev, "retrieved date/time is not valid.\n"); | ||
96 | |||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | static int pcf2127_set_datetime(struct i2c_client *client, struct rtc_time *tm) | ||
101 | { | ||
102 | unsigned char buf[8]; | ||
103 | int i = 0, err; | ||
104 | |||
105 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " | ||
106 | "mday=%d, mon=%d, year=%d, wday=%d\n", | ||
107 | __func__, | ||
108 | tm->tm_sec, tm->tm_min, tm->tm_hour, | ||
109 | tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); | ||
110 | |||
111 | /* start register address */ | ||
112 | buf[i++] = PCF2127_REG_SC; | ||
113 | |||
114 | /* hours, minutes and seconds */ | ||
115 | buf[i++] = bin2bcd(tm->tm_sec); | ||
116 | buf[i++] = bin2bcd(tm->tm_min); | ||
117 | buf[i++] = bin2bcd(tm->tm_hour); | ||
118 | buf[i++] = bin2bcd(tm->tm_mday); | ||
119 | buf[i++] = tm->tm_wday & 0x07; | ||
120 | |||
121 | /* month, 1 - 12 */ | ||
122 | buf[i++] = bin2bcd(tm->tm_mon + 1); | ||
123 | |||
124 | /* year */ | ||
125 | buf[i++] = bin2bcd(tm->tm_year % 100); | ||
126 | |||
127 | /* write register's data */ | ||
128 | err = i2c_master_send(client, buf, i); | ||
129 | if (err != i) { | ||
130 | dev_err(&client->dev, | ||
131 | "%s: err=%d", __func__, err); | ||
132 | return -EIO; | ||
133 | } | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | #ifdef CONFIG_RTC_INTF_DEV | ||
139 | static int pcf2127_rtc_ioctl(struct device *dev, | ||
140 | unsigned int cmd, unsigned long arg) | ||
141 | { | ||
142 | struct pcf2127 *pcf2127 = i2c_get_clientdata(to_i2c_client(dev)); | ||
143 | |||
144 | switch (cmd) { | ||
145 | case RTC_VL_READ: | ||
146 | if (pcf2127->voltage_low) | ||
147 | dev_info(dev, "low voltage detected, date/time is not reliable.\n"); | ||
148 | |||
149 | if (copy_to_user((void __user *)arg, &pcf2127->voltage_low, | ||
150 | sizeof(int))) | ||
151 | return -EFAULT; | ||
152 | return 0; | ||
153 | default: | ||
154 | return -ENOIOCTLCMD; | ||
155 | } | ||
156 | } | ||
157 | #else | ||
158 | #define pcf2127_rtc_ioctl NULL | ||
159 | #endif | ||
160 | |||
161 | static int pcf2127_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
162 | { | ||
163 | return pcf2127_get_datetime(to_i2c_client(dev), tm); | ||
164 | } | ||
165 | |||
166 | static int pcf2127_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
167 | { | ||
168 | return pcf2127_set_datetime(to_i2c_client(dev), tm); | ||
169 | } | ||
170 | |||
171 | static const struct rtc_class_ops pcf2127_rtc_ops = { | ||
172 | .ioctl = pcf2127_rtc_ioctl, | ||
173 | .read_time = pcf2127_rtc_read_time, | ||
174 | .set_time = pcf2127_rtc_set_time, | ||
175 | }; | ||
176 | |||
177 | static int pcf2127_probe(struct i2c_client *client, | ||
178 | const struct i2c_device_id *id) | ||
179 | { | ||
180 | struct pcf2127 *pcf2127; | ||
181 | |||
182 | dev_dbg(&client->dev, "%s\n", __func__); | ||
183 | |||
184 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | ||
185 | return -ENODEV; | ||
186 | |||
187 | pcf2127 = devm_kzalloc(&client->dev, sizeof(struct pcf2127), | ||
188 | GFP_KERNEL); | ||
189 | if (!pcf2127) | ||
190 | return -ENOMEM; | ||
191 | |||
192 | dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); | ||
193 | |||
194 | i2c_set_clientdata(client, pcf2127); | ||
195 | |||
196 | pcf2127->rtc = devm_rtc_device_register(&client->dev, | ||
197 | pcf2127_driver.driver.name, | ||
198 | &pcf2127_rtc_ops, THIS_MODULE); | ||
199 | |||
200 | if (IS_ERR(pcf2127->rtc)) | ||
201 | return PTR_ERR(pcf2127->rtc); | ||
202 | |||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static int pcf2127_remove(struct i2c_client *client) | ||
207 | { | ||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | static const struct i2c_device_id pcf2127_id[] = { | ||
212 | { "pcf2127", 0 }, | ||
213 | { } | ||
214 | }; | ||
215 | MODULE_DEVICE_TABLE(i2c, pcf2127_id); | ||
216 | |||
217 | #ifdef CONFIG_OF | ||
218 | static const struct of_device_id pcf2127_of_match[] = { | ||
219 | { .compatible = "nxp,pcf2127" }, | ||
220 | {} | ||
221 | }; | ||
222 | MODULE_DEVICE_TABLE(of, pcf2127_of_match); | ||
223 | #endif | ||
224 | |||
225 | static struct i2c_driver pcf2127_driver = { | ||
226 | .driver = { | ||
227 | .name = "rtc-pcf2127", | ||
228 | .owner = THIS_MODULE, | ||
229 | .of_match_table = of_match_ptr(pcf2127_of_match), | ||
230 | }, | ||
231 | .probe = pcf2127_probe, | ||
232 | .remove = pcf2127_remove, | ||
233 | .id_table = pcf2127_id, | ||
234 | }; | ||
235 | |||
236 | module_i2c_driver(pcf2127_driver); | ||
237 | |||
238 | MODULE_AUTHOR("Renaud Cerrato <r.cerrato@til-technologies.fr>"); | ||
239 | MODULE_DESCRIPTION("NXP PCF2127 RTC driver"); | ||
240 | MODULE_LICENSE("GPL"); | ||
241 | MODULE_VERSION(DRV_VERSION); | ||
diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c index 305c9515e5bb..5c8f8226c848 100644 --- a/drivers/rtc/rtc-pcf8523.c +++ b/drivers/rtc/rtc-pcf8523.c | |||
@@ -317,11 +317,6 @@ static int pcf8523_probe(struct i2c_client *client, | |||
317 | return 0; | 317 | return 0; |
318 | } | 318 | } |
319 | 319 | ||
320 | static int pcf8523_remove(struct i2c_client *client) | ||
321 | { | ||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | static const struct i2c_device_id pcf8523_id[] = { | 320 | static const struct i2c_device_id pcf8523_id[] = { |
326 | { "pcf8523", 0 }, | 321 | { "pcf8523", 0 }, |
327 | { } | 322 | { } |
@@ -343,7 +338,6 @@ static struct i2c_driver pcf8523_driver = { | |||
343 | .of_match_table = of_match_ptr(pcf8523_of_match), | 338 | .of_match_table = of_match_ptr(pcf8523_of_match), |
344 | }, | 339 | }, |
345 | .probe = pcf8523_probe, | 340 | .probe = pcf8523_probe, |
346 | .remove = pcf8523_remove, | ||
347 | .id_table = pcf8523_id, | 341 | .id_table = pcf8523_id, |
348 | }; | 342 | }; |
349 | module_i2c_driver(pcf8523_driver); | 343 | module_i2c_driver(pcf8523_driver); |
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 97b354a26a44..710c3a5aa6ff 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/of.h> | 22 | #include <linux/of.h> |
23 | #include <linux/err.h> | ||
23 | 24 | ||
24 | #define DRV_VERSION "0.4.3" | 25 | #define DRV_VERSION "0.4.3" |
25 | 26 | ||
@@ -263,15 +264,7 @@ static int pcf8563_probe(struct i2c_client *client, | |||
263 | pcf8563_driver.driver.name, | 264 | pcf8563_driver.driver.name, |
264 | &pcf8563_rtc_ops, THIS_MODULE); | 265 | &pcf8563_rtc_ops, THIS_MODULE); |
265 | 266 | ||
266 | if (IS_ERR(pcf8563->rtc)) | 267 | return PTR_RET(pcf8563->rtc); |
267 | return PTR_ERR(pcf8563->rtc); | ||
268 | |||
269 | return 0; | ||
270 | } | ||
271 | |||
272 | static int pcf8563_remove(struct i2c_client *client) | ||
273 | { | ||
274 | return 0; | ||
275 | } | 268 | } |
276 | 269 | ||
277 | static const struct i2c_device_id pcf8563_id[] = { | 270 | static const struct i2c_device_id pcf8563_id[] = { |
@@ -296,7 +289,6 @@ static struct i2c_driver pcf8563_driver = { | |||
296 | .of_match_table = of_match_ptr(pcf8563_of_match), | 289 | .of_match_table = of_match_ptr(pcf8563_of_match), |
297 | }, | 290 | }, |
298 | .probe = pcf8563_probe, | 291 | .probe = pcf8563_probe, |
299 | .remove = pcf8563_remove, | ||
300 | .id_table = pcf8563_id, | 292 | .id_table = pcf8563_id, |
301 | }; | 293 | }; |
302 | 294 | ||
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index 95886dcf4a39..843a745c42f3 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/err.h> | ||
20 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
21 | #include <linux/bcd.h> | 22 | #include <linux/bcd.h> |
22 | 23 | ||
@@ -188,7 +189,8 @@ static int pcf8583_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
188 | dev_warn(dev, "resetting control %02x -> %02x\n", | 189 | dev_warn(dev, "resetting control %02x -> %02x\n", |
189 | ctrl, new_ctrl); | 190 | ctrl, new_ctrl); |
190 | 191 | ||
191 | if ((err = pcf8583_set_ctrl(client, &new_ctrl)) < 0) | 192 | err = pcf8583_set_ctrl(client, &new_ctrl); |
193 | if (err < 0) | ||
192 | return err; | 194 | return err; |
193 | } | 195 | } |
194 | 196 | ||
@@ -283,15 +285,7 @@ static int pcf8583_probe(struct i2c_client *client, | |||
283 | pcf8583_driver.driver.name, | 285 | pcf8583_driver.driver.name, |
284 | &pcf8583_rtc_ops, THIS_MODULE); | 286 | &pcf8583_rtc_ops, THIS_MODULE); |
285 | 287 | ||
286 | if (IS_ERR(pcf8583->rtc)) | 288 | return PTR_RET(pcf8583->rtc); |
287 | return PTR_ERR(pcf8583->rtc); | ||
288 | |||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static int pcf8583_remove(struct i2c_client *client) | ||
293 | { | ||
294 | return 0; | ||
295 | } | 289 | } |
296 | 290 | ||
297 | static const struct i2c_device_id pcf8583_id[] = { | 291 | static const struct i2c_device_id pcf8583_id[] = { |
@@ -306,7 +300,6 @@ static struct i2c_driver pcf8583_driver = { | |||
306 | .owner = THIS_MODULE, | 300 | .owner = THIS_MODULE, |
307 | }, | 301 | }, |
308 | .probe = pcf8583_probe, | 302 | .probe = pcf8583_probe, |
309 | .remove = pcf8583_remove, | ||
310 | .id_table = pcf8583_id, | 303 | .id_table = pcf8583_id, |
311 | }; | 304 | }; |
312 | 305 | ||
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index f1a6557261f3..03f8f75d5af2 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c | |||
@@ -395,7 +395,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
395 | if (pdata != NULL) | 395 | if (pdata != NULL) |
396 | rtc_write_enable = pdata->rtc_write_enable; | 396 | rtc_write_enable = pdata->rtc_write_enable; |
397 | 397 | ||
398 | rtc_dd = kzalloc(sizeof(*rtc_dd), GFP_KERNEL); | 398 | rtc_dd = devm_kzalloc(&pdev->dev, sizeof(*rtc_dd), GFP_KERNEL); |
399 | if (rtc_dd == NULL) { | 399 | if (rtc_dd == NULL) { |
400 | dev_err(&pdev->dev, "Unable to allocate memory!\n"); | 400 | dev_err(&pdev->dev, "Unable to allocate memory!\n"); |
401 | return -ENOMEM; | 401 | return -ENOMEM; |
@@ -407,16 +407,14 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
407 | rtc_dd->rtc_alarm_irq = platform_get_irq(pdev, 0); | 407 | rtc_dd->rtc_alarm_irq = platform_get_irq(pdev, 0); |
408 | if (rtc_dd->rtc_alarm_irq < 0) { | 408 | if (rtc_dd->rtc_alarm_irq < 0) { |
409 | dev_err(&pdev->dev, "Alarm IRQ resource absent!\n"); | 409 | dev_err(&pdev->dev, "Alarm IRQ resource absent!\n"); |
410 | rc = -ENXIO; | 410 | return -ENXIO; |
411 | goto fail_rtc_enable; | ||
412 | } | 411 | } |
413 | 412 | ||
414 | rtc_resource = platform_get_resource_byname(pdev, IORESOURCE_IO, | 413 | rtc_resource = platform_get_resource_byname(pdev, IORESOURCE_IO, |
415 | "pmic_rtc_base"); | 414 | "pmic_rtc_base"); |
416 | if (!(rtc_resource && rtc_resource->start)) { | 415 | if (!(rtc_resource && rtc_resource->start)) { |
417 | dev_err(&pdev->dev, "RTC IO resource absent!\n"); | 416 | dev_err(&pdev->dev, "RTC IO resource absent!\n"); |
418 | rc = -ENXIO; | 417 | return -ENXIO; |
419 | goto fail_rtc_enable; | ||
420 | } | 418 | } |
421 | 419 | ||
422 | rtc_dd->rtc_base = rtc_resource->start; | 420 | rtc_dd->rtc_base = rtc_resource->start; |
@@ -432,7 +430,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
432 | rc = pm8xxx_read_wrapper(rtc_dd, &ctrl_reg, rtc_dd->rtc_base, 1); | 430 | rc = pm8xxx_read_wrapper(rtc_dd, &ctrl_reg, rtc_dd->rtc_base, 1); |
433 | if (rc < 0) { | 431 | if (rc < 0) { |
434 | dev_err(&pdev->dev, "RTC control register read failed!\n"); | 432 | dev_err(&pdev->dev, "RTC control register read failed!\n"); |
435 | goto fail_rtc_enable; | 433 | return rc; |
436 | } | 434 | } |
437 | 435 | ||
438 | if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) { | 436 | if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) { |
@@ -442,7 +440,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
442 | if (rc < 0) { | 440 | if (rc < 0) { |
443 | dev_err(&pdev->dev, "Write to RTC control register " | 441 | dev_err(&pdev->dev, "Write to RTC control register " |
444 | "failed\n"); | 442 | "failed\n"); |
445 | goto fail_rtc_enable; | 443 | return rc; |
446 | } | 444 | } |
447 | } | 445 | } |
448 | 446 | ||
@@ -453,13 +451,12 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
453 | platform_set_drvdata(pdev, rtc_dd); | 451 | platform_set_drvdata(pdev, rtc_dd); |
454 | 452 | ||
455 | /* Register the RTC device */ | 453 | /* Register the RTC device */ |
456 | rtc_dd->rtc = rtc_device_register("pm8xxx_rtc", &pdev->dev, | 454 | rtc_dd->rtc = devm_rtc_device_register(&pdev->dev, "pm8xxx_rtc", |
457 | &pm8xxx_rtc_ops, THIS_MODULE); | 455 | &pm8xxx_rtc_ops, THIS_MODULE); |
458 | if (IS_ERR(rtc_dd->rtc)) { | 456 | if (IS_ERR(rtc_dd->rtc)) { |
459 | dev_err(&pdev->dev, "%s: RTC registration failed (%ld)\n", | 457 | dev_err(&pdev->dev, "%s: RTC registration failed (%ld)\n", |
460 | __func__, PTR_ERR(rtc_dd->rtc)); | 458 | __func__, PTR_ERR(rtc_dd->rtc)); |
461 | rc = PTR_ERR(rtc_dd->rtc); | 459 | return PTR_ERR(rtc_dd->rtc); |
462 | goto fail_rtc_enable; | ||
463 | } | 460 | } |
464 | 461 | ||
465 | /* Request the alarm IRQ */ | 462 | /* Request the alarm IRQ */ |
@@ -468,7 +465,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
468 | "pm8xxx_rtc_alarm", rtc_dd); | 465 | "pm8xxx_rtc_alarm", rtc_dd); |
469 | if (rc < 0) { | 466 | if (rc < 0) { |
470 | dev_err(&pdev->dev, "Request IRQ failed (%d)\n", rc); | 467 | dev_err(&pdev->dev, "Request IRQ failed (%d)\n", rc); |
471 | goto fail_req_irq; | 468 | return rc; |
472 | } | 469 | } |
473 | 470 | ||
474 | device_init_wakeup(&pdev->dev, 1); | 471 | device_init_wakeup(&pdev->dev, 1); |
@@ -476,13 +473,6 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) | |||
476 | dev_dbg(&pdev->dev, "Probe success !!\n"); | 473 | dev_dbg(&pdev->dev, "Probe success !!\n"); |
477 | 474 | ||
478 | return 0; | 475 | return 0; |
479 | |||
480 | fail_req_irq: | ||
481 | rtc_device_unregister(rtc_dd->rtc); | ||
482 | fail_rtc_enable: | ||
483 | platform_set_drvdata(pdev, NULL); | ||
484 | kfree(rtc_dd); | ||
485 | return rc; | ||
486 | } | 476 | } |
487 | 477 | ||
488 | static int pm8xxx_rtc_remove(struct platform_device *pdev) | 478 | static int pm8xxx_rtc_remove(struct platform_device *pdev) |
@@ -491,9 +481,6 @@ static int pm8xxx_rtc_remove(struct platform_device *pdev) | |||
491 | 481 | ||
492 | device_init_wakeup(&pdev->dev, 0); | 482 | device_init_wakeup(&pdev->dev, 0); |
493 | free_irq(rtc_dd->rtc_alarm_irq, rtc_dd); | 483 | free_irq(rtc_dd->rtc_alarm_irq, rtc_dd); |
494 | rtc_device_unregister(rtc_dd->rtc); | ||
495 | platform_set_drvdata(pdev, NULL); | ||
496 | kfree(rtc_dd); | ||
497 | 484 | ||
498 | return 0; | 485 | return 0; |
499 | } | 486 | } |
diff --git a/drivers/rtc/rtc-ps3.c b/drivers/rtc/rtc-ps3.c index 4bb825bb5804..554ada5e9b76 100644 --- a/drivers/rtc/rtc-ps3.c +++ b/drivers/rtc/rtc-ps3.c | |||
@@ -71,17 +71,11 @@ static int __init ps3_rtc_probe(struct platform_device *dev) | |||
71 | return 0; | 71 | return 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | static int __exit ps3_rtc_remove(struct platform_device *dev) | ||
75 | { | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static struct platform_driver ps3_rtc_driver = { | 74 | static struct platform_driver ps3_rtc_driver = { |
80 | .driver = { | 75 | .driver = { |
81 | .name = "rtc-ps3", | 76 | .name = "rtc-ps3", |
82 | .owner = THIS_MODULE, | 77 | .owner = THIS_MODULE, |
83 | }, | 78 | }, |
84 | .remove = __exit_p(ps3_rtc_remove), | ||
85 | }; | 79 | }; |
86 | 80 | ||
87 | module_platform_driver_probe(ps3_rtc_driver, ps3_rtc_probe); | 81 | module_platform_driver_probe(ps3_rtc_driver, ps3_rtc_probe); |
diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c index 72f437170d2e..402732cfb32a 100644 --- a/drivers/rtc/rtc-puv3.c +++ b/drivers/rtc/rtc-puv3.c | |||
@@ -224,7 +224,6 @@ static int 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 | ||
227 | platform_set_drvdata(dev, NULL); | ||
228 | rtc_device_unregister(rtc); | 227 | rtc_device_unregister(rtc); |
229 | 228 | ||
230 | puv3_rtc_setpie(&dev->dev, 0); | 229 | puv3_rtc_setpie(&dev->dev, 0); |
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index ed037ae91c5f..a355f2b82bb8 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -324,37 +324,35 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) | |||
324 | int ret; | 324 | int ret; |
325 | u32 rttr; | 325 | u32 rttr; |
326 | 326 | ||
327 | pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL); | 327 | pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL); |
328 | if (!pxa_rtc) | 328 | if (!pxa_rtc) |
329 | return -ENOMEM; | 329 | return -ENOMEM; |
330 | 330 | ||
331 | spin_lock_init(&pxa_rtc->lock); | 331 | spin_lock_init(&pxa_rtc->lock); |
332 | platform_set_drvdata(pdev, pxa_rtc); | 332 | platform_set_drvdata(pdev, pxa_rtc); |
333 | 333 | ||
334 | ret = -ENXIO; | ||
335 | pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 334 | pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
336 | if (!pxa_rtc->ress) { | 335 | if (!pxa_rtc->ress) { |
337 | dev_err(dev, "No I/O memory resource defined\n"); | 336 | dev_err(dev, "No I/O memory resource defined\n"); |
338 | goto err_ress; | 337 | return -ENXIO; |
339 | } | 338 | } |
340 | 339 | ||
341 | pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); | 340 | pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); |
342 | if (pxa_rtc->irq_1Hz < 0) { | 341 | if (pxa_rtc->irq_1Hz < 0) { |
343 | dev_err(dev, "No 1Hz IRQ resource defined\n"); | 342 | dev_err(dev, "No 1Hz IRQ resource defined\n"); |
344 | goto err_ress; | 343 | return -ENXIO; |
345 | } | 344 | } |
346 | pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1); | 345 | pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1); |
347 | if (pxa_rtc->irq_Alrm < 0) { | 346 | if (pxa_rtc->irq_Alrm < 0) { |
348 | dev_err(dev, "No alarm IRQ resource defined\n"); | 347 | dev_err(dev, "No alarm IRQ resource defined\n"); |
349 | goto err_ress; | 348 | return -ENXIO; |
350 | } | 349 | } |
351 | pxa_rtc_open(dev); | 350 | pxa_rtc_open(dev); |
352 | ret = -ENOMEM; | 351 | pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start, |
353 | pxa_rtc->base = ioremap(pxa_rtc->ress->start, | ||
354 | resource_size(pxa_rtc->ress)); | 352 | resource_size(pxa_rtc->ress)); |
355 | if (!pxa_rtc->base) { | 353 | if (!pxa_rtc->base) { |
356 | dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n"); | 354 | dev_err(dev, "Unable to map pxa RTC I/O memory\n"); |
357 | goto err_map; | 355 | return -ENOMEM; |
358 | } | 356 | } |
359 | 357 | ||
360 | /* | 358 | /* |
@@ -370,41 +368,24 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) | |||
370 | 368 | ||
371 | rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); | 369 | rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); |
372 | 370 | ||
373 | pxa_rtc->rtc = rtc_device_register("pxa-rtc", &pdev->dev, &pxa_rtc_ops, | 371 | pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc", |
374 | THIS_MODULE); | 372 | &pxa_rtc_ops, THIS_MODULE); |
375 | ret = PTR_ERR(pxa_rtc->rtc); | ||
376 | if (IS_ERR(pxa_rtc->rtc)) { | 373 | if (IS_ERR(pxa_rtc->rtc)) { |
374 | ret = PTR_ERR(pxa_rtc->rtc); | ||
377 | dev_err(dev, "Failed to register RTC device -> %d\n", ret); | 375 | dev_err(dev, "Failed to register RTC device -> %d\n", ret); |
378 | goto err_rtc_reg; | 376 | return ret; |
379 | } | 377 | } |
380 | 378 | ||
381 | device_init_wakeup(dev, 1); | 379 | device_init_wakeup(dev, 1); |
382 | 380 | ||
383 | return 0; | 381 | return 0; |
384 | |||
385 | err_rtc_reg: | ||
386 | iounmap(pxa_rtc->base); | ||
387 | err_ress: | ||
388 | err_map: | ||
389 | kfree(pxa_rtc); | ||
390 | return ret; | ||
391 | } | 382 | } |
392 | 383 | ||
393 | static int __exit pxa_rtc_remove(struct platform_device *pdev) | 384 | static int __exit pxa_rtc_remove(struct platform_device *pdev) |
394 | { | 385 | { |
395 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); | ||
396 | |||
397 | struct device *dev = &pdev->dev; | 386 | struct device *dev = &pdev->dev; |
398 | pxa_rtc_release(dev); | ||
399 | |||
400 | rtc_device_unregister(pxa_rtc->rtc); | ||
401 | |||
402 | spin_lock_irq(&pxa_rtc->lock); | ||
403 | iounmap(pxa_rtc->base); | ||
404 | spin_unlock_irq(&pxa_rtc->lock); | ||
405 | |||
406 | kfree(pxa_rtc); | ||
407 | 387 | ||
388 | pxa_rtc_release(dev); | ||
408 | return 0; | 389 | return 0; |
409 | } | 390 | } |
410 | 391 | ||
diff --git a/drivers/rtc/rtc-rc5t583.c b/drivers/rtc/rtc-rc5t583.c index 8eabcf51b35a..e53e9b1c69b3 100644 --- a/drivers/rtc/rtc-rc5t583.c +++ b/drivers/rtc/rtc-rc5t583.c | |||
@@ -273,7 +273,7 @@ static int rc5t583_rtc_probe(struct platform_device *pdev) | |||
273 | */ | 273 | */ |
274 | static int rc5t583_rtc_remove(struct platform_device *pdev) | 274 | static int rc5t583_rtc_remove(struct platform_device *pdev) |
275 | { | 275 | { |
276 | struct rc5t583_rtc *rc5t583_rtc = dev_get_drvdata(&pdev->dev); | 276 | struct rc5t583_rtc *rc5t583_rtc = platform_get_drvdata(pdev); |
277 | 277 | ||
278 | rc5t583_rtc_alarm_irq_enable(&rc5t583_rtc->rtc->dev, 0); | 278 | rc5t583_rtc_alarm_irq_enable(&rc5t583_rtc->rtc->dev, 0); |
279 | return 0; | 279 | return 0; |
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c index 873c689f01c3..89d073679267 100644 --- a/drivers/rtc/rtc-rp5c01.c +++ b/drivers/rtc/rtc-rp5c01.c | |||
@@ -251,21 +251,15 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev) | |||
251 | 251 | ||
252 | rtc = devm_rtc_device_register(&dev->dev, "rtc-rp5c01", &rp5c01_rtc_ops, | 252 | rtc = devm_rtc_device_register(&dev->dev, "rtc-rp5c01", &rp5c01_rtc_ops, |
253 | THIS_MODULE); | 253 | THIS_MODULE); |
254 | if (IS_ERR(rtc)) { | 254 | if (IS_ERR(rtc)) |
255 | error = PTR_ERR(rtc); | 255 | return PTR_ERR(rtc); |
256 | goto out; | ||
257 | } | ||
258 | priv->rtc = rtc; | 256 | priv->rtc = rtc; |
259 | 257 | ||
260 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); | 258 | error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); |
261 | if (error) | 259 | if (error) |
262 | goto out; | 260 | return error; |
263 | 261 | ||
264 | return 0; | 262 | return 0; |
265 | |||
266 | out: | ||
267 | platform_set_drvdata(dev, NULL); | ||
268 | return error; | ||
269 | } | 263 | } |
270 | 264 | ||
271 | static int __exit rp5c01_rtc_remove(struct platform_device *dev) | 265 | static int __exit rp5c01_rtc_remove(struct platform_device *dev) |
diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index 8089fc63e403..68f7856422f1 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c | |||
@@ -47,10 +47,10 @@ | |||
47 | #include <linux/platform_device.h> | 47 | #include <linux/platform_device.h> |
48 | #include <linux/bcd.h> | 48 | #include <linux/bcd.h> |
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <asm/io.h> | 50 | #include <linux/io.h> |
51 | 51 | ||
52 | #define DRV_NAME "rs5c313" | 52 | #define DRV_NAME "rs5c313" |
53 | #define DRV_VERSION "1.13" | 53 | #define DRV_VERSION "1.13" |
54 | 54 | ||
55 | #ifdef CONFIG_SH_LANDISK | 55 | #ifdef CONFIG_SH_LANDISK |
56 | /*****************************************************/ | 56 | /*****************************************************/ |
@@ -301,7 +301,7 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
301 | rs5c313_write_reg(RS5C313_ADDR_SEC10, (data >> 4)); | 301 | rs5c313_write_reg(RS5C313_ADDR_SEC10, (data >> 4)); |
302 | 302 | ||
303 | data = bin2bcd(tm->tm_min); | 303 | data = bin2bcd(tm->tm_min); |
304 | rs5c313_write_reg(RS5C313_ADDR_MIN, data ); | 304 | rs5c313_write_reg(RS5C313_ADDR_MIN, data); |
305 | rs5c313_write_reg(RS5C313_ADDR_MIN10, (data >> 4)); | 305 | rs5c313_write_reg(RS5C313_ADDR_MIN10, (data >> 4)); |
306 | 306 | ||
307 | data = bin2bcd(tm->tm_hour); | 307 | data = bin2bcd(tm->tm_hour); |
@@ -310,7 +310,7 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
310 | 310 | ||
311 | data = bin2bcd(tm->tm_mday); | 311 | data = bin2bcd(tm->tm_mday); |
312 | rs5c313_write_reg(RS5C313_ADDR_DAY, data); | 312 | rs5c313_write_reg(RS5C313_ADDR_DAY, data); |
313 | rs5c313_write_reg(RS5C313_ADDR_DAY10, (data>> 4)); | 313 | rs5c313_write_reg(RS5C313_ADDR_DAY10, (data >> 4)); |
314 | 314 | ||
315 | data = bin2bcd(tm->tm_mon + 1); | 315 | data = bin2bcd(tm->tm_mon + 1); |
316 | rs5c313_write_reg(RS5C313_ADDR_MON, data); | 316 | rs5c313_write_reg(RS5C313_ADDR_MON, data); |
@@ -349,9 +349,9 @@ static void rs5c313_check_xstp_bit(void) | |||
349 | } | 349 | } |
350 | 350 | ||
351 | memset(&tm, 0, sizeof(struct rtc_time)); | 351 | memset(&tm, 0, sizeof(struct rtc_time)); |
352 | tm.tm_mday = 1; | 352 | tm.tm_mday = 1; |
353 | tm.tm_mon = 1 - 1; | 353 | tm.tm_mon = 1 - 1; |
354 | tm.tm_year = 2000 - 1900; | 354 | tm.tm_year = 2000 - 1900; |
355 | 355 | ||
356 | rs5c313_rtc_set_time(NULL, &tm); | 356 | rs5c313_rtc_set_time(NULL, &tm); |
357 | pr_err("invalid value, resetting to 1 Jan 2000\n"); | 357 | pr_err("invalid value, resetting to 1 Jan 2000\n"); |
@@ -378,18 +378,12 @@ static int rs5c313_rtc_probe(struct platform_device *pdev) | |||
378 | return 0; | 378 | return 0; |
379 | } | 379 | } |
380 | 380 | ||
381 | static int rs5c313_rtc_remove(struct platform_device *pdev) | ||
382 | { | ||
383 | return 0; | ||
384 | } | ||
385 | |||
386 | static struct platform_driver rs5c313_rtc_platform_driver = { | 381 | static struct platform_driver rs5c313_rtc_platform_driver = { |
387 | .driver = { | 382 | .driver = { |
388 | .name = DRV_NAME, | 383 | .name = DRV_NAME, |
389 | .owner = THIS_MODULE, | 384 | .owner = THIS_MODULE, |
390 | }, | 385 | }, |
391 | .probe = rs5c313_rtc_probe, | 386 | .probe = rs5c313_rtc_probe, |
392 | .remove = rs5c313_rtc_remove, | ||
393 | }; | 387 | }; |
394 | 388 | ||
395 | static int __init rs5c313_rtc_init(void) | 389 | static int __init rs5c313_rtc_init(void) |
@@ -408,7 +402,7 @@ static int __init rs5c313_rtc_init(void) | |||
408 | 402 | ||
409 | static void __exit rs5c313_rtc_exit(void) | 403 | static void __exit rs5c313_rtc_exit(void) |
410 | { | 404 | { |
411 | platform_driver_unregister( &rs5c313_rtc_platform_driver ); | 405 | platform_driver_unregister(&rs5c313_rtc_platform_driver); |
412 | } | 406 | } |
413 | 407 | ||
414 | module_init(rs5c313_rtc_init); | 408 | module_init(rs5c313_rtc_init); |
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index 2c37df3586c7..f7a90a116a39 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c | |||
@@ -218,18 +218,12 @@ static int rs5c348_probe(struct spi_device *spi) | |||
218 | return ret; | 218 | return ret; |
219 | } | 219 | } |
220 | 220 | ||
221 | static int rs5c348_remove(struct spi_device *spi) | ||
222 | { | ||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static struct spi_driver rs5c348_driver = { | 221 | static struct spi_driver rs5c348_driver = { |
227 | .driver = { | 222 | .driver = { |
228 | .name = "rtc-rs5c348", | 223 | .name = "rtc-rs5c348", |
229 | .owner = THIS_MODULE, | 224 | .owner = THIS_MODULE, |
230 | }, | 225 | }, |
231 | .probe = rs5c348_probe, | 226 | .probe = rs5c348_probe, |
232 | .remove = rs5c348_remove, | ||
233 | }; | 227 | }; |
234 | 228 | ||
235 | module_spi_driver(rs5c348_driver); | 229 | module_spi_driver(rs5c348_driver); |
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c index 5032c24ec159..1a779a67ff66 100644 --- a/drivers/rtc/rtc-rv3029c2.c +++ b/drivers/rtc/rtc-rv3029c2.c | |||
@@ -310,7 +310,7 @@ static int rv3029c2_rtc_i2c_set_alarm(struct i2c_client *client, | |||
310 | dev_dbg(&client->dev, "alarm IRQ armed\n"); | 310 | dev_dbg(&client->dev, "alarm IRQ armed\n"); |
311 | } else { | 311 | } else { |
312 | /* disable AIE irq */ | 312 | /* disable AIE irq */ |
313 | ret = rv3029c2_rtc_i2c_alarm_set_irq(client, 1); | 313 | ret = rv3029c2_rtc_i2c_alarm_set_irq(client, 0); |
314 | if (ret) | 314 | if (ret) |
315 | return ret; | 315 | return ret; |
316 | 316 | ||
@@ -412,17 +412,11 @@ static int rv3029c2_probe(struct i2c_client *client, | |||
412 | return 0; | 412 | return 0; |
413 | } | 413 | } |
414 | 414 | ||
415 | static int rv3029c2_remove(struct i2c_client *client) | ||
416 | { | ||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | static struct i2c_driver rv3029c2_driver = { | 415 | static struct i2c_driver rv3029c2_driver = { |
421 | .driver = { | 416 | .driver = { |
422 | .name = "rtc-rv3029c2", | 417 | .name = "rtc-rv3029c2", |
423 | }, | 418 | }, |
424 | .probe = rv3029c2_probe, | 419 | .probe = rv3029c2_probe, |
425 | .remove = rv3029c2_remove, | ||
426 | .id_table = rv3029c2_id, | 420 | .id_table = rv3029c2_id, |
427 | }; | 421 | }; |
428 | 422 | ||
diff --git a/drivers/rtc/rtc-rx4581.c b/drivers/rtc/rtc-rx4581.c index 84eb08d65d30..6889222f9ed6 100644 --- a/drivers/rtc/rtc-rx4581.c +++ b/drivers/rtc/rtc-rx4581.c | |||
@@ -282,11 +282,6 @@ static int rx4581_probe(struct spi_device *spi) | |||
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | static int rx4581_remove(struct spi_device *spi) | ||
286 | { | ||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | static const struct spi_device_id rx4581_id[] = { | 285 | static const struct spi_device_id rx4581_id[] = { |
291 | { "rx4581", 0 }, | 286 | { "rx4581", 0 }, |
292 | { } | 287 | { } |
@@ -299,7 +294,6 @@ static struct spi_driver rx4581_driver = { | |||
299 | .owner = THIS_MODULE, | 294 | .owner = THIS_MODULE, |
300 | }, | 295 | }, |
301 | .probe = rx4581_probe, | 296 | .probe = rx4581_probe, |
302 | .remove = rx4581_remove, | ||
303 | .id_table = rx4581_id, | 297 | .id_table = rx4581_id, |
304 | }; | 298 | }; |
305 | 299 | ||
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c index 0722d36b9c9a..8fa23eabcb68 100644 --- a/drivers/rtc/rtc-rx8025.c +++ b/drivers/rtc/rtc-rx8025.c | |||
@@ -549,7 +549,7 @@ static int rx8025_probe(struct i2c_client *client, | |||
549 | goto errout; | 549 | goto errout; |
550 | } | 550 | } |
551 | 551 | ||
552 | rx8025 = kzalloc(sizeof(*rx8025), GFP_KERNEL); | 552 | rx8025 = devm_kzalloc(&client->dev, sizeof(*rx8025), GFP_KERNEL); |
553 | if (!rx8025) { | 553 | if (!rx8025) { |
554 | dev_err(&adapter->dev, "failed to alloc memory\n"); | 554 | dev_err(&adapter->dev, "failed to alloc memory\n"); |
555 | err = -ENOMEM; | 555 | err = -ENOMEM; |
@@ -562,7 +562,7 @@ static int rx8025_probe(struct i2c_client *client, | |||
562 | 562 | ||
563 | err = rx8025_init_client(client, &need_reset); | 563 | err = rx8025_init_client(client, &need_reset); |
564 | if (err) | 564 | if (err) |
565 | goto errout_free; | 565 | goto errout; |
566 | 566 | ||
567 | if (need_reset) { | 567 | if (need_reset) { |
568 | struct rtc_time tm; | 568 | struct rtc_time tm; |
@@ -572,12 +572,12 @@ static int rx8025_probe(struct i2c_client *client, | |||
572 | rx8025_set_time(&client->dev, &tm); | 572 | rx8025_set_time(&client->dev, &tm); |
573 | } | 573 | } |
574 | 574 | ||
575 | rx8025->rtc = rtc_device_register(client->name, &client->dev, | 575 | rx8025->rtc = devm_rtc_device_register(&client->dev, client->name, |
576 | &rx8025_rtc_ops, THIS_MODULE); | 576 | &rx8025_rtc_ops, THIS_MODULE); |
577 | if (IS_ERR(rx8025->rtc)) { | 577 | if (IS_ERR(rx8025->rtc)) { |
578 | err = PTR_ERR(rx8025->rtc); | 578 | err = PTR_ERR(rx8025->rtc); |
579 | dev_err(&client->dev, "unable to register the class device\n"); | 579 | dev_err(&client->dev, "unable to register the class device\n"); |
580 | goto errout_free; | 580 | goto errout; |
581 | } | 581 | } |
582 | 582 | ||
583 | if (client->irq > 0) { | 583 | if (client->irq > 0) { |
@@ -586,7 +586,7 @@ static int rx8025_probe(struct i2c_client *client, | |||
586 | 0, "rx8025", client); | 586 | 0, "rx8025", client); |
587 | if (err) { | 587 | if (err) { |
588 | dev_err(&client->dev, "unable to request IRQ\n"); | 588 | dev_err(&client->dev, "unable to request IRQ\n"); |
589 | goto errout_reg; | 589 | goto errout; |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
@@ -603,12 +603,6 @@ errout_irq: | |||
603 | if (client->irq > 0) | 603 | if (client->irq > 0) |
604 | free_irq(client->irq, client); | 604 | free_irq(client->irq, client); |
605 | 605 | ||
606 | errout_reg: | ||
607 | rtc_device_unregister(rx8025->rtc); | ||
608 | |||
609 | errout_free: | ||
610 | kfree(rx8025); | ||
611 | |||
612 | errout: | 606 | errout: |
613 | dev_err(&adapter->dev, "probing for rx8025 failed\n"); | 607 | dev_err(&adapter->dev, "probing for rx8025 failed\n"); |
614 | return err; | 608 | return err; |
@@ -629,8 +623,6 @@ static int rx8025_remove(struct i2c_client *client) | |||
629 | } | 623 | } |
630 | 624 | ||
631 | rx8025_sysfs_unregister(&client->dev); | 625 | rx8025_sysfs_unregister(&client->dev); |
632 | rtc_device_unregister(rx8025->rtc); | ||
633 | kfree(rx8025); | ||
634 | return 0; | 626 | return 0; |
635 | } | 627 | } |
636 | 628 | ||
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c index 07f3037b18f4..00b0eb7fe166 100644 --- a/drivers/rtc/rtc-rx8581.c +++ b/drivers/rtc/rtc-rx8581.c | |||
@@ -251,11 +251,6 @@ static int rx8581_probe(struct i2c_client *client, | |||
251 | return 0; | 251 | return 0; |
252 | } | 252 | } |
253 | 253 | ||
254 | static int rx8581_remove(struct i2c_client *client) | ||
255 | { | ||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static const struct i2c_device_id rx8581_id[] = { | 254 | static const struct i2c_device_id rx8581_id[] = { |
260 | { "rx8581", 0 }, | 255 | { "rx8581", 0 }, |
261 | { } | 256 | { } |
@@ -268,7 +263,6 @@ static struct i2c_driver rx8581_driver = { | |||
268 | .owner = THIS_MODULE, | 263 | .owner = THIS_MODULE, |
269 | }, | 264 | }, |
270 | .probe = rx8581_probe, | 265 | .probe = rx8581_probe, |
271 | .remove = rx8581_remove, | ||
272 | .id_table = rx8581_id, | 266 | .id_table = rx8581_id, |
273 | }; | 267 | }; |
274 | 268 | ||
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 0b495e8b8e66..7afd373b9595 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -421,8 +421,6 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en) | |||
421 | 421 | ||
422 | static int s3c_rtc_remove(struct platform_device *dev) | 422 | static int s3c_rtc_remove(struct platform_device *dev) |
423 | { | 423 | { |
424 | platform_set_drvdata(dev, NULL); | ||
425 | |||
426 | s3c_rtc_setaie(&dev->dev, 0); | 424 | s3c_rtc_setaie(&dev->dev, 0); |
427 | 425 | ||
428 | clk_unprepare(rtc_clk); | 426 | clk_unprepare(rtc_clk); |
@@ -549,23 +547,20 @@ static int s3c_rtc_probe(struct platform_device *pdev) | |||
549 | 0, "s3c2410-rtc alarm", rtc); | 547 | 0, "s3c2410-rtc alarm", rtc); |
550 | if (ret) { | 548 | if (ret) { |
551 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); | 549 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); |
552 | goto err_alarm_irq; | 550 | goto err_nortc; |
553 | } | 551 | } |
554 | 552 | ||
555 | ret = devm_request_irq(&pdev->dev, s3c_rtc_tickno, s3c_rtc_tickirq, | 553 | ret = devm_request_irq(&pdev->dev, s3c_rtc_tickno, s3c_rtc_tickirq, |
556 | 0, "s3c2410-rtc tick", rtc); | 554 | 0, "s3c2410-rtc tick", rtc); |
557 | if (ret) { | 555 | if (ret) { |
558 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); | 556 | dev_err(&pdev->dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); |
559 | goto err_alarm_irq; | 557 | goto err_nortc; |
560 | } | 558 | } |
561 | 559 | ||
562 | clk_disable(rtc_clk); | 560 | clk_disable(rtc_clk); |
563 | 561 | ||
564 | return 0; | 562 | return 0; |
565 | 563 | ||
566 | err_alarm_irq: | ||
567 | platform_set_drvdata(pdev, NULL); | ||
568 | |||
569 | err_nortc: | 564 | err_nortc: |
570 | s3c_rtc_enable(pdev, 0); | 565 | s3c_rtc_enable(pdev, 0); |
571 | clk_disable_unprepare(rtc_clk); | 566 | clk_disable_unprepare(rtc_clk); |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 00605601dbf7..0f7adeb1944a 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -249,7 +249,7 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
249 | 249 | ||
250 | ret = clk_prepare_enable(info->clk); | 250 | ret = clk_prepare_enable(info->clk); |
251 | if (ret) | 251 | if (ret) |
252 | goto err_enable_clk; | 252 | return ret; |
253 | /* | 253 | /* |
254 | * According to the manual we should be able to let RTTR be zero | 254 | * According to the manual we should be able to let RTTR be zero |
255 | * and then a default diviser for a 32.768KHz clock is used. | 255 | * and then a default diviser for a 32.768KHz clock is used. |
@@ -303,8 +303,6 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
303 | return 0; | 303 | return 0; |
304 | err_dev: | 304 | err_dev: |
305 | clk_disable_unprepare(info->clk); | 305 | clk_disable_unprepare(info->clk); |
306 | err_enable_clk: | ||
307 | platform_set_drvdata(pdev, NULL); | ||
308 | return ret; | 306 | return ret; |
309 | } | 307 | } |
310 | 308 | ||
@@ -312,10 +310,8 @@ static int sa1100_rtc_remove(struct platform_device *pdev) | |||
312 | { | 310 | { |
313 | struct sa1100_rtc *info = platform_get_drvdata(pdev); | 311 | struct sa1100_rtc *info = platform_get_drvdata(pdev); |
314 | 312 | ||
315 | if (info) { | 313 | if (info) |
316 | clk_disable_unprepare(info->clk); | 314 | clk_disable_unprepare(info->clk); |
317 | platform_set_drvdata(pdev, NULL); | ||
318 | } | ||
319 | 315 | ||
320 | return 0; | 316 | return 0; |
321 | } | 317 | } |
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 8d5bd2e36776..6d87e26355a3 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -593,7 +593,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
593 | char clk_name[6]; | 593 | char clk_name[6]; |
594 | int clk_id, ret; | 594 | int clk_id, ret; |
595 | 595 | ||
596 | rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL); | 596 | rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); |
597 | if (unlikely(!rtc)) | 597 | if (unlikely(!rtc)) |
598 | return -ENOMEM; | 598 | return -ENOMEM; |
599 | 599 | ||
@@ -602,9 +602,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
602 | /* get periodic/carry/alarm irqs */ | 602 | /* get periodic/carry/alarm irqs */ |
603 | ret = platform_get_irq(pdev, 0); | 603 | ret = platform_get_irq(pdev, 0); |
604 | if (unlikely(ret <= 0)) { | 604 | if (unlikely(ret <= 0)) { |
605 | ret = -ENOENT; | ||
606 | dev_err(&pdev->dev, "No IRQ resource\n"); | 605 | dev_err(&pdev->dev, "No IRQ resource\n"); |
607 | goto err_badres; | 606 | return -ENOENT; |
608 | } | 607 | } |
609 | 608 | ||
610 | rtc->periodic_irq = ret; | 609 | rtc->periodic_irq = ret; |
@@ -613,24 +612,21 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
613 | 612 | ||
614 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 613 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
615 | if (unlikely(res == NULL)) { | 614 | if (unlikely(res == NULL)) { |
616 | ret = -ENOENT; | ||
617 | dev_err(&pdev->dev, "No IO resource\n"); | 615 | dev_err(&pdev->dev, "No IO resource\n"); |
618 | goto err_badres; | 616 | return -ENOENT; |
619 | } | 617 | } |
620 | 618 | ||
621 | rtc->regsize = resource_size(res); | 619 | rtc->regsize = resource_size(res); |
622 | 620 | ||
623 | rtc->res = request_mem_region(res->start, rtc->regsize, pdev->name); | 621 | rtc->res = devm_request_mem_region(&pdev->dev, res->start, |
624 | if (unlikely(!rtc->res)) { | 622 | rtc->regsize, pdev->name); |
625 | ret = -EBUSY; | 623 | if (unlikely(!rtc->res)) |
626 | goto err_badres; | 624 | return -EBUSY; |
627 | } | ||
628 | 625 | ||
629 | rtc->regbase = ioremap_nocache(rtc->res->start, rtc->regsize); | 626 | rtc->regbase = devm_ioremap_nocache(&pdev->dev, rtc->res->start, |
630 | if (unlikely(!rtc->regbase)) { | 627 | rtc->regsize); |
631 | ret = -EINVAL; | 628 | if (unlikely(!rtc->regbase)) |
632 | goto err_badmap; | 629 | return -EINVAL; |
633 | } | ||
634 | 630 | ||
635 | clk_id = pdev->id; | 631 | clk_id = pdev->id; |
636 | /* With a single device, the clock id is still "rtc0" */ | 632 | /* With a single device, the clock id is still "rtc0" */ |
@@ -639,7 +635,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
639 | 635 | ||
640 | snprintf(clk_name, sizeof(clk_name), "rtc%d", clk_id); | 636 | snprintf(clk_name, sizeof(clk_name), "rtc%d", clk_id); |
641 | 637 | ||
642 | rtc->clk = clk_get(&pdev->dev, clk_name); | 638 | rtc->clk = devm_clk_get(&pdev->dev, clk_name); |
643 | if (IS_ERR(rtc->clk)) { | 639 | if (IS_ERR(rtc->clk)) { |
644 | /* | 640 | /* |
645 | * No error handling for rtc->clk intentionally, not all | 641 | * No error handling for rtc->clk intentionally, not all |
@@ -665,8 +661,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
665 | 661 | ||
666 | if (rtc->carry_irq <= 0) { | 662 | if (rtc->carry_irq <= 0) { |
667 | /* register shared periodic/carry/alarm irq */ | 663 | /* register shared periodic/carry/alarm irq */ |
668 | ret = request_irq(rtc->periodic_irq, sh_rtc_shared, | 664 | ret = devm_request_irq(&pdev->dev, rtc->periodic_irq, |
669 | 0, "sh-rtc", rtc); | 665 | sh_rtc_shared, 0, "sh-rtc", rtc); |
670 | if (unlikely(ret)) { | 666 | if (unlikely(ret)) { |
671 | dev_err(&pdev->dev, | 667 | dev_err(&pdev->dev, |
672 | "request IRQ failed with %d, IRQ %d\n", ret, | 668 | "request IRQ failed with %d, IRQ %d\n", ret, |
@@ -675,8 +671,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
675 | } | 671 | } |
676 | } else { | 672 | } else { |
677 | /* register periodic/carry/alarm irqs */ | 673 | /* register periodic/carry/alarm irqs */ |
678 | ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, | 674 | ret = devm_request_irq(&pdev->dev, rtc->periodic_irq, |
679 | 0, "sh-rtc period", rtc); | 675 | sh_rtc_periodic, 0, "sh-rtc period", rtc); |
680 | if (unlikely(ret)) { | 676 | if (unlikely(ret)) { |
681 | dev_err(&pdev->dev, | 677 | dev_err(&pdev->dev, |
682 | "request period IRQ failed with %d, IRQ %d\n", | 678 | "request period IRQ failed with %d, IRQ %d\n", |
@@ -684,24 +680,21 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
684 | goto err_unmap; | 680 | goto err_unmap; |
685 | } | 681 | } |
686 | 682 | ||
687 | ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, | 683 | ret = devm_request_irq(&pdev->dev, rtc->carry_irq, |
688 | 0, "sh-rtc carry", rtc); | 684 | sh_rtc_interrupt, 0, "sh-rtc carry", rtc); |
689 | if (unlikely(ret)) { | 685 | if (unlikely(ret)) { |
690 | dev_err(&pdev->dev, | 686 | dev_err(&pdev->dev, |
691 | "request carry IRQ failed with %d, IRQ %d\n", | 687 | "request carry IRQ failed with %d, IRQ %d\n", |
692 | ret, rtc->carry_irq); | 688 | ret, rtc->carry_irq); |
693 | free_irq(rtc->periodic_irq, rtc); | ||
694 | goto err_unmap; | 689 | goto err_unmap; |
695 | } | 690 | } |
696 | 691 | ||
697 | ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, | 692 | ret = devm_request_irq(&pdev->dev, rtc->alarm_irq, |
698 | 0, "sh-rtc alarm", rtc); | 693 | sh_rtc_alarm, 0, "sh-rtc alarm", rtc); |
699 | if (unlikely(ret)) { | 694 | if (unlikely(ret)) { |
700 | dev_err(&pdev->dev, | 695 | dev_err(&pdev->dev, |
701 | "request alarm IRQ failed with %d, IRQ %d\n", | 696 | "request alarm IRQ failed with %d, IRQ %d\n", |
702 | ret, rtc->alarm_irq); | 697 | ret, rtc->alarm_irq); |
703 | free_irq(rtc->carry_irq, rtc); | ||
704 | free_irq(rtc->periodic_irq, rtc); | ||
705 | goto err_unmap; | 698 | goto err_unmap; |
706 | } | 699 | } |
707 | } | 700 | } |
@@ -714,13 +707,10 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
714 | sh_rtc_setaie(&pdev->dev, 0); | 707 | sh_rtc_setaie(&pdev->dev, 0); |
715 | sh_rtc_setcie(&pdev->dev, 0); | 708 | sh_rtc_setcie(&pdev->dev, 0); |
716 | 709 | ||
717 | rtc->rtc_dev = rtc_device_register("sh", &pdev->dev, | 710 | rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "sh", |
718 | &sh_rtc_ops, THIS_MODULE); | 711 | &sh_rtc_ops, THIS_MODULE); |
719 | if (IS_ERR(rtc->rtc_dev)) { | 712 | if (IS_ERR(rtc->rtc_dev)) { |
720 | ret = PTR_ERR(rtc->rtc_dev); | 713 | ret = PTR_ERR(rtc->rtc_dev); |
721 | free_irq(rtc->periodic_irq, rtc); | ||
722 | free_irq(rtc->carry_irq, rtc); | ||
723 | free_irq(rtc->alarm_irq, rtc); | ||
724 | goto err_unmap; | 714 | goto err_unmap; |
725 | } | 715 | } |
726 | 716 | ||
@@ -737,12 +727,6 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
737 | 727 | ||
738 | err_unmap: | 728 | err_unmap: |
739 | clk_disable(rtc->clk); | 729 | clk_disable(rtc->clk); |
740 | clk_put(rtc->clk); | ||
741 | iounmap(rtc->regbase); | ||
742 | err_badmap: | ||
743 | release_mem_region(rtc->res->start, rtc->regsize); | ||
744 | err_badres: | ||
745 | kfree(rtc); | ||
746 | 730 | ||
747 | return ret; | 731 | return ret; |
748 | } | 732 | } |
@@ -751,28 +735,12 @@ static int __exit sh_rtc_remove(struct platform_device *pdev) | |||
751 | { | 735 | { |
752 | struct sh_rtc *rtc = platform_get_drvdata(pdev); | 736 | struct sh_rtc *rtc = platform_get_drvdata(pdev); |
753 | 737 | ||
754 | rtc_device_unregister(rtc->rtc_dev); | ||
755 | sh_rtc_irq_set_state(&pdev->dev, 0); | 738 | sh_rtc_irq_set_state(&pdev->dev, 0); |
756 | 739 | ||
757 | sh_rtc_setaie(&pdev->dev, 0); | 740 | sh_rtc_setaie(&pdev->dev, 0); |
758 | sh_rtc_setcie(&pdev->dev, 0); | 741 | sh_rtc_setcie(&pdev->dev, 0); |
759 | 742 | ||
760 | free_irq(rtc->periodic_irq, rtc); | ||
761 | |||
762 | if (rtc->carry_irq > 0) { | ||
763 | free_irq(rtc->carry_irq, rtc); | ||
764 | free_irq(rtc->alarm_irq, rtc); | ||
765 | } | ||
766 | |||
767 | iounmap(rtc->regbase); | ||
768 | release_mem_region(rtc->res->start, rtc->regsize); | ||
769 | |||
770 | clk_disable(rtc->clk); | 743 | clk_disable(rtc->clk); |
771 | clk_put(rtc->clk); | ||
772 | |||
773 | platform_set_drvdata(pdev, NULL); | ||
774 | |||
775 | kfree(rtc); | ||
776 | 744 | ||
777 | return 0; | 745 | return 0; |
778 | } | 746 | } |
diff --git a/drivers/rtc/rtc-sirfsoc.c b/drivers/rtc/rtc-sirfsoc.c new file mode 100644 index 000000000000..aa7ed4b5f7f0 --- /dev/null +++ b/drivers/rtc/rtc-sirfsoc.c | |||
@@ -0,0 +1,475 @@ | |||
1 | /* | ||
2 | * SiRFSoC Real Time Clock interface for Linux | ||
3 | * | ||
4 | * Copyright (c) 2013 Cambridge Silicon Radio Limited, a CSR plc group company. | ||
5 | * | ||
6 | * Licensed under GPLv2 or later. | ||
7 | */ | ||
8 | |||
9 | #include <linux/module.h> | ||
10 | #include <linux/err.h> | ||
11 | #include <linux/rtc.h> | ||
12 | #include <linux/platform_device.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/of.h> | ||
16 | #include <linux/rtc/sirfsoc_rtciobrg.h> | ||
17 | |||
18 | |||
19 | #define RTC_CN 0x00 | ||
20 | #define RTC_ALARM0 0x04 | ||
21 | #define RTC_ALARM1 0x18 | ||
22 | #define RTC_STATUS 0x08 | ||
23 | #define RTC_SW_VALUE 0x40 | ||
24 | #define SIRFSOC_RTC_AL1E (1<<6) | ||
25 | #define SIRFSOC_RTC_AL1 (1<<4) | ||
26 | #define SIRFSOC_RTC_HZE (1<<3) | ||
27 | #define SIRFSOC_RTC_AL0E (1<<2) | ||
28 | #define SIRFSOC_RTC_HZ (1<<1) | ||
29 | #define SIRFSOC_RTC_AL0 (1<<0) | ||
30 | #define RTC_DIV 0x0c | ||
31 | #define RTC_DEEP_CTRL 0x14 | ||
32 | #define RTC_CLOCK_SWITCH 0x1c | ||
33 | #define SIRFSOC_RTC_CLK 0x03 /* others are reserved */ | ||
34 | |||
35 | /* Refer to RTC DIV switch */ | ||
36 | #define RTC_HZ 16 | ||
37 | |||
38 | /* This macro is also defined in arch/arm/plat-sirfsoc/cpu.c */ | ||
39 | #define RTC_SHIFT 4 | ||
40 | |||
41 | #define INTR_SYSRTC_CN 0x48 | ||
42 | |||
43 | struct sirfsoc_rtc_drv { | ||
44 | struct rtc_device *rtc; | ||
45 | u32 rtc_base; | ||
46 | u32 irq; | ||
47 | /* Overflow for every 8 years extra time */ | ||
48 | u32 overflow_rtc; | ||
49 | #ifdef CONFIG_PM | ||
50 | u32 saved_counter; | ||
51 | u32 saved_overflow_rtc; | ||
52 | #endif | ||
53 | }; | ||
54 | |||
55 | static int sirfsoc_rtc_read_alarm(struct device *dev, | ||
56 | struct rtc_wkalrm *alrm) | ||
57 | { | ||
58 | unsigned long rtc_alarm, rtc_count; | ||
59 | struct sirfsoc_rtc_drv *rtcdrv; | ||
60 | |||
61 | rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); | ||
62 | |||
63 | local_irq_disable(); | ||
64 | |||
65 | rtc_count = sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_CN); | ||
66 | |||
67 | rtc_alarm = sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_ALARM0); | ||
68 | memset(alrm, 0, sizeof(struct rtc_wkalrm)); | ||
69 | |||
70 | /* | ||
71 | * assume alarm interval not beyond one round counter overflow_rtc: | ||
72 | * 0->0xffffffff | ||
73 | */ | ||
74 | /* if alarm is in next overflow cycle */ | ||
75 | if (rtc_count > rtc_alarm) | ||
76 | rtc_time_to_tm((rtcdrv->overflow_rtc + 1) | ||
77 | << (BITS_PER_LONG - RTC_SHIFT) | ||
78 | | rtc_alarm >> RTC_SHIFT, &(alrm->time)); | ||
79 | else | ||
80 | rtc_time_to_tm(rtcdrv->overflow_rtc | ||
81 | << (BITS_PER_LONG - RTC_SHIFT) | ||
82 | | rtc_alarm >> RTC_SHIFT, &(alrm->time)); | ||
83 | if (sirfsoc_rtc_iobrg_readl( | ||
84 | rtcdrv->rtc_base + RTC_STATUS) & SIRFSOC_RTC_AL0E) | ||
85 | alrm->enabled = 1; | ||
86 | local_irq_enable(); | ||
87 | |||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | static int sirfsoc_rtc_set_alarm(struct device *dev, | ||
92 | struct rtc_wkalrm *alrm) | ||
93 | { | ||
94 | unsigned long rtc_status_reg, rtc_alarm; | ||
95 | struct sirfsoc_rtc_drv *rtcdrv; | ||
96 | rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); | ||
97 | |||
98 | if (alrm->enabled) { | ||
99 | rtc_tm_to_time(&(alrm->time), &rtc_alarm); | ||
100 | |||
101 | local_irq_disable(); | ||
102 | |||
103 | rtc_status_reg = sirfsoc_rtc_iobrg_readl( | ||
104 | rtcdrv->rtc_base + RTC_STATUS); | ||
105 | if (rtc_status_reg & SIRFSOC_RTC_AL0E) { | ||
106 | /* | ||
107 | * An ongoing alarm in progress - ingore it and not | ||
108 | * to return EBUSY | ||
109 | */ | ||
110 | dev_info(dev, "An old alarm was set, will be replaced by a new one\n"); | ||
111 | } | ||
112 | |||
113 | sirfsoc_rtc_iobrg_writel( | ||
114 | rtc_alarm << RTC_SHIFT, rtcdrv->rtc_base + RTC_ALARM0); | ||
115 | rtc_status_reg &= ~0x07; /* mask out the lower status bits */ | ||
116 | /* | ||
117 | * This bit RTC_AL sets it as a wake-up source for Sleep Mode | ||
118 | * Writing 1 into this bit will clear it | ||
119 | */ | ||
120 | rtc_status_reg |= SIRFSOC_RTC_AL0; | ||
121 | /* enable the RTC alarm interrupt */ | ||
122 | rtc_status_reg |= SIRFSOC_RTC_AL0E; | ||
123 | sirfsoc_rtc_iobrg_writel( | ||
124 | rtc_status_reg, rtcdrv->rtc_base + RTC_STATUS); | ||
125 | local_irq_enable(); | ||
126 | } else { | ||
127 | /* | ||
128 | * if this function was called with enabled=0 | ||
129 | * then it could mean that the application is | ||
130 | * trying to cancel an ongoing alarm | ||
131 | */ | ||
132 | local_irq_disable(); | ||
133 | |||
134 | rtc_status_reg = sirfsoc_rtc_iobrg_readl( | ||
135 | rtcdrv->rtc_base + RTC_STATUS); | ||
136 | if (rtc_status_reg & SIRFSOC_RTC_AL0E) { | ||
137 | /* clear the RTC status register's alarm bit */ | ||
138 | rtc_status_reg &= ~0x07; | ||
139 | /* write 1 into SIRFSOC_RTC_AL0 to force a clear */ | ||
140 | rtc_status_reg |= (SIRFSOC_RTC_AL0); | ||
141 | /* Clear the Alarm enable bit */ | ||
142 | rtc_status_reg &= ~(SIRFSOC_RTC_AL0E); | ||
143 | |||
144 | sirfsoc_rtc_iobrg_writel(rtc_status_reg, | ||
145 | rtcdrv->rtc_base + RTC_STATUS); | ||
146 | } | ||
147 | |||
148 | local_irq_enable(); | ||
149 | } | ||
150 | |||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | static int sirfsoc_rtc_read_time(struct device *dev, | ||
155 | struct rtc_time *tm) | ||
156 | { | ||
157 | unsigned long tmp_rtc = 0; | ||
158 | struct sirfsoc_rtc_drv *rtcdrv; | ||
159 | rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); | ||
160 | /* | ||
161 | * This patch is taken from WinCE - Need to validate this for | ||
162 | * correctness. To work around sirfsoc RTC counter double sync logic | ||
163 | * fail, read several times to make sure get stable value. | ||
164 | */ | ||
165 | do { | ||
166 | tmp_rtc = sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_CN); | ||
167 | cpu_relax(); | ||
168 | } while (tmp_rtc != sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_CN)); | ||
169 | |||
170 | rtc_time_to_tm(rtcdrv->overflow_rtc << (BITS_PER_LONG - RTC_SHIFT) | | ||
171 | tmp_rtc >> RTC_SHIFT, tm); | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static int sirfsoc_rtc_set_time(struct device *dev, | ||
176 | struct rtc_time *tm) | ||
177 | { | ||
178 | unsigned long rtc_time; | ||
179 | struct sirfsoc_rtc_drv *rtcdrv; | ||
180 | rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); | ||
181 | |||
182 | rtc_tm_to_time(tm, &rtc_time); | ||
183 | |||
184 | rtcdrv->overflow_rtc = rtc_time >> (BITS_PER_LONG - RTC_SHIFT); | ||
185 | |||
186 | sirfsoc_rtc_iobrg_writel(rtcdrv->overflow_rtc, | ||
187 | rtcdrv->rtc_base + RTC_SW_VALUE); | ||
188 | sirfsoc_rtc_iobrg_writel( | ||
189 | rtc_time << RTC_SHIFT, rtcdrv->rtc_base + RTC_CN); | ||
190 | |||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | static int sirfsoc_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
195 | unsigned long arg) | ||
196 | { | ||
197 | switch (cmd) { | ||
198 | case RTC_PIE_ON: | ||
199 | case RTC_PIE_OFF: | ||
200 | case RTC_UIE_ON: | ||
201 | case RTC_UIE_OFF: | ||
202 | case RTC_AIE_ON: | ||
203 | case RTC_AIE_OFF: | ||
204 | return 0; | ||
205 | |||
206 | default: | ||
207 | return -ENOIOCTLCMD; | ||
208 | } | ||
209 | } | ||
210 | |||
211 | static const struct rtc_class_ops sirfsoc_rtc_ops = { | ||
212 | .read_time = sirfsoc_rtc_read_time, | ||
213 | .set_time = sirfsoc_rtc_set_time, | ||
214 | .read_alarm = sirfsoc_rtc_read_alarm, | ||
215 | .set_alarm = sirfsoc_rtc_set_alarm, | ||
216 | .ioctl = sirfsoc_rtc_ioctl | ||
217 | }; | ||
218 | |||
219 | static irqreturn_t sirfsoc_rtc_irq_handler(int irq, void *pdata) | ||
220 | { | ||
221 | struct sirfsoc_rtc_drv *rtcdrv = pdata; | ||
222 | unsigned long rtc_status_reg = 0x0; | ||
223 | unsigned long events = 0x0; | ||
224 | |||
225 | rtc_status_reg = sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_STATUS); | ||
226 | /* this bit will be set ONLY if an alarm was active | ||
227 | * and it expired NOW | ||
228 | * So this is being used as an ASSERT | ||
229 | */ | ||
230 | if (rtc_status_reg & SIRFSOC_RTC_AL0) { | ||
231 | /* | ||
232 | * clear the RTC status register's alarm bit | ||
233 | * mask out the lower status bits | ||
234 | */ | ||
235 | rtc_status_reg &= ~0x07; | ||
236 | /* write 1 into SIRFSOC_RTC_AL0 to ACK the alarm interrupt */ | ||
237 | rtc_status_reg |= (SIRFSOC_RTC_AL0); | ||
238 | /* Clear the Alarm enable bit */ | ||
239 | rtc_status_reg &= ~(SIRFSOC_RTC_AL0E); | ||
240 | } | ||
241 | sirfsoc_rtc_iobrg_writel(rtc_status_reg, rtcdrv->rtc_base + RTC_STATUS); | ||
242 | /* this should wake up any apps polling/waiting on the read | ||
243 | * after setting the alarm | ||
244 | */ | ||
245 | events |= RTC_IRQF | RTC_AF; | ||
246 | rtc_update_irq(rtcdrv->rtc, 1, events); | ||
247 | |||
248 | return IRQ_HANDLED; | ||
249 | } | ||
250 | |||
251 | static const struct of_device_id sirfsoc_rtc_of_match[] = { | ||
252 | { .compatible = "sirf,prima2-sysrtc"}, | ||
253 | {}, | ||
254 | }; | ||
255 | MODULE_DEVICE_TABLE(of, sirfsoc_rtc_of_match); | ||
256 | |||
257 | static int sirfsoc_rtc_probe(struct platform_device *pdev) | ||
258 | { | ||
259 | int err; | ||
260 | unsigned long rtc_div; | ||
261 | struct sirfsoc_rtc_drv *rtcdrv; | ||
262 | struct device_node *np = pdev->dev.of_node; | ||
263 | |||
264 | rtcdrv = devm_kzalloc(&pdev->dev, | ||
265 | sizeof(struct sirfsoc_rtc_drv), GFP_KERNEL); | ||
266 | if (rtcdrv == NULL) { | ||
267 | dev_err(&pdev->dev, | ||
268 | "%s: can't alloc mem for drv struct\n", | ||
269 | pdev->name); | ||
270 | return -ENOMEM; | ||
271 | } | ||
272 | |||
273 | err = of_property_read_u32(np, "reg", &rtcdrv->rtc_base); | ||
274 | if (err) { | ||
275 | dev_err(&pdev->dev, "unable to find base address of rtc node in dtb\n"); | ||
276 | goto error; | ||
277 | } | ||
278 | |||
279 | platform_set_drvdata(pdev, rtcdrv); | ||
280 | |||
281 | /* Register rtc alarm as a wakeup source */ | ||
282 | device_init_wakeup(&pdev->dev, 1); | ||
283 | |||
284 | /* | ||
285 | * Set SYS_RTC counter in RTC_HZ HZ Units | ||
286 | * We are using 32K RTC crystal (32768 / RTC_HZ / 2) -1 | ||
287 | * If 16HZ, therefore RTC_DIV = 1023; | ||
288 | */ | ||
289 | rtc_div = ((32768 / RTC_HZ) / 2) - 1; | ||
290 | sirfsoc_rtc_iobrg_writel(rtc_div, rtcdrv->rtc_base + RTC_DIV); | ||
291 | |||
292 | rtcdrv->rtc = rtc_device_register(pdev->name, &(pdev->dev), | ||
293 | &sirfsoc_rtc_ops, THIS_MODULE); | ||
294 | if (IS_ERR(rtcdrv->rtc)) { | ||
295 | err = PTR_ERR(rtcdrv->rtc); | ||
296 | dev_err(&pdev->dev, "can't register RTC device\n"); | ||
297 | return err; | ||
298 | } | ||
299 | |||
300 | /* 0x3 -> RTC_CLK */ | ||
301 | sirfsoc_rtc_iobrg_writel(SIRFSOC_RTC_CLK, | ||
302 | rtcdrv->rtc_base + RTC_CLOCK_SWITCH); | ||
303 | |||
304 | /* reset SYS RTC ALARM0 */ | ||
305 | sirfsoc_rtc_iobrg_writel(0x0, rtcdrv->rtc_base + RTC_ALARM0); | ||
306 | |||
307 | /* reset SYS RTC ALARM1 */ | ||
308 | sirfsoc_rtc_iobrg_writel(0x0, rtcdrv->rtc_base + RTC_ALARM1); | ||
309 | |||
310 | /* Restore RTC Overflow From Register After Command Reboot */ | ||
311 | rtcdrv->overflow_rtc = | ||
312 | sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_SW_VALUE); | ||
313 | |||
314 | rtcdrv->irq = platform_get_irq(pdev, 0); | ||
315 | err = devm_request_irq( | ||
316 | &pdev->dev, | ||
317 | rtcdrv->irq, | ||
318 | sirfsoc_rtc_irq_handler, | ||
319 | IRQF_SHARED, | ||
320 | pdev->name, | ||
321 | rtcdrv); | ||
322 | if (err) { | ||
323 | dev_err(&pdev->dev, "Unable to register for the SiRF SOC RTC IRQ\n"); | ||
324 | goto error; | ||
325 | } | ||
326 | |||
327 | return 0; | ||
328 | |||
329 | error: | ||
330 | if (rtcdrv->rtc) | ||
331 | rtc_device_unregister(rtcdrv->rtc); | ||
332 | |||
333 | return err; | ||
334 | } | ||
335 | |||
336 | static int sirfsoc_rtc_remove(struct platform_device *pdev) | ||
337 | { | ||
338 | struct sirfsoc_rtc_drv *rtcdrv = platform_get_drvdata(pdev); | ||
339 | |||
340 | device_init_wakeup(&pdev->dev, 0); | ||
341 | rtc_device_unregister(rtcdrv->rtc); | ||
342 | |||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | #ifdef CONFIG_PM | ||
347 | |||
348 | static int sirfsoc_rtc_suspend(struct device *dev) | ||
349 | { | ||
350 | struct platform_device *pdev = to_platform_device(dev); | ||
351 | struct sirfsoc_rtc_drv *rtcdrv = platform_get_drvdata(pdev); | ||
352 | rtcdrv->overflow_rtc = | ||
353 | sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_SW_VALUE); | ||
354 | |||
355 | rtcdrv->saved_counter = | ||
356 | sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_CN); | ||
357 | rtcdrv->saved_overflow_rtc = rtcdrv->overflow_rtc; | ||
358 | if (device_may_wakeup(&pdev->dev)) | ||
359 | enable_irq_wake(rtcdrv->irq); | ||
360 | |||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | static int sirfsoc_rtc_freeze(struct device *dev) | ||
365 | { | ||
366 | sirfsoc_rtc_suspend(dev); | ||
367 | |||
368 | return 0; | ||
369 | } | ||
370 | |||
371 | static int sirfsoc_rtc_thaw(struct device *dev) | ||
372 | { | ||
373 | u32 tmp; | ||
374 | struct sirfsoc_rtc_drv *rtcdrv; | ||
375 | rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); | ||
376 | |||
377 | /* | ||
378 | * if resume from snapshot and the rtc power is losed, | ||
379 | * restroe the rtc settings | ||
380 | */ | ||
381 | if (SIRFSOC_RTC_CLK != sirfsoc_rtc_iobrg_readl( | ||
382 | rtcdrv->rtc_base + RTC_CLOCK_SWITCH)) { | ||
383 | u32 rtc_div; | ||
384 | /* 0x3 -> RTC_CLK */ | ||
385 | sirfsoc_rtc_iobrg_writel(SIRFSOC_RTC_CLK, | ||
386 | rtcdrv->rtc_base + RTC_CLOCK_SWITCH); | ||
387 | /* | ||
388 | * Set SYS_RTC counter in RTC_HZ HZ Units | ||
389 | * We are using 32K RTC crystal (32768 / RTC_HZ / 2) -1 | ||
390 | * If 16HZ, therefore RTC_DIV = 1023; | ||
391 | */ | ||
392 | rtc_div = ((32768 / RTC_HZ) / 2) - 1; | ||
393 | |||
394 | sirfsoc_rtc_iobrg_writel(rtc_div, rtcdrv->rtc_base + RTC_DIV); | ||
395 | |||
396 | /* reset SYS RTC ALARM0 */ | ||
397 | sirfsoc_rtc_iobrg_writel(0x0, rtcdrv->rtc_base + RTC_ALARM0); | ||
398 | |||
399 | /* reset SYS RTC ALARM1 */ | ||
400 | sirfsoc_rtc_iobrg_writel(0x0, rtcdrv->rtc_base + RTC_ALARM1); | ||
401 | } | ||
402 | rtcdrv->overflow_rtc = rtcdrv->saved_overflow_rtc; | ||
403 | |||
404 | /* | ||
405 | * if current counter is small than previous, | ||
406 | * it means overflow in sleep | ||
407 | */ | ||
408 | tmp = sirfsoc_rtc_iobrg_readl(rtcdrv->rtc_base + RTC_CN); | ||
409 | if (tmp <= rtcdrv->saved_counter) | ||
410 | rtcdrv->overflow_rtc++; | ||
411 | /* | ||
412 | *PWRC Value Be Changed When Suspend, Restore Overflow | ||
413 | * In Memory To Register | ||
414 | */ | ||
415 | sirfsoc_rtc_iobrg_writel(rtcdrv->overflow_rtc, | ||
416 | rtcdrv->rtc_base + RTC_SW_VALUE); | ||
417 | |||
418 | return 0; | ||
419 | } | ||
420 | |||
421 | static int sirfsoc_rtc_resume(struct device *dev) | ||
422 | { | ||
423 | struct platform_device *pdev = to_platform_device(dev); | ||
424 | struct sirfsoc_rtc_drv *rtcdrv = platform_get_drvdata(pdev); | ||
425 | sirfsoc_rtc_thaw(dev); | ||
426 | if (device_may_wakeup(&pdev->dev)) | ||
427 | disable_irq_wake(rtcdrv->irq); | ||
428 | |||
429 | return 0; | ||
430 | } | ||
431 | |||
432 | static int sirfsoc_rtc_restore(struct device *dev) | ||
433 | { | ||
434 | struct platform_device *pdev = to_platform_device(dev); | ||
435 | struct sirfsoc_rtc_drv *rtcdrv = platform_get_drvdata(pdev); | ||
436 | |||
437 | if (device_may_wakeup(&pdev->dev)) | ||
438 | disable_irq_wake(rtcdrv->irq); | ||
439 | return 0; | ||
440 | } | ||
441 | |||
442 | #else | ||
443 | #define sirfsoc_rtc_suspend NULL | ||
444 | #define sirfsoc_rtc_resume NULL | ||
445 | #define sirfsoc_rtc_freeze NULL | ||
446 | #define sirfsoc_rtc_thaw NULL | ||
447 | #define sirfsoc_rtc_restore NULL | ||
448 | #endif | ||
449 | |||
450 | static const struct dev_pm_ops sirfsoc_rtc_pm_ops = { | ||
451 | .suspend = sirfsoc_rtc_suspend, | ||
452 | .resume = sirfsoc_rtc_resume, | ||
453 | .freeze = sirfsoc_rtc_freeze, | ||
454 | .thaw = sirfsoc_rtc_thaw, | ||
455 | .restore = sirfsoc_rtc_restore, | ||
456 | }; | ||
457 | |||
458 | static struct platform_driver sirfsoc_rtc_driver = { | ||
459 | .driver = { | ||
460 | .name = "sirfsoc-rtc", | ||
461 | .owner = THIS_MODULE, | ||
462 | #ifdef CONFIG_PM | ||
463 | .pm = &sirfsoc_rtc_pm_ops, | ||
464 | #endif | ||
465 | .of_match_table = of_match_ptr(sirfsoc_rtc_of_match), | ||
466 | }, | ||
467 | .probe = sirfsoc_rtc_probe, | ||
468 | .remove = sirfsoc_rtc_remove, | ||
469 | }; | ||
470 | module_platform_driver(sirfsoc_rtc_driver); | ||
471 | |||
472 | MODULE_DESCRIPTION("SiRF SoC rtc driver"); | ||
473 | MODULE_AUTHOR("Xianglong Du <Xianglong.Du@csr.com>"); | ||
474 | MODULE_LICENSE("GPL v2"); | ||
475 | MODULE_ALIAS("platform:sirfsoc-rtc"); | ||
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index b04f09a1df2a..316a342115b2 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c | |||
@@ -294,11 +294,6 @@ static int snvs_rtc_probe(struct platform_device *pdev) | |||
294 | return 0; | 294 | return 0; |
295 | } | 295 | } |
296 | 296 | ||
297 | static int snvs_rtc_remove(struct platform_device *pdev) | ||
298 | { | ||
299 | return 0; | ||
300 | } | ||
301 | |||
302 | #ifdef CONFIG_PM_SLEEP | 297 | #ifdef CONFIG_PM_SLEEP |
303 | static int snvs_rtc_suspend(struct device *dev) | 298 | static int snvs_rtc_suspend(struct device *dev) |
304 | { | 299 | { |
@@ -337,7 +332,6 @@ static struct platform_driver snvs_rtc_driver = { | |||
337 | .of_match_table = of_match_ptr(snvs_dt_ids), | 332 | .of_match_table = of_match_ptr(snvs_dt_ids), |
338 | }, | 333 | }, |
339 | .probe = snvs_rtc_probe, | 334 | .probe = snvs_rtc_probe, |
340 | .remove = snvs_rtc_remove, | ||
341 | }; | 335 | }; |
342 | module_platform_driver(snvs_rtc_driver); | 336 | module_platform_driver(snvs_rtc_driver); |
343 | 337 | ||
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c index 574359c48f65..c492cf0ab8cd 100644 --- a/drivers/rtc/rtc-spear.c +++ b/drivers/rtc/rtc-spear.c | |||
@@ -417,7 +417,6 @@ static int spear_rtc_probe(struct platform_device *pdev) | |||
417 | return 0; | 417 | return 0; |
418 | 418 | ||
419 | err_disable_clock: | 419 | err_disable_clock: |
420 | platform_set_drvdata(pdev, NULL); | ||
421 | clk_disable_unprepare(config->clk); | 420 | clk_disable_unprepare(config->clk); |
422 | 421 | ||
423 | return status; | 422 | return status; |
diff --git a/drivers/rtc/rtc-starfire.c b/drivers/rtc/rtc-starfire.c index 987b5ec0ae56..f7d8a6db8078 100644 --- a/drivers/rtc/rtc-starfire.c +++ b/drivers/rtc/rtc-starfire.c | |||
@@ -51,17 +51,11 @@ static int __init starfire_rtc_probe(struct platform_device *pdev) | |||
51 | return 0; | 51 | return 0; |
52 | } | 52 | } |
53 | 53 | ||
54 | static int __exit starfire_rtc_remove(struct platform_device *pdev) | ||
55 | { | ||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static struct platform_driver starfire_rtc_driver = { | 54 | static struct platform_driver starfire_rtc_driver = { |
60 | .driver = { | 55 | .driver = { |
61 | .name = "rtc-starfire", | 56 | .name = "rtc-starfire", |
62 | .owner = THIS_MODULE, | 57 | .owner = THIS_MODULE, |
63 | }, | 58 | }, |
64 | .remove = __exit_p(starfire_rtc_remove), | ||
65 | }; | 59 | }; |
66 | 60 | ||
67 | module_platform_driver_probe(starfire_rtc_driver, starfire_rtc_probe); | 61 | module_platform_driver_probe(starfire_rtc_driver, starfire_rtc_probe); |
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 483ce086990b..90a3e864b8fe 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c | |||
@@ -225,7 +225,6 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev) | |||
225 | 225 | ||
226 | writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, | 226 | writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, |
227 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); | 227 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); |
228 | platform_set_drvdata(pdev, NULL); | ||
229 | 228 | ||
230 | return 0; | 229 | return 0; |
231 | } | 230 | } |
@@ -274,25 +273,19 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) | |||
274 | 273 | ||
275 | rtc_data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, | 274 | rtc_data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, |
276 | &stmp3xxx_rtc_ops, THIS_MODULE); | 275 | &stmp3xxx_rtc_ops, THIS_MODULE); |
277 | if (IS_ERR(rtc_data->rtc)) { | 276 | if (IS_ERR(rtc_data->rtc)) |
278 | err = PTR_ERR(rtc_data->rtc); | 277 | return PTR_ERR(rtc_data->rtc); |
279 | goto out; | ||
280 | } | ||
281 | 278 | ||
282 | err = devm_request_irq(&pdev->dev, rtc_data->irq_alarm, | 279 | err = devm_request_irq(&pdev->dev, rtc_data->irq_alarm, |
283 | stmp3xxx_rtc_interrupt, 0, "RTC alarm", &pdev->dev); | 280 | stmp3xxx_rtc_interrupt, 0, "RTC alarm", &pdev->dev); |
284 | if (err) { | 281 | if (err) { |
285 | dev_err(&pdev->dev, "Cannot claim IRQ%d\n", | 282 | dev_err(&pdev->dev, "Cannot claim IRQ%d\n", |
286 | rtc_data->irq_alarm); | 283 | rtc_data->irq_alarm); |
287 | goto out; | 284 | return err; |
288 | } | 285 | } |
289 | 286 | ||
290 | stmp3xxx_wdt_register(pdev); | 287 | stmp3xxx_wdt_register(pdev); |
291 | return 0; | 288 | return 0; |
292 | |||
293 | out: | ||
294 | platform_set_drvdata(pdev, NULL); | ||
295 | return err; | ||
296 | } | 289 | } |
297 | 290 | ||
298 | #ifdef CONFIG_PM_SLEEP | 291 | #ifdef CONFIG_PM_SLEEP |
diff --git a/drivers/rtc/rtc-sun4v.c b/drivers/rtc/rtc-sun4v.c index ce42e5fa9e09..bc97ff91341d 100644 --- a/drivers/rtc/rtc-sun4v.c +++ b/drivers/rtc/rtc-sun4v.c | |||
@@ -92,17 +92,11 @@ static int __init sun4v_rtc_probe(struct platform_device *pdev) | |||
92 | return 0; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | static int __exit sun4v_rtc_remove(struct platform_device *pdev) | ||
96 | { | ||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | static struct platform_driver sun4v_rtc_driver = { | 95 | static struct platform_driver sun4v_rtc_driver = { |
101 | .driver = { | 96 | .driver = { |
102 | .name = "rtc-sun4v", | 97 | .name = "rtc-sun4v", |
103 | .owner = THIS_MODULE, | 98 | .owner = THIS_MODULE, |
104 | }, | 99 | }, |
105 | .remove = __exit_p(sun4v_rtc_remove), | ||
106 | }; | 100 | }; |
107 | 101 | ||
108 | module_platform_driver_probe(sun4v_rtc_driver, sun4v_rtc_probe); | 102 | module_platform_driver_probe(sun4v_rtc_driver, sun4v_rtc_probe); |
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index b70e2bb63645..4b26f8672b2d 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c | |||
@@ -164,6 +164,7 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, | |||
164 | { | 164 | { |
165 | ssize_t retval; | 165 | ssize_t retval; |
166 | unsigned long now, alarm; | 166 | unsigned long now, alarm; |
167 | unsigned long push = 0; | ||
167 | struct rtc_wkalrm alm; | 168 | struct rtc_wkalrm alm; |
168 | struct rtc_device *rtc = to_rtc_device(dev); | 169 | struct rtc_device *rtc = to_rtc_device(dev); |
169 | char *buf_ptr; | 170 | char *buf_ptr; |
@@ -180,13 +181,17 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, | |||
180 | buf_ptr = (char *)buf; | 181 | buf_ptr = (char *)buf; |
181 | if (*buf_ptr == '+') { | 182 | if (*buf_ptr == '+') { |
182 | buf_ptr++; | 183 | buf_ptr++; |
183 | adjust = 1; | 184 | if (*buf_ptr == '=') { |
185 | buf_ptr++; | ||
186 | push = 1; | ||
187 | } else | ||
188 | adjust = 1; | ||
184 | } | 189 | } |
185 | alarm = simple_strtoul(buf_ptr, NULL, 0); | 190 | alarm = simple_strtoul(buf_ptr, NULL, 0); |
186 | if (adjust) { | 191 | if (adjust) { |
187 | alarm += now; | 192 | alarm += now; |
188 | } | 193 | } |
189 | if (alarm > now) { | 194 | if (alarm > now || push) { |
190 | /* Avoid accidentally clobbering active alarms; we can't | 195 | /* Avoid accidentally clobbering active alarms; we can't |
191 | * entirely prevent that here, without even the minimal | 196 | * entirely prevent that here, without even the minimal |
192 | * locking from the /dev/rtcN api. | 197 | * locking from the /dev/rtcN api. |
@@ -194,9 +199,14 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, | |||
194 | retval = rtc_read_alarm(rtc, &alm); | 199 | retval = rtc_read_alarm(rtc, &alm); |
195 | if (retval < 0) | 200 | if (retval < 0) |
196 | return retval; | 201 | return retval; |
197 | if (alm.enabled) | 202 | if (alm.enabled) { |
198 | return -EBUSY; | 203 | if (push) { |
199 | 204 | rtc_tm_to_time(&alm.time, &push); | |
205 | alarm += push; | ||
206 | } else | ||
207 | return -EBUSY; | ||
208 | } else if (push) | ||
209 | return -EINVAL; | ||
200 | alm.enabled = 1; | 210 | alm.enabled = 1; |
201 | } else { | 211 | } else { |
202 | alm.enabled = 0; | 212 | alm.enabled = 0; |
diff --git a/drivers/rtc/rtc-tile.c b/drivers/rtc/rtc-tile.c index fc3dee95f166..ff9632eb79f2 100644 --- a/drivers/rtc/rtc-tile.c +++ b/drivers/rtc/rtc-tile.c | |||
@@ -91,23 +91,12 @@ static int tile_rtc_probe(struct platform_device *dev) | |||
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |
93 | 93 | ||
94 | /* | ||
95 | * Device cleanup routine. | ||
96 | */ | ||
97 | static int tile_rtc_remove(struct platform_device *dev) | ||
98 | { | ||
99 | platform_set_drvdata(dev, NULL); | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static struct platform_driver tile_rtc_platform_driver = { | 94 | static struct platform_driver tile_rtc_platform_driver = { |
105 | .driver = { | 95 | .driver = { |
106 | .name = "rtc-tile", | 96 | .name = "rtc-tile", |
107 | .owner = THIS_MODULE, | 97 | .owner = THIS_MODULE, |
108 | }, | 98 | }, |
109 | .probe = tile_rtc_probe, | 99 | .probe = tile_rtc_probe, |
110 | .remove = tile_rtc_remove, | ||
111 | }; | 100 | }; |
112 | 101 | ||
113 | /* | 102 | /* |
diff --git a/drivers/rtc/rtc-tps80031.c b/drivers/rtc/rtc-tps80031.c index 72662eafb938..3e400dce2d06 100644 --- a/drivers/rtc/rtc-tps80031.c +++ b/drivers/rtc/rtc-tps80031.c | |||
@@ -298,11 +298,6 @@ static int tps80031_rtc_probe(struct platform_device *pdev) | |||
298 | return 0; | 298 | return 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | static int tps80031_rtc_remove(struct platform_device *pdev) | ||
302 | { | ||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | #ifdef CONFIG_PM_SLEEP | 301 | #ifdef CONFIG_PM_SLEEP |
307 | static int tps80031_rtc_suspend(struct device *dev) | 302 | static int tps80031_rtc_suspend(struct device *dev) |
308 | { | 303 | { |
@@ -333,7 +328,6 @@ static struct platform_driver tps80031_rtc_driver = { | |||
333 | .pm = &tps80031_pm_ops, | 328 | .pm = &tps80031_pm_ops, |
334 | }, | 329 | }, |
335 | .probe = tps80031_rtc_probe, | 330 | .probe = tps80031_rtc_probe, |
336 | .remove = tps80031_rtc_remove, | ||
337 | }; | 331 | }; |
338 | 332 | ||
339 | module_platform_driver(tps80031_rtc_driver); | 333 | module_platform_driver(tps80031_rtc_driver); |
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index b2eab34f38d9..02faf3c4e0d5 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c | |||
@@ -213,12 +213,24 @@ static int mask_rtc_irq_bit(unsigned char bit) | |||
213 | 213 | ||
214 | static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) | 214 | static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) |
215 | { | 215 | { |
216 | struct platform_device *pdev = to_platform_device(dev); | ||
217 | int irq = platform_get_irq(pdev, 0); | ||
218 | static bool twl_rtc_wake_enabled; | ||
216 | int ret; | 219 | int ret; |
217 | 220 | ||
218 | if (enabled) | 221 | if (enabled) { |
219 | ret = set_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); | 222 | ret = set_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); |
220 | else | 223 | if (device_can_wakeup(dev) && !twl_rtc_wake_enabled) { |
224 | enable_irq_wake(irq); | ||
225 | twl_rtc_wake_enabled = true; | ||
226 | } | ||
227 | } else { | ||
221 | ret = mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); | 228 | ret = mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); |
229 | if (twl_rtc_wake_enabled) { | ||
230 | disable_irq_wake(irq); | ||
231 | twl_rtc_wake_enabled = false; | ||
232 | } | ||
233 | } | ||
222 | 234 | ||
223 | return ret; | 235 | return ret; |
224 | } | 236 | } |
@@ -469,6 +481,12 @@ static int twl_rtc_probe(struct platform_device *pdev) | |||
469 | if (irq <= 0) | 481 | if (irq <= 0) |
470 | goto out1; | 482 | goto out1; |
471 | 483 | ||
484 | /* Initialize the register map */ | ||
485 | if (twl_class_is_4030()) | ||
486 | rtc_reg_map = (u8 *)twl4030_rtc_reg_map; | ||
487 | else | ||
488 | rtc_reg_map = (u8 *)twl6030_rtc_reg_map; | ||
489 | |||
472 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); | 490 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); |
473 | if (ret < 0) | 491 | if (ret < 0) |
474 | goto out1; | 492 | goto out1; |
@@ -556,7 +574,6 @@ static int twl_rtc_remove(struct platform_device *pdev) | |||
556 | free_irq(irq, rtc); | 574 | free_irq(irq, rtc); |
557 | 575 | ||
558 | rtc_device_unregister(rtc); | 576 | rtc_device_unregister(rtc); |
559 | platform_set_drvdata(pdev, NULL); | ||
560 | return 0; | 577 | return 0; |
561 | } | 578 | } |
562 | 579 | ||
@@ -609,22 +626,7 @@ static struct platform_driver twl4030rtc_driver = { | |||
609 | }, | 626 | }, |
610 | }; | 627 | }; |
611 | 628 | ||
612 | static int __init twl_rtc_init(void) | 629 | module_platform_driver(twl4030rtc_driver); |
613 | { | ||
614 | if (twl_class_is_4030()) | ||
615 | rtc_reg_map = (u8 *) twl4030_rtc_reg_map; | ||
616 | else | ||
617 | rtc_reg_map = (u8 *) twl6030_rtc_reg_map; | ||
618 | |||
619 | return platform_driver_register(&twl4030rtc_driver); | ||
620 | } | ||
621 | module_init(twl_rtc_init); | ||
622 | |||
623 | static void __exit twl_rtc_exit(void) | ||
624 | { | ||
625 | platform_driver_unregister(&twl4030rtc_driver); | ||
626 | } | ||
627 | module_exit(twl_rtc_exit); | ||
628 | 630 | ||
629 | MODULE_AUTHOR("Texas Instruments, MontaVista Software"); | 631 | MODULE_AUTHOR("Texas Instruments, MontaVista Software"); |
630 | MODULE_LICENSE("GPL"); | 632 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c index 6e0cba8f47d5..d07d89823020 100644 --- a/drivers/rtc/rtc-v3020.c +++ b/drivers/rtc/rtc-v3020.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * - Use the generic rtc class | 16 | * - Use the generic rtc class |
17 | * | 17 | * |
18 | * ??-???-2004: Someone at Compulab | 18 | * ??-???-2004: Someone at Compulab |
19 | * - Initial driver creation. | 19 | * - Initial driver creation. |
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
@@ -278,13 +278,13 @@ static int v3020_set_time(struct device *dev, struct rtc_time *dt) | |||
278 | dev_dbg(dev, "tm_year: %i\n", dt->tm_year); | 278 | dev_dbg(dev, "tm_year: %i\n", dt->tm_year); |
279 | 279 | ||
280 | /* Write all the values to ram... */ | 280 | /* Write all the values to ram... */ |
281 | v3020_set_reg(chip, V3020_SECONDS, bin2bcd(dt->tm_sec)); | 281 | v3020_set_reg(chip, V3020_SECONDS, bin2bcd(dt->tm_sec)); |
282 | v3020_set_reg(chip, V3020_MINUTES, bin2bcd(dt->tm_min)); | 282 | v3020_set_reg(chip, V3020_MINUTES, bin2bcd(dt->tm_min)); |
283 | v3020_set_reg(chip, V3020_HOURS, bin2bcd(dt->tm_hour)); | 283 | v3020_set_reg(chip, V3020_HOURS, bin2bcd(dt->tm_hour)); |
284 | v3020_set_reg(chip, V3020_MONTH_DAY, bin2bcd(dt->tm_mday)); | 284 | v3020_set_reg(chip, V3020_MONTH_DAY, bin2bcd(dt->tm_mday)); |
285 | v3020_set_reg(chip, V3020_MONTH, bin2bcd(dt->tm_mon + 1)); | 285 | v3020_set_reg(chip, V3020_MONTH, bin2bcd(dt->tm_mon + 1)); |
286 | v3020_set_reg(chip, V3020_WEEK_DAY, bin2bcd(dt->tm_wday)); | 286 | v3020_set_reg(chip, V3020_WEEK_DAY, bin2bcd(dt->tm_wday)); |
287 | v3020_set_reg(chip, V3020_YEAR, bin2bcd(dt->tm_year % 100)); | 287 | v3020_set_reg(chip, V3020_YEAR, bin2bcd(dt->tm_year % 100)); |
288 | 288 | ||
289 | /* ...and set the clock. */ | 289 | /* ...and set the clock. */ |
290 | v3020_set_reg(chip, V3020_CMD_RAM2CLOCK, 0); | 290 | v3020_set_reg(chip, V3020_CMD_RAM2CLOCK, 0); |
@@ -320,7 +320,7 @@ static int rtc_probe(struct platform_device *pdev) | |||
320 | 320 | ||
321 | retval = chip->ops->map_io(chip, pdev, pdata); | 321 | retval = chip->ops->map_io(chip, pdev, pdata); |
322 | if (retval) | 322 | if (retval) |
323 | goto err_chip; | 323 | return retval; |
324 | 324 | ||
325 | /* Make sure the v3020 expects a communication cycle | 325 | /* Make sure the v3020 expects a communication cycle |
326 | * by reading 8 times */ | 326 | * by reading 8 times */ |
@@ -364,7 +364,7 @@ static int rtc_probe(struct platform_device *pdev) | |||
364 | 364 | ||
365 | err_io: | 365 | err_io: |
366 | chip->ops->unmap_io(chip); | 366 | chip->ops->unmap_io(chip); |
367 | err_chip: | 367 | |
368 | return retval; | 368 | return retval; |
369 | } | 369 | } |
370 | 370 | ||
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index f91be04b9050..54e104e197e3 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -103,7 +103,7 @@ static inline unsigned long read_elapsed_second(void) | |||
103 | second_mid = rtc1_read(ETIMEMREG); | 103 | second_mid = rtc1_read(ETIMEMREG); |
104 | second_high = rtc1_read(ETIMEHREG); | 104 | second_high = rtc1_read(ETIMEHREG); |
105 | } while (first_low != second_low || first_mid != second_mid || | 105 | } while (first_low != second_low || first_mid != second_mid || |
106 | first_high != second_high); | 106 | first_high != second_high); |
107 | 107 | ||
108 | return (first_high << 17) | (first_mid << 1) | (first_low >> 15); | 108 | return (first_high << 17) | (first_mid << 1) | (first_low >> 15); |
109 | } | 109 | } |
@@ -154,7 +154,7 @@ static int vr41xx_rtc_set_time(struct device *dev, struct rtc_time *time) | |||
154 | 154 | ||
155 | epoch_sec = mktime(epoch, 1, 1, 0, 0, 0); | 155 | epoch_sec = mktime(epoch, 1, 1, 0, 0, 0); |
156 | current_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, | 156 | current_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, |
157 | time->tm_hour, time->tm_min, time->tm_sec); | 157 | time->tm_hour, time->tm_min, time->tm_sec); |
158 | 158 | ||
159 | write_elapsed_second(current_sec - epoch_sec); | 159 | write_elapsed_second(current_sec - epoch_sec); |
160 | 160 | ||
@@ -186,7 +186,7 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
186 | struct rtc_time *time = &wkalrm->time; | 186 | struct rtc_time *time = &wkalrm->time; |
187 | 187 | ||
188 | alarm_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, | 188 | alarm_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, |
189 | time->tm_hour, time->tm_min, time->tm_sec); | 189 | time->tm_hour, time->tm_min, time->tm_sec); |
190 | 190 | ||
191 | spin_lock_irq(&rtc_lock); | 191 | spin_lock_irq(&rtc_lock); |
192 | 192 | ||
@@ -334,16 +334,18 @@ static int rtc_probe(struct platform_device *pdev) | |||
334 | } | 334 | } |
335 | 335 | ||
336 | retval = request_irq(aie_irq, elapsedtime_interrupt, 0, | 336 | retval = request_irq(aie_irq, elapsedtime_interrupt, 0, |
337 | "elapsed_time", pdev); | 337 | "elapsed_time", pdev); |
338 | if (retval < 0) | 338 | if (retval < 0) |
339 | goto err_device_unregister; | 339 | goto err_device_unregister; |
340 | 340 | ||
341 | pie_irq = platform_get_irq(pdev, 1); | 341 | pie_irq = platform_get_irq(pdev, 1); |
342 | if (pie_irq <= 0) | 342 | if (pie_irq <= 0) { |
343 | retval = -EBUSY; | ||
343 | goto err_free_irq; | 344 | goto err_free_irq; |
345 | } | ||
344 | 346 | ||
345 | retval = request_irq(pie_irq, rtclong1_interrupt, 0, | 347 | retval = request_irq(pie_irq, rtclong1_interrupt, 0, |
346 | "rtclong1", pdev); | 348 | "rtclong1", pdev); |
347 | if (retval < 0) | 349 | if (retval < 0) |
348 | goto err_free_irq; | 350 | goto err_free_irq; |
349 | 351 | ||
@@ -381,8 +383,6 @@ static int rtc_remove(struct platform_device *pdev) | |||
381 | if (rtc) | 383 | if (rtc) |
382 | rtc_device_unregister(rtc); | 384 | rtc_device_unregister(rtc); |
383 | 385 | ||
384 | platform_set_drvdata(pdev, NULL); | ||
385 | |||
386 | free_irq(aie_irq, pdev); | 386 | free_irq(aie_irq, pdev); |
387 | free_irq(pie_irq, pdev); | 387 | free_irq(pie_irq, pdev); |
388 | if (rtc1_base) | 388 | if (rtc1_base) |
diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c index d89efee6d29e..c2d6331fc712 100644 --- a/drivers/rtc/rtc-vt8500.c +++ b/drivers/rtc/rtc-vt8500.c | |||
@@ -282,8 +282,6 @@ static int vt8500_rtc_remove(struct platform_device *pdev) | |||
282 | /* Disable alarm matching */ | 282 | /* Disable alarm matching */ |
283 | writel(0, vt8500_rtc->regbase + VT8500_RTC_IS); | 283 | writel(0, vt8500_rtc->regbase + VT8500_RTC_IS); |
284 | 284 | ||
285 | platform_set_drvdata(pdev, NULL); | ||
286 | |||
287 | return 0; | 285 | return 0; |
288 | } | 286 | } |
289 | 287 | ||
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c index 8d65b94e5a7e..75aea4c4d334 100644 --- a/drivers/rtc/rtc-wm831x.c +++ b/drivers/rtc/rtc-wm831x.c | |||
@@ -460,11 +460,6 @@ err: | |||
460 | return ret; | 460 | return ret; |
461 | } | 461 | } |
462 | 462 | ||
463 | static int wm831x_rtc_remove(struct platform_device *pdev) | ||
464 | { | ||
465 | return 0; | ||
466 | } | ||
467 | |||
468 | static const struct dev_pm_ops wm831x_rtc_pm_ops = { | 463 | static const struct dev_pm_ops wm831x_rtc_pm_ops = { |
469 | .suspend = wm831x_rtc_suspend, | 464 | .suspend = wm831x_rtc_suspend, |
470 | .resume = wm831x_rtc_resume, | 465 | .resume = wm831x_rtc_resume, |
@@ -478,7 +473,6 @@ static const struct dev_pm_ops wm831x_rtc_pm_ops = { | |||
478 | 473 | ||
479 | static struct platform_driver wm831x_rtc_driver = { | 474 | static struct platform_driver wm831x_rtc_driver = { |
480 | .probe = wm831x_rtc_probe, | 475 | .probe = wm831x_rtc_probe, |
481 | .remove = wm831x_rtc_remove, | ||
482 | .driver = { | 476 | .driver = { |
483 | .name = "wm831x-rtc", | 477 | .name = "wm831x-rtc", |
484 | .pm = &wm831x_rtc_pm_ops, | 478 | .pm = &wm831x_rtc_pm_ops, |
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index fa9b0679fb60..365dc6505148 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright 2005 Alessandro Zummo | 4 | * Copyright 2005 Alessandro Zummo |
5 | * | 5 | * |
6 | * please send all reports to: | 6 | * please send all reports to: |
7 | * Karen Spearel <kas111 at gmail dot com> | 7 | * Karen Spearel <kas111 at gmail dot com> |
8 | * Alessandro Zummo <a.zummo@towertech.it> | 8 | * Alessandro Zummo <a.zummo@towertech.it> |
9 | * | 9 | * |
10 | * based on a lot of other RTC drivers. | 10 | * based on a lot of other RTC drivers. |
@@ -215,12 +215,14 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
215 | buf[i] |= 0x80; | 215 | buf[i] |= 0x80; |
216 | 216 | ||
217 | /* this sequence is required to unlock the chip */ | 217 | /* this sequence is required to unlock the chip */ |
218 | if ((xfer = i2c_master_send(client, wel, 3)) != 3) { | 218 | xfer = i2c_master_send(client, wel, 3); |
219 | if (xfer != 3) { | ||
219 | dev_err(&client->dev, "%s: wel - %d\n", __func__, xfer); | 220 | dev_err(&client->dev, "%s: wel - %d\n", __func__, xfer); |
220 | return -EIO; | 221 | return -EIO; |
221 | } | 222 | } |
222 | 223 | ||
223 | if ((xfer = i2c_master_send(client, rwel, 3)) != 3) { | 224 | xfer = i2c_master_send(client, rwel, 3); |
225 | if (xfer != 3) { | ||
224 | dev_err(&client->dev, "%s: rwel - %d\n", __func__, xfer); | 226 | dev_err(&client->dev, "%s: rwel - %d\n", __func__, xfer); |
225 | return -EIO; | 227 | return -EIO; |
226 | } | 228 | } |
@@ -269,7 +271,8 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
269 | } | 271 | } |
270 | 272 | ||
271 | /* disable further writes */ | 273 | /* disable further writes */ |
272 | if ((xfer = i2c_master_send(client, diswe, 3)) != 3) { | 274 | xfer = i2c_master_send(client, diswe, 3); |
275 | if (xfer != 3) { | ||
273 | dev_err(&client->dev, "%s: diswe - %d\n", __func__, xfer); | 276 | dev_err(&client->dev, "%s: diswe - %d\n", __func__, xfer); |
274 | return -EIO; | 277 | return -EIO; |
275 | } | 278 | } |
@@ -375,8 +378,7 @@ static int x1205_get_atrim(struct i2c_client *client, int *trim) | |||
375 | return 0; | 378 | return 0; |
376 | } | 379 | } |
377 | 380 | ||
378 | struct x1205_limit | 381 | struct x1205_limit { |
379 | { | ||
380 | unsigned char reg, mask, min, max; | 382 | unsigned char reg, mask, min, max; |
381 | }; | 383 | }; |
382 | 384 | ||
@@ -430,7 +432,8 @@ static int x1205_validate_client(struct i2c_client *client) | |||
430 | }, | 432 | }, |
431 | }; | 433 | }; |
432 | 434 | ||
433 | if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) { | 435 | xfer = i2c_transfer(client->adapter, msgs, 2); |
436 | if (xfer != 2) { | ||
434 | dev_err(&client->dev, | 437 | dev_err(&client->dev, |
435 | "%s: could not read register %x\n", | 438 | "%s: could not read register %x\n", |
436 | __func__, probe_zero_pattern[i]); | 439 | __func__, probe_zero_pattern[i]); |
@@ -467,7 +470,8 @@ static int x1205_validate_client(struct i2c_client *client) | |||
467 | }, | 470 | }, |
468 | }; | 471 | }; |
469 | 472 | ||
470 | if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) { | 473 | xfer = i2c_transfer(client->adapter, msgs, 2); |
474 | if (xfer != 2) { | ||
471 | dev_err(&client->dev, | 475 | dev_err(&client->dev, |
472 | "%s: could not read register %x\n", | 476 | "%s: could not read register %x\n", |
473 | __func__, probe_limits_pattern[i].reg); | 477 | __func__, probe_limits_pattern[i].reg); |
@@ -548,10 +552,12 @@ static int x1205_rtc_proc(struct device *dev, struct seq_file *seq) | |||
548 | { | 552 | { |
549 | int err, dtrim, atrim; | 553 | int err, dtrim, atrim; |
550 | 554 | ||
551 | if ((err = x1205_get_dtrim(to_i2c_client(dev), &dtrim)) == 0) | 555 | err = x1205_get_dtrim(to_i2c_client(dev), &dtrim); |
556 | if (!err) | ||
552 | seq_printf(seq, "digital_trim\t: %d ppm\n", dtrim); | 557 | seq_printf(seq, "digital_trim\t: %d ppm\n", dtrim); |
553 | 558 | ||
554 | if ((err = x1205_get_atrim(to_i2c_client(dev), &atrim)) == 0) | 559 | err = x1205_get_atrim(to_i2c_client(dev), &atrim); |
560 | if (!err) | ||
555 | seq_printf(seq, "analog_trim\t: %d.%02d pF\n", | 561 | seq_printf(seq, "analog_trim\t: %d.%02d pF\n", |
556 | atrim / 1000, atrim % 1000); | 562 | atrim / 1000, atrim % 1000); |
557 | return 0; | 563 | return 0; |
@@ -639,7 +645,8 @@ static int x1205_probe(struct i2c_client *client, | |||
639 | i2c_set_clientdata(client, rtc); | 645 | i2c_set_clientdata(client, rtc); |
640 | 646 | ||
641 | /* Check for power failures and eventually enable the osc */ | 647 | /* Check for power failures and eventually enable the osc */ |
642 | if ((err = x1205_get_status(client, &sr)) == 0) { | 648 | err = x1205_get_status(client, &sr); |
649 | if (!err) { | ||
643 | if (sr & X1205_SR_RTCF) { | 650 | if (sr & X1205_SR_RTCF) { |
644 | dev_err(&client->dev, | 651 | dev_err(&client->dev, |
645 | "power failure detected, " | 652 | "power failure detected, " |
@@ -647,9 +654,9 @@ static int x1205_probe(struct i2c_client *client, | |||
647 | udelay(50); | 654 | udelay(50); |
648 | x1205_fix_osc(client); | 655 | x1205_fix_osc(client); |
649 | } | 656 | } |
650 | } | 657 | } else { |
651 | else | ||
652 | dev_err(&client->dev, "couldn't read status\n"); | 658 | dev_err(&client->dev, "couldn't read status\n"); |
659 | } | ||
653 | 660 | ||
654 | err = x1205_sysfs_register(&client->dev); | 661 | err = x1205_sysfs_register(&client->dev); |
655 | if (err) | 662 | if (err) |