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: nsnames - Name manipulation and search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^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) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define _COMPONENT          ACPI_NAMESPACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) ACPI_MODULE_NAME("nsnames")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * FUNCTION:    acpi_ns_get_external_pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * PARAMETERS:  node            - Namespace node whose pathname is needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * RETURN:      Pointer to storage containing the fully qualified name of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *              the node, In external format (name segments separated by path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *              separators.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *              for error and debug statements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	char *name_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	ACPI_FUNCTION_TRACE_PTR(ns_get_external_pathname, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	name_buffer = acpi_ns_get_normalized_pathname(node, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	return_PTR(name_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^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)  * FUNCTION:    acpi_ns_get_pathname_length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * PARAMETERS:  node        - Namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * RETURN:      Length of path, including prefix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * DESCRIPTION: Get the length of the pathname string for this node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	acpi_size size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	/* Validate the Node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			    "Invalid/cached reference target node: %p, descriptor type %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			    node, ACPI_GET_DESCRIPTOR_TYPE(node)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		return (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	size = acpi_ns_build_normalized_path(node, NULL, 0, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	return (size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * FUNCTION:    acpi_ns_handle_to_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * PARAMETERS:  target_handle           - Handle of named object whose name is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *                                        to be found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *              buffer                  - Where the name is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * RETURN:      Status, Buffer is filled with name if status is AE_OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * DESCRIPTION: Build and return a full namespace name
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) acpi_ns_handle_to_name(acpi_handle target_handle, struct acpi_buffer *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	const char *node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	ACPI_FUNCTION_TRACE_PTR(ns_handle_to_name, target_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	node = acpi_ns_validate_handle(target_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/* Validate/Allocate/Clear caller buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	/* Just copy the ACPI name from the Node and zero terminate it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	node_name = acpi_ut_get_node_name(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	ACPI_COPY_NAMESEG(buffer->pointer, node_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	((char *)buffer->pointer)[ACPI_NAMESEG_SIZE] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%4.4s\n", (char *)buffer->pointer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * FUNCTION:    acpi_ns_handle_to_pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * PARAMETERS:  target_handle           - Handle of named object whose name is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  *                                        to be found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  *              buffer                  - Where the pathname is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  *              no_trailing             - Remove trailing '_' for each name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *                                        segment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * RETURN:      Status, Buffer is filled with pathname if status is AE_OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * DESCRIPTION: Build and return a full namespace pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) acpi_ns_handle_to_pathname(acpi_handle target_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			   struct acpi_buffer *buffer, u8 no_trailing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	acpi_size required_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	node = acpi_ns_validate_handle(target_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^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) 	/* Determine size required for the caller buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	required_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	    acpi_ns_build_normalized_path(node, NULL, 0, no_trailing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (!required_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	/* Validate/Allocate/Clear caller buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	status = acpi_ut_initialize_buffer(buffer, required_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	/* Build the path in the caller buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	(void)acpi_ns_build_normalized_path(node, buffer->pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 					    (u32)required_size, no_trailing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			  (char *)buffer->pointer, (u32) required_size));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * FUNCTION:    acpi_ns_build_normalized_path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * PARAMETERS:  node        - Namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *              full_path   - Where the path name is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  *              path_size   - Size of returned path name buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  *              no_trailing - Remove trailing '_' from each name segment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * RETURN:      Return 1 if the AML path is empty, otherwise returning (length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  *              of pathname + 1) which means the 'FullPath' contains a trailing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  *              null.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * DESCRIPTION: Build and return a full namespace pathname.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *              Note that if the size of 'FullPath' isn't large enough to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *              contain the namespace node's path name, the actual required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  *              buffer length is returned, and it should be greater than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *              'PathSize'. So callers are able to check the returning value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *              to determine the buffer size of 'FullPath'.
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) acpi_ns_build_normalized_path(struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			      char *full_path, u32 path_size, u8 no_trailing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	u32 length = 0, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	char name[ACPI_NAMESEG_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	u8 do_no_trailing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	char c, *left, *right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	struct acpi_namespace_node *next_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	ACPI_FUNCTION_TRACE_PTR(ns_build_normalized_path, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #define ACPI_PATH_PUT8(path, size, byte, length)    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	do {                                            \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		if ((length) < (size))                      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		{                                           \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			(path)[(length)] = (byte);              \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		}                                           \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		(length)++;                                 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	 * Make sure the path_size is correct, so that we don't need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	 * validate both full_path and path_size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (!full_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		path_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		goto build_trailing_null;
^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) 	next_node = node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	while (next_node && next_node != acpi_gbl_root_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		if (next_node != node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			ACPI_PATH_PUT8(full_path, path_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 				       AML_DUAL_NAME_PREFIX, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		ACPI_MOVE_32_TO_32(name, &next_node->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		do_no_trailing = no_trailing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			c = name[4 - i - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			if (do_no_trailing && c != '_') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 				do_no_trailing = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			if (!do_no_trailing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 				ACPI_PATH_PUT8(full_path, path_size, c, length);
^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) 		next_node = next_node->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	ACPI_PATH_PUT8(full_path, path_size, AML_ROOT_PREFIX, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	/* Reverse the path string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	if (length <= path_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		left = full_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		right = full_path + length - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		while (left < right) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			c = *left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			*left++ = *right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			*right-- = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	/* Append the trailing null */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) build_trailing_null:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	ACPI_PATH_PUT8(full_path, path_size, '\0', length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) #undef ACPI_PATH_PUT8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	return_UINT32(length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^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)  * FUNCTION:    acpi_ns_get_normalized_pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  * PARAMETERS:  node            - Namespace node whose pathname is needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  *              no_trailing     - Remove trailing '_' from each name segment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * RETURN:      Pointer to storage containing the fully qualified name of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  *              the node, In external format (name segments separated by path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  *              separators.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  *              for error and debug statements. All trailing '_' will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)  *              removed from the full pathname if 'NoTrailing' is specified..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 				      u8 no_trailing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	char *name_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	acpi_size size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	ACPI_FUNCTION_TRACE_PTR(ns_get_normalized_pathname, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	/* Calculate required buffer size based on depth below root */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	size = acpi_ns_build_normalized_path(node, NULL, 0, no_trailing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	if (!size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		return_PTR(NULL);
^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) 	/* Allocate a buffer to be returned to caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	name_buffer = ACPI_ALLOCATE_ZEROED(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	if (!name_buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		ACPI_ERROR((AE_INFO, "Could not allocate %u bytes", (u32)size));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		return_PTR(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	/* Build the path in the allocated buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	(void)acpi_ns_build_normalized_path(node, name_buffer, (u32)size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 					    no_trailing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES, "%s: Path \"%s\"\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			      ACPI_GET_FUNCTION_NAME, name_buffer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	return_PTR(name_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)  * FUNCTION:    acpi_ns_build_prefixed_pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  * PARAMETERS:  prefix_scope        - Scope/Path that prefixes the internal path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  *              internal_path       - Name or path of the namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  * DESCRIPTION: Construct a fully qualified pathname from a concatenation of:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  *              1) Path associated with the prefix_scope namespace node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  *              2) External path representation of the Internal path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) char *acpi_ns_build_prefixed_pathname(union acpi_generic_state *prefix_scope,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 				      const char *internal_path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	char *full_path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	char *external_path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	char *prefix_path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	acpi_size prefix_path_length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	/* If there is a prefix, get the pathname to it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	if (prefix_scope && prefix_scope->scope.node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		prefix_path =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		    acpi_ns_get_normalized_pathname(prefix_scope->scope.node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 						    TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		if (prefix_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 			prefix_path_length = strlen(prefix_path);
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	status = acpi_ns_externalize_name(ACPI_UINT32_MAX, internal_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 					  NULL, &external_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		goto cleanup;
^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) 	/* Merge the prefix path and the path. 2 is for one dot and trailing null */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	full_path =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	    ACPI_ALLOCATE_ZEROED(prefix_path_length + strlen(external_path) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 				 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	if (!full_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	/* Don't merge if the External path is already fully qualified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	if (prefix_path && (*external_path != '\\') && (*external_path != '^')) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		strcat(full_path, prefix_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		if (prefix_path[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 			strcat(full_path, ".");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	acpi_ns_normalize_pathname(external_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	strcat(full_path, external_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	if (prefix_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		ACPI_FREE(prefix_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	if (external_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		ACPI_FREE(external_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	return (full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)  * FUNCTION:    acpi_ns_normalize_pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)  * PARAMETERS:  original_path       - Path to be normalized, in External format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)  * RETURN:      The original path is processed in-place
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  * DESCRIPTION: Remove trailing underscores from each element of a path.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  *              For example:  \A___.B___.C___ becomes \A.B.C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) void acpi_ns_normalize_pathname(char *original_path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	char *input_path = original_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	char *new_path_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	char *new_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	/* Allocate a temp buffer in which to construct the new path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	new_path_buffer = ACPI_ALLOCATE_ZEROED(strlen(input_path) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	new_path = new_path_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	if (!new_path_buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	/* Special characters may appear at the beginning of the path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	if (*input_path == '\\') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		*new_path = *input_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		new_path++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 		input_path++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	while (*input_path == '^') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		*new_path = *input_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		new_path++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		input_path++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	/* Remainder of the path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	while (*input_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		/* Do one nameseg at a time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		for (i = 0; (i < ACPI_NAMESEG_SIZE) && *input_path; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			if ((i == 0) || (*input_path != '_')) {	/* First char is allowed to be underscore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 				*new_path = *input_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 				new_path++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 			input_path++;
^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) 		/* Dot means that there are more namesegs to come */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		if (*input_path == '.') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			*new_path = *input_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 			new_path++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 			input_path++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	*new_path = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	strcpy(original_path, new_path_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	ACPI_FREE(new_path_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }