patch-2.4.22 linux-2.4.22/drivers/acpi/namespace/nsxfname.c

Next file: linux-2.4.22/drivers/acpi/namespace/nsxfobj.c
Previous file: linux-2.4.22/drivers/acpi/namespace/nsxfeval.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.21/drivers/acpi/namespace/nsxfname.c linux-2.4.22/drivers/acpi/namespace/nsxfname.c
@@ -2,50 +2,63 @@
  *
  * Module Name: nsxfname - Public interfaces to the ACPI subsystem
  *                         ACPI Namespace oriented interfaces
- *              $Revision: 82 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * All rights reserved.
  *
- *  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
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
-#include "acpi.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "amlcode.h"
-#include "acparser.h"
-#include "acdispat.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acnamesp.h>
 
 
 #define _COMPONENT          ACPI_NAMESPACE
-	 MODULE_NAME         ("nsxfname")
+	 ACPI_MODULE_NAME    ("nsxfname")
 
 
-/****************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_get_handle
+ * FUNCTION:    acpi_get_handle
  *
  * PARAMETERS:  Parent          - Object to search under (search scope).
- *              Path_name       - Pointer to an asciiz string containing the
+ *              path_name       - Pointer to an asciiz string containing the
  *                                  name
- *              Ret_handle      - Where the return handle is placed
+ *              ret_handle      - Where the return handle is placed
  *
  * RETURN:      Status
  *
@@ -58,16 +71,16 @@
 
 acpi_status
 acpi_get_handle (
-	acpi_handle             parent,
-	acpi_string             pathname,
-	acpi_handle             *ret_handle)
+	acpi_handle                     parent,
+	acpi_string                     pathname,
+	acpi_handle                     *ret_handle)
 {
-	acpi_status             status;
-	acpi_namespace_node     *node = NULL;
-	acpi_namespace_node     *prefix_node = NULL;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node = NULL;
+	struct acpi_namespace_node      *prefix_node = NULL;
 
 
-	FUNCTION_ENTRY ();
+	ACPI_FUNCTION_ENTRY ();
 
 
 	/* Parameter Validation */
@@ -79,20 +92,26 @@
 	/* Convert a parent handle to a prefix node */
 
 	if (parent) {
-		acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+		status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
 
 		prefix_node = acpi_ns_map_handle_to_node (parent);
 		if (!prefix_node) {
-			acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+			(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 			return (AE_BAD_PARAMETER);
 		}
 
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		if (ACPI_FAILURE (status)) {
+			return (status);
+		}
 	}
 
 	/* Special case for root, since we can't search for it */
 
-	if (STRCMP (pathname, NS_ROOT_PATH) == 0) {
+	if (ACPI_STRCMP (pathname, ACPI_NS_ROOT_PATH) == 0) {
 		*ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node);
 		return (AE_OK);
 	}
@@ -100,7 +119,8 @@
 	/*
 	 *  Find the Node and convert to a handle
 	 */
-	status = acpi_ns_get_node (pathname, prefix_node, &node);
+	status = acpi_ns_get_node_by_path (pathname, prefix_node, ACPI_NS_NO_UPSEARCH,
+			  &node);
 
 	*ret_handle = NULL;
 	if (ACPI_SUCCESS (status)) {
@@ -111,90 +131,90 @@
 }
 
 
-/****************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_get_name
+ * FUNCTION:    acpi_get_name
  *
  * PARAMETERS:  Handle          - Handle to be converted to a pathname
- *              Name_type       - Full pathname or single segment
- *              Ret_path_ptr    - Buffer for returned path
+ *              name_type       - Full pathname or single segment
+ *              Buffer          - Buffer for returned path
  *
  * RETURN:      Pointer to a string containing the fully qualified Name.
  *
  * DESCRIPTION: This routine returns the fully qualified name associated with
- *              the Handle parameter.  This and the Acpi_pathname_to_handle are
+ *              the Handle parameter.  This and the acpi_pathname_to_handle are
  *              complementary functions.
  *
  ******************************************************************************/
 
 acpi_status
 acpi_get_name (
-	acpi_handle             handle,
-	u32                     name_type,
-	acpi_buffer             *ret_path_ptr)
+	acpi_handle                     handle,
+	u32                             name_type,
+	struct acpi_buffer              *buffer)
 {
-	acpi_status             status;
-	acpi_namespace_node     *node;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
 
 
-	/* Buffer pointer must be valid always */
+	/* Parameter validation */
 
-	if (!ret_path_ptr || (name_type > ACPI_NAME_TYPE_MAX)) {
+	if (name_type > ACPI_NAME_TYPE_MAX) {
 		return (AE_BAD_PARAMETER);
 	}
 
-	/* Allow length to be zero and ignore the pointer */
-
-	if ((ret_path_ptr->length) &&
-	   (!ret_path_ptr->pointer)) {
-		return (AE_BAD_PARAMETER);
+	status = acpi_ut_validate_buffer (buffer);
+	if (ACPI_FAILURE (status)) {
+		return (status);
 	}
 
 	if (name_type == ACPI_FULL_PATHNAME) {
 		/* Get the full pathname (From the namespace root) */
 
-		status = acpi_ns_handle_to_pathname (handle, &ret_path_ptr->length,
-				   ret_path_ptr->pointer);
+		status = acpi_ns_handle_to_pathname (handle, buffer);
 		return (status);
 	}
 
 	/*
 	 * Wants the single segment ACPI name.
-	 * Validate handle and convert to an Node
+	 * Validate handle and convert to a namespace Node
 	 */
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
 	node = acpi_ns_map_handle_to_node (handle);
 	if (!node) {
 		status = AE_BAD_PARAMETER;
 		goto unlock_and_exit;
 	}
 
-	/* Check if name will fit in buffer */
+	/* Validate/Allocate/Clear caller buffer */
 
-	if (ret_path_ptr->length < PATH_SEGMENT_LENGTH) {
-		ret_path_ptr->length = PATH_SEGMENT_LENGTH;
-		status = AE_BUFFER_OVERFLOW;
+	status = acpi_ut_initialize_buffer (buffer, ACPI_PATH_SEGMENT_LENGTH);
+	if (ACPI_FAILURE (status)) {
 		goto unlock_and_exit;
 	}
 
 	/* Just copy the ACPI name from the Node and zero terminate it */
 
-	STRNCPY (ret_path_ptr->pointer, (NATIVE_CHAR *) &node->name,
+	ACPI_STRNCPY (buffer->pointer, node->name.ascii,
 			 ACPI_NAME_SIZE);
-	((NATIVE_CHAR *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0;
+	((char *) buffer->pointer) [ACPI_NAME_SIZE] = 0;
 	status = AE_OK;
 
 
 unlock_and_exit:
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 	return (status);
 }
 
 
-/****************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_get_object_info
+ * FUNCTION:    acpi_get_object_info
  *
  * PARAMETERS:  Handle          - Object Handle
  *              Info            - Where the info is returned
@@ -209,93 +229,127 @@
 
 acpi_status
 acpi_get_object_info (
-	acpi_handle             handle,
-	acpi_device_info        *info)
+	acpi_handle                     handle,
+	struct acpi_buffer              *buffer)
 {
-	acpi_device_id          hid;
-	acpi_device_id          uid;
-	acpi_status             status;
-	u32                     device_status = 0;
-	acpi_integer            address = 0;
-	acpi_namespace_node     *node;
+	acpi_status                     status;
+	struct acpi_namespace_node      *node;
+	struct acpi_device_info         info;
+	struct acpi_device_info         *return_info;
+	struct acpi_compatible_id_list *cid_list = NULL;
+	acpi_size                       size;
 
 
 	/* Parameter validation */
 
-	if (!handle || !info) {
+	if (!handle || !buffer) {
 		return (AE_BAD_PARAMETER);
 	}
 
-	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	status = acpi_ut_validate_buffer (buffer);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
+
+	status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
+	}
 
 	node = acpi_ns_map_handle_to_node (handle);
 	if (!node) {
-		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+		(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
 		return (AE_BAD_PARAMETER);
 	}
 
-	info->type      = node->type;
-	info->name      = node->name;
+	/* Init return structure */
 
-	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	size = sizeof (struct acpi_device_info);
+	ACPI_MEMSET (&info, 0, size);
 
-	/*
-	 * If not a device, we are all done.
-	 */
-	if (info->type != ACPI_TYPE_DEVICE) {
-		return (AE_OK);
+	info.type  = node->type;
+	info.name  = node->name.integer;
+	info.valid = 0;
+
+	status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
+	if (ACPI_FAILURE (status)) {
+		return (status);
 	}
 
+	/* If not a device, we are all done */
 
-	/*
-	 * Get extra info for ACPI devices only.  Run the
-	 * _HID, _UID, _STA, and _ADR methods.  Note: none
-	 * of these methods are required, so they may or may
-	 * not be present.  The Info->Valid bits are used
-	 * to indicate which methods ran successfully.
-	 */
-	info->valid = 0;
+	if (info.type == ACPI_TYPE_DEVICE) {
+		/*
+		 * Get extra info for ACPI Devices objects only:
+		 * Run the Device _HID, _UID, _CID, _STA, and _ADR methods.
+		 *
+		 * Note: none of these methods are required, so they may or may
+		 * not be present for this device.  The Info.Valid bitfield is used
+		 * to indicate which methods were found and ran successfully.
+		 */
+
+		/* Execute the Device._HID method */
+
+		status = acpi_ut_execute_HID (node, &info.hardware_id);
+		if (ACPI_SUCCESS (status)) {
+			info.valid |= ACPI_VALID_HID;
+		}
 
-	/* Execute the _HID method and save the result */
+		/* Execute the Device._UID method */
 
-	status = acpi_ut_execute_HID (node, &hid);
-	if (ACPI_SUCCESS (status)) {
-		STRNCPY (info->hardware_id, hid.buffer, sizeof(info->hardware_id));
+		status = acpi_ut_execute_UID (node, &info.unique_id);
+		if (ACPI_SUCCESS (status)) {
+			info.valid |= ACPI_VALID_UID;
+		}
 
-		info->valid |= ACPI_VALID_HID;
-	}
+		/* Execute the Device._CID method */
 
-	/* Execute the _UID method and save the result */
+		status = acpi_ut_execute_CID (node, &cid_list);
+		if (ACPI_SUCCESS (status)) {
+			size += ((acpi_size) cid_list->count - 1) *
+					 sizeof (struct acpi_compatible_id);
+			info.valid |= ACPI_VALID_CID;
+		}
 
-	status = acpi_ut_execute_UID (node, &uid);
-	if (ACPI_SUCCESS (status)) {
-		STRCPY (info->unique_id, uid.buffer);
+		/* Execute the Device._STA method */
 
-		info->valid |= ACPI_VALID_UID;
+		status = acpi_ut_execute_STA (node, &info.current_status);
+		if (ACPI_SUCCESS (status)) {
+			info.valid |= ACPI_VALID_STA;
+		}
+
+		/* Execute the Device._ADR method */
+
+		status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, node,
+				  &info.address);
+		if (ACPI_SUCCESS (status)) {
+			info.valid |= ACPI_VALID_ADR;
+		}
+
+		status = AE_OK;
 	}
 
-	/*
-	 * Execute the _STA method and save the result
-	 * _STA is not always present
-	 */
-	status = acpi_ut_execute_STA (node, &device_status);
-	if (ACPI_SUCCESS (status)) {
-		info->current_status = device_status;
-		info->valid |= ACPI_VALID_STA;
+	/* Validate/Allocate/Clear caller buffer */
+
+	status = acpi_ut_initialize_buffer (buffer, size);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
 	}
 
-	/*
-	 * Execute the _ADR method and save result if successful
-	 * _ADR is not always present
-	 */
-	status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR,
-			  node, &address);
+	/* Populate the return buffer */
 
-	if (ACPI_SUCCESS (status)) {
-		info->address = address;
-		info->valid |= ACPI_VALID_ADR;
+	return_info = buffer->pointer;
+	ACPI_MEMCPY (return_info, &info, sizeof (struct acpi_device_info));
+
+	if (cid_list) {
+		ACPI_MEMCPY (&return_info->compatibility_id, cid_list, cid_list->size);
 	}
 
-	return (AE_OK);
+
+cleanup:
+	if (cid_list) {
+		ACPI_MEM_FREE (cid_list);
+	}
+	return (status);
 }
 

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