[parisc-linux-cvs] linux tausq

Randolph Chung Randolph Chung <randolph@tausq.org>
Tue, 24 Sep 2002 10:52:12 -0700


> thanks to willy for pointing out that the unaligned procfs interface 
> was not done using the correct sysctl APIs. fixed that now... also
> modified the soft-power code to do the same thing. 

and here's the patch

Index: kernel/sysctl.c
===================================================================
RCS file: /var/cvs/linux/kernel/sysctl.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- kernel/sysctl.c	4 Aug 2002 23:00:15 -0000	1.13
+++ kernel/sysctl.c	24 Sep 2002 05:52:46 -0000	1.14
@@ -79,6 +79,11 @@ extern char reboot_command [];
 extern int stop_a_enabled;
 #endif
 
+#ifdef __hppa__
+extern int pwrsw_enabled;
+extern int unaligned_enabled;
+#endif
+
 #ifdef CONFIG_ARCH_S390
 #ifdef CONFIG_MATHEMU
 extern int sysctl_ieee_emulation_warnings;
@@ -183,6 +188,12 @@ static ctl_table kern_table[] = {
 	{KERN_SPARC_REBOOT, "reboot-cmd", reboot_command,
 	 256, 0644, NULL, &proc_dostring, &sysctl_string },
 	{KERN_SPARC_STOP_A, "stop-a", &stop_a_enabled, sizeof (int),
+	 0644, NULL, &proc_dointvec},
+#endif
+#ifdef __hppa__
+	{KERN_HPPA_PWRSW, "soft-power", &pwrsw_enabled, sizeof (int),
+	 0644, NULL, &proc_dointvec},
+	{KERN_HPPA_UNALIGNED, "unaligned-trap", &unaligned_enabled, sizeof (int),
 	 0644, NULL, &proc_dointvec},
 #endif
 #ifdef CONFIG_PPC32
Index: include/linux/sysctl.h
===================================================================
RCS file: /var/cvs/linux/include/linux/sysctl.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -p -r1.11 -r1.12
--- include/linux/sysctl.h	4 Aug 2002 23:00:11 -0000	1.11
+++ include/linux/sysctl.h	24 Sep 2002 05:52:46 -0000	1.12
@@ -124,6 +124,8 @@ enum
 	KERN_CORE_USES_PID=52,		/* int: use core or core.%pid */
 	KERN_TAINTED=53,	/* int: various kernel tainted flags */
 	KERN_CADPID=54,		/* int: PID of the process to notify on CAD */
+ 	KERN_HPPA_PWRSW=55,	/* int: hppa soft-power enable */
+ 	KERN_HPPA_UNALIGNED=56,	/* int: hppa unaligned-trap enable */
 };
 
 
Index: arch/parisc/kernel/power.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/power.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -p -r1.10 -r1.11
--- arch/parisc/kernel/power.c	27 Jun 2002 21:34:44 -0000	1.10
+++ arch/parisc/kernel/power.c	24 Sep 2002 05:52:46 -0000	1.11
@@ -44,8 +44,6 @@
 #include <linux/reboot.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
-#include <linux/proc_fs.h>
-#include <linux/ctype.h>
 
 #include <asm/gsc.h>
 #include <asm/pdc.h>
@@ -144,11 +142,7 @@ static void process_shutdown(void)
 DECLARE_TASKLET_DISABLED(power_tasklet, NULL, 0);
 
 /* soft power switch enabled/disabled */
-#ifdef CONFIG_PROC_FS
-static int pwrsw_enabled = 1;
-#else
-#define pwrsw_enabled (1)
-#endif
+int pwrsw_enabled = 1;
 
 /*
  * On gecko style machines (e.g. 712/xx and 715/xx) 
@@ -209,90 +203,6 @@ static void powerfail_interrupt(int code
 
 
 
-/* 
- * /proc filesystem support 
- */
-
-#ifdef CONFIG_SYSCTL
-static int power_proc_read(char *page, char **start, off_t off, int count, 
-	int *eof, void *data)
-{
-	char *out = page;
-	int len;
-
-	out += sprintf(out, "Software power switch support: ");
-	out += sprintf(out, pwrsw_enabled ? "enabled (1)" : "disabled (0)" );
-	out += sprintf(out, "\n");
-
-	len = out - page - off;
-	if (len < count) {
-		*eof = 1;
-		if (len <= 0) return 0;
-	} else {
-		len = count;
-	}
-	*start = page + off;
-	return len;
-}
-
-static int power_proc_write(struct file *file, const char *buf, 
-	unsigned long count, void *data)
-{
-	char *cur, lbuf[count];
-
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
-	memset(lbuf, 0, count);
-
-	copy_from_user(lbuf, buf, count);
-	cur = lbuf;
-
-	/* skip initial spaces */
-	while (*cur && isspace(*cur))
-		cur++;
-
-	switch (*cur) {
-	case '0':	pwrsw_enabled = 0;
-			break;
-	case '1':	pwrsw_enabled = 1;
-			break;
-	default:	printk(KERN_CRIT "/proc/" SYSCTL_FILENAME 
-					": Parse error: only '0' or '1' allowed!\n");
-			return -EINVAL;
-	} /* switch() */
-
-	return count;
-}
-
-static struct proc_dir_entry *ent;
-
-static void __init power_create_procfs(void)
-{
-	if (!power_tasklet.func)
-		return;
-	
-	ent = create_proc_entry(SYSCTL_FILENAME, S_IFREG|S_IRUGO|S_IWUSR, 0);
-	if (!ent) return;
-	
-	ent->nlink = 1;
-	ent->read_proc = power_proc_read;
-	ent->write_proc = power_proc_write;
-	ent->owner = THIS_MODULE;
-}
-
-static void __exit power_remove_procfs(void)
-{
-	remove_proc_entry(SYSCTL_FILENAME, NULL);
-}
-
-#else
-#define power_create_procfs()	do { } while (0)
-#define power_remove_procfs()	do { } while (0)
-#endif	/* CONFIG_SYSCTL */
-
-
-
 /* parisc_panic_event() is called by the panic handler.
  * As soon as a panic occurs, our tasklets above will not be
  * executed any longer. This function then re-enables the 
@@ -346,7 +256,6 @@ static int __init power_init(void)
 	/* Register a call for panic conditions. */
 	notifier_chain_register(&panic_notifier_list, &parisc_panic_block);
 
-	power_create_procfs();
 	tasklet_enable(&power_tasklet);
 
 	return 0;
@@ -359,7 +268,6 @@ static void __exit power_exit(void)
 
 	tasklet_disable(&power_tasklet);
 	notifier_chain_unregister(&panic_notifier_list, &parisc_panic_block);
-	power_remove_procfs();
 	power_tasklet.func = NULL;
 	pdc_soft_power_button(0);
 }
Index: arch/parisc/kernel/unaligned.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/unaligned.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -p -r1.10 -r1.11
--- arch/parisc/kernel/unaligned.c	22 Sep 2002 02:21:05 -0000	1.10
+++ arch/parisc/kernel/unaligned.c	24 Sep 2002 05:52:46 -0000	1.11
@@ -1,4 +1,4 @@
-/*    $Id: unaligned.c,v 1.10 2002/09/22 02:21:05 tausq Exp $
+/*    $Id: unaligned.c,v 1.11 2002/09/24 05:52:46 tausq Exp $
  *
  *    Unaligned memory access handler
  *
@@ -33,9 +33,6 @@
 #include <linux/spinlock.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/ctype.h>
-#include <linux/module.h>
-#include <linux/proc_fs.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -111,8 +108,7 @@
 #define OPCODE_STW_L    OPCODE4(0x1A)
 #define OPCODE_STW_L2   OPCODE4(0x1B)
 
-#define SYSCTL_FILENAME		"sys/kernel/unaligned_trap"
-static int unaligned_enabled = 1;
+int unaligned_enabled = 1;
 
 void die_if_kernel (char *str, struct pt_regs *regs, long err);
 
@@ -440,65 +436,3 @@ check_unaligned(struct pt_regs *regs)
 	return (int)(regs->ior & align_mask);
 }
 
-#ifdef CONFIG_PROC_FS
-static int unaligned_proc_read(char *page, char **start, off_t off, int count, 
-	int *eof, void *data)
-{
-	char *out = page;
-	int len;
-
-	out += sprintf(out, "%d\n", unaligned_enabled);
-
-	len = out - page - off;
-	*eof = 1;
-	*start = page + off;
-	return len;
-}
-
-static int unaligned_proc_write(struct file *file, const char *buf, 
-	unsigned long count, void *data)
-{
-	char *cur, lbuf[count];
-
-	if (!capable(CAP_SYS_ADMIN))
-		return -EACCES;
-
-	memset(lbuf, 0, count);
-
-	copy_from_user(lbuf, buf, count);
-	cur = lbuf;
-
-	/* skip initial spaces */
-	while (*cur && isspace(*cur))
-		cur++;
-
-	switch (*cur) {
-	case '0':	unaligned_enabled = 0;
-			break;
-	case '1':	unaligned_enabled = 1;
-			break;
-	default:	printk(KERN_CRIT "/proc/" SYSCTL_FILENAME 
-					": Parse error: only '0' or '1' allowed!\n");
-			return -EINVAL;
-	} /* switch() */
-
-	return count;
-}
-
-static int __init unaligned_create_procfs(void)
-{
-	struct proc_dir_entry *ent;
-
-	ent = create_proc_entry(SYSCTL_FILENAME, S_IFREG|S_IRUGO|S_IWUSR, 0);
-	if (!ent) return -1;
-	
-	ent->nlink = 1;
-	ent->read_proc = unaligned_proc_read;
-	ent->write_proc = unaligned_proc_write;
-	ent->owner = THIS_MODULE;
-
-	return 0;
-}
-
-module_init(unaligned_create_procfs)
-#endif