Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *                         ACPI Object evaluation interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define EXPORT_ACPI_INTERFACES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define _COMPONENT          ACPI_NAMESPACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) ACPI_MODULE_NAME("nsxfeval")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static void acpi_ns_resolve_references(struct acpi_evaluate_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * FUNCTION:    acpi_evaluate_object_typed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * PARAMETERS:  handle              - Object handle (optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *              pathname            - Object pathname (optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *              external_params     - List of parameters to pass to a method,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *                                    terminated by NULL. May be NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *                                    if no parameters are being passed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *              return_buffer       - Where to put the object's return value (if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *                                    any). If NULL, no value is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *              return_type         - Expected type of return object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * DESCRIPTION: Find and evaluate the given object, passing the given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *              parameters if necessary. One of "Handle" or "Pathname" must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *              be valid (non-null)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) acpi_evaluate_object_typed(acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			   acpi_string pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			   struct acpi_object_list *external_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 			   struct acpi_buffer *return_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 			   acpi_object_type return_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	u8 free_buffer_on_error = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	acpi_handle target_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	char *full_pathname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	/* Return buffer must be valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	if (!return_buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if (return_buffer->length == ACPI_ALLOCATE_BUFFER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		free_buffer_on_error = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	/* Get a handle here, in order to build an error message if needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	target_handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (pathname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		status = acpi_get_handle(handle, pathname, &target_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	full_pathname = acpi_ns_get_external_pathname(target_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	if (!full_pathname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/* Evaluate the object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	status = acpi_evaluate_object(target_handle, NULL, external_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 				      return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/* Type ANY means "don't care about return value type" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (return_type == ACPI_TYPE_ANY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	if (return_buffer->length == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		/* Error because caller specifically asked for a return value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		ACPI_ERROR((AE_INFO, "%s did not return any object",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			    full_pathname));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		status = AE_NULL_OBJECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	/* Examine the object type returned from evaluate_object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	if (((union acpi_object *)return_buffer->pointer)->type == return_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	/* Return object type does not match requested type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		    "Incorrect return type from %s - received [%s], requested [%s]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		    full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		    acpi_ut_get_type_name(((union acpi_object *)return_buffer->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 					   pointer)->type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		    acpi_ut_get_type_name(return_type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (free_buffer_on_error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		 * Free a buffer created via ACPI_ALLOCATE_BUFFER.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		 * Note: We use acpi_os_free here because acpi_os_allocate was used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		 * to allocate the buffer. This purposefully bypasses the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		 * (optionally enabled) allocation tracking mechanism since we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		 * only want to track internal allocations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		acpi_os_free(return_buffer->pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		return_buffer->pointer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	return_buffer->length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	ACPI_FREE(full_pathname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  * FUNCTION:    acpi_evaluate_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * PARAMETERS:  handle              - Object handle (optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *              pathname            - Object pathname (optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  *              external_params     - List of parameters to pass to method,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  *                                    terminated by NULL. May be NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  *                                    if no parameters are being passed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  *              return_buffer       - Where to put method's return value (if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  *                                    any). If NULL, no value is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * DESCRIPTION: Find and evaluate the given object, passing the given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  *              parameters if necessary. One of "Handle" or "Pathname" must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *              be valid (non-null)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) acpi_evaluate_object(acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		     acpi_string pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		     struct acpi_object_list *external_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		     struct acpi_buffer *return_buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	struct acpi_evaluate_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	acpi_size buffer_space_needed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	ACPI_FUNCTION_TRACE(acpi_evaluate_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	/* Allocate and initialize the evaluation information block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (!info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	/* Convert and validate the device handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	info->prefix_node = acpi_ns_validate_handle(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	if (!info->prefix_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	 * Get the actual namespace node for the target object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	 * Handles these cases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	 * 1) Null node, valid pathname from root (absolute path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	 * 2) Node and valid pathname (path relative to Node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	 * 3) Node, Null pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	if ((pathname) && (ACPI_IS_ROOT_PREFIX(pathname[0]))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		/* The path is fully qualified, just evaluate by name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		info->prefix_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	} else if (!handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		 * A handle is optional iff a fully qualified pathname is specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		 * Since we've already handled fully qualified names above, this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		 * an error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		if (!pathname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 					  "Both Handle and Pathname are NULL"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 					  "Null Handle with relative pathname [%s]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 					  pathname));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	info->relative_pathname = pathname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	 * Convert all external objects passed as arguments to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	 * internal version(s).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (external_params && external_params->count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		info->param_count = (u16)external_params->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		/* Warn on impossible argument count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		if (info->param_count > ACPI_METHOD_NUM_ARGS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			ACPI_WARN_PREDEFINED((AE_INFO, pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 					      ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 					      "Excess arguments (%u) - using only %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 					      info->param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 					      ACPI_METHOD_NUM_ARGS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			info->param_count = ACPI_METHOD_NUM_ARGS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		 * Allocate a new parameter block for the internal objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		 * Add 1 to count to allow for null terminated internal list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size)info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 							 param_count +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 							 1) * sizeof(void *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		if (!info->parameters) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 			goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		/* Convert each external object in the list to an internal object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		for (i = 0; i < info->param_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			    acpi_ut_copy_eobject_to_iobject(&external_params->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 							    pointer[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 							    &info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 							    parameters[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 				goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		info->parameters[info->param_count] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #ifdef _FUTURE_FEATURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	 * Begin incoming argument count analysis. Check for too few args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	 * and too many args.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	switch (acpi_ns_get_type(info->node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	case ACPI_TYPE_METHOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		/* Check incoming argument count against the method definition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		if (info->obj_desc->method.param_count > info->param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 				    "Insufficient arguments (%u) - %u are required",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 				    info->param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 				    info->obj_desc->method.param_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			status = AE_MISSING_ARGUMENTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		else if (info->obj_desc->method.param_count < info->param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			ACPI_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				      "Excess arguments (%u) - only %u are required",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 				      info->param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 				      info->obj_desc->method.param_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 			/* Just pass the required number of arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 			info->param_count = info->obj_desc->method.param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		 * Any incoming external objects to be passed as arguments to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		 * method must be converted to internal objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		if (info->param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 			 * Allocate a new parameter block for the internal objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 			 * Add 1 to count to allow for null terminated internal list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 								 info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 								 param_count +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 								 1) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 								sizeof(void *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			if (!info->parameters) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 				status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 				goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 			/* Convert each external object in the list to an internal object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 			for (i = 0; i < info->param_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 				status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 				    acpi_ut_copy_eobject_to_iobject
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 				    (&external_params->pointer[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 				     &info->parameters[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 				if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 					goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			info->parameters[info->param_count] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		/* Warn if arguments passed to an object that is not a method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		if (info->param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 			ACPI_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 				      "%u arguments were passed to a non-method ACPI object",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 				      info->param_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	/* Now we can evaluate the object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	status = acpi_ns_evaluate(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	 * If we are expecting a return value, and all went well above,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	 * copy the return value to an external object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	if (!return_buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		goto cleanup_return_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	if (!info->return_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		return_buffer->length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	if (ACPI_GET_DESCRIPTOR_TYPE(info->return_object) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	    ACPI_DESC_TYPE_NAMED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		 * If we received a NS Node as a return object, this means that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		 * the object we are evaluating has nothing interesting to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		 * return (such as a mutex, etc.)  We return an error because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		 * these types are essentially unsupported by this interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		 * We don't check up front because this makes it easier to add
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		 * support for various types at a later date if necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		info->return_object = NULL;	/* No need to delete a NS Node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		return_buffer->length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		goto cleanup_return_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	/* Dereference Index and ref_of references */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	acpi_ns_resolve_references(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	/* Get the size of the returned object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	status = acpi_ut_get_object_size(info->return_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 					 &buffer_space_needed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		/* Validate/Allocate/Clear caller buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		status = acpi_ut_initialize_buffer(return_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 						   buffer_space_needed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 			 * Caller's buffer is too small or a new one can't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 			 * be allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 					  "Needed buffer size %X, %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 					  (u32)buffer_space_needed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 					  acpi_format_exception(status)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 			/* We have enough space for the object, build it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			    acpi_ut_copy_iobject_to_eobject(info->return_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 							    return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) cleanup_return_object:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	if (info->return_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 		 * Delete the internal return object. NOTE: Interpreter must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 		 * locked to avoid race condition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		acpi_ex_enter_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		/* Remove one reference on the return object (should delete it) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		acpi_ut_remove_reference(info->return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	/* Free the input parameter list (if we created one) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	if (info->parameters) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		/* Free the allocated parameter block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		acpi_ut_delete_internal_object_list(info->parameters);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	ACPI_FREE(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) ACPI_EXPORT_SYMBOL(acpi_evaluate_object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)  * FUNCTION:    acpi_ns_resolve_references
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)  * PARAMETERS:  info                    - Evaluation info block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)  * RETURN:      Info->return_object is replaced with the dereferenced object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)  * DESCRIPTION: Dereference certain reference objects. Called before an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)  *              internal return object is converted to an external union acpi_object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)  * Performs an automatic dereference of Index and ref_of reference objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)  * These reference objects are not supported by the union acpi_object, so this is a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)  * last resort effort to return something useful. Also, provides compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)  * with other ACPI implementations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)  * NOTE: does not handle references within returned package objects or nested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)  * references, but this support could be added later if found to be necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	union acpi_operand_object *obj_desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	/* We are interested in reference objects only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	if ((info->return_object)->common.type != ACPI_TYPE_LOCAL_REFERENCE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	 * Two types of references are supported - those created by Index and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	 * ref_of operators. A name reference (AML_NAMEPATH_OP) can be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	 * to a union acpi_object, so it is not dereferenced here. A ddb_handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	 * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	 * a union acpi_object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	switch (info->return_object->reference.class) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	case ACPI_REFCLASS_INDEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 		obj_desc = *(info->return_object->reference.where);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	case ACPI_REFCLASS_REFOF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		node = info->return_object->reference.object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		if (node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 			obj_desc = node->object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	/* Replace the existing reference object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	if (obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		acpi_ut_add_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		acpi_ut_remove_reference(info->return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		info->return_object = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)  * FUNCTION:    acpi_walk_namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)  * PARAMETERS:  type                - acpi_object_type to search for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)  *              start_object        - Handle in namespace where search begins
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)  *              max_depth           - Depth to which search is to reach
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)  *              descending_callback - Called during tree descent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)  *                                    when an object of "Type" is found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)  *              ascending_callback  - Called during tree ascent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)  *                                    when an object of "Type" is found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)  *              context             - Passed to user function(s) above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)  *              return_value        - Location where return value of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)  *                                    user_function is put if terminated early
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)  * RETURNS      Return value from the user_function if terminated early.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)  *              Otherwise, returns NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)  * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)  *              starting (and ending) at the object specified by start_handle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)  *              The callback function is called whenever an object that matches
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)  *              the type parameter is found. If the callback function returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)  *              a non-zero value, the search is terminated immediately and this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)  *              value is returned to the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)  *              The point of this procedure is to provide a generic namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)  *              walk routine that can be called from multiple places to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)  *              provide multiple services; the callback function(s) can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)  *              tailored to each task, whether it is a print function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)  *              a compare function, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) acpi_walk_namespace(acpi_object_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 		    acpi_handle start_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 		    u32 max_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 		    acpi_walk_callback descending_callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 		    acpi_walk_callback ascending_callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 		    void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	ACPI_FUNCTION_TRACE(acpi_walk_namespace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	if ((type > ACPI_TYPE_LOCAL_MAX) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	    (!max_depth) || (!descending_callback && !ascending_callback)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	 * Need to acquire the namespace reader lock to prevent interference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	 * with any concurrent table unloads (which causes the deletion of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	 * namespace objects). We cannot allow the deletion of a namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	 * while the user function is using it. The exception to this are the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	 * nodes created and deleted during control method execution -- these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	 * nodes are marked as temporary nodes and are ignored by the namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	 * walk. Thus, control methods can be executed while holding the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	 * namespace deletion lock (and the user function can execute control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	 * methods.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	status = acpi_ut_acquire_read_lock(&acpi_gbl_namespace_rw_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	 * Lock the namespace around the walk. The namespace will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	 * unlocked/locked around each call to the user function - since the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	 * function must be allowed to make ACPICA calls itself (for example, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	 * will typically execute control methods during device enumeration.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	/* Now we can validate the starting node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	if (!acpi_ns_validate_handle(start_object)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 		status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 		goto unlock_and_exit2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	status = acpi_ns_walk_namespace(type, start_object, max_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 					ACPI_NS_WALK_UNLOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 					descending_callback, ascending_callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 					context, return_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) unlock_and_exit2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	(void)acpi_ut_release_read_lock(&acpi_gbl_namespace_rw_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) ACPI_EXPORT_SYMBOL(acpi_walk_namespace)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)  * FUNCTION:    acpi_ns_get_device_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)  * PARAMETERS:  Callback from acpi_get_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)  * DESCRIPTION: Takes callbacks from walk_namespace and filters out all non-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)  *              present devices, or if they specified a HID, it filters based
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)  *              on that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) acpi_ns_get_device_callback(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 			    u32 nesting_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 			    void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 	struct acpi_get_devices_info *info = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	struct acpi_pnp_device_id *hid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	struct acpi_pnp_device_id_list *cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	u8 found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	int no_match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	node = acpi_ns_validate_handle(obj_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	 * First, filter based on the device HID and CID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 	 * 01/2010: For this case where a specific HID is requested, we don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	 * want to run _STA until we have an actual HID match. Thus, we will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 	 * not unnecessarily execute _STA on devices for which the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	 * doesn't care about. Previously, _STA was executed unconditionally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	 * on all devices found here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	 * A side-effect of this change is that now we will continue to search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	 * for a matching HID even under device trees where the parent device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 	 * would have returned a _STA that indicates it is not present or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	 * not functioning (thus aborting the search on that branch).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	if (info->hid != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		status = acpi_ut_execute_HID(node, &hid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		if (status == AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 			return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 		} else if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 			return (AE_CTRL_DEPTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 		no_match = strcmp(hid->string, info->hid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 		ACPI_FREE(hid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 		if (no_match) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 			 * HID does not match, attempt match within the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 			 * list of Compatible IDs (CIDs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 			status = acpi_ut_execute_CID(node, &cid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 			if (status == AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 				return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 			} else if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 				return (AE_CTRL_DEPTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 			/* Walk the CID list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 			found = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 			for (i = 0; i < cid->count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 				if (strcmp(cid->ids[i].string, info->hid) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 					/* Found a matching CID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 					found = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 			ACPI_FREE(cid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 			if (!found) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 				return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	/* Run _STA to determine if device is present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 	status = acpi_ut_execute_STA(node, &flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 		return (AE_CTRL_DEPTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 	if (!(flags & ACPI_STA_DEVICE_PRESENT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 	    !(flags & ACPI_STA_DEVICE_FUNCTIONING)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 		 * Don't examine the children of the device only when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 		 * device is neither present nor functional. See ACPI spec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 		 * description of _STA for more information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 		return (AE_CTRL_DEPTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	/* We have a valid device, invoke the user function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	status = info->user_function(obj_handle, nesting_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 				     info->context, return_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)  * FUNCTION:    acpi_get_devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749)  * PARAMETERS:  HID                 - HID to search for. Can be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)  *              user_function       - Called when a matching object is found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)  *              context             - Passed to user function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)  *              return_value        - Location where return value of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)  *                                    user_function is put if terminated early
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)  * RETURNS      Return value from the user_function if terminated early.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)  *              Otherwise, returns NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)  * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)  *              starting (and ending) at the object specified by start_handle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)  *              The user_function is called whenever an object of type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761)  *              Device is found. If the user function returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)  *              a non-zero value, the search is terminated immediately and this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763)  *              value is returned to the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)  *              This is a wrapper for walk_namespace, but the callback performs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766)  *              additional filtering. Please see acpi_ns_get_device_callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) acpi_get_devices(const char *HID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 		 acpi_walk_callback user_function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 		 void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 	struct acpi_get_devices_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) 	ACPI_FUNCTION_TRACE(acpi_get_devices);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 	if (!user_function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 	 * We're going to call their callback from OUR callback, so we need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 	 * to know what it is, and their context parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 	info.hid = HID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 	info.context = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 	info.user_function = user_function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 	 * Lock the namespace around the walk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 	 * The namespace will be unlocked/locked around each call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 	 * to the user function - since this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 	 * must be allowed to make Acpi calls itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 	status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 					ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 					acpi_ns_get_device_callback, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) 					&info, return_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) ACPI_EXPORT_SYMBOL(acpi_get_devices)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)  * FUNCTION:    acpi_attach_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)  * PARAMETERS:  obj_handle          - Namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)  *              handler             - Handler for this attachment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)  *              data                - Pointer to data to be attached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)  * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) acpi_attach_data(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) 		 acpi_object_handler handler, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) 	if (!obj_handle || !handler || !data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) 	/* Convert and validate the handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) 	node = acpi_ns_validate_handle(obj_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) 		status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) 		goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) 	status = acpi_ns_attach_data(node, handler, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) ACPI_EXPORT_SYMBOL(acpi_attach_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)  * FUNCTION:    acpi_detach_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868)  * PARAMETERS:  obj_handle          - Namespace node handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)  *              handler             - Handler used in call to acpi_attach_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873)  * DESCRIPTION: Remove data that was previously attached to a node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) 	if (!obj_handle || !handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) 	/* Convert and validate the handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) 	node = acpi_ns_validate_handle(obj_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) 		status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) 		goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) 	status = acpi_ns_detach_data(node, handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) ACPI_EXPORT_SYMBOL(acpi_detach_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912)  * FUNCTION:    acpi_get_data_full
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914)  * PARAMETERS:  obj_handle          - Namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915)  *              handler             - Handler used in call to attach_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916)  *              data                - Where the data is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917)  *              callback            - function to execute before returning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921)  * DESCRIPTION: Retrieve data that was previously attached to a namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922)  *              and execute a callback before returning.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) acpi_get_data_full(acpi_handle obj_handle, acpi_object_handler handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) 		   void **data, void (*callback)(void *))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) 	/* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) 	if (!obj_handle || !handler || !data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) 	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) 	/* Convert and validate the handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) 	node = acpi_ns_validate_handle(obj_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) 		status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) 		goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) 	status = acpi_ns_get_attached_data(node, handler, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) 	if (ACPI_SUCCESS(status) && callback) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) 		callback(*data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) ACPI_EXPORT_SYMBOL(acpi_get_data_full)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)  * FUNCTION:    acpi_get_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967)  * PARAMETERS:  obj_handle          - Namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)  *              handler             - Handler used in call to attach_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969)  *              data                - Where the data is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973)  * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) 	return acpi_get_data_full(obj_handle, handler, data, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) ACPI_EXPORT_SYMBOL(acpi_get_data)