Fix for oops at system halt

Jan Echternach (echter@informatik.uni-rostock.de)
Tue, 8 Sep 1998 12:22:22 +0200


--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii

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

--bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=apm-power-off-patch

--- 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)); =20 -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); =20 --- 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; } =20 -int apm_set_power_state(u_short state) +static int apm_set_power_state(u_short state) { u_short error; =20 @@ -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 =3D apm_set_power_state(APM_STATE_OFF); + if (error =3D=3D APM_SUCCESS) + return 1; + apm_error("set power off", error); + return 0; +} +#endif =20 int apm_register_callback(int (*callback)(apm_event_t)) {

--bg08WKrSYDhXBjb5--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/faq.html