patch-2.4.10 linux/drivers/acpi/namespace/nsobject.c

Next file: linux/drivers/acpi/namespace/nssearch.c
Previous file: linux/drivers/acpi/namespace/nsnames.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/namespace/nsobject.c linux/drivers/acpi/namespace/nsobject.c
@@ -2,7 +2,7 @@
  *
  * Module Name: nsobject - Utilities for objects attached to namespace
  *                         table entries
- *              $Revision: 55 $
+ *              $Revision: 65 $
  *
  ******************************************************************************/
 
@@ -40,68 +40,73 @@
  *
  * FUNCTION:    Acpi_ns_attach_object
  *
- * PARAMETERS:  Node            - Parent Node
+ * PARAMETERS:  Node                - Parent Node
  *              Object              - Object to be attached
  *              Type                - Type of object, or ACPI_TYPE_ANY if not
- *                                      known
+ *                                    known
  *
  * DESCRIPTION: Record the given object as the value associated with the
- *              name whose ACPI_HANDLE is passed.  If Object is NULL
+ *              name whose acpi_handle is passed.  If Object is NULL
  *              and Type is ACPI_TYPE_ANY, set the name as having no value.
  *
  * MUTEX:       Assumes namespace is locked
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_ns_attach_object (
-	ACPI_NAMESPACE_NODE     *node,
-	ACPI_OPERAND_OBJECT     *object,
-	ACPI_OBJECT_TYPE8       type)
+	acpi_namespace_node     *node,
+	acpi_operand_object     *object,
+	acpi_object_type8       type)
 {
-	ACPI_OPERAND_OBJECT     *obj_desc;
-	ACPI_OPERAND_OBJECT     *previous_obj_desc;
-	ACPI_OBJECT_TYPE8      obj_type = ACPI_TYPE_ANY;
+	acpi_operand_object     *obj_desc;
+	acpi_operand_object     *previous_obj_desc;
+	acpi_object_type8       obj_type = ACPI_TYPE_ANY;
 	u8                      flags;
 	u16                     opcode;
 
 
+	FUNCTION_TRACE ("Ns_attach_object");
+
+
 	/*
 	 * Parameter validation
 	 */
-
 	if (!acpi_gbl_root_node) {
 		/* Name space not initialized  */
 
 		REPORT_ERROR (("Ns_attach_object: Namespace not initialized\n"));
-		return (AE_NO_NAMESPACE);
+		return_ACPI_STATUS (AE_NO_NAMESPACE);
 	}
 
 	if (!node) {
 		/* Invalid handle */
 
 		REPORT_ERROR (("Ns_attach_object: Null Named_obj handle\n"));
-		return (AE_BAD_PARAMETER);
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 	if (!object && (ACPI_TYPE_ANY != type)) {
 		/* Null object */
 
 		REPORT_ERROR (("Ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
-		return (AE_BAD_PARAMETER);
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 	if (!VALID_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED)) {
 		/* Not a name handle */
 
 		REPORT_ERROR (("Ns_attach_object: Invalid handle\n"));
-		return (AE_BAD_PARAMETER);
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 	/* Check if this object is already attached */
 
 	if (node->object == object) {
-		return (AE_OK);
+		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj %p already installed in Name_obj %p\n",
+			object, node));
+
+		return_ACPI_STATUS (AE_OK);
 	}
 
 
@@ -119,25 +124,22 @@
 	}
 
 	/*
-	 * If the object is an Node with an attached object,
+	 * If the source object is a namespace Node with an attached object,
 	 * we will use that (attached) object
 	 */
-
 	else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED) &&
-			((ACPI_NAMESPACE_NODE *) object)->object) {
+			((acpi_namespace_node *) object)->object) {
 		/*
 		 * Value passed is a name handle and that name has a
 		 * non-null value.  Use that name's value and type.
 		 */
-
-		obj_desc = ((ACPI_NAMESPACE_NODE *) object)->object;
-		obj_type = ((ACPI_NAMESPACE_NODE *) object)->type;
+		obj_desc = ((acpi_namespace_node *) object)->object;
+		obj_type = ((acpi_namespace_node *) object)->type;
 
 		/*
 		 * Copy appropriate flags
 		 */
-
-		if (((ACPI_NAMESPACE_NODE *) object)->flags & ANOBJ_AML_ATTACHMENT) {
+		if (((acpi_namespace_node *) object)->flags & ANOBJ_AML_ATTACHMENT) {
 			flags |= ANOBJ_AML_ATTACHMENT;
 		}
 	}
@@ -147,10 +149,8 @@
 	 * Otherwise, we will use the parameter object, but we must type
 	 * it first
 	 */
-
 	else {
-		obj_desc = (ACPI_OPERAND_OBJECT *) object;
-
+		obj_desc = (acpi_operand_object *) object;
 
 		/* If a valid type (non-ANY) was given, just use it */
 
@@ -158,13 +158,9 @@
 			obj_type = type;
 		}
 
-
 		/*
 		 * Type is TYPE_Any, we must try to determinte the
-		 * actual type of the object
-		 */
-
-		/*
+		 * actual type of the object.
 		 * Check if value points into the AML code
 		 */
 		else if (acpi_tb_system_table_pointer (object)) {
@@ -172,14 +168,12 @@
 			 * Object points into the AML stream.
 			 * Set a flag bit in the Node to indicate this
 			 */
-
 			flags |= ANOBJ_AML_ATTACHMENT;
 
 			/*
 			 * The next byte (perhaps the next two bytes)
 			 * will be the AML opcode
 			 */
-
 			MOVE_UNALIGNED16_TO_16 (&opcode, object);
 
 			/* Check for a recognized Opcode */
@@ -193,15 +187,18 @@
 					 * Op_prefix is unrecognized unless part
 					 * of Revision_op
 					 */
-
 					break;
 				}
 
-				/* Else fall through to set type as Number */
+				/* case AML_REVISION_OP: fall through and set the type to Integer */
 
-
-			case AML_ZERO_OP: case AML_ONES_OP: case AML_ONE_OP:
-			case AML_BYTE_OP: case AML_WORD_OP: case AML_DWORD_OP:
+			case AML_ZERO_OP:
+			case AML_ONES_OP:
+			case AML_ONE_OP:
+			case AML_BYTE_OP:
+			case AML_WORD_OP:
+			case AML_DWORD_OP:
+			case AML_QWORD_OP:
 
 				obj_type = ACPI_TYPE_INTEGER;
 				break;
@@ -233,7 +230,11 @@
 
 			default:
 
-				return (AE_TYPE);
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+					"AML Opcode/Type [%x] not supported in attach\n",
+					(u8) opcode));
+
+				return_ACPI_STATUS (AE_TYPE);
 				break;
 			}
 		}
@@ -243,18 +244,39 @@
 			 * Cannot figure out the type -- set to Def_any which
 			 * will print as an error in the name table dump
 			 */
+			if (acpi_dbg_level > 0) {
+				DUMP_PATHNAME (node,
+					"Ns_attach_object confused: setting bogus type for ",
+					ACPI_LV_INFO, _COMPONENT);
+
+				if (acpi_tb_system_table_pointer (object)) {
+					ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+						"AML-stream code %02x\n", *(u8 *) object));
+				}
+
+				else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED)) {
+					DUMP_PATHNAME (object, "name ", ACPI_LV_INFO, _COMPONENT);
+				}
 
+				else {
+					DUMP_PATHNAME (object, "object ", ACPI_LV_INFO, _COMPONENT);
+					DUMP_STACK_ENTRY (object);
+				}
+			}
 
 			obj_type = INTERNAL_TYPE_DEF_ANY;
 		}
 	}
 
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
+		obj_desc, node, &node->name));
+
+
 	/*
 	 * Must increment the new value's reference count
 	 * (if it is an internal object)
 	 */
-
 	acpi_ut_add_reference (obj_desc);
 
 	/* Save the existing object (if any) for deletion later */
@@ -271,7 +293,6 @@
 	/*
 	 * Delete an existing attached object.
 	 */
-
 	if (previous_obj_desc) {
 		/* One for the attach to the Node */
 
@@ -282,7 +303,7 @@
 		acpi_ut_remove_reference (previous_obj_desc);
 	}
 
-	return (AE_OK);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -302,14 +323,17 @@
 
 void
 acpi_ns_detach_object (
-	ACPI_NAMESPACE_NODE     *node)
+	acpi_namespace_node     *node)
 {
-	ACPI_OPERAND_OBJECT     *obj_desc;
+	acpi_operand_object     *obj_desc;
+
+
+	FUNCTION_TRACE ("Ns_detach_object");
 
 
 	obj_desc = node->object;
 	if (!obj_desc) {
-		return;
+		return_VOID;
 	}
 
 	/* Clear the entry in all cases */
@@ -318,18 +342,20 @@
 
 	/* Found a valid value */
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Object=%p Value=%p Name %4.4s\n",
+		node, obj_desc, &node->name));
+
 	/*
-	 * Not every value is an object allocated via Acpi_ut_callocate,
+	 * Not every value is an object allocated via ACPI_MEM_CALLOCATE,
 	 * - must check
 	 */
-
 	if (!acpi_tb_system_table_pointer (obj_desc)) {
 		/* Attempt to delete the object (and all subobjects) */
 
 		acpi_ut_remove_reference (obj_desc);
 	}
 
-	return;
+	return_VOID;
 }
 
 
@@ -346,16 +372,19 @@
 
 void *
 acpi_ns_get_attached_object (
-	ACPI_NAMESPACE_NODE     *node)
+	acpi_namespace_node     *node)
 {
+	FUNCTION_TRACE_PTR ("Ns_get_attached_object", node);
+
 
 	if (!node) {
 		/* handle invalid */
 
-		return (NULL);
+		ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Null Node ptr\n"));
+		return_PTR (NULL);
 	}
 
-	return (node->object);
+	return_PTR (node->object);
 }
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)