summaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/apm.c
diff options
context:
space:
mode:
authorNeil Horman2006-09-26 08:32:21 +0200
committerLinus Torvalds2006-09-26 17:48:55 +0200
commitc94a62aae6ebc99b416e55c023b6f5a1d19a400b (patch)
tree9176d4e723f6c427afef069b64753e1b1141afdb /arch/i386/kernel/apm.c
parent[PATCH] Use BUG_ON(foo) instead of "if (foo) BUG()" in include/asm-i386/dma-m... (diff)
downloadkernel-qcow2-linux-c94a62aae6ebc99b416e55c023b6f5a1d19a400b.tar.gz
kernel-qcow2-linux-c94a62aae6ebc99b416e55c023b6f5a1d19a400b.tar.xz
kernel-qcow2-linux-c94a62aae6ebc99b416e55c023b6f5a1d19a400b.zip
[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: Neil Horman <nhorman@tuxdriver.com> Acked-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386/kernel/apm.c')
-rw-r--r--arch/i386/kernel/apm.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 8591f2fa920c..24fd577861f1 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -2339,6 +2339,7 @@ static int __init apm_init(void)
ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD);
if (ret < 0) {
printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n");
+ remove_proc_entry("apm", NULL);
return -ENOMEM;
}
@@ -2348,7 +2349,13 @@ static int __init apm_init(void)
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)
idle_period = (idle_period * HZ) / 100;