From: Ramon Casellas <casellas@infres.enst.fr>

Hi,

Original patch from Li, Shaohua <shaohua@in...> for 2.4.22/23, ported to 
2.6.0-test5-mm3 (with acpi 20030916), please test.

[1] Bug Report 
----------------------------------------------------------
http://sourceforge.net/mailarchive/forum.php?thread_id=3144527&forum_id=6102

[2] Answer
-----------------------------------------------------------
> From: Li, Shaohua <shaohua@in...> 
> RE: Re: IBM Thinkpad and ACPI 20030916 for 2.4.23-pre4   
2003-09-17 17:28 

>Hi,
> Patch for the battery error is available in OSDL bugzilla #1038. Pl. 
try.
> Thanks,
> Shaohua
-----------------------------------------------------------

Note: Works for me.



 25-akpm/drivers/acpi/utilities/utdelete.c |   34 ++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff -puN drivers/acpi/utilities/utdelete.c~acpi-thinkpad-fix drivers/acpi/utilities/utdelete.c
--- 25/drivers/acpi/utilities/utdelete.c~acpi-thinkpad-fix	Mon Oct  6 05:48:31 2003
+++ 25-akpm/drivers/acpi/utilities/utdelete.c	Mon Oct  6 05:48:31 2003
@@ -417,6 +417,8 @@ acpi_ut_update_object_reference (
 	union acpi_generic_state         *state_list = NULL;
 	union acpi_generic_state         *state;
 
+	union acpi_operand_object        *tmp;
+
 
 	ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object);
 
@@ -448,8 +450,15 @@ acpi_ut_update_object_reference (
 		switch (ACPI_GET_OBJECT_TYPE (object)) {
 		case ACPI_TYPE_DEVICE:
 
-			acpi_ut_update_ref_count (object->device.system_notify, action);
-			acpi_ut_update_ref_count (object->device.device_notify, action);
+			tmp = object->device.system_notify;
+			if(tmp && tmp->common.reference_count<=1 && action == REF_DECREMENT)
+				object->device.system_notify = NULL;
+			acpi_ut_update_ref_count (tmp, action);
+
+			tmp = object->device.device_notify;
+			if(tmp && tmp->common.reference_count <=1 && action == REF_DECREMENT)
+				object->device.device_notify = NULL;
+			acpi_ut_update_ref_count (tmp, action);
 			break;
 
 
@@ -467,6 +476,9 @@ acpi_ut_update_object_reference (
 				 */
 				status = acpi_ut_create_update_state_and_push (
 						 object->package.elements[i], action, &state_list);
+				tmp = object->package.elements[i];
+				if(tmp && tmp->common.reference_count<=1  && action == REF_DECREMENT) /*reference count didn't refresh now*/
+					object->package.elements[i] = NULL;
 				if (ACPI_FAILURE (status)) {
 					goto error_exit;
 				}
@@ -478,6 +490,9 @@ acpi_ut_update_object_reference (
 
 			status = acpi_ut_create_update_state_and_push (
 					 object->buffer_field.buffer_obj, action, &state_list);
+			tmp = object->buffer_field.buffer_obj;
+			if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
+				object->buffer_field.buffer_obj = NULL;
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
@@ -491,6 +506,9 @@ acpi_ut_update_object_reference (
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+			tmp = object->field.region_obj;
+			if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
+				object->field.region_obj = NULL;
 		   break;
 
 
@@ -501,12 +519,18 @@ acpi_ut_update_object_reference (
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+			tmp = object->bank_field.bank_obj;
+			if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
+				object->bank_field.bank_obj = NULL;
 
 			status = acpi_ut_create_update_state_and_push (
 					 object->bank_field.region_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+			tmp = object->bank_field.region_obj;
+			if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
+				object->bank_field.region_obj = NULL;
 			break;
 
 
@@ -517,12 +541,18 @@ acpi_ut_update_object_reference (
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+			tmp = object->index_field.index_obj;
+			if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
+				object->index_field.index_obj = NULL;
 
 			status = acpi_ut_create_update_state_and_push (
 					 object->index_field.data_obj, action, &state_list);
 			if (ACPI_FAILURE (status)) {
 				goto error_exit;
 			}
+			tmp = object->index_field.data_obj;
+			if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
+				object->index_field.data_obj = NULL;
 			break;
 
 

_