]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/rtc/rtc-parisc.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
[mv-sheeva.git] / drivers / rtc / rtc-parisc.c
1 /* rtc-parisc: RTC for HP PA-RISC firmware
2  *
3  * Copyright (C) 2008 Kyle McMartin <kyle@mcmartin.ca>
4  */
5
6 #include <linux/kernel.h>
7 #include <linux/module.h>
8 #include <linux/time.h>
9 #include <linux/platform_device.h>
10 #include <linux/rtc.h>
11
12 #include <asm/rtc.h>
13
14 static int parisc_get_time(struct device *dev, struct rtc_time *tm)
15 {
16         unsigned long ret;
17
18         ret = get_rtc_time(tm);
19
20         if (ret & RTC_BATT_BAD)
21                 return -EOPNOTSUPP;
22
23         return rtc_valid_tm(tm);
24 }
25
26 static int parisc_set_time(struct device *dev, struct rtc_time *tm)
27 {
28         if (set_rtc_time(tm) < 0)
29                 return -EOPNOTSUPP;
30
31         return 0;
32 }
33
34 static const struct rtc_class_ops parisc_rtc_ops = {
35         .read_time = parisc_get_time,
36         .set_time = parisc_set_time,
37 };
38
39 static int __init parisc_rtc_probe(struct platform_device *dev)
40 {
41         struct rtc_device *rtc;
42
43         rtc = rtc_device_register("rtc-parisc", &dev->dev, &parisc_rtc_ops,
44                                   THIS_MODULE);
45         if (IS_ERR(rtc))
46                 return PTR_ERR(rtc);
47
48         platform_set_drvdata(dev, rtc);
49
50         return 0;
51 }
52
53 static int __exit parisc_rtc_remove(struct platform_device *dev)
54 {
55         struct rtc_device *rtc = platform_get_drvdata(dev);
56
57         rtc_device_unregister(rtc);
58
59         return 0;
60 }
61
62 static struct platform_driver parisc_rtc_driver = {
63         .driver = {
64                 .name = "rtc-parisc",
65                 .owner = THIS_MODULE,
66         },
67         .probe = parisc_rtc_probe,
68         .remove = __devexit_p(parisc_rtc_remove),
69 };
70
71 static int __init parisc_rtc_init(void)
72 {
73         return platform_driver_probe(&parisc_rtc_driver, parisc_rtc_probe);
74 }
75
76 static void __exit parisc_rtc_fini(void)
77 {
78         platform_driver_unregister(&parisc_rtc_driver);
79 }
80
81 module_init(parisc_rtc_init);
82 module_exit(parisc_rtc_fini);
83
84 MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>");
85 MODULE_LICENSE("GPL");
86 MODULE_DESCRIPTION("HP PA-RISC RTC driver");