From 39122bac1afe28561450f1d0f5a0632f63027429 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Mathieu=20B=C3=A9rard?= <mathieu.berard@crans.org>
Date: Mon, 11 Sep 2006 19:07:21 +0000
Subject: [PATCH] * Add Toshiba Satellite M45 DMI string * Fix hotkeys funtions
 return values   (hotkeys file was always empty) * Update BUGS TODO an README

---
 doc/BUGS             | 33 ++++++---------------------------
 doc/README           |  8 ++++++--
 doc/TODO             |  1 -
 hotkeys.c            | 22 ++++++++++++++--------
 laptop.h             |  9 +++++++++
 misc/dmi_strings.txt | 14 ++++++++++++++
 6 files changed, 49 insertions(+), 38 deletions(-)

diff --git a/doc/BUGS b/doc/BUGS
index eb36396..c17999a 100644
--- a/doc/BUGS
+++ b/doc/BUGS
@@ -1,37 +1,16 @@
 Bugs and problems in omnibook module code
 =========================================
 
-* You can use /proc/apm emulation for battery status monitoring only.
-* Volume Control buttons do not generate scancodes on XE3GC style models.
-  Scancode emulation needs intensive testing to be reliable.
 * Volume Control buttons on machine (not on docking station) do not generate
   scancodes on OB500 style models. It is unhandled yet.
-* Sometimes (I assume when the embedded controller is busy) the procfs
-  interface displays fake values.
 * Setting the LCD brightness on HP OmniBook XE3 GF via /proc/omnibook/lcd
   is working if you press one of the brightness control keys once after
   writing the value into /proc/omnibook/lcd.
-* After reenable the touchpad via /proc/omnibook/touchpad you may restart
-  X / gpm.
 * I'm not a native English speaker so text corrections are welcome.
-* obtest can BADLY confuse the in-kernel ACPI code due to racy 
-  implementation of obtest
+* obtest can BADLY confuse the in-kernel ACPI code due to its racy 
+  implementation.
+* Reenabling wifi adapter after previous disabling is broken on 
+  Toshiba Satellite M100 (ipw3945)
+* See http://sourceforge.net/tracker/?atid=868542&group_id=174260&func=browse
+  for sf.net bug tracking system.
 
-Problems with OmniBook machines running Linux
-=============================================
-
-* If you use APM there are a lot of mysterious hangs at suspend/resume on
-  the new models. The OmniBooks use ACPI not APM but ACPI for Linux does not
-  provide reliable power management functions yet. Use swsusp instead.
-* In some cases the touchpad in XE3 GF models can freeze the laptop after
-  disabling and reenabling it with the disable button and doing a tap
-  action when neither gpm nor X is running. It seems to be a BIOS or
-  firmware bug.
-  Please report if you can reproduce it.
-* On XE3 GC models Fn-s key combination try to suspend to ram which freezes
-  the machine completely.
-* The ESS winmodem in XE3 (and other) machines is not working with Linux.
-  There are (or at least was) binary only drivers but those have a lot of 
-  problems (eg. lock up the machine at disconnect etc.)
-* The 3Com winmodem in OmniBook 5xx (and other) laptops is unsupported by
-  Linux.
diff --git a/doc/README b/doc/README
index 0b8abcc..436d44e 100644
--- a/doc/README
+++ b/doc/README
@@ -80,8 +80,12 @@ How does it work?
        Toshiba Satellite P20
    12. Toshiba Satellite M30X
        Toshiba Satellite M35X
+       Toshiba Satellite M40X
        Toshiba Satellite M70
+       Toshiba Satellite M100
    13. Toshiba Satellite M40
+       Toshiba Satellite M45
+       Toshiba Tecra S1
    14. Toshiba Satellite A105
    
    If your model is not listed above you may try to load the module. If it
@@ -166,9 +170,9 @@ How to use?
 	Fn + F5 hotkey:			0x40
 
     That is to enable multimedia hotkeys only do: 
-	$cat 0x2 > /proc/omnibook/hotkeys
+	$echo 0x2 > /proc/omnibook/hotkeys
     To enable Fn hotkeys and Dock events only do:
-	$cat 0x24 > /proc/omnibook/hotkeys	(as 0x24 = 0x4 + 0x20)
+	$echo 0x24 > /proc/omnibook/hotkeys	(as 0x24 = 0x4 + 0x20)
 
     Finally 'off' is equivalent to 0x0, and 'on' to 0x67 that is
     Onetouch, Multimedia, Fn, Dock and Fn+F5.
diff --git a/doc/TODO b/doc/TODO
index a32c289..b9fefb8 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -8,7 +8,6 @@ Current issues:
 * Create a clean access method to the i8042 kbd controller (this will require
   a kernel patch)
 * To be cleaned: battery dump fan_policy
-* Fix wifi and Toshiba Satellite M100 (ipw3945)
 
 Old items imported from previous version:
 
diff --git a/hotkeys.c b/hotkeys.c
index 3fd00a9..f4e111e 100644
--- a/hotkeys.c
+++ b/hotkeys.c
@@ -34,12 +34,13 @@ static int omnibook_hotkeys_set(struct omnibook_operation *io_op, unsigned int s
 
 	write_capability = io_op->backend->hotkeys_set(io_op, state);
 	if( write_capability < 0)
-		return write_capability;
+		goto out;
 
 	/* Update saved state */
 	saved_state = state & write_capability;
-	
-	return 0;
+
+out:	
+	return write_capability;
 }
 
 static int omnibook_hotkeys_get(struct omnibook_operation *io_op, unsigned int *state)
@@ -51,12 +52,13 @@ static int omnibook_hotkeys_get(struct omnibook_operation *io_op, unsigned int *
 	if(io_op->backend->hotkeys_get)
 		read_capability = io_op->backend->hotkeys_get(io_op, &read_state);
 	if(read_capability < 0)
-		return read_capability;
+		goto out;
 
 	/* Return previously set state for the fields that are write only */
 	*state = (read_state & read_capability) + (saved_state & ~read_capability);
-	
-	return 0;
+
+out:	
+	return read_capability;
 }
 
 /*
@@ -108,14 +110,16 @@ static int omnibook_hotkeys_read(char *buffer,struct omnibook_operation *io_op)
 	unsigned int read_state, mask;
 
 	read_capability = omnibook_hotkeys_get(io_op, &read_state);
+	dprintk("read_cap :%i\n",read_capability);
 	if(read_capability < 0)
 		return read_capability;
 
 	write_capability = omnibook_hotkeys_set(io_op, read_state);
+	dprintk("write_cap :%i\n",write_capability);
 	if(write_capability < 0)
 		return write_capability;
 
-	for( mask = DISPLAY_LCD_ON ; mask <= HKEY_FNF5; mask = mask << 1) {
+	for( mask = HKEY_ONETOUCH ; mask <= HKEY_FNF5; mask = mask << 1) {
 	/* we assume write capability or read capability imply support */
 		 if( (read_capability | write_capability ) & mask )
 			len += sprintf(buffer + len, "%s %s.\n", 
@@ -146,8 +150,10 @@ static int omnibook_hotkeys_write(char *buffer,struct omnibook_operation *io_op)
 
 static int __init omnibook_hotkeys_init(struct omnibook_operation *io_op)
 {	
+	int retval;	
 	printk(O_INFO "Enabling all hotkeys.\n");
-	return omnibook_hotkeys_set(io_op, HKEY_ON);
+	retval = omnibook_hotkeys_set(io_op, HKEY_ON);
+	return retval < 0 ? retval : 0;
 }
 
 static void __exit omnibook_hotkeys_cleanup(struct omnibook_operation *io_op)
diff --git a/laptop.h b/laptop.h
index 54935f3..be3f616 100644
--- a/laptop.h
+++ b/laptop.h
@@ -623,6 +623,15 @@ static struct  dmi_system_id omnibook_ids[] __initdata = {
 		},
 		.driver_data = (void*) TSM40
 	},
+	{
+		.callback = dmi_matched,
+		.ident = "Toshiba Satellite M45",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Satellite M45"),
+		},
+		.driver_data = (void*) TSM40
+	},
 	{
 		.callback = dmi_matched,
 		.ident = "Toshiba Tecra S1",
diff --git a/misc/dmi_strings.txt b/misc/dmi_strings.txt
index bc0d098..9005720 100644
--- a/misc/dmi_strings.txt
+++ b/misc/dmi_strings.txt
@@ -219,8 +219,22 @@ Board Vendor:  ATI
 Board Name:    SB400
 Board Version: Rev0.4b
 
+---------------------------------------------
+Toshiba Satellite M45 (S355) ----------------
+
+BIOS Vendor:   TOSHIBA
+BIOS Version:  Version 2.00
+BIOS Release:  02/07/2006
+System Vendor: TOSHIBA
+Product Name:  Satellite M45
+Version:       PSM40U-073001
+Serial Number: 85080639Q
+Board Vendor:  TOSHIBA
+Board Name:    Version A0
+
 ---------------------------------------------
 Toshiba Satellite M40X (-131)----------------
+
 BIOS Vendor:   TOSHIBA
 BIOS Version:  V1.60
 BIOS Release:  06/09/2005
-- 
2.43.5