Commit 259bf51c authored by Randy Dunlap's avatar Randy Dunlap Committed by Linus Torvalds

[PATCH] janitor: input cleanups

From: Daniele Bellucci <bellucda@tiscali.it>
parent c4fc7293
...@@ -685,25 +685,47 @@ struct class input_class = { ...@@ -685,25 +685,47 @@ struct class input_class = {
static int __init input_init(void) static int __init input_init(void)
{ {
struct proc_dir_entry *entry; struct proc_dir_entry *entry;
int retval = -ENOMEM;
class_register(&input_class); class_register(&input_class);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
proc_bus_input_dir = proc_mkdir("input", proc_bus); proc_bus_input_dir = proc_mkdir("input", proc_bus);
if (proc_bus_input_dir == NULL)
return -ENOMEM;
proc_bus_input_dir->owner = THIS_MODULE; proc_bus_input_dir->owner = THIS_MODULE;
entry = create_proc_read_entry("devices", 0, proc_bus_input_dir, input_devices_read, NULL); entry = create_proc_read_entry("devices", 0, proc_bus_input_dir, input_devices_read, NULL);
if (entry == NULL) {
remove_proc_entry("input", proc_bus);
return -ENOMEM;
}
entry->owner = THIS_MODULE; entry->owner = THIS_MODULE;
entry->proc_fops->poll = input_devices_poll; entry->proc_fops->poll = input_devices_poll;
entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL); entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL);
if (entry == NULL) {
remove_proc_entry("devices", proc_bus_input_dir);
remove_proc_entry("input", proc_bus);
return -ENOMEM;
}
entry->owner = THIS_MODULE; entry->owner = THIS_MODULE;
#endif #endif
if (register_chrdev(INPUT_MAJOR, "input", &input_fops)) { retval = register_chrdev(INPUT_MAJOR, "input", &input_fops);
if (retval) {
printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR); printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR);
return -EBUSY; remove_proc_entry("devices", proc_bus_input_dir);
remove_proc_entry("handlers", proc_bus_input_dir);
remove_proc_entry("input", proc_bus);
return retval;
} }
devfs_mk_dir("input"); retval = devfs_mk_dir("input");
return 0; if (retval) {
remove_proc_entry("devices", proc_bus_input_dir);
remove_proc_entry("handlers", proc_bus_input_dir);
remove_proc_entry("input", proc_bus);
unregister_chrdev(INPUT_MAJOR, "input");
}
return retval;
} }
static void __exit input_exit(void) static void __exit input_exit(void)
...@@ -714,8 +736,7 @@ static void __exit input_exit(void) ...@@ -714,8 +736,7 @@ static void __exit input_exit(void)
remove_proc_entry("input", proc_bus); remove_proc_entry("input", proc_bus);
#endif #endif
devfs_remove("input"); devfs_remove("input");
if (unregister_chrdev(INPUT_MAJOR, "input")) unregister_chrdev(INPUT_MAJOR, "input");
printk(KERN_ERR "input: can't unregister char major %d", INPUT_MAJOR);
class_unregister(&input_class); class_unregister(&input_class);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment