aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-proc.c')
-rw-r--r--drivers/rtc/rtc-proc.c51
1 files changed, 4 insertions, 47 deletions
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
22static struct class_device *rtc_dev = NULL;
23static DEFINE_MUTEX(rtc_lock);
24
25static int rtc_proc_show(struct seq_file *seq, void *offset) 22static 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
109static int rtc_proc_add_device(struct class_device *class_dev, 106void 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
136static void rtc_proc_remove_device(struct class_device *class_dev, 120void 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
147static struct class_interface rtc_proc_interface = {
148 .add = &rtc_proc_add_device,
149 .remove = &rtc_proc_remove_device,
150};
151
152static int __init rtc_proc_init(void)
153{
154 return rtc_interface_register(&rtc_proc_interface);
155} 124}
156
157static void __exit rtc_proc_exit(void)
158{
159 class_interface_unregister(&rtc_proc_interface);
160}
161
162subsys_initcall(rtc_proc_init);
163module_exit(rtc_proc_exit);
164
165MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
166MODULE_DESCRIPTION("RTC class proc interface");
167MODULE_LICENSE("GPL");