aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-05-08 03:33:38 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:18 -0400
commit7d9f99eccc8f94ace31030a2a7ff73cf5f8c12a0 (patch)
tree4a4690e4050db31d7ea14c629d5710fd74cb16ae
parent446ecbd925dc580c9972049c926c17aa8d967fe4 (diff)
rtc: simplified /proc/driver/rtc handling
This simplifies the RTC procfs support by removing the class_interface that hooks it into the rtc core. If it's configured, then sysfs support is now part of the RTC core, and is never a separate module. It also removes the class_interface hook, now that its last remaining user is gone. (That API is usable only with a "struct class_device".) It's another step towards being able to remove "struct class_device". Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-By: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/rtc/Kconfig2
-rw-r--r--drivers/rtc/Makefile3
-rw-r--r--drivers/rtc/class.c9
-rw-r--r--drivers/rtc/rtc-core.h14
-rw-r--r--drivers/rtc/rtc-proc.c51
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
61config RTC_INTF_PROC 61config 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
12rtc-core-y := class.o interface.o 12rtc-core-y := class.o interface.o
13 13
14rtc-core-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o 14rtc-core-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o
15rtc-core-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o
15rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o 16rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o
16 17
17obj-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o
18
19obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o 18obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
20obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o 19obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
21obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o 20obj-$(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}
135EXPORT_SYMBOL_GPL(rtc_device_unregister); 137EXPORT_SYMBOL_GPL(rtc_device_unregister);
136 138
137int rtc_interface_register(struct class_interface *intf)
138{
139 intf->class = rtc_class;
140 return class_interface_register(intf);
141}
142EXPORT_SYMBOL_GPL(rtc_interface_register);
143
144static int __init rtc_init(void) 139static 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 @@
1extern int rtc_interface_register(struct class_interface *intf);
2
3#ifdef CONFIG_RTC_INTF_DEV 1#ifdef CONFIG_RTC_INTF_DEV
4 2
5extern void __init rtc_dev_init(void); 3extern 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
19void rtc_proc_add_device(struct rtc_device *rtc);
20void 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
21extern void __init rtc_sysfs_init(struct class *); 31extern 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
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");