diff -urN -X /home/arm/dontdiff_tml_arm /home/download/kernels/linux-2.4.19-rmk2-vanilla/drivers/char/psionw_procfs.c linux-2.4.19-rmk2/drivers/char/psionw_procfs.c
diff -urN -X /home/arm/dontdiff_tml_arm /home/download/kernels/linux-2.4.19-rmk2-vanilla/drivers/char/psionw_procfs.c linux-2.4.19-rmk2/drivers/char/psionw_procfs.c
--- /home/download/kernels/linux-2.4.19-rmk2-vanilla/drivers/char/psionw_procfs.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.19-rmk2/drivers/char/psionw_procfs.c	2002-10-02 22:07:30.000000000 -0700
@@ -0,0 +1,666 @@
+/*
+ *  linux/drivers/chars/psionw_utils.c
+ *
+ * Psion procfs entries for manipulating backlight, contrast, power off 
+ * and auto-sleep on Psion Windmere based Computers (Psion5mx(Pro), 
+ * Revo(Plus), Mako).
+ *
+ * Copyright (C) 2002 Thilo Hille <thilo@resourcery.de>
+ *                    Vaclav Kulakovsky <vaclav.kulakovsky@definity.cz>
+ *                    Tony Lindgren <tony@atomide.com>
+ *                    Simon Howard <sdh300@ecs.soton.ac.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <asm/io.h>
+
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/uaccess.h>
+
+#include <asm/hardware/psionw.h>
+#include <../drivers/pcmcia/psion_etna.h>
+
+#define MODULE_VERSION "0.2"
+#define MODULE_NAME "procfs_psionw"
+#define MODULE_DIR_NAME "psionw"
+#define COREAD 3
+
+extern void psion_off(void);
+extern void psion_lcd_powerdown(int lock);
+extern void psion_lcd_powerup(int lock);
+extern int psion_get_contrast(void);
+extern int psion_set_contrast(int new_contrast, int lock);
+extern unsigned int psionw_get_cpu_speed(int cpu);
+extern void psionw_set_cpu_speed(int speed);
+
+/* Psion sleep variables */
+
+//#define PSLEEP_DEBUG 1
+#ifdef PSLEEP_DEBUG
+	#define DEBUG_PSLEEP(x...) printk(x)
+#else
+	#define DEBUG_PSLEEP(x...)                do { ; } while(0)
+#endif
+
+#define PROC_SLEEP_MAX_LEN 8
+
+static struct timer_list psion_sleep_timer;
+static int psionblankinterval = 0;
+
+struct fb_data_t {
+	char name[PROC_SLEEP_MAX_LEN + 1];
+	char value[PROC_SLEEP_MAX_LEN + 1];
+};
+
+struct fb_data_t psion_sleep_data;
+
+static struct proc_dir_entry *psion_sleep_file;
+extern void (*psion_sleep_set_callback)(void);
+void psion_sleep_set(void);
+
+static int psionw_proc_lcdpower_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data);
+static int psionw_proc_lcdpower_write(struct file *file,
+		const char *buffer, unsigned long count, void *data);
+
+static int psionw_proc_backlight_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data);
+static int psionw_proc_backlight_write(struct file *file,
+		const char *buffer, unsigned long count, void *data);
+static int psionw_proc_contrast_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data);
+static int psionw_proc_contrast_write(struct file *file,
+		const char *buffer, unsigned long count, void *data);
+static int psionw_proc_state_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data);
+static int psionw_proc_state_write(struct file *file,
+		const char *buffer, unsigned long count, void *data);
+static int psionw_proc_uart_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data);
+static int psionw_proc_uart_write(struct file *file,
+		const char *buffer, unsigned long count, void *data);
+static int psionw_proc_cpu_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data);
+static int psionw_proc_cpu_write(struct file *file,
+		const char *buffer, unsigned long count, void *data);
+
+static struct proc_dir_entry *psionw_proc_dir,
+	*psionw_lcdpower_proc_entry,
+	*psionw_backlight_proc_entry,
+	*psionw_contrast_proc_entry,
+	*psionw_state_proc_entry,
+	*psionw_uart1_proc_entry,
+	*psionw_uart2_proc_entry,
+	*psionw_mains_proc_entry,
+	*psionw_case_proc_entry;
+
+struct uart_data_t {
+	short uart;
+};
+
+struct uart_data_t uart1_data, uart2_data;
+
+static int
+psionw_proc_lcdpower_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+	return sprintf(page, "%d\n",
+		(psionw_readl(LCDCTL) & LCDCTL_EN)? 1 : 0 );
+}
+
+static int
+psionw_proc_lcdpower_write(struct file *file, const char *buffer,
+		unsigned long count, void *data)
+{
+	unsigned char char_value;
+	int value;
+
+	if (count < 1) {
+		return -EINVAL;
+	}
+
+	if (copy_from_user(&char_value, buffer, 1))
+		return -EFAULT;
+
+	value = char_value - '0';
+
+        if (value) {
+                psionw_lcd_powerup(1);
+        } else {
+                psionw_lcd_powerdown(1);
+	}
+
+	return count;
+}
+
+static int
+psionw_proc_contrast_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+	return	sprintf(page, "%i\n", psion_get_contrast());
+}
+
+static int damn_atoi(const char *name)
+{
+    int val = 0;
+
+    for (;; name++) {
+        switch (*name) {
+            case '0'...'9':
+                val = 10*val+(*name-'0');
+                break;
+            default:
+                return val;
+        }
+    }
+}
+
+static int
+psionw_proc_contrast_write(struct file *file, const char *buffer,
+                unsigned long count, void *data)
+{
+        char rbuffer[COREAD + 1];
+	int new_contrast;
+	int len;
+
+        if (count < 1)
+                return -EINVAL;
+
+        if (count > COREAD){
+		len = COREAD;
+	}
+	else {
+		len = count;
+	}
+
+        if (copy_from_user(&rbuffer, buffer, len))
+                return -EFAULT;
+
+        rbuffer[len]='\0';
+	new_contrast = damn_atoi(rbuffer);
+
+	psion_set_contrast(new_contrast, 1);
+
+	return len;
+}
+
+
+static int
+psionw_proc_backlight_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+	return sprintf(page, "%d\n",
+		(psionw_readl(PCDR) & PCDR_LIGHT)? 1 : 0 );
+}
+
+static int
+psionw_proc_backlight_write(struct file *file, const char *buffer,
+		unsigned long count, void *data)
+{
+	unsigned char char_value;
+	int value;
+	int pcdr;
+	long flags;
+
+	if (count < 1) {
+		return -EINVAL;
+	}
+
+	if (copy_from_user(&char_value, buffer, 1))
+		return -EFAULT;
+
+	value = char_value - '0';
+
+	save_flags_cli(flags);
+        pcdr = psionw_readl(PCDR);
+        if (value) {
+                pcdr |= PCDR_LIGHT;
+        } else {
+                pcdr &= ~PCDR_LIGHT;
+	}
+        psionw_writel(pcdr, PCDR);
+	restore_flags(flags);
+
+	return count;
+}
+
+static int
+psionw_proc_uart_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+	int psionw_proc_uart_state;
+	struct uart_data_t *uart_data = (struct uart_data_t *)data;
+	int pcdr;
+
+	if (uart_data->uart == 1) {
+	 	pcdr = PCDR_UART1;
+	}
+	else if (uart_data->uart == 2) {
+	 	pcdr = PCDR_UART2;
+	}
+	else
+		return -EINVAL;
+
+	psionw_proc_uart_state = (psionw_readb(PCDR) & pcdr);
+
+	return sprintf(page, "%i\n",(psionw_proc_uart_state) ? 1 : 0);
+}
+
+static int
+psionw_proc_uart_write(struct file *file, const char *buffer,
+		unsigned long count, void *data)
+{
+	struct uart_data_t *uart_data = (struct uart_data_t *)data;
+	unsigned char char_value;
+	int value;
+	int pcdr;
+	long flags;
+
+	if (copy_from_user(&char_value, buffer, 1))
+		return -EFAULT;
+
+	value = char_value - '0';
+	if (count < 1) {
+		return -EINVAL;
+	}
+	if (uart_data->uart==1){
+	 	pcdr=PCDR_UART1;
+	}
+	else if (uart_data->uart==2){
+	 	pcdr=PCDR_UART2;
+	}
+	else
+		return -EINVAL;
+
+	save_flags_cli(flags);
+	if (value) {
+	 	printk("uart%i: powerup: \n",uart_data->uart);
+		psionw_writeb(psionw_readb(PCDR) | pcdr, PCDR);
+	}
+	else {
+	 	printk("uart%i: powerdown: \n",uart_data->uart);
+		psionw_writeb(psionw_readb(PCDR) & ~pcdr, PCDR);
+	}
+	restore_flags(flags);
+
+	return count;
+}
+
+static int
+psionw_proc_state_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+/*
+ * SlothAttack!
+ * If i had invented the refrigerator, their lights would remain on even with their door closed .
+ * We should output 0 if the machine is in sleepmode. But since noone will ever be able to read it
+ * it always sends 1
+ */
+	return sprintf(page, "1\n");
+
+}
+
+static int
+psionw_proc_state_write(struct file *file, const char *buffer,
+		unsigned long count, void *data)
+{
+	unsigned char char_value;
+	int value;
+	int pcdr;
+
+	if (count < 1) {
+		return -EINVAL;
+	}
+
+	if (copy_from_user(&char_value, buffer, 1))
+		return -EFAULT;
+
+	value = char_value - '0';
+
+        pcdr = psionw_readl(PCDR);
+        if (!value){
+	 	psion_off();
+	}
+
+	return count;
+}
+
+static int
+psionw_proc_cpu_read(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
+{
+	int speed = 0;
+	
+	speed = psionw_get_cpu_speed(0) / 100000;	
+	return sprintf(page, "%d.%d\n", speed/10, speed%10);
+}
+
+static int
+psionw_proc_cpu_write(struct file *file, const char *buffer,
+		unsigned long count, void *data)
+{
+	unsigned char char_value;
+	int value;
+	int pcdr;
+
+	if (count < 1) {
+		return -EINVAL;
+	}
+
+	if (copy_from_user(&char_value, buffer, 1))
+		return -EFAULT;
+
+	value = char_value - '0';
+
+	psionw_set_cpu_speed(value);
+
+	return count;
+}
+
+static void psion_sleep_timer_func(unsigned long dummy)
+{
+	psion_off();
+	psion_sleep_set();
+}
+
+/* Called from keyboard_psion.c on a key press */
+void psion_sleep_set(void)
+{
+	/* modify timer*/
+	psion_sleep_timer.function = psion_sleep_timer_func;
+	if (psionblankinterval) {
+		mod_timer(&psion_sleep_timer, jiffies + psionblankinterval);
+	} else {
+		del_timer(&psion_sleep_timer);
+	}	
+}
+
+static int psion_sleep_proc_read(char *page, char **start,
+			    off_t off, int count, 
+			    int *eof, void *data)
+{
+	int len;
+	struct fb_data_t *fb_data = (struct fb_data_t *)data;
+
+	len = sprintf(page, "%s\n", fb_data->value);
+	return len;
+}
+
+static int psion_sleep_proc_write(struct file *file,
+			     const char *buffer,
+			     unsigned long count, 
+			     void *data)
+{
+	int len, interval;
+	struct fb_data_t *fb_data = (struct fb_data_t *)data;
+
+	if (count > PROC_SLEEP_MAX_LEN) len = PROC_SLEEP_MAX_LEN;
+	else len = count;
+
+	if (copy_from_user(fb_data->value, buffer, len)) {
+		return 0;
+	}
+	fb_data->value[len] = '\0';
+	
+	/* read new timeout */
+	sscanf( fb_data->value, "%d", &interval );
+	if( interval ) 
+		if( interval < 10 ) {
+			interval = 10;
+			printk( "Minimal sleep inerval is 10 sec.\n" );
+		}
+	snprintf(fb_data->value, PROC_SLEEP_MAX_LEN, "%d", interval);
+	fb_data->value[len] = '\0';
+	
+	psionblankinterval = interval * HZ;
+	psion_sleep_set();
+	DEBUG_PSLEEP("Psion sleep after %d s. \n", psionblankinterval/HZ );
+
+	return len;
+}
+
+
+static int psionw_proc_mains_read(char *page, char **start,
+				  off_t off, int count,
+				  int *eof, void *data) {
+	return sprintf(page, "%i\n", (psionw_readb(PWRSR) & DCDET) != 0);
+}
+
+static int psionw_proc_mains_write(struct file *file,
+				   const char *buffer,
+				   unsigned long count,
+				   void *data) {
+	/* i cant do that */
+	return 0;
+}
+
+static int psionw_proc_case_read(char *page, char **start,
+				 off_t off, int count,
+				 int *eof, void *data) {
+
+	/* Make sure the data direction is set for read */
+	if (psionw_readb(PBDDR) & PBDR_OPEN) {
+		long flags;
+		save_flags_cli(flags);
+		psionw_writeb(psionw_readb(PBDDR) & ~PBDR_OPEN, PBDDR);
+		restore_flags(flags);
+	}
+
+	/* 0 on PBDR_OPEN = open, 1 = closed, invert this
+	   (seems more intuitive this way) */
+	return sprintf(page, "%i\n", (psionw_readb(PBDR) & PBDR_OPEN) == 0);
+}
+
+static int psionw_proc_case_write(struct file *file,
+				  const char *buffer,
+				  unsigned long count,
+				  void *data) {
+	/* i cant close the case for you! */
+	return 0;
+}
+
+
+int __init psionwbl_init(void)
+{
+	int rv = 0;
+
+	/* Create directory */
+	psionw_proc_dir = proc_mkdir(MODULE_DIR_NAME, NULL);
+	if(psionw_proc_dir == NULL) {
+		printk("Couldn't create the procfs dir for psionw \n");
+		rv = -ENOMEM;
+		goto out;
+	}
+	psionw_proc_dir->owner = THIS_MODULE;
+
+	/* Register the /proc/psionw/lcd entry */
+	psionw_lcdpower_proc_entry = create_proc_entry("lcd", 0444,
+						       psionw_proc_dir);
+	if (psionw_lcdpower_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for lcd. \n");
+		rv = -EINVAL;
+		goto out;
+	}
+	psionw_lcdpower_proc_entry->read_proc =
+		&psionw_proc_lcdpower_read;
+	psionw_lcdpower_proc_entry->write_proc =
+		&psionw_proc_lcdpower_write;
+
+	/* Register the /proc/psionw/backlight entry. */
+	psionw_backlight_proc_entry = create_proc_entry("backlight", 0444,
+							psionw_proc_dir);
+	if (psionw_backlight_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for backlight.\n");
+		rv = -EINVAL;
+		goto out;
+	}
+        psionw_backlight_proc_entry->read_proc =
+                &psionw_proc_backlight_read;
+        psionw_backlight_proc_entry->write_proc =
+                &psionw_proc_backlight_write;
+
+	/* Register the /proc/psionw/contrast entry. */
+	psionw_contrast_proc_entry = create_proc_entry("contrast", 0444,
+		psionw_proc_dir);
+	if (psionw_contrast_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for the psionw-contrast.\n");
+		rv = -EINVAL;
+		goto out;
+	}
+
+	psionw_contrast_proc_entry->read_proc =
+		&psionw_proc_contrast_read;
+	psionw_contrast_proc_entry->write_proc =
+		&psionw_proc_contrast_write;
+
+	/* Register the /proc/psionw/state entry. */
+	psionw_state_proc_entry = create_proc_entry("state", 0444,
+		psionw_proc_dir);
+	if (psionw_state_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for the psionw-state.\n");
+		rv = -EINVAL;
+		goto out;
+	}
+	psionw_state_proc_entry->read_proc =
+		&psionw_proc_state_read;
+	psionw_state_proc_entry->write_proc =
+		&psionw_proc_state_write;
+
+	/* Register the /proc/psionw/cpu entry. */
+	psionw_state_proc_entry = create_proc_entry("cpu", 0644,
+		psionw_proc_dir);
+	if (psionw_state_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for the psionw-cpu.\n");
+		rv = -EINVAL;
+		goto out;
+	}
+	psionw_state_proc_entry->read_proc =
+		&psionw_proc_cpu_read;
+	psionw_state_proc_entry->write_proc =
+		&psionw_proc_cpu_write;
+
+	/* Register the /proc/psionw/sleep entry. */
+	psion_sleep_file = create_proc_entry("sleep", 0644, psionw_proc_dir );
+	if( psion_sleep_file == NULL) {
+		printk("Couldn't create the procfs entry for the psionw-sleep.\n");
+	} else {
+		strcpy(psion_sleep_data.name, "sleep");
+		strcpy(psion_sleep_data.value, "0");
+		psion_sleep_file->data = &psion_sleep_data;
+		psion_sleep_file->read_proc = psion_sleep_proc_read;
+		psion_sleep_file->write_proc = psion_sleep_proc_write;
+		psion_sleep_file->owner = THIS_MODULE;
+	}
+
+	/* Init timer */
+	psion_sleep_set();
+
+	/* Autosleep is initialised from keyboard_psion.c */
+	psion_sleep_set_callback = psion_sleep_set;
+	DEBUG_PSLEEP("SLEEP: Callback registered.\n");
+	
+	/* Register the /proc/psionw/uart entries for uart1 */
+	psionw_uart1_proc_entry = create_proc_entry("uart1", 0444,
+		psionw_proc_dir);
+	if (psionw_uart1_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for the psionw-uart1.\n");
+		rv = -EINVAL;
+		goto out;
+	}
+	uart1_data.uart = 1;
+	psionw_uart1_proc_entry->data = &uart1_data;
+	psionw_uart1_proc_entry->read_proc =
+		&psionw_proc_uart_read;
+	psionw_uart1_proc_entry->write_proc =
+		&psionw_proc_uart_write;
+
+	/* Uart2 */
+	psionw_uart2_proc_entry = create_proc_entry("uart2", 0444,
+		psionw_proc_dir);
+	if (psionw_uart2_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for the psionw-uart2.\n");
+		rv = -EINVAL;
+		goto out;
+	}
+	uart2_data.uart = 2;
+	psionw_uart2_proc_entry->data = &uart2_data;
+	psionw_uart2_proc_entry->read_proc =
+		&psionw_proc_uart_read;
+	psionw_uart2_proc_entry->write_proc =
+		&psionw_proc_uart_write;
+
+	psionw_mains_proc_entry = create_proc_entry("mains", 0444,
+		psionw_proc_dir);
+
+	if (psionw_mains_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for mains\n");
+		rv = -EINVAL;
+		goto out;
+	} else {
+		psionw_mains_proc_entry->read_proc = &psionw_proc_mains_read;
+		psionw_mains_proc_entry->write_proc = &psionw_proc_mains_write;
+	}
+
+	psionw_case_proc_entry = create_proc_entry("case", 0444,
+		psionw_proc_dir);
+
+	if (psionw_case_proc_entry == NULL) {
+		printk("Couldn't create the procfs entry for case\n");
+		rv = -EINVAL;
+		goto out;
+	} else {
+		psionw_case_proc_entry->read_proc = &psionw_proc_case_read;
+		psionw_case_proc_entry->write_proc = &psionw_proc_case_write;
+	}
+
+	return 0;
+	out:
+		return rv;
+}
+
+static void __exit psionwbl_exit(void)
+{
+	del_timer(&psion_sleep_timer);
+
+	/* Unregister sleep callback function */
+	psion_sleep_set_callback = 0;
+
+	remove_proc_entry("lcd", psionw_proc_dir);
+	remove_proc_entry("backlight", psionw_proc_dir);
+	remove_proc_entry("contrast", psionw_proc_dir);
+	remove_proc_entry("state", psionw_proc_dir);
+	remove_proc_entry("cpu", psionw_proc_dir);
+	remove_proc_entry("sleep", psionw_proc_dir);
+	remove_proc_entry("uart1", psionw_proc_dir);
+	remove_proc_entry("uart2", psionw_proc_dir);
+	remove_proc_entry("mains", psionw_proc_dir);
+	remove_proc_entry("case", psionw_proc_dir);
+
+	remove_proc_entry(MODULE_NAME, NULL);
+}
+
+module_init(psionwbl_init);
+module_exit(psionwbl_exit);
+MODULE_AUTHOR("Thilo Hille/Vaclac Kulakovsky");
+MODULE_DESCRIPTION("procfs utils for Psion5mx(Pro)/Revo(Plus)/Mako");
+EXPORT_NO_SYMBOLS;
+
