2000-11-14 03:43:21

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH] make SMP power off work when APM is a module

Hi Linus,

This patch corrects the return codes from apm's init routine
and in particular should allow SMP power off to work when APM
is compiled as a module.

Cheers,
Stephen
--
Stephen Rothwell, Open Source Researcher, Linuxcare, Inc.
+61-2-62628990 tel, +61-2-62628991 fax
[email protected], http://www.linuxcare.com/
Linuxcare. Support for the revolution.

diff -ruN 2.4.0-test11pre4/arch/i386/kernel/apm.c 2.4.0-test11pre4-APM.1/arch/i386/kernel/apm.c
--- 2.4.0-test11pre4/arch/i386/kernel/apm.c Mon Nov 13 17:46:42 2000
+++ 2.4.0-test11pre4-APM.1/arch/i386/kernel/apm.c Tue Nov 14 00:30:28 2000
@@ -1571,8 +1571,6 @@
&apm_bios_fops
};

-#define APM_INIT_ERROR_RETURN return -1
-
/*
* Just start the APM thread. We do NOT want to do APM BIOS
* calls from anything but the APM thread, if for no other reason
@@ -1587,7 +1585,7 @@
{
if (apm_bios_info.version == 0) {
printk(KERN_INFO "apm: BIOS not found.\n");
- APM_INIT_ERROR_RETURN;
+ return -ENODEV;
}
printk(KERN_INFO
"apm: BIOS version %d.%d Flags 0x%02x (Driver version %s)\n",
@@ -1597,7 +1595,7 @@
driver_version);
if ((apm_bios_info.flags & APM_32_BIT_SUPPORT) == 0) {
printk(KERN_INFO "apm: no 32 bit BIOS support\n");
- APM_INIT_ERROR_RETURN;
+ return -ENODEV;
}

/*
@@ -1626,15 +1624,15 @@

if (apm_disabled) {
printk(KERN_NOTICE "apm: disabled on user request.\n");
- APM_INIT_ERROR_RETURN;
+ return -ENODEV;
}
if ((smp_num_cpus > 1) && !power_off) {
printk(KERN_NOTICE "apm: disabled - APM is not SMP safe.\n");
- APM_INIT_ERROR_RETURN;
+ return -ENODEV;
}
if (PM_IS_ACTIVE()) {
printk(KERN_NOTICE "apm: overridden by ACPI.\n");
- APM_INIT_ERROR_RETURN;
+ return -ENODEV;
}
pm_active = 1;

@@ -1683,7 +1681,7 @@
if (smp_num_cpus > 1) {
printk(KERN_NOTICE
"apm: disabled - APM is not SMP safe (power off active).\n");
- APM_INIT_ERROR_RETURN;
+ return 0;
}

misc_register(&apm_device);