aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-generic.c
diff options
context:
space:
mode:
authorGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>2009-02-19 10:46:49 -0500
committerKyle McMartin <kyle@mcmartin.ca>2009-04-01 21:05:31 -0400
commit3afe6d04626f8de87b15150a30b78df492ab68ee (patch)
tree5be89e6b7cb0053bd8e0d2b97b9905fb4adc1afe /drivers/rtc/rtc-generic.c
parent8c534e95d595750d888a7aa8b6151f196d06c75b (diff)
parisc: rtc: Rename rtc-parisc to rtc-generic
The rtc-parisc driver is not PA-RISC specific at all, as it uses the existing (but deprecated) generic RTC infrastructure ([gs]et_rtc_time()). Rename the driver from rtc-parisc to rtc-generic. Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
Diffstat (limited to 'drivers/rtc/rtc-generic.c')
-rw-r--r--drivers/rtc/rtc-generic.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c
new file mode 100644
index 000000000000..98322004ad2e
--- /dev/null
+++ b/drivers/rtc/rtc-generic.c
@@ -0,0 +1,84 @@
1/* rtc-generic: RTC driver using the generic RTC abstraction
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
14static int generic_get_time(struct device *dev, struct rtc_time *tm)
15{
16 unsigned int ret = get_rtc_time(tm);
17
18 if (ret & RTC_BATT_BAD)
19 return -EOPNOTSUPP;
20
21 return rtc_valid_tm(tm);
22}
23
24static int generic_set_time(struct device *dev, struct rtc_time *tm)
25{
26 if (set_rtc_time(tm) < 0)
27 return -EOPNOTSUPP;
28
29 return 0;
30}
31
32static const struct rtc_class_ops generic_rtc_ops = {
33 .read_time = generic_get_time,
34 .set_time = generic_set_time,
35};
36
37static int __init generic_rtc_probe(struct platform_device *dev)
38{
39 struct rtc_device *rtc;
40
41 rtc = rtc_device_register("rtc-generic", &dev->dev, &generic_rtc_ops,
42 THIS_MODULE);
43 if (IS_ERR(rtc))
44 return PTR_ERR(rtc);
45
46 platform_set_drvdata(dev, rtc);
47
48 return 0;
49}
50
51static int __exit generic_rtc_remove(struct platform_device *dev)
52{
53 struct rtc_device *rtc = platform_get_drvdata(dev);
54
55 rtc_device_unregister(rtc);
56
57 return 0;
58}
59
60static struct platform_driver generic_rtc_driver = {
61 .driver = {
62 .name = "rtc-generic",
63 .owner = THIS_MODULE,
64 },
65 .remove = __exit_p(generic_rtc_remove),
66};
67
68static int __init generic_rtc_init(void)
69{
70 return platform_driver_probe(&generic_rtc_driver, generic_rtc_probe);
71}
72
73static void __exit generic_rtc_fini(void)
74{
75 platform_driver_unregister(&generic_rtc_driver);
76}
77
78module_init(generic_rtc_init);
79module_exit(generic_rtc_fini);
80
81MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>");
82MODULE_LICENSE("GPL");
83MODULE_DESCRIPTION("Generic RTC driver");
84MODULE_ALIAS("platform:rtc-generic");