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: exconvrt - Object conversion routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2000 - 2020, Intel Corp.
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define _COMPONENT          ACPI_EXECUTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) ACPI_MODULE_NAME("exconvrt")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
^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_ex_convert_to_integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * PARAMETERS:  obj_desc            - Object to be converted. Must be an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *                                    Integer, Buffer, or String
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *              result_desc         - Where the new Integer object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *              implicit_conversion - Used for string conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * DESCRIPTION: Convert an ACPI Object to an integer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			   union acpi_operand_object **result_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			   u32 implicit_conversion)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	union acpi_operand_object *return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	u8 *pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	u64 result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	ACPI_FUNCTION_TRACE_PTR(ex_convert_to_integer, obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	switch (obj_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		/* No conversion necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		*result_desc = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		/* Note: Takes advantage of common buffer/string fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		pointer = obj_desc->buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		count = obj_desc->buffer.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		return_ACPI_STATUS(AE_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	 * Convert the buffer/string to an integer. Note that both buffers and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	 * strings are treated as raw data - we don't convert ascii to hex for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	 * strings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	 * There are two terminating conditions for the loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	 * 1) The size of an integer has been reached, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	 * 2) The end of the buffer or string has been reached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	/* String conversion is different than Buffer conversion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	switch (obj_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		 * Convert string to an integer - for most cases, the string must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		 * hexadecimal as per the ACPI specification. The only exception (as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		 * of ACPI 3.0) is that the to_integer() operator allows both decimal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		 * and hexadecimal strings (hex prefixed with "0x").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		 * Explicit conversion is used only by to_integer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		 * All other string-to-integer conversions are implicit conversions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		if (implicit_conversion) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			result =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			    acpi_ut_implicit_strtoul64(ACPI_CAST_PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 						       (char, pointer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			result =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			    acpi_ut_explicit_strtoul64(ACPI_CAST_PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 						       (char, pointer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		/* Check for zero-length buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		if (!count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
^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) 		/* Transfer no more than an integer's worth of data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		if (count > acpi_gbl_integer_byte_width) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			count = acpi_gbl_integer_byte_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		 * Convert buffer to an integer - we simply grab enough raw data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		 * from the buffer to fill an integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			 * Get next byte and shift it into the Result.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			 * Little endian is used, meaning that the first byte of the buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			 * is the LSB of the integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			result |= (((u64) pointer[i]) << (i * 8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		/* No other types can get here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	/* Create a new integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	return_desc = acpi_ut_create_integer_object(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			  ACPI_FORMAT_UINT64(result)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	/* Save the Result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	(void)acpi_ex_truncate_for32bit_table(return_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	*result_desc = return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^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)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * FUNCTION:    acpi_ex_convert_to_buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * PARAMETERS:  obj_desc        - Object to be converted. Must be an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  *                                Integer, Buffer, or String
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  *              result_desc     - Where the new buffer object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * DESCRIPTION: Convert an ACPI Object to a Buffer
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 			  union acpi_operand_object **result_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	union acpi_operand_object *return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	u8 *new_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	ACPI_FUNCTION_TRACE_PTR(ex_convert_to_buffer, obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	switch (obj_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		/* No conversion necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		*result_desc = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		 * Create a new Buffer object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		 * Need enough space for one integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		return_desc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		    acpi_ut_create_buffer_object(acpi_gbl_integer_byte_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		/* Copy the integer to the buffer, LSB first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		new_buf = return_desc->buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		memcpy(new_buf, &obj_desc->integer.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		       acpi_gbl_integer_byte_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		 * Create a new Buffer object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		 * Size will be the string length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		 * NOTE: Add one to the string length to include the null terminator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		 * The ACPI spec is unclear on this subject, but there is existing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		 * ASL/AML code that depends on the null being transferred to the new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		 * buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		return_desc = acpi_ut_create_buffer_object((acpi_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 							   obj_desc->string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 							   length + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			return_ACPI_STATUS(AE_NO_MEMORY);
^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) 		/* Copy the string to the buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		new_buf = return_desc->buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		strncpy((char *)new_buf, (char *)obj_desc->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			obj_desc->string.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		return_ACPI_STATUS(AE_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	/* Mark buffer initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	return_desc->common.flags |= AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	*result_desc = return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	return_ACPI_STATUS(AE_OK);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  * FUNCTION:    acpi_ex_convert_to_ascii
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  * PARAMETERS:  integer         - Value to be converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)  *              base            - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  *              string          - Where the string is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  *              data_width      - Size of data item to be converted, in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  * RETURN:      Actual string length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	u64 digit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	u32 j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	u32 k = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	u32 hex_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	u32 decimal_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	u32 remainder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	u8 supress_zeros;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	switch (base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	case 10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		/* Setup max length for the decimal number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		switch (data_width) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			decimal_length = ACPI_MAX8_DECIMAL_DIGITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			decimal_length = ACPI_MAX32_DECIMAL_DIGITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		case 8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 			decimal_length = ACPI_MAX64_DECIMAL_DIGITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		supress_zeros = TRUE;	/* No leading zeros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		remainder = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		for (i = decimal_length; i > 0; i--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 			/* Divide by nth factor of 10 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 			digit = integer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 			for (j = 0; j < i; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 				(void)acpi_ut_short_divide(digit, 10, &digit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 							   &remainder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 			/* Handle leading zeros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			if (remainder != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 				supress_zeros = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 			if (!supress_zeros) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 				string[k] = (u8) (ACPI_ASCII_ZERO + remainder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 				k++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	case 16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		/* hex_length: 2 ascii hex chars per data byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		hex_length = (data_width * 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 			/* Get one hex digit, most significant digits first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 			string[k] = (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			    acpi_ut_hex_to_ascii_char(integer, ACPI_MUL_4(j));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 			k++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		return (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	 * Since leading zeros are suppressed, we must check for the case where
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	 * the integer equals 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	 * Finally, null terminate the string and return the length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	if (!k) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		string[0] = ACPI_ASCII_ZERO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		k = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	string[k] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	return ((u32) k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^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)  * FUNCTION:    acpi_ex_convert_to_string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  * PARAMETERS:  obj_desc        - Object to be converted. Must be an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)  *                                Integer, Buffer, or String
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  *              result_desc     - Where the string object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  *              type            - String flags (base and conversion type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)  * DESCRIPTION: Convert an ACPI Object to a string. Supports both implicit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)  *              and explicit conversions and related rules.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 			  union acpi_operand_object ** result_desc, u32 type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	union acpi_operand_object *return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	u8 *new_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	u32 string_length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	u16 base = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	u8 separator = ',';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	ACPI_FUNCTION_TRACE_PTR(ex_convert_to_string, obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	switch (obj_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		/* No conversion necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		*result_desc = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		case ACPI_EXPLICIT_CONVERT_DECIMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 			 * From to_decimal_string, integer source.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 			 * Make room for the maximum decimal number size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 			string_length = ACPI_MAX_DECIMAL_DIGITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 			base = 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 			/* Two hex string characters for each integer byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 			string_length = ACPI_MUL_2(acpi_gbl_integer_byte_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		 * Create a new String
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		 * Need enough space for one ASCII integer (plus null terminator)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		return_desc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		    acpi_ut_create_string_object((acpi_size)string_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 			return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 		new_buf = return_desc->buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		/* Convert integer to string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		string_length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		    acpi_ex_convert_to_ascii(obj_desc->integer.value, base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 					     new_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 					     acpi_gbl_integer_byte_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		/* Null terminate at the correct place */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		return_desc->string.length = string_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		new_buf[string_length] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		/* Setup string length, base, and separator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		case ACPI_EXPLICIT_CONVERT_DECIMAL:	/* Used by to_decimal_string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			 * Explicit conversion from the to_decimal_string ASL operator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 			 * From ACPI: "If the input is a buffer, it is converted to a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			 * a string of decimal values separated by commas."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 			base = 10;
^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) 			 * Calculate the final string length. Individual string values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 			 * are variable length (include separator for each)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			for (i = 0; i < obj_desc->buffer.length; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 				if (obj_desc->buffer.pointer[i] >= 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 					string_length += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 				} else if (obj_desc->buffer.pointer[i] >= 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 					string_length += 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 				} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 					string_length += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 		case ACPI_IMPLICIT_CONVERT_HEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 			 * Implicit buffer-to-string conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 			 * From the ACPI spec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 			 * "The entire contents of the buffer are converted to a string of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 			 * two-character hexadecimal numbers, each separated by a space."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 			 * Each hex number is prefixed with 0x (11/2018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 			separator = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 			string_length = (obj_desc->buffer.length * 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 		case ACPI_EXPLICIT_CONVERT_HEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 			 * Explicit conversion from the to_hex_string ASL operator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 			 * From ACPI: "If Data is a buffer, it is converted to a string of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 			 * hexadecimal values separated by commas."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 			 * Each hex number is prefixed with 0x (11/2018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 			separator = ',';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 			string_length = (obj_desc->buffer.length * 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 			return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		 * Create a new string object and string buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		 * (-1 because of extra separator included in string_length from above)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		 * Allow creation of zero-length strings from zero-length buffers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		if (string_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 			string_length--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		return_desc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		    acpi_ut_create_string_object((acpi_size)string_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 			return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		new_buf = return_desc->buffer.pointer;
^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) 		 * Convert buffer bytes to hex or decimal values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 		 * (separated by commas or spaces)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		for (i = 0; i < obj_desc->buffer.length; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 			if (base == 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 				/* Emit 0x prefix for explicit/implicit hex conversion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 				*new_buf++ = '0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 				*new_buf++ = 'x';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 			new_buf += acpi_ex_convert_to_ascii((u64) obj_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 							    buffer.pointer[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 							    base, new_buf, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 			/* Each digit is separated by either a comma or space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 			*new_buf++ = separator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 		 * Null terminate the string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 		 * (overwrites final comma/space from above)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 		if (obj_desc->buffer.length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 			new_buf--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 		*new_buf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		return_ACPI_STATUS(AE_TYPE);
^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) 	*result_desc = return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)  * FUNCTION:    acpi_ex_convert_to_target_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)  * PARAMETERS:  destination_type    - Current type of the destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)  *              source_desc         - Source object to be converted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)  *              result_desc         - Where the converted object is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)  *              walk_state          - Current method state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)  * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)  *
^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) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) acpi_ex_convert_to_target_type(acpi_object_type destination_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 			       union acpi_operand_object *source_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 			       union acpi_operand_object **result_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 			       struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	ACPI_FUNCTION_TRACE(ex_convert_to_target_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	/* Default behavior */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	*result_desc = source_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	 * If required by the target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	 * perform implicit conversion on the source before we store it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	switch (GET_CURRENT_ARG_TYPE(walk_state->op_info->runtime_args)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	case ARGI_SIMPLE_TARGET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	case ARGI_FIXED_TARGET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	case ARGI_INTEGER_REF:	/* Handles Increment, Decrement cases */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 		switch (destination_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		case ACPI_TYPE_LOCAL_REGION_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 			 * Named field can always handle conversions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 			/* No conversion allowed for these types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 			if (destination_type != source_desc->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 				ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 						  "Explicit operator, will store (%s) over existing type (%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 						  acpi_ut_get_object_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 						  (source_desc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 						  acpi_ut_get_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 						  (destination_type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 				status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	case ARGI_TARGETREF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	case ARGI_STORE_TARGET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 		switch (destination_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 		case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 		case ACPI_TYPE_BUFFER_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		case ACPI_TYPE_LOCAL_BANK_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 		case ACPI_TYPE_LOCAL_INDEX_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 			 * These types require an Integer operand. We can convert
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 			 * a Buffer or a String to an Integer if necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 			    acpi_ex_convert_to_integer(source_desc, result_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 						       ACPI_IMPLICIT_CONVERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 		case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 			 * The operand must be a String. We can convert an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 			 * Integer or Buffer if necessary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 			    acpi_ex_convert_to_string(source_desc, result_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 						      ACPI_IMPLICIT_CONVERT_HEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 		case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 			 * The operand must be a Buffer. We can convert an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 			 * Integer or String if necessary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 			    acpi_ex_convert_to_buffer(source_desc, result_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 			ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 				    "Bad destination type during conversion: 0x%X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 				    destination_type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 			status = AE_AML_INTERNAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	case ARGI_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 		 * create_xxxx_field cases - we are storing the field object into the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 			    "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 			    GET_CURRENT_ARG_TYPE(walk_state->op_info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 						 runtime_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 			    walk_state->opcode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 			    acpi_ut_get_type_name(destination_type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 		status = AE_AML_INTERNAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	 * Source-to-Target conversion semantics:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 	 * If conversion to the target type cannot be performed, then simply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 	 * overwrite the target with the new object and type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 	if (status == AE_TYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 		status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) }