Commit c94a62aa authored by Neil Horman's avatar Neil Horman Committed by Linus Torvalds

[PATCH] apm: clean up module initalization

Clean up module initalization for apm.c.  I had started by auditing for
proper return code checks in misc_register, but I found that in the event
of an initalization failure, a proc file and a kernel thread were left
hanging out.  this patch properly cleans up those loose ends on any
initalization failure.
Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Acked-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 3a750363
...@@ -2339,6 +2339,7 @@ static int __init apm_init(void) ...@@ -2339,6 +2339,7 @@ static int __init apm_init(void)
ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD); ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n"); printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n");
remove_proc_entry("apm", NULL);
return -ENOMEM; return -ENOMEM;
} }
...@@ -2348,7 +2349,13 @@ static int __init apm_init(void) ...@@ -2348,7 +2349,13 @@ static int __init apm_init(void)
return 0; return 0;
} }
misc_register(&apm_device); /*
* Note we don't actually care if the misc_device cannot be registered.
* this driver can do its job without it, even if userspace can't
* control it. just log the error
*/
if (misc_register(&apm_device))
printk(KERN_WARNING "apm: Could not register misc device.\n");
if (HZ != 100) if (HZ != 100)
idle_period = (idle_period * HZ) / 100; idle_period = (idle_period * HZ) / 100;
......
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