Pull acpica into release branch
[pandora-kernel.git] / drivers / acpi / utilities / utcopy.c
index 5442b32..5e1a80d 100644 (file)
@@ -5,7 +5,7 @@
  *****************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2005, R. Byron Moore
+ * Copyright (C) 2000 - 2006, R. Byron Moore
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -109,7 +109,7 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
 {
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("ut_copy_isimple_to_esimple");
+       ACPI_FUNCTION_TRACE(ut_copy_isimple_to_esimple);
 
        *buffer_space_used = 0;
 
@@ -325,7 +325,7 @@ acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
        acpi_status status;
        struct acpi_pkg_info info;
 
-       ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_epackage");
+       ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_epackage);
 
        /*
         * First package at head of the buffer
@@ -383,7 +383,7 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
 {
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("ut_copy_iobject_to_eobject");
+       ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject);
 
        if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) {
                /*
@@ -398,14 +398,17 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
                 * Build a simple object (no nested objects)
                 */
                status = acpi_ut_copy_isimple_to_esimple(internal_object,
-                                                        (union acpi_object *)
-                                                        ret_buffer->pointer,
-                                                        ((u8 *) ret_buffer->
-                                                         pointer +
-                                                         ACPI_ROUND_UP_TO_NATIVE_WORD
-                                                         (sizeof
-                                                          (union
-                                                           acpi_object))),
+                                                        ACPI_CAST_PTR(union
+                                                                      acpi_object,
+                                                                      ret_buffer->
+                                                                      pointer),
+                                                        ACPI_ADD_PTR(u8,
+                                                                     ret_buffer->
+                                                                     pointer,
+                                                                     ACPI_ROUND_UP_TO_NATIVE_WORD
+                                                                     (sizeof
+                                                                      (union
+                                                                       acpi_object))),
                                                         &ret_buffer->length);
                /*
                 * build simple does not include the object size in the length
@@ -439,7 +442,7 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
 {
        union acpi_operand_object *internal_object;
 
-       ACPI_FUNCTION_TRACE("ut_copy_esimple_to_isimple");
+       ACPI_FUNCTION_TRACE(ut_copy_esimple_to_isimple);
 
        /*
         * Simple types supported are: String, Buffer, Integer
@@ -469,8 +472,8 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
        case ACPI_TYPE_STRING:
 
                internal_object->string.pointer =
-                   ACPI_MEM_CALLOCATE((acpi_size) external_object->string.
-                                      length + 1);
+                   ACPI_ALLOCATE_ZEROED((acpi_size) external_object->string.
+                                        length + 1);
                if (!internal_object->string.pointer) {
                        goto error_exit;
                }
@@ -485,7 +488,7 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
        case ACPI_TYPE_BUFFER:
 
                internal_object->buffer.pointer =
-                   ACPI_MEM_CALLOCATE(external_object->buffer.length);
+                   ACPI_ALLOCATE_ZEROED(external_object->buffer.length);
                if (!internal_object->buffer.pointer) {
                        goto error_exit;
                }
@@ -549,7 +552,7 @@ acpi_ut_copy_epackage_to_ipackage(union acpi_operand_object *internal_object,
        union acpi_operand_object *this_internal_obj;
        union acpi_object *this_external_obj;
 
-       ACPI_FUNCTION_TRACE("ut_copy_epackage_to_ipackage");
+       ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage);
 
        /*
         * First package at head of the buffer
@@ -597,14 +600,14 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
 {
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("ut_copy_eobject_to_iobject");
+       ACPI_FUNCTION_TRACE(ut_copy_eobject_to_iobject);
 
        if (external_object->type == ACPI_TYPE_PACKAGE) {
                /*
                 * Packages as external input to control methods are not supported,
                 */
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Packages as parameters not implemented!\n"));
+               ACPI_ERROR((AE_INFO,
+                           "Packages as parameters not implemented!"));
 
                return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
        }
@@ -673,7 +676,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
                if ((source_desc->buffer.pointer) &&
                    (source_desc->buffer.length)) {
                        dest_desc->buffer.pointer =
-                           ACPI_MEM_ALLOCATE(source_desc->buffer.length);
+                           ACPI_ALLOCATE(source_desc->buffer.length);
                        if (!dest_desc->buffer.pointer) {
                                return (AE_NO_MEMORY);
                        }
@@ -694,8 +697,8 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
                 */
                if (source_desc->string.pointer) {
                        dest_desc->string.pointer =
-                           ACPI_MEM_ALLOCATE((acpi_size) source_desc->string.
-                                             length + 1);
+                           ACPI_ALLOCATE((acpi_size) source_desc->string.
+                                         length + 1);
                        if (!dest_desc->string.pointer) {
                                return (AE_NO_MEMORY);
                        }
@@ -802,9 +805,7 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type,
                /*
                 * Create the object array
                 */
-               target_object->package.elements =
-                   ACPI_MEM_CALLOCATE(((acpi_size) source_object->package.
-                                       count + 1) * sizeof(void *));
+               target_object->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) source_object->package.count + 1) * sizeof(void *));
                if (!target_object->package.elements) {
                        status = AE_NO_MEMORY;
                        goto error_exit;
@@ -853,7 +854,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
 {
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_ipackage");
+       ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage);
 
        dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj);
        dest_obj->common.flags = source_obj->common.flags;
@@ -862,12 +863,12 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
        /*
         * Create the object array and walk the source package tree
         */
-       dest_obj->package.elements = ACPI_MEM_CALLOCATE(((acpi_size)
-                                                        source_obj->package.
-                                                        count +
-                                                        1) * sizeof(void *));
+       dest_obj->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
+                                                          source_obj->package.
+                                                          count +
+                                                          1) * sizeof(void *));
        if (!dest_obj->package.elements) {
-               ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n"));
+               ACPI_ERROR((AE_INFO, "Package allocation failure"));
                return_ACPI_STATUS(AE_NO_MEMORY);
        }
 
@@ -879,6 +880,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
                                           acpi_ut_copy_ielement_to_ielement,
                                           walk_state);
        if (ACPI_FAILURE(status)) {
+
                /* On failure, delete the destination package object */
 
                acpi_ut_remove_reference(dest_obj);
@@ -908,7 +910,7 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
 {
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("ut_copy_iobject_to_iobject");
+       ACPI_FUNCTION_TRACE(ut_copy_iobject_to_iobject);
 
        /* Create the top level object */