| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** | 
 | 2 |  * | 
 | 3 |  * Module Name: uteval - Object evaluation | 
 | 4 |  * | 
 | 5 |  *****************************************************************************/ | 
 | 6 |  | 
 | 7 | /* | 
| Bob Moore | b4e104e | 2011-01-17 11:05:40 +0800 | [diff] [blame] | 8 |  * Copyright (C) 2000 - 2011, Intel Corp. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 |  * All rights reserved. | 
 | 10 |  * | 
 | 11 |  * Redistribution and use in source and binary forms, with or without | 
 | 12 |  * modification, are permitted provided that the following conditions | 
 | 13 |  * are met: | 
 | 14 |  * 1. Redistributions of source code must retain the above copyright | 
 | 15 |  *    notice, this list of conditions, and the following disclaimer, | 
 | 16 |  *    without modification. | 
 | 17 |  * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 
 | 18 |  *    substantially similar to the "NO WARRANTY" disclaimer below | 
 | 19 |  *    ("Disclaimer") and any redistribution must be conditioned upon | 
 | 20 |  *    including a substantially similar Disclaimer requirement for further | 
 | 21 |  *    binary redistribution. | 
 | 22 |  * 3. Neither the names of the above-listed copyright holders nor the names | 
 | 23 |  *    of any contributors may be used to endorse or promote products derived | 
 | 24 |  *    from this software without specific prior written permission. | 
 | 25 |  * | 
 | 26 |  * Alternatively, this software may be distributed under the terms of the | 
 | 27 |  * GNU General Public License ("GPL") version 2 as published by the Free | 
 | 28 |  * Software Foundation. | 
 | 29 |  * | 
 | 30 |  * NO WARRANTY | 
 | 31 |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
 | 32 |  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
 | 33 |  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 
 | 34 |  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
 | 35 |  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
 | 36 |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
 | 37 |  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
 | 38 |  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 
 | 39 |  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 
 | 40 |  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
 | 41 |  * POSSIBILITY OF SUCH DAMAGES. | 
 | 42 |  */ | 
 | 43 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> | 
| Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" | 
 | 46 | #include "acnamesp.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define _COMPONENT          ACPI_UTILITIES | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("uteval") | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 |  | 
| Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 51 | /******************************************************************************* | 
 | 52 |  * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 |  * FUNCTION:    acpi_ut_evaluate_object | 
 | 54 |  * | 
 | 55 |  * PARAMETERS:  prefix_node         - Starting node | 
 | 56 |  *              Path                - Path to object from starting node | 
 | 57 |  *              expected_return_types - Bitmap of allowed return types | 
 | 58 |  *              return_desc         - Where a return value is stored | 
 | 59 |  * | 
 | 60 |  * RETURN:      Status | 
 | 61 |  * | 
 | 62 |  * DESCRIPTION: Evaluates a namespace object and verifies the type of the | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 63 |  *              return object. Common code that simplifies accessing objects | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 |  *              that have required return objects of fixed types. | 
 | 65 |  * | 
 | 66 |  *              NOTE: Internal function, no parameter validation | 
 | 67 |  * | 
 | 68 |  ******************************************************************************/ | 
 | 69 |  | 
 | 70 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 71 | acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, | 
 | 72 | 			char *path, | 
 | 73 | 			u32 expected_return_btypes, | 
 | 74 | 			union acpi_operand_object **return_desc) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | { | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 76 | 	struct acpi_evaluate_info *info; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 77 | 	acpi_status status; | 
 | 78 | 	u32 return_btype; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 80 | 	ACPI_FUNCTION_TRACE(ut_evaluate_object); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 82 | 	/* Allocate the evaluation information block */ | 
 | 83 |  | 
 | 84 | 	info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); | 
 | 85 | 	if (!info) { | 
 | 86 | 		return_ACPI_STATUS(AE_NO_MEMORY); | 
 | 87 | 	} | 
 | 88 |  | 
 | 89 | 	info->prefix_node = prefix_node; | 
 | 90 | 	info->pathname = path; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 |  | 
 | 92 | 	/* Evaluate the object/method */ | 
 | 93 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 94 | 	status = acpi_ns_evaluate(info); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 95 | 	if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | 		if (status == AE_NOT_FOUND) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 97 | 			ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
 | 98 | 					  "[%4.4s.%s] was not found\n", | 
 | 99 | 					  acpi_ut_get_node_name(prefix_node), | 
 | 100 | 					  path)); | 
 | 101 | 		} else { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 102 | 			ACPI_ERROR_METHOD("Method execution failed", | 
 | 103 | 					  prefix_node, path, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | 		} | 
 | 105 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 106 | 		goto cleanup; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | 	} | 
 | 108 |  | 
 | 109 | 	/* Did we get a return object? */ | 
 | 110 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 111 | 	if (!info->return_object) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | 		if (expected_return_btypes) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 113 | 			ACPI_ERROR_METHOD("No object was returned from", | 
 | 114 | 					  prefix_node, path, AE_NOT_EXIST); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 116 | 			status = AE_NOT_EXIST; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | 		} | 
 | 118 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 119 | 		goto cleanup; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | 	} | 
 | 121 |  | 
 | 122 | 	/* Map the return object type to the bitmapped type */ | 
 | 123 |  | 
| Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 124 | 	switch ((info->return_object)->common.type) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | 	case ACPI_TYPE_INTEGER: | 
 | 126 | 		return_btype = ACPI_BTYPE_INTEGER; | 
 | 127 | 		break; | 
 | 128 |  | 
 | 129 | 	case ACPI_TYPE_BUFFER: | 
 | 130 | 		return_btype = ACPI_BTYPE_BUFFER; | 
 | 131 | 		break; | 
 | 132 |  | 
 | 133 | 	case ACPI_TYPE_STRING: | 
 | 134 | 		return_btype = ACPI_BTYPE_STRING; | 
 | 135 | 		break; | 
 | 136 |  | 
 | 137 | 	case ACPI_TYPE_PACKAGE: | 
 | 138 | 		return_btype = ACPI_BTYPE_PACKAGE; | 
 | 139 | 		break; | 
 | 140 |  | 
 | 141 | 	default: | 
 | 142 | 		return_btype = 0; | 
 | 143 | 		break; | 
 | 144 | 	} | 
 | 145 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 146 | 	if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | 		/* | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 148 | 		 * We received a return object, but one was not expected. This can | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | 		 * happen frequently if the "implicit return" feature is enabled. | 
 | 150 | 		 * Just delete the return object and return AE_OK. | 
 | 151 | 		 */ | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 152 | 		acpi_ut_remove_reference(info->return_object); | 
 | 153 | 		goto cleanup; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | 	} | 
 | 155 |  | 
 | 156 | 	/* Is the return object one of the expected types? */ | 
 | 157 |  | 
 | 158 | 	if (!(expected_return_btypes & return_btype)) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 159 | 		ACPI_ERROR_METHOD("Return object type is incorrect", | 
 | 160 | 				  prefix_node, path, AE_TYPE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 |  | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 162 | 		ACPI_ERROR((AE_INFO, | 
| Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 163 | 			    "Type returned from %s was incorrect: %s, expected Btypes: 0x%X", | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 164 | 			    path, | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 165 | 			    acpi_ut_get_object_type_name(info->return_object), | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 166 | 			    expected_return_btypes)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 |  | 
 | 168 | 		/* On error exit, we must delete the return object */ | 
 | 169 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 170 | 		acpi_ut_remove_reference(info->return_object); | 
 | 171 | 		status = AE_TYPE; | 
 | 172 | 		goto cleanup; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | 	} | 
 | 174 |  | 
 | 175 | 	/* Object type is OK, return it */ | 
 | 176 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 177 | 	*return_desc = info->return_object; | 
 | 178 |  | 
 | 179 |       cleanup: | 
 | 180 | 	ACPI_FREE(info); | 
 | 181 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | } | 
 | 183 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | /******************************************************************************* | 
 | 185 |  * | 
 | 186 |  * FUNCTION:    acpi_ut_evaluate_numeric_object | 
 | 187 |  * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 188 |  * PARAMETERS:  object_name         - Object name to be evaluated | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 |  *              device_node         - Node for the device | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 190 |  *              Value               - Where the value is returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 |  * | 
 | 192 |  * RETURN:      Status | 
 | 193 |  * | 
 | 194 |  * DESCRIPTION: Evaluates a numeric namespace object for a selected device | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 195 |  *              and stores result in *Value. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 |  * | 
 | 197 |  *              NOTE: Internal function, no parameter validation | 
 | 198 |  * | 
 | 199 |  ******************************************************************************/ | 
 | 200 |  | 
 | 201 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 202 | acpi_ut_evaluate_numeric_object(char *object_name, | 
 | 203 | 				struct acpi_namespace_node *device_node, | 
| Bob Moore | 5df7e6c | 2010-01-21 10:06:32 +0800 | [diff] [blame] | 204 | 				u64 *value) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 206 | 	union acpi_operand_object *obj_desc; | 
 | 207 | 	acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 209 | 	ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 211 | 	status = acpi_ut_evaluate_object(device_node, object_name, | 
 | 212 | 					 ACPI_BTYPE_INTEGER, &obj_desc); | 
 | 213 | 	if (ACPI_FAILURE(status)) { | 
 | 214 | 		return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | 	} | 
 | 216 |  | 
 | 217 | 	/* Get the returned Integer */ | 
 | 218 |  | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 219 | 	*value = obj_desc->integer.value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 |  | 
 | 221 | 	/* On exit, we must delete the return object */ | 
 | 222 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 223 | 	acpi_ut_remove_reference(obj_desc); | 
 | 224 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } | 
 | 226 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | /******************************************************************************* | 
 | 228 |  * | 
 | 229 |  * FUNCTION:    acpi_ut_execute_STA | 
 | 230 |  * | 
 | 231 |  * PARAMETERS:  device_node         - Node for the device | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 232 |  *              Flags               - Where the status flags are returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 |  * | 
 | 234 |  * RETURN:      Status | 
 | 235 |  * | 
 | 236 |  * DESCRIPTION: Executes _STA for selected device and stores results in | 
 | 237 |  *              *Flags. | 
 | 238 |  * | 
 | 239 |  *              NOTE: Internal function, no parameter validation | 
 | 240 |  * | 
 | 241 |  ******************************************************************************/ | 
 | 242 |  | 
 | 243 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 244 | acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 246 | 	union acpi_operand_object *obj_desc; | 
 | 247 | 	acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 249 | 	ACPI_FUNCTION_TRACE(ut_execute_STA); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 251 | 	status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, | 
 | 252 | 					 ACPI_BTYPE_INTEGER, &obj_desc); | 
 | 253 | 	if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | 		if (AE_NOT_FOUND == status) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 255 | 			ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
 | 256 | 					  "_STA on %4.4s was not found, assuming device is present\n", | 
 | 257 | 					  acpi_ut_get_node_name(device_node))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 |  | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 259 | 			*flags = ACPI_UINT32_MAX; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | 			status = AE_OK; | 
 | 261 | 		} | 
 | 262 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 263 | 		return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | 	} | 
 | 265 |  | 
 | 266 | 	/* Extract the status flags */ | 
 | 267 |  | 
 | 268 | 	*flags = (u32) obj_desc->integer.value; | 
 | 269 |  | 
 | 270 | 	/* On exit, we must delete the return object */ | 
 | 271 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | 	acpi_ut_remove_reference(obj_desc); | 
 | 273 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | } | 
 | 275 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | /******************************************************************************* | 
 | 277 |  * | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 278 |  * FUNCTION:    acpi_ut_execute_power_methods | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 |  * | 
 | 280 |  * PARAMETERS:  device_node         - Node for the device | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 281 |  *              method_names        - Array of power method names | 
 | 282 |  *              method_count        - Number of methods to execute | 
 | 283 |  *              out_values          - Where the power method values are returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 |  * | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 285 |  * RETURN:      Status, out_values | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 |  * | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 287 |  * DESCRIPTION: Executes the specified power methods for the device and returns | 
 | 288 |  *              the result(s). | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 |  * | 
 | 290 |  *              NOTE: Internal function, no parameter validation | 
 | 291 |  * | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 292 | ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 |  | 
 | 294 | acpi_status | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 295 | acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node, | 
 | 296 | 			      const char **method_names, | 
 | 297 | 			      u8 method_count, u8 *out_values) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 299 | 	union acpi_operand_object *obj_desc; | 
 | 300 | 	acpi_status status; | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 301 | 	acpi_status final_status = AE_NOT_FOUND; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 302 | 	u32 i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 |  | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 304 | 	ACPI_FUNCTION_TRACE(ut_execute_power_methods); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 |  | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 306 | 	for (i = 0; i < method_count; i++) { | 
 | 307 | 		/* | 
 | 308 | 		 * Execute the power method (_sx_d or _sx_w). The only allowable | 
 | 309 | 		 * return type is an Integer. | 
 | 310 | 		 */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 311 | 		status = acpi_ut_evaluate_object(device_node, | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 312 | 						 ACPI_CAST_PTR(char, | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 313 | 							       method_names[i]), | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 314 | 						 ACPI_BTYPE_INTEGER, &obj_desc); | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 315 | 		if (ACPI_SUCCESS(status)) { | 
 | 316 | 			out_values[i] = (u8)obj_desc->integer.value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 |  | 
 | 318 | 			/* Delete the return object */ | 
 | 319 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 320 | 			acpi_ut_remove_reference(obj_desc); | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 321 | 			final_status = AE_OK;	/* At least one value is valid */ | 
 | 322 | 			continue; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | 		} | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 324 |  | 
 | 325 | 		out_values[i] = ACPI_UINT8_MAX; | 
 | 326 | 		if (status == AE_NOT_FOUND) { | 
 | 327 | 			continue;	/* Ignore if not found */ | 
 | 328 | 		} | 
 | 329 |  | 
 | 330 | 		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
 | 331 | 				  "Failed %s on Device %4.4s, %s\n", | 
 | 332 | 				  ACPI_CAST_PTR(char, method_names[i]), | 
 | 333 | 				  acpi_ut_get_node_name(device_node), | 
 | 334 | 				  acpi_format_exception(status))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | 	} | 
 | 336 |  | 
| Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 337 | 	return_ACPI_STATUS(final_status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | } |