aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/misc.c')
-rw-r--r--drivers/char/misc.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 62ebe09656e3..7e975f606924 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -169,11 +169,6 @@ fail:
169 return err; 169 return err;
170} 170}
171 171
172/*
173 * TODO for 2.7:
174 * - add a struct kref to struct miscdevice and make all usages of
175 * them dynamic.
176 */
177static struct class *misc_class; 172static struct class *misc_class;
178 173
179static const struct file_operations misc_fops = { 174static const struct file_operations misc_fops = {
@@ -204,6 +199,8 @@ int misc_register(struct miscdevice * misc)
204 dev_t dev; 199 dev_t dev;
205 int err = 0; 200 int err = 0;
206 201
202 INIT_LIST_HEAD(&misc->list);
203
207 down(&misc_sem); 204 down(&misc_sem);
208 list_for_each_entry(c, &misc_list, list) { 205 list_for_each_entry(c, &misc_list, list) {
209 if (c->minor == misc->minor) { 206 if (c->minor == misc->minor) {
@@ -228,10 +225,10 @@ int misc_register(struct miscdevice * misc)
228 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 225 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
229 dev = MKDEV(MISC_MAJOR, misc->minor); 226 dev = MKDEV(MISC_MAJOR, misc->minor);
230 227
231 misc->class = class_device_create(misc_class, NULL, dev, misc->dev, 228 misc->this_device = device_create(misc_class, misc->parent, dev,
232 "%s", misc->name); 229 "%s", misc->name);
233 if (IS_ERR(misc->class)) { 230 if (IS_ERR(misc->this_device)) {
234 err = PTR_ERR(misc->class); 231 err = PTR_ERR(misc->this_device);
235 goto out; 232 goto out;
236 } 233 }
237 234
@@ -264,7 +261,7 @@ int misc_deregister(struct miscdevice * misc)
264 261
265 down(&misc_sem); 262 down(&misc_sem);
266 list_del(&misc->list); 263 list_del(&misc->list);
267 class_device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); 264 device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
268 if (i < DYNAMIC_MINORS && i>0) { 265 if (i < DYNAMIC_MINORS && i>0) {
269 misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); 266 misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
270 } 267 }