class.c (5726fb2012f0d96153113ddb7f988a0daea587ce) class.c (446ecbd925dc580c9972049c926c17aa8d967fe4)
1/*
2 * RTC subsystem, base class
3 *
4 * Copyright (C) 2005 Tower Technologies
5 * Author: Alessandro Zummo <a.zummo@towertech.it>
6 *
7 * class skeleton from drivers/hwmon/hwmon.c
8 *

--- 75 unchanged lines hidden (view full) ---

84 strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE);
85 snprintf(rtc->class_dev.class_id, BUS_ID_SIZE, "rtc%d", id);
86
87 err = class_device_register(&rtc->class_dev);
88 if (err)
89 goto exit_kfree;
90
91 rtc_dev_add_device(rtc);
1/*
2 * RTC subsystem, base class
3 *
4 * Copyright (C) 2005 Tower Technologies
5 * Author: Alessandro Zummo <a.zummo@towertech.it>
6 *
7 * class skeleton from drivers/hwmon/hwmon.c
8 *

--- 75 unchanged lines hidden (view full) ---

84 strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE);
85 snprintf(rtc->class_dev.class_id, BUS_ID_SIZE, "rtc%d", id);
86
87 err = class_device_register(&rtc->class_dev);
88 if (err)
89 goto exit_kfree;
90
91 rtc_dev_add_device(rtc);
92 rtc_sysfs_add_device(rtc);
92
93 dev_info(dev, "rtc core: registered %s as %s\n",
94 rtc->name, rtc->class_dev.class_id);
95
96 return rtc;
97
98exit_kfree:
99 kfree(rtc);

--- 18 unchanged lines hidden (view full) ---

118 */
119void rtc_device_unregister(struct rtc_device *rtc)
120{
121 if (class_device_get(&rtc->class_dev) != NULL) {
122 mutex_lock(&rtc->ops_lock);
123 /* remove innards of this RTC, then disable it, before
124 * letting any rtc_class_open() users access it again
125 */
93
94 dev_info(dev, "rtc core: registered %s as %s\n",
95 rtc->name, rtc->class_dev.class_id);
96
97 return rtc;
98
99exit_kfree:
100 kfree(rtc);

--- 18 unchanged lines hidden (view full) ---

119 */
120void rtc_device_unregister(struct rtc_device *rtc)
121{
122 if (class_device_get(&rtc->class_dev) != NULL) {
123 mutex_lock(&rtc->ops_lock);
124 /* remove innards of this RTC, then disable it, before
125 * letting any rtc_class_open() users access it again
126 */
127 rtc_sysfs_del_device(rtc);
126 rtc_dev_del_device(rtc);
127 class_device_unregister(&rtc->class_dev);
128 rtc->ops = NULL;
129 mutex_unlock(&rtc->ops_lock);
130 class_device_put(&rtc->class_dev);
131 }
132}
133EXPORT_SYMBOL_GPL(rtc_device_unregister);

--- 8 unchanged lines hidden (view full) ---

142static int __init rtc_init(void)
143{
144 rtc_class = class_create(THIS_MODULE, "rtc");
145 if (IS_ERR(rtc_class)) {
146 printk(KERN_ERR "%s: couldn't create class\n", __FILE__);
147 return PTR_ERR(rtc_class);
148 }
149 rtc_dev_init();
128 rtc_dev_del_device(rtc);
129 class_device_unregister(&rtc->class_dev);
130 rtc->ops = NULL;
131 mutex_unlock(&rtc->ops_lock);
132 class_device_put(&rtc->class_dev);
133 }
134}
135EXPORT_SYMBOL_GPL(rtc_device_unregister);

--- 8 unchanged lines hidden (view full) ---

144static int __init rtc_init(void)
145{
146 rtc_class = class_create(THIS_MODULE, "rtc");
147 if (IS_ERR(rtc_class)) {
148 printk(KERN_ERR "%s: couldn't create class\n", __FILE__);
149 return PTR_ERR(rtc_class);
150 }
151 rtc_dev_init();
152 rtc_sysfs_init(rtc_class);
150 return 0;
151}
152
153static void __exit rtc_exit(void)
154{
155 rtc_dev_exit();
156 class_destroy(rtc_class);
157}
158
159subsys_initcall(rtc_init);
160module_exit(rtc_exit);
161
162MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
163MODULE_DESCRIPTION("RTC class support");
164MODULE_LICENSE("GPL");
153 return 0;
154}
155
156static void __exit rtc_exit(void)
157{
158 rtc_dev_exit();
159 class_destroy(rtc_class);
160}
161
162subsys_initcall(rtc_init);
163module_exit(rtc_exit);
164
165MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
166MODULE_DESCRIPTION("RTC class support");
167MODULE_LICENSE("GPL");