From owner-acpi-jp@jp.freebsd.org  Wed Jan  3 12:30:31 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id MAA48794;
	Wed, 3 Jan 2001 12:30:31 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from freya.yggdrasil.com (freya.yggdrasil.com [209.249.10.20])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id MAA48789
	for <acpi-jp@jp.freebsd.org>; Wed, 3 Jan 2001 12:30:30 +0900 (JST)
	(envelope-from adam@yggdrasil.com)
Received: from adam.yggdrasil.com (adam.yggdrasil.com [209.249.10.6])
	by freya.yggdrasil.com (8.9.3/8.9.3) with ESMTP id TAA11678;
	Tue, 2 Jan 2001 19:26:56 -0800
Received: (from adam@localhost)
	by adam.yggdrasil.com (8.9.3/8.9.3) id TAA06429;
	Tue, 2 Jan 2001 19:26:56 -0800
Date: Tue, 2 Jan 2001 19:26:56 -0800
From: "Adam J. Richter" <adam@yggdrasil.com>
To: peter@netplex.com.au
Cc: takawata@shidahara1.planet.sci.kobe-u.ac.jp, msmith@freebsd.org,
        acpi-jp@jp.freebsd.org, fudge_factor@hotmail.com,
        acme@conectiva.com.br, acpi@phobos.fachschaften.tu-muenchen.de,
        marc@mbsi.ca
Message-ID: <20010102192656.A6412@adam.yggdrasil.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C"
Content-Disposition: inline
User-Agent: Mutt/1.2i
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 1019
Subject: [acpi-jp 1019] Re: [Acpi] Patch(?): Peter Wemm's Sony Vaio ACPI fix simplified and adapted to linux-2.4.0-prerelease
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: adam@yggdrasil.com


--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Peter Wemm wrote:
[...]
>bit_granulatity is sometimes 32, for which we need the mask to be
>0xffffffff.
[...]
>Note that << 32 for a 32 bit type is essentially undefined.  It is too late
>to subtract 1 in "(1UL << bit_granularity) - 1".
[...]

Doh!

You're right.  We have to support bit_granularity == 32, although
bit_granularity == 0 is something that we don't have to support (right?)

OK.  Here is my second attempt.  It is actually the arithmetic expression
that I wanted to use in the first place, but I thought it was a little
less intuitive.

Please let me know if this version works.  This version also runs and is
able to deactivate the power on my Sony PictureBook PCG-C1VN.  Perhaps
this will resolve the other problems that people reported with my previous
patch.

-- 
Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
adam@yggdrasil.com     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America
fax +1 408 261-6631      "Free Software For The Rest Of Us."

--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="acpi.diff"

--- linux-2.4.0-prerelease/drivers/acpi/interpreter/amfldio.c	Fri Dec 29 14:07:21 2000
+++ linux/drivers/acpi/interpreter/amfldio.c	Tue Jan  2 19:15:48 2001
@@ -391,9 +391,6 @@
 
 	merged_value = field_value;
 
-	/* Check if update rule needs to be applied (not if mask is all ones) */
-
-
 	/* Decode the update rule */
 
 	switch (obj_desc->field.update_rule)
@@ -402,12 +399,19 @@
 	case UPDATE_PRESERVE:
 
 		/*
-		 * Read the current contents of the byte/word/dword containing
-		 * the field, and merge with the new field value.
+	  	 * Check if update rule needs to be applied (not if mask
+		 * is all ones).  If so, read the current contents of
+		 * the byte/word/dword containing the field, and merge
+		 * with the new field value.
 		 */
-		status = acpi_aml_read_field_data (obj_desc, this_field_byte_offset,
+
+		/* The left shift drops the bits we want to ignore. */
+	  	if ((~mask << (sizeof(mask)*8 - bit_granularity)) != 0) {
+			status = acpi_aml_read_field_data (obj_desc,
+				   this_field_byte_offset,
 				   bit_granularity, &current_value);
-		merged_value |= (current_value & ~mask);
+			merged_value |= (current_value & ~mask);
+		}
 		break;
 
 

--a8Wt8u1KmwUX3Y2C--
