diff options
Diffstat (limited to 'drivers/acpi/utils.c')
| -rw-r--r-- | drivers/acpi/utils.c | 104 |
1 files changed, 49 insertions, 55 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 6b516852ac12..1930e1a75b22 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
| @@ -58,31 +58,29 @@ acpi_extract_package(union acpi_object *package, | |||
| 58 | u8 *head = NULL; | 58 | u8 *head = NULL; |
| 59 | u8 *tail = NULL; | 59 | u8 *tail = NULL; |
| 60 | 60 | ||
| 61 | ACPI_FUNCTION_TRACE("acpi_extract_package"); | ||
| 62 | 61 | ||
| 63 | if (!package || (package->type != ACPI_TYPE_PACKAGE) | 62 | if (!package || (package->type != ACPI_TYPE_PACKAGE) |
| 64 | || (package->package.count < 1)) { | 63 | || (package->package.count < 1)) { |
| 65 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 64 | printk(KERN_WARNING PREFIX "Invalid package argument\n"); |
| 66 | "Invalid 'package' argument\n")); | 65 | return AE_BAD_PARAMETER; |
| 67 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 68 | } | 66 | } |
| 69 | 67 | ||
| 70 | if (!format || !format->pointer || (format->length < 1)) { | 68 | if (!format || !format->pointer || (format->length < 1)) { |
| 71 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); | 69 | printk(KERN_WARNING PREFIX "Invalid format argument\n"); |
| 72 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 70 | return AE_BAD_PARAMETER; |
| 73 | } | 71 | } |
| 74 | 72 | ||
| 75 | if (!buffer) { | 73 | if (!buffer) { |
| 76 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); | 74 | printk(KERN_WARNING PREFIX "Invalid buffer argument\n"); |
| 77 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 75 | return AE_BAD_PARAMETER; |
| 78 | } | 76 | } |
| 79 | 77 | ||
| 80 | format_count = (format->length / sizeof(char)) - 1; | 78 | format_count = (format->length / sizeof(char)) - 1; |
| 81 | if (format_count > package->package.count) { | 79 | if (format_count > package->package.count) { |
| 82 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 80 | printk(KERN_WARNING PREFIX "Format specifies more objects [%d]" |
| 83 | "Format specifies more objects [%d] than exist in package [%d].", | 81 | " than exist in package [%d].\n", |
| 84 | format_count, package->package.count)); | 82 | format_count, package->package.count); |
| 85 | return_ACPI_STATUS(AE_BAD_DATA); | 83 | return AE_BAD_DATA; |
| 86 | } | 84 | } |
| 87 | 85 | ||
| 88 | format_string = (char *)format->pointer; | 86 | format_string = (char *)format->pointer; |
| @@ -95,7 +93,7 @@ acpi_extract_package(union acpi_object *package, | |||
| 95 | union acpi_object *element = &(package->package.elements[i]); | 93 | union acpi_object *element = &(package->package.elements[i]); |
| 96 | 94 | ||
| 97 | if (!element) { | 95 | if (!element) { |
| 98 | return_ACPI_STATUS(AE_BAD_DATA); | 96 | return AE_BAD_DATA; |
| 99 | } | 97 | } |
| 100 | 98 | ||
| 101 | switch (element->type) { | 99 | switch (element->type) { |
| @@ -113,10 +111,11 @@ acpi_extract_package(union acpi_object *package, | |||
| 113 | tail_offset += sizeof(char *); | 111 | tail_offset += sizeof(char *); |
| 114 | break; | 112 | break; |
| 115 | default: | 113 | default: |
| 116 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 114 | printk(KERN_WARNING PREFIX "Invalid package element" |
| 117 | "Invalid package element [%d]: got number, expecing [%c].\n", | 115 | " [%d]: got number, expecing" |
| 118 | i, format_string[i])); | 116 | " [%c]\n", |
| 119 | return_ACPI_STATUS(AE_BAD_DATA); | 117 | i, format_string[i]); |
| 118 | return AE_BAD_DATA; | ||
| 120 | break; | 119 | break; |
| 121 | } | 120 | } |
| 122 | break; | 121 | break; |
| @@ -138,10 +137,11 @@ acpi_extract_package(union acpi_object *package, | |||
| 138 | tail_offset += sizeof(u8 *); | 137 | tail_offset += sizeof(u8 *); |
| 139 | break; | 138 | break; |
| 140 | default: | 139 | default: |
| 141 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, | 140 | printk(KERN_WARNING PREFIX "Invalid package element" |
| 142 | "Invalid package element [%d] got string/buffer, expecing [%c].\n", | 141 | " [%d] got string/buffer," |
| 143 | i, format_string[i])); | 142 | " expecing [%c]\n", |
| 144 | return_ACPI_STATUS(AE_BAD_DATA); | 143 | i, format_string[i]); |
| 144 | return AE_BAD_DATA; | ||
| 145 | break; | 145 | break; |
| 146 | } | 146 | } |
| 147 | break; | 147 | break; |
| @@ -152,7 +152,7 @@ acpi_extract_package(union acpi_object *package, | |||
| 152 | "Found unsupported element at index=%d\n", | 152 | "Found unsupported element at index=%d\n", |
| 153 | i)); | 153 | i)); |
| 154 | /* TBD: handle nested packages... */ | 154 | /* TBD: handle nested packages... */ |
| 155 | return_ACPI_STATUS(AE_SUPPORT); | 155 | return AE_SUPPORT; |
| 156 | break; | 156 | break; |
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| @@ -162,9 +162,9 @@ acpi_extract_package(union acpi_object *package, | |||
| 162 | */ | 162 | */ |
| 163 | if (buffer->length < size_required) { | 163 | if (buffer->length < size_required) { |
| 164 | buffer->length = size_required; | 164 | buffer->length = size_required; |
| 165 | return_ACPI_STATUS(AE_BUFFER_OVERFLOW); | 165 | return AE_BUFFER_OVERFLOW; |
| 166 | } else if (buffer->length != size_required || !buffer->pointer) { | 166 | } else if (buffer->length != size_required || !buffer->pointer) { |
| 167 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 167 | return AE_BAD_PARAMETER; |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | head = buffer->pointer; | 170 | head = buffer->pointer; |
| @@ -179,7 +179,7 @@ acpi_extract_package(union acpi_object *package, | |||
| 179 | union acpi_object *element = &(package->package.elements[i]); | 179 | union acpi_object *element = &(package->package.elements[i]); |
| 180 | 180 | ||
| 181 | if (!element) { | 181 | if (!element) { |
| 182 | return_ACPI_STATUS(AE_BAD_DATA); | 182 | return AE_BAD_DATA; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | switch (element->type) { | 185 | switch (element->type) { |
| @@ -244,7 +244,7 @@ acpi_extract_package(union acpi_object *package, | |||
| 244 | } | 244 | } |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | return_ACPI_STATUS(AE_OK); | 247 | return AE_OK; |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | EXPORT_SYMBOL(acpi_extract_package); | 250 | EXPORT_SYMBOL(acpi_extract_package); |
| @@ -258,14 +258,13 @@ acpi_evaluate_integer(acpi_handle handle, | |||
| 258 | union acpi_object *element; | 258 | union acpi_object *element; |
| 259 | struct acpi_buffer buffer = { 0, NULL }; | 259 | struct acpi_buffer buffer = { 0, NULL }; |
| 260 | 260 | ||
| 261 | ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); | ||
| 262 | 261 | ||
| 263 | if (!data) | 262 | if (!data) |
| 264 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 263 | return AE_BAD_PARAMETER; |
| 265 | 264 | ||
| 266 | element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); | 265 | element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); |
| 267 | if (!element) | 266 | if (!element) |
| 268 | return_ACPI_STATUS(AE_NO_MEMORY); | 267 | return AE_NO_MEMORY; |
| 269 | 268 | ||
| 270 | memset(element, 0, sizeof(union acpi_object)); | 269 | memset(element, 0, sizeof(union acpi_object)); |
| 271 | buffer.length = sizeof(union acpi_object); | 270 | buffer.length = sizeof(union acpi_object); |
| @@ -274,13 +273,13 @@ acpi_evaluate_integer(acpi_handle handle, | |||
| 274 | if (ACPI_FAILURE(status)) { | 273 | if (ACPI_FAILURE(status)) { |
| 275 | acpi_util_eval_error(handle, pathname, status); | 274 | acpi_util_eval_error(handle, pathname, status); |
| 276 | kfree(element); | 275 | kfree(element); |
| 277 | return_ACPI_STATUS(status); | 276 | return status; |
| 278 | } | 277 | } |
| 279 | 278 | ||
| 280 | if (element->type != ACPI_TYPE_INTEGER) { | 279 | if (element->type != ACPI_TYPE_INTEGER) { |
| 281 | acpi_util_eval_error(handle, pathname, AE_BAD_DATA); | 280 | acpi_util_eval_error(handle, pathname, AE_BAD_DATA); |
| 282 | kfree(element); | 281 | kfree(element); |
| 283 | return_ACPI_STATUS(AE_BAD_DATA); | 282 | return AE_BAD_DATA; |
| 284 | } | 283 | } |
| 285 | 284 | ||
| 286 | *data = element->integer.value; | 285 | *data = element->integer.value; |
| @@ -288,7 +287,7 @@ acpi_evaluate_integer(acpi_handle handle, | |||
| 288 | 287 | ||
| 289 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); | 288 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); |
| 290 | 289 | ||
| 291 | return_ACPI_STATUS(AE_OK); | 290 | return AE_OK; |
| 292 | } | 291 | } |
| 293 | 292 | ||
| 294 | EXPORT_SYMBOL(acpi_evaluate_integer); | 293 | EXPORT_SYMBOL(acpi_evaluate_integer); |
| @@ -303,15 +302,14 @@ acpi_evaluate_string(acpi_handle handle, | |||
| 303 | acpi_object *element = NULL; | 302 | acpi_object *element = NULL; |
| 304 | acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 303 | acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 305 | 304 | ||
| 306 | ACPI_FUNCTION_TRACE("acpi_evaluate_string"); | ||
| 307 | 305 | ||
| 308 | if (!data) | 306 | if (!data) |
| 309 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 307 | return AE_BAD_PARAMETER; |
| 310 | 308 | ||
| 311 | status = acpi_evaluate_object(handle, pathname, arguments, &buffer); | 309 | status = acpi_evaluate_object(handle, pathname, arguments, &buffer); |
| 312 | if (ACPI_FAILURE(status)) { | 310 | if (ACPI_FAILURE(status)) { |
| 313 | acpi_util_eval_error(handle, pathname, status); | 311 | acpi_util_eval_error(handle, pathname, status); |
| 314 | return_ACPI_STATUS(status); | 312 | return status; |
| 315 | } | 313 | } |
| 316 | 314 | ||
| 317 | element = (acpi_object *) buffer.pointer; | 315 | element = (acpi_object *) buffer.pointer; |
| @@ -320,13 +318,13 @@ acpi_evaluate_string(acpi_handle handle, | |||
| 320 | || (element->type != ACPI_TYPE_BUFFER) | 318 | || (element->type != ACPI_TYPE_BUFFER) |
| 321 | || !element->string.length) { | 319 | || !element->string.length) { |
| 322 | acpi_util_eval_error(handle, pathname, AE_BAD_DATA); | 320 | acpi_util_eval_error(handle, pathname, AE_BAD_DATA); |
| 323 | return_ACPI_STATUS(AE_BAD_DATA); | 321 | return AE_BAD_DATA; |
| 324 | } | 322 | } |
| 325 | 323 | ||
| 326 | *data = kmalloc(element->string.length + 1, GFP_KERNEL); | 324 | *data = kmalloc(element->string.length + 1, GFP_KERNEL); |
| 327 | if (!data) { | 325 | if (!data) { |
| 328 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); | 326 | printk(KERN_ERR PREFIX "Memory allocation\n"); |
| 329 | return_VALUE(-ENOMEM); | 327 | return -ENOMEM; |
| 330 | } | 328 | } |
| 331 | memset(*data, 0, element->string.length + 1); | 329 | memset(*data, 0, element->string.length + 1); |
| 332 | 330 | ||
| @@ -336,7 +334,7 @@ acpi_evaluate_string(acpi_handle handle, | |||
| 336 | 334 | ||
| 337 | acpi_os_free(buffer.pointer); | 335 | acpi_os_free(buffer.pointer); |
| 338 | 336 | ||
| 339 | return_ACPI_STATUS(AE_OK); | 337 | return AE_OK; |
| 340 | } | 338 | } |
| 341 | #endif | 339 | #endif |
| 342 | 340 | ||
| @@ -352,10 +350,9 @@ acpi_evaluate_reference(acpi_handle handle, | |||
| 352 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 350 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 353 | u32 i = 0; | 351 | u32 i = 0; |
| 354 | 352 | ||
| 355 | ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); | ||
| 356 | 353 | ||
| 357 | if (!list) { | 354 | if (!list) { |
| 358 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 355 | return AE_BAD_PARAMETER; |
| 359 | } | 356 | } |
| 360 | 357 | ||
| 361 | /* Evaluate object. */ | 358 | /* Evaluate object. */ |
| @@ -367,32 +364,29 @@ acpi_evaluate_reference(acpi_handle handle, | |||
| 367 | package = (union acpi_object *)buffer.pointer; | 364 | package = (union acpi_object *)buffer.pointer; |
| 368 | 365 | ||
| 369 | if ((buffer.length == 0) || !package) { | 366 | if ((buffer.length == 0) || !package) { |
| 370 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 367 | printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n", |
| 371 | "No return object (len %X ptr %p)\n", | 368 | (unsigned)buffer.length, package); |
| 372 | (unsigned)buffer.length, package)); | ||
| 373 | status = AE_BAD_DATA; | 369 | status = AE_BAD_DATA; |
| 374 | acpi_util_eval_error(handle, pathname, status); | 370 | acpi_util_eval_error(handle, pathname, status); |
| 375 | goto end; | 371 | goto end; |
| 376 | } | 372 | } |
| 377 | if (package->type != ACPI_TYPE_PACKAGE) { | 373 | if (package->type != ACPI_TYPE_PACKAGE) { |
| 378 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 374 | printk(KERN_ERR PREFIX "Expecting a [Package], found type %X\n", |
| 379 | "Expecting a [Package], found type %X\n", | 375 | package->type); |
| 380 | package->type)); | ||
| 381 | status = AE_BAD_DATA; | 376 | status = AE_BAD_DATA; |
| 382 | acpi_util_eval_error(handle, pathname, status); | 377 | acpi_util_eval_error(handle, pathname, status); |
| 383 | goto end; | 378 | goto end; |
| 384 | } | 379 | } |
| 385 | if (!package->package.count) { | 380 | if (!package->package.count) { |
| 386 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 381 | printk(KERN_ERR PREFIX "[Package] has zero elements (%p)\n", |
| 387 | "[Package] has zero elements (%p)\n", | 382 | package); |
| 388 | package)); | ||
| 389 | status = AE_BAD_DATA; | 383 | status = AE_BAD_DATA; |
| 390 | acpi_util_eval_error(handle, pathname, status); | 384 | acpi_util_eval_error(handle, pathname, status); |
| 391 | goto end; | 385 | goto end; |
| 392 | } | 386 | } |
| 393 | 387 | ||
| 394 | if (package->package.count > ACPI_MAX_HANDLES) { | 388 | if (package->package.count > ACPI_MAX_HANDLES) { |
| 395 | return_ACPI_STATUS(AE_NO_MEMORY); | 389 | return AE_NO_MEMORY; |
| 396 | } | 390 | } |
| 397 | list->count = package->package.count; | 391 | list->count = package->package.count; |
| 398 | 392 | ||
| @@ -404,9 +398,9 @@ acpi_evaluate_reference(acpi_handle handle, | |||
| 404 | 398 | ||
| 405 | if (element->type != ACPI_TYPE_ANY) { | 399 | if (element->type != ACPI_TYPE_ANY) { |
| 406 | status = AE_BAD_DATA; | 400 | status = AE_BAD_DATA; |
| 407 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 401 | printk(KERN_ERR PREFIX |
| 408 | "Expecting a [Reference] package element, found type %X\n", | 402 | "Expecting a [Reference] package element, found type %X\n", |
| 409 | element->type)); | 403 | element->type); |
| 410 | acpi_util_eval_error(handle, pathname, status); | 404 | acpi_util_eval_error(handle, pathname, status); |
| 411 | break; | 405 | break; |
| 412 | } | 406 | } |
| @@ -426,7 +420,7 @@ acpi_evaluate_reference(acpi_handle handle, | |||
| 426 | 420 | ||
| 427 | acpi_os_free(buffer.pointer); | 421 | acpi_os_free(buffer.pointer); |
| 428 | 422 | ||
| 429 | return_ACPI_STATUS(status); | 423 | return status; |
| 430 | } | 424 | } |
| 431 | 425 | ||
| 432 | EXPORT_SYMBOL(acpi_evaluate_reference); | 426 | EXPORT_SYMBOL(acpi_evaluate_reference); |
