diff options
-rw-r--r-- | drivers/rtc/Kconfig | 2 | ||||
-rw-r--r-- | drivers/rtc/Makefile | 3 | ||||
-rw-r--r-- | drivers/rtc/class.c | 9 | ||||
-rw-r--r-- | drivers/rtc/rtc-core.h | 14 | ||||
-rw-r--r-- | drivers/rtc/rtc-proc.c | 51 |
5 files changed, 20 insertions, 59 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index d738725d4a1d..ec33ee87735e 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -59,7 +59,7 @@ config RTC_INTF_SYSFS | |||
59 | will be called rtc-sysfs. | 59 | will be called rtc-sysfs. |
60 | 60 | ||
61 | config RTC_INTF_PROC | 61 | config RTC_INTF_PROC |
62 | tristate "proc" | 62 | boolean "proc" |
63 | depends on RTC_CLASS && PROC_FS | 63 | depends on RTC_CLASS && PROC_FS |
64 | default RTC_CLASS | 64 | default RTC_CLASS |
65 | help | 65 | help |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 37bb9ceba277..a1afbc236073 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -12,10 +12,9 @@ obj-$(CONFIG_RTC_CLASS) += rtc-core.o | |||
12 | rtc-core-y := class.o interface.o | 12 | rtc-core-y := class.o interface.o |
13 | 13 | ||
14 | rtc-core-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o | 14 | rtc-core-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o |
15 | rtc-core-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o | ||
15 | rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o | 16 | rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o |
16 | 17 | ||
17 | obj-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o | ||
18 | |||
19 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o | 18 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o |
20 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o | 19 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o |
21 | obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o | 20 | obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o |
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 5845e6e9b579..9230001bd591 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -90,6 +90,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
90 | 90 | ||
91 | rtc_dev_add_device(rtc); | 91 | rtc_dev_add_device(rtc); |
92 | rtc_sysfs_add_device(rtc); | 92 | rtc_sysfs_add_device(rtc); |
93 | rtc_proc_add_device(rtc); | ||
93 | 94 | ||
94 | dev_info(dev, "rtc core: registered %s as %s\n", | 95 | dev_info(dev, "rtc core: registered %s as %s\n", |
95 | rtc->name, rtc->class_dev.class_id); | 96 | rtc->name, rtc->class_dev.class_id); |
@@ -126,6 +127,7 @@ void rtc_device_unregister(struct rtc_device *rtc) | |||
126 | */ | 127 | */ |
127 | rtc_sysfs_del_device(rtc); | 128 | rtc_sysfs_del_device(rtc); |
128 | rtc_dev_del_device(rtc); | 129 | rtc_dev_del_device(rtc); |
130 | rtc_proc_del_device(rtc); | ||
129 | class_device_unregister(&rtc->class_dev); | 131 | class_device_unregister(&rtc->class_dev); |
130 | rtc->ops = NULL; | 132 | rtc->ops = NULL; |
131 | mutex_unlock(&rtc->ops_lock); | 133 | mutex_unlock(&rtc->ops_lock); |
@@ -134,13 +136,6 @@ void rtc_device_unregister(struct rtc_device *rtc) | |||
134 | } | 136 | } |
135 | EXPORT_SYMBOL_GPL(rtc_device_unregister); | 137 | EXPORT_SYMBOL_GPL(rtc_device_unregister); |
136 | 138 | ||
137 | int rtc_interface_register(struct class_interface *intf) | ||
138 | { | ||
139 | intf->class = rtc_class; | ||
140 | return class_interface_register(intf); | ||
141 | } | ||
142 | EXPORT_SYMBOL_GPL(rtc_interface_register); | ||
143 | |||
144 | static int __init rtc_init(void) | 139 | static int __init rtc_init(void) |
145 | { | 140 | { |
146 | rtc_class = class_create(THIS_MODULE, "rtc"); | 141 | rtc_class = class_create(THIS_MODULE, "rtc"); |
diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h index 30bcd14377c5..4675a9fd5b14 100644 --- a/drivers/rtc/rtc-core.h +++ b/drivers/rtc/rtc-core.h | |||
@@ -1,5 +1,3 @@ | |||
1 | extern int rtc_interface_register(struct class_interface *intf); | ||
2 | |||
3 | #ifdef CONFIG_RTC_INTF_DEV | 1 | #ifdef CONFIG_RTC_INTF_DEV |
4 | 2 | ||
5 | extern void __init rtc_dev_init(void); | 3 | extern void __init rtc_dev_init(void); |
@@ -16,6 +14,18 @@ extern void rtc_dev_del_device(struct rtc_device *rtc); | |||
16 | 14 | ||
17 | #endif | 15 | #endif |
18 | 16 | ||
17 | #ifdef CONFIG_RTC_INTF_PROC | ||
18 | |||
19 | void rtc_proc_add_device(struct rtc_device *rtc); | ||
20 | void rtc_proc_del_device(struct rtc_device *rtc); | ||
21 | |||
22 | #else | ||
23 | |||
24 | #define rtc_proc_add_device(r) do{}while(0) | ||
25 | #define rtc_proc_del_device(r) do{}while(0) | ||
26 | |||
27 | #endif | ||
28 | |||
19 | #ifdef CONFIG_RTC_INTF_SYSFS | 29 | #ifdef CONFIG_RTC_INTF_SYSFS |
20 | 30 | ||
21 | extern void __init rtc_sysfs_init(struct class *); | 31 | extern void __init rtc_sysfs_init(struct class *); |
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c index 195be6587b30..3d7f4547c7d4 100644 --- a/drivers/rtc/rtc-proc.c +++ b/drivers/rtc/rtc-proc.c | |||
@@ -19,9 +19,6 @@ | |||
19 | #include "rtc-core.h" | 19 | #include "rtc-core.h" |
20 | 20 | ||
21 | 21 | ||
22 | static struct class_device *rtc_dev = NULL; | ||
23 | static DEFINE_MUTEX(rtc_lock); | ||
24 | |||
25 | static int rtc_proc_show(struct seq_file *seq, void *offset) | 22 | static int rtc_proc_show(struct seq_file *seq, void *offset) |
26 | { | 23 | { |
27 | int err; | 24 | int err; |
@@ -106,62 +103,22 @@ static const struct file_operations rtc_proc_fops = { | |||
106 | .release = rtc_proc_release, | 103 | .release = rtc_proc_release, |
107 | }; | 104 | }; |
108 | 105 | ||
109 | static int rtc_proc_add_device(struct class_device *class_dev, | 106 | void rtc_proc_add_device(struct rtc_device *rtc) |
110 | struct class_interface *class_intf) | ||
111 | { | 107 | { |
112 | mutex_lock(&rtc_lock); | 108 | if (rtc->id == 0) { |
113 | if (rtc_dev == NULL) { | ||
114 | struct proc_dir_entry *ent; | 109 | struct proc_dir_entry *ent; |
115 | 110 | ||
116 | rtc_dev = class_dev; | ||
117 | |||
118 | ent = create_proc_entry("driver/rtc", 0, NULL); | 111 | ent = create_proc_entry("driver/rtc", 0, NULL); |
119 | if (ent) { | 112 | if (ent) { |
120 | struct rtc_device *rtc = to_rtc_device(class_dev); | ||
121 | |||
122 | ent->proc_fops = &rtc_proc_fops; | 113 | ent->proc_fops = &rtc_proc_fops; |
123 | ent->owner = rtc->owner; | 114 | ent->owner = rtc->owner; |
124 | ent->data = rtc; | 115 | ent->data = rtc; |
125 | |||
126 | dev_dbg(class_dev->dev, "rtc intf: proc\n"); | ||
127 | } | 116 | } |
128 | else | ||
129 | rtc_dev = NULL; | ||
130 | } | 117 | } |
131 | mutex_unlock(&rtc_lock); | ||
132 | |||
133 | return 0; | ||
134 | } | 118 | } |
135 | 119 | ||
136 | static void rtc_proc_remove_device(struct class_device *class_dev, | 120 | void rtc_proc_del_device(struct rtc_device *rtc) |
137 | struct class_interface *class_intf) | ||
138 | { | 121 | { |
139 | mutex_lock(&rtc_lock); | 122 | if (rtc->id == 0) |
140 | if (rtc_dev == class_dev) { | ||
141 | remove_proc_entry("driver/rtc", NULL); | 123 | remove_proc_entry("driver/rtc", NULL); |
142 | rtc_dev = NULL; | ||
143 | } | ||
144 | mutex_unlock(&rtc_lock); | ||
145 | } | ||
146 | |||
147 | static struct class_interface rtc_proc_interface = { | ||
148 | .add = &rtc_proc_add_device, | ||
149 | .remove = &rtc_proc_remove_device, | ||
150 | }; | ||
151 | |||
152 | static int __init rtc_proc_init(void) | ||
153 | { | ||
154 | return rtc_interface_register(&rtc_proc_interface); | ||
155 | } | 124 | } |
156 | |||
157 | static void __exit rtc_proc_exit(void) | ||
158 | { | ||
159 | class_interface_unregister(&rtc_proc_interface); | ||
160 | } | ||
161 | |||
162 | subsys_initcall(rtc_proc_init); | ||
163 | module_exit(rtc_proc_exit); | ||
164 | |||
165 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | ||
166 | MODULE_DESCRIPTION("RTC class proc interface"); | ||
167 | MODULE_LICENSE("GPL"); | ||