[PATCH] APM 2.0.35 and 2.1.120 (was: Fix for oops at system halt)

Stephen.Rothwell@canb.auug.org.au
Wed, 09 Sep 1998 02:12:27 +1000


------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <16001.905270439.1@canb.auug.org.au>

Hi Jan,

Jan Echternach <echter@informatik.uni-rostock.de> writes:
>
> 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.

Good catch. I have appended a smaller patch (errors don't matter
when you are powering off).

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

Same here.

Alan, can this go into 2.0.36?

This is available also at http://www.canb.auug.org.au/~sfr/
as is the equivalent patch for 2.1.120 (which includes other fixes
as well).

[BTW: anyone know why the PPC and M68K ports have (conditional)
call to the apm_power_off routine? It is not likely to work ...]

Cheers,
Stephen

--
Stephen Rothwell                    Stephen.Rothwell@canb.auug.org.au

------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16001.905270439.2@canb.auug.org.au>

diff -ru linux-2.0.35/drivers/char/apm_bios.c linux/drivers/char/apm_bios.c --- linux-2.0.35/drivers/char/apm_bios.c Mon Jul 20 01:03:06 1998 +++ linux/drivers/char/apm_bios.c Wed Sep 9 01:55:41 1998 @@ -40,6 +40,8 @@ * is only incorrect by 30-60mS (vs. 1S previously) (Gabor J. Toth * <jtoth@princeton.edu>); improve interaction between * screen-blanking and gpm (Stephen Rothwell); Linux 1.99.4 + * 1.2a: Fix OOPs on power off with no APM BIOS + * Jan Echternach <echter@informatik.uni-rostock.de> * * Reference: * @@ -444,7 +446,7 @@ return APM_SUCCESS; } -int apm_set_power_state(u_short state) +static int apm_set_power_state(u_short state) { u_short error; @@ -453,6 +455,14 @@ return (error >> 8); return APM_SUCCESS; } + +#ifdef CONFIG_APM_POWER_OFF +void apm_power_off(void) +{ + if (apm_enabled) + (void) apm_set_power_state(APM_STATE_OFF); +} +#endif #ifdef CONFIG_APM_DISPLAY_BLANK /* Called by apm_display_blank and apm_display_unblank when apm_enabled. */ diff -ru linux-2.0.35/include/linux/apm_bios.h linux/include/linux/apm_bios.h --- linux-2.0.35/include/linux/apm_bios.h Sun Jun 9 19:23:53 1996 +++ linux/include/linux/apm_bios.h Wed Sep 9 01:52:00 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 void apm_power_off(void); extern int apm_display_blank(void); extern int apm_display_unblank(void); diff -ru linux-2.0.35/kernel/sys.c linux/kernel/sys.c --- linux-2.0.35/kernel/sys.c Fri Jul 10 23:45:08 1998 +++ linux/kernel/sys.c Wed Sep 9 01:51:26 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); + apm_power_off(); #endif do_exit(0); } else

------- =_aaaaaaaaaa0--

- 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