aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-parisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-parisc.c')
-rw-r--r--drivers/rtc/rtc-parisc.c56
1 files changed, 15 insertions, 41 deletions
diff --git a/drivers/rtc/rtc-parisc.c b/drivers/rtc/rtc-parisc.c
index c6bfa6fe1a2a..b966f56da976 100644
--- a/drivers/rtc/rtc-parisc.c
+++ b/drivers/rtc/rtc-parisc.c
@@ -7,41 +7,25 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/time.h> 8#include <linux/time.h>
9#include <linux/platform_device.h> 9#include <linux/platform_device.h>
10#include <linux/rtc.h>
10 11
11#include <asm/rtc.h> 12#include <asm/rtc.h>
12 13
13/* as simple as can be, and no simpler. */
14struct parisc_rtc {
15 struct rtc_device *rtc;
16 spinlock_t lock;
17};
18
19static int parisc_get_time(struct device *dev, struct rtc_time *tm) 14static int parisc_get_time(struct device *dev, struct rtc_time *tm)
20{ 15{
21 struct parisc_rtc *p = dev_get_drvdata(dev); 16 unsigned long ret;
22 unsigned long flags, ret;
23 17
24 spin_lock_irqsave(&p->lock, flags);
25 ret = get_rtc_time(tm); 18 ret = get_rtc_time(tm);
26 spin_unlock_irqrestore(&p->lock, flags);
27 19
28 if (ret & RTC_BATT_BAD) 20 if (ret & RTC_BATT_BAD)
29 return -EOPNOTSUPP; 21 return -EOPNOTSUPP;
30 22
31 return 0; 23 return rtc_valid_tm(tm);
32} 24}
33 25
34static int parisc_set_time(struct device *dev, struct rtc_time *tm) 26static int parisc_set_time(struct device *dev, struct rtc_time *tm)
35{ 27{
36 struct parisc_rtc *p = dev_get_drvdata(dev); 28 if (set_rtc_time(tm) < 0)
37 unsigned long flags;
38 int ret;
39
40 spin_lock_irqsave(&p->lock, flags);
41 ret = set_rtc_time(tm);
42 spin_unlock_irqrestore(&p->lock, flags);
43
44 if (ret < 0)
45 return -EOPNOTSUPP; 29 return -EOPNOTSUPP;
46 30
47 return 0; 31 return 0;
@@ -52,35 +36,25 @@ static const struct rtc_class_ops parisc_rtc_ops = {
52 .set_time = parisc_set_time, 36 .set_time = parisc_set_time,
53}; 37};
54 38
55static int __devinit parisc_rtc_probe(struct platform_device *dev) 39static int __init parisc_rtc_probe(struct platform_device *dev)
56{ 40{
57 struct parisc_rtc *p; 41 struct rtc_device *rtc;
58
59 p = kzalloc(sizeof (*p), GFP_KERNEL);
60 if (!p)
61 return -ENOMEM;
62
63 spin_lock_init(&p->lock);
64 42
65 p->rtc = rtc_device_register("rtc-parisc", &dev->dev, &parisc_rtc_ops, 43 rtc = rtc_device_register("rtc-parisc", &dev->dev, &parisc_rtc_ops,
66 THIS_MODULE); 44 THIS_MODULE);
67 if (IS_ERR(p->rtc)) { 45 if (IS_ERR(rtc))
68 int err = PTR_ERR(p->rtc); 46 return PTR_ERR(rtc);
69 kfree(p);
70 return err;
71 }
72 47
73 platform_set_drvdata(dev, p); 48 platform_set_drvdata(dev, rtc);
74 49
75 return 0; 50 return 0;
76} 51}
77 52
78static int __devexit parisc_rtc_remove(struct platform_device *dev) 53static int __exit parisc_rtc_remove(struct platform_device *dev)
79{ 54{
80 struct parisc_rtc *p = platform_get_drvdata(dev); 55 struct rtc_device *rtc = platform_get_drvdata(dev);
81 56
82 rtc_device_unregister(p->rtc); 57 rtc_device_unregister(rtc);
83 kfree(p);
84 58
85 return 0; 59 return 0;
86} 60}
@@ -96,7 +70,7 @@ static struct platform_driver parisc_rtc_driver = {
96 70
97static int __init parisc_rtc_init(void) 71static int __init parisc_rtc_init(void)
98{ 72{
99 return platform_driver_register(&parisc_rtc_driver); 73 return platform_driver_probe(&parisc_rtc_driver, parisc_rtc_probe);
100} 74}
101 75
102static void __exit parisc_rtc_fini(void) 76static void __exit parisc_rtc_fini(void)