lkml.org 
[lkml]   [1998]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectFix for oops at system halt
Hi,

If CONFIG_APM_POWER_OFF is set, but APM BIOS is not present, the
kernel dies with an oops right after the "System halted." message. Not
really a serious bug, but it should be fixed in 2.0.X.

The attached patch fixes the problem for me, but note that I could not
test the patch with an APM BIOS present.

--
Jan
--- kernel/sys.c-orig Tue Sep 8 00:11:36 1998
+++ kernel/sys.c Tue Sep 8 00:11:43 1998
@@ -200,7 +200,7 @@
printk(KERN_EMERG "System halted\n");
sys_kill(-1, SIGKILL);
#if defined(CONFIG_APM) && defined(CONFIG_APM_POWER_OFF)
- apm_set_power_state(APM_STATE_OFF);
+ (void) apm_power_off();
#endif
do_exit(0);
} else
--- include/linux/apm_bios.h-orig Tue Sep 8 00:04:48 1998
+++ include/linux/apm_bios.h Tue Sep 8 00:07:54 1998
@@ -83,7 +83,7 @@
extern int apm_register_callback(int (*callback)(apm_event_t));
extern void apm_unregister_callback(int (*callback)(apm_event_t));

-extern int apm_set_power_state(ushort state);
+extern int apm_power_off(void);
extern int apm_display_blank(void);
extern int apm_display_unblank(void);

--- drivers/char/apm_bios.c-orig Tue Sep 8 00:01:48 1998
+++ drivers/char/apm_bios.c Tue Sep 8 00:15:31 1998
@@ -444,7 +444,7 @@
return APM_SUCCESS;
}

-int apm_set_power_state(u_short state)
+static int apm_set_power_state(u_short state)
{
u_short error;

@@ -545,6 +545,21 @@
#endif
return 0;
}
+
+#ifdef CONFIG_APM_POWER_OFF
+int apm_power_off(void)
+{
+ int error;
+
+ if (!apm_enabled)
+ return 0;
+ error = apm_set_power_state(APM_STATE_OFF);
+ if (error == APM_SUCCESS)
+ return 1;
+ apm_error("set power off", error);
+ return 0;
+}
+#endif

int apm_register_callback(int (*callback)(apm_event_t))
{
\
 
 \ /
  Last update: 2005-03-22 13:44    [from the cache]
©2003-2011 Jasper Spaans. Advertise on this site