public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix register_sysrq() in 2.4.9++
@ 2001-09-20 15:51 Randy.Dunlap
  2001-09-20 17:41 ` Alan Cox
  0 siblings, 1 reply; 8+ messages in thread
From: Randy.Dunlap @ 2001-09-20 15:51 UTC (permalink / raw)
  To: Alan, Linus, lkml, sfr, crutcher+kernel

[-- Attachment #1: Type: text/plain, Size: 452 bytes --]

Linus, Alan-

register_sysrq_key() is typed #ifdef CONFIG_MAGIC_SYSRQ,
but untyped if it's not defined, causing problems for callers
when CONFIG_MAGIC_SYSRQ is not defined.
This patch fixes that problem.

arch/i386/kernel/apm.c calls [un]register_sysrq_key() with
a pointer to a sysrq_poweroff_op data structure that is
only declared #ifdef CONFIG_MAGIC_SYSRQ.
This patch also wraps the register/unregister calls with
#ifdef CONFIG_MAGIC_SYSRQ.

~Randy

[-- Attachment #2: sysrq-if.patch --]
[-- Type: text/plain, Size: 1235 bytes --]

--- linux/include/linux/sysrq.h.org	Mon Sep 17 10:21:07 2001
+++ linux/include/linux/sysrq.h	Thu Sep 20 08:29:15 2001
@@ -87,8 +87,17 @@
 }
 
 #else
-#define register_sysrq_key(a,b)		do {} while(0)
-#define unregister_sysrq_key(a,b)	do {} while(0)
+
+static inline int register_sysrq_key(int key, struct sysrq_key_op *op_p)
+{
+	return -1;
+}
+
+static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
+{
+	return 0;
+}
+
 #endif
 
 /* Deferred actions */
--- linux/arch/i386/kernel/apm.c.org	Mon Sep 17 10:15:45 2001
+++ linux/arch/i386/kernel/apm.c	Thu Sep 20 08:34:44 2001
@@ -1564,7 +1564,10 @@
 	/* Install our power off handler.. */
 	if (power_off)
 		pm_power_off = apm_power_off;
-	register_sysrq_key('o',&sysrq_poweroff_op);
+#ifdef CONFIG_MAGIC_SYSRQ
+	if (register_sysrq_key('o',&sysrq_poweroff_op))
+		printk (KERN_ERR "Error: cannot register APM PowerOff SysRq key\n");
+#endif
 
 	if (smp_num_cpus == 1) {
 #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
@@ -1780,7 +1783,9 @@
 	}
 	misc_deregister(&apm_device);
 	remove_proc_entry("apm", NULL);
+#ifdef CONFIG_MAGIC_SYSRQ
 	unregister_sysrq_key('o',&sysrq_poweroff_op);
+#endif
 	if (power_off)
 		pm_power_off = NULL;
 	exit_kapmd = 1;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-09-24 16:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-20 15:51 [PATCH] fix register_sysrq() in 2.4.9++ Randy.Dunlap
2001-09-20 17:41 ` Alan Cox
2001-09-20 17:48   ` Randy.Dunlap
2001-09-20 17:59     ` Alan Cox
2001-09-20 18:57       ` [PATCH:v2] " Randy.Dunlap
2001-09-21 22:22         ` Crutcher Dunnavant
2001-09-21 22:36           ` [PATCH] Magic SysRq alternate fix register functions Crutcher Dunnavant
2001-09-24 16:32             ` Randy.Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox