diff options
author | Bob Moore <robert.moore@intel.com> | 2016-05-05 00:58:00 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-05-05 09:22:25 -0400 |
commit | 7dbec55350cea5fff97162ed2663741a48893f6f (patch) | |
tree | 7275fc44d8ddbb2684601e72d8061ab3bd02d9f6 | |
parent | f5c1e1c5a652e4b43eb9b571577ef72731f3fa8b (diff) |
ACPICA: Refactor evaluate_object to reduce nesting
ACPICA commit 599e9159f53565e4a3f3e67f6a03f81fcb10a4cf
Original patch from hanjun.guo@linaro.org
ACPICA BZ 1072.
Link: https://github.com/acpica/acpica/commit/599e9159
Link: https://bugs.acpica.org/show_bug.cgi?id=1072
Original-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/acpica/nsxfeval.c | 111 |
1 files changed, 55 insertions, 56 deletions
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index 614e4baacaf4..d2a9b4fd739f 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c | |||
@@ -280,13 +280,12 @@ acpi_evaluate_object(acpi_handle handle, | |||
280 | info->parameters[info->param_count] = NULL; | 280 | info->parameters[info->param_count] = NULL; |
281 | } | 281 | } |
282 | 282 | ||
283 | #if 0 | 283 | #ifdef _FUTURE_FEATURE |
284 | 284 | ||
285 | /* | 285 | /* |
286 | * Begin incoming argument count analysis. Check for too few args | 286 | * Begin incoming argument count analysis. Check for too few args |
287 | * and too many args. | 287 | * and too many args. |
288 | */ | 288 | */ |
289 | |||
290 | switch (acpi_ns_get_type(info->node)) { | 289 | switch (acpi_ns_get_type(info->node)) { |
291 | case ACPI_TYPE_METHOD: | 290 | case ACPI_TYPE_METHOD: |
292 | 291 | ||
@@ -370,68 +369,68 @@ acpi_evaluate_object(acpi_handle handle, | |||
370 | * If we are expecting a return value, and all went well above, | 369 | * If we are expecting a return value, and all went well above, |
371 | * copy the return value to an external object. | 370 | * copy the return value to an external object. |
372 | */ | 371 | */ |
373 | if (return_buffer) { | 372 | if (!return_buffer) { |
374 | if (!info->return_object) { | 373 | goto cleanup_return_object; |
375 | return_buffer->length = 0; | 374 | } |
376 | } else { | ||
377 | if (ACPI_GET_DESCRIPTOR_TYPE(info->return_object) == | ||
378 | ACPI_DESC_TYPE_NAMED) { | ||
379 | /* | ||
380 | * If we received a NS Node as a return object, this means that | ||
381 | * the object we are evaluating has nothing interesting to | ||
382 | * return (such as a mutex, etc.) We return an error because | ||
383 | * these types are essentially unsupported by this interface. | ||
384 | * We don't check up front because this makes it easier to add | ||
385 | * support for various types at a later date if necessary. | ||
386 | */ | ||
387 | status = AE_TYPE; | ||
388 | info->return_object = NULL; /* No need to delete a NS Node */ | ||
389 | return_buffer->length = 0; | ||
390 | } | ||
391 | 375 | ||
392 | if (ACPI_SUCCESS(status)) { | 376 | if (!info->return_object) { |
377 | return_buffer->length = 0; | ||
378 | goto cleanup; | ||
379 | } | ||
393 | 380 | ||
394 | /* Dereference Index and ref_of references */ | 381 | if (ACPI_GET_DESCRIPTOR_TYPE(info->return_object) == |
382 | ACPI_DESC_TYPE_NAMED) { | ||
383 | /* | ||
384 | * If we received a NS Node as a return object, this means that | ||
385 | * the object we are evaluating has nothing interesting to | ||
386 | * return (such as a mutex, etc.) We return an error because | ||
387 | * these types are essentially unsupported by this interface. | ||
388 | * We don't check up front because this makes it easier to add | ||
389 | * support for various types at a later date if necessary. | ||
390 | */ | ||
391 | status = AE_TYPE; | ||
392 | info->return_object = NULL; /* No need to delete a NS Node */ | ||
393 | return_buffer->length = 0; | ||
394 | } | ||
395 | 395 | ||
396 | acpi_ns_resolve_references(info); | 396 | if (ACPI_FAILURE(status)) { |
397 | goto cleanup_return_object; | ||
398 | } | ||
397 | 399 | ||
398 | /* Get the size of the returned object */ | 400 | /* Dereference Index and ref_of references */ |
399 | 401 | ||
400 | status = | 402 | acpi_ns_resolve_references(info); |
401 | acpi_ut_get_object_size(info->return_object, | 403 | |
402 | &buffer_space_needed); | 404 | /* Get the size of the returned object */ |
403 | if (ACPI_SUCCESS(status)) { | 405 | |
404 | 406 | status = acpi_ut_get_object_size(info->return_object, | |
405 | /* Validate/Allocate/Clear caller buffer */ | 407 | &buffer_space_needed); |
406 | 408 | if (ACPI_SUCCESS(status)) { | |
407 | status = | 409 | |
408 | acpi_ut_initialize_buffer | 410 | /* Validate/Allocate/Clear caller buffer */ |
409 | (return_buffer, | 411 | |
410 | buffer_space_needed); | 412 | status = acpi_ut_initialize_buffer(return_buffer, |
411 | if (ACPI_FAILURE(status)) { | 413 | buffer_space_needed); |
412 | /* | 414 | if (ACPI_FAILURE(status)) { |
413 | * Caller's buffer is too small or a new one can't | 415 | /* |
414 | * be allocated | 416 | * Caller's buffer is too small or a new one can't |
415 | */ | 417 | * be allocated |
416 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 418 | */ |
417 | "Needed buffer size %X, %s\n", | 419 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
418 | (u32) | 420 | "Needed buffer size %X, %s\n", |
419 | buffer_space_needed, | 421 | (u32)buffer_space_needed, |
420 | acpi_format_exception | 422 | acpi_format_exception(status))); |
421 | (status))); | 423 | } else { |
422 | } else { | 424 | /* We have enough space for the object, build it */ |
423 | /* We have enough space for the object, build it */ | 425 | |
424 | 426 | status = | |
425 | status = | 427 | acpi_ut_copy_iobject_to_eobject(info->return_object, |
426 | acpi_ut_copy_iobject_to_eobject | 428 | return_buffer); |
427 | (info->return_object, | ||
428 | return_buffer); | ||
429 | } | ||
430 | } | ||
431 | } | ||
432 | } | 429 | } |
433 | } | 430 | } |
434 | 431 | ||
432 | cleanup_return_object: | ||
433 | |||
435 | if (info->return_object) { | 434 | if (info->return_object) { |
436 | /* | 435 | /* |
437 | * Delete the internal return object. NOTE: Interpreter must be | 436 | * Delete the internal return object. NOTE: Interpreter must be |