aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/misc.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-29 04:02:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:22 -0400
commit1b50221738108c438d5f25c7a043fb89e9e27044 (patch)
tree510b2baf0675fee9ce450b6756ff36c77e2f626c /drivers/char/misc.c
parent0fd689468231cb5eee9cc5d6331081b77c7a7a76 (diff)
drivers: use non-racy method for proc entries creation
Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree. Signed-off-by: Denis V. Lunev <den@openvz.org> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/misc.c')
-rw-r--r--drivers/char/misc.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 4d058dadbfcc..eaace0db0ff4 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -263,23 +263,26 @@ EXPORT_SYMBOL(misc_deregister);
263 263
264static int __init misc_init(void) 264static int __init misc_init(void)
265{ 265{
266#ifdef CONFIG_PROC_FS 266 int err;
267 struct proc_dir_entry *ent;
268 267
269 ent = create_proc_entry("misc", 0, NULL); 268#ifdef CONFIG_PROC_FS
270 if (ent) 269 proc_create("misc", 0, NULL, &misc_proc_fops);
271 ent->proc_fops = &misc_proc_fops;
272#endif 270#endif
273 misc_class = class_create(THIS_MODULE, "misc"); 271 misc_class = class_create(THIS_MODULE, "misc");
272 err = PTR_ERR(misc_class);
274 if (IS_ERR(misc_class)) 273 if (IS_ERR(misc_class))
275 return PTR_ERR(misc_class); 274 goto fail_remove;
276 275
277 if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) { 276 err = -EIO;
278 printk("unable to get major %d for misc devices\n", 277 if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
279 MISC_MAJOR); 278 goto fail_printk;
280 class_destroy(misc_class);
281 return -EIO;
282 }
283 return 0; 279 return 0;
280
281fail_printk:
282 printk("unable to get major %d for misc devices\n", MISC_MAJOR);
283 class_destroy(misc_class);
284fail_remove:
285 remove_proc_entry("misc", NULL);
286 return err;
284} 287}
285subsys_initcall(misc_init); 288subsys_initcall(misc_init);