ACPI: ACPICA 20060310
[sfrench/cifs-2.6.git] / drivers / acpi / namespace / nsxfeval.c
index c07b046659ff6c9dd298bf9ca6afd7dbdefce089..7cdedc96a40a22ba2e321317bdfd8087d41ec7ba 100644 (file)
@@ -6,7 +6,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
@@ -42,8 +42,6 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
-#include <linux/module.h>
-
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
 #include <acpi/acinterp.h>
@@ -51,6 +49,7 @@
 #define _COMPONENT          ACPI_NAMESPACE
 ACPI_MODULE_NAME("nsxfeval")
 
+#ifdef ACPI_FUTURE_USAGE
 /*******************************************************************************
  *
  * FUNCTION:    acpi_evaluate_object_typed
@@ -71,12 +70,11 @@ ACPI_MODULE_NAME("nsxfeval")
  *              be valid (non-null)
  *
  ******************************************************************************/
-#ifdef ACPI_FUTURE_USAGE
 acpi_status
 acpi_evaluate_object_typed(acpi_handle handle,
                           acpi_string pathname,
-                          struct acpi_object_list *external_params,
-                          struct acpi_buffer *return_buffer,
+                          struct acpi_object_list * external_params,
+                          struct acpi_buffer * return_buffer,
                           acpi_object_type return_type)
 {
        acpi_status status;
@@ -110,10 +108,10 @@ acpi_evaluate_object_typed(acpi_handle handle,
        }
 
        if (return_buffer->length == 0) {
-               /* Error because caller specifically asked for a return value */
 
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No return value\n"));
+               /* Error because caller specifically asked for a return value */
 
+               ACPI_ERROR((AE_INFO, "No return value"));
                return_ACPI_STATUS(AE_NULL_OBJECT);
        }
 
@@ -125,13 +123,14 @@ acpi_evaluate_object_typed(acpi_handle handle,
 
        /* Return object type does not match requested type */
 
-       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                         "Incorrect return type [%s] requested [%s]\n",
-                         acpi_ut_get_type_name(((union acpi_object *)
-                                                return_buffer->pointer)->type),
-                         acpi_ut_get_type_name(return_type)));
+       ACPI_ERROR((AE_INFO,
+                   "Incorrect return type [%s] requested [%s]",
+                   acpi_ut_get_type_name(((union acpi_object *)return_buffer->
+                                          pointer)->type),
+                   acpi_ut_get_type_name(return_type)));
 
        if (must_free) {
+
                /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
 
                acpi_os_free(return_buffer->pointer);
@@ -141,6 +140,8 @@ acpi_evaluate_object_typed(acpi_handle handle,
        return_buffer->length = 0;
        return_ACPI_STATUS(AE_TYPE);
 }
+
+ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed)
 #endif                         /*  ACPI_FUTURE_USAGE  */
 
 /*******************************************************************************
@@ -162,7 +163,6 @@ acpi_evaluate_object_typed(acpi_handle handle,
  *              be valid (non-null)
  *
  ******************************************************************************/
-
 acpi_status
 acpi_evaluate_object(acpi_handle handle,
                     acpi_string pathname,
@@ -192,9 +192,9 @@ acpi_evaluate_object(acpi_handle handle,
                 * Allocate a new parameter block for the internal objects
                 * Add 1 to count to allow for null terminated internal list
                 */
-               info.parameters = ACPI_MEM_CALLOCATE(((acpi_size)
-                                                     external_params->count +
-                                                     1) * sizeof(void *));
+               info.parameters = ACPI_ALLOCATE_ZEROED(((acpi_size)
+                                                       external_params->count +
+                                                       1) * sizeof(void *));
                if (!info.parameters) {
                        return_ACPI_STATUS(AE_NO_MEMORY);
                }
@@ -225,9 +225,9 @@ acpi_evaluate_object(acpi_handle handle,
         * 3) Valid handle
         */
        if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) {
-               /*
-                *  The path is fully qualified, just evaluate by name
-                */
+
+               /* The path is fully qualified, just evaluate by name */
+
                status = acpi_ns_evaluate_by_name(pathname, &info);
        } else if (!handle) {
                /*
@@ -236,11 +236,12 @@ acpi_evaluate_object(acpi_handle handle,
                 * qualified names above, this is an error
                 */
                if (!pathname) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Both Handle and Pathname are NULL\n"));
+                       ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+                                         "Both Handle and Pathname are NULL"));
                } else {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Handle is NULL and Pathname is relative\n"));
+                       ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+                                         "Null Handle with relative pathname [%s]",
+                                         pathname));
                }
 
                status = AE_BAD_PARAMETER;
@@ -257,9 +258,8 @@ acpi_evaluate_object(acpi_handle handle,
                         */
                        status = acpi_ns_evaluate_by_handle(&info);
                } else {
-                       /*
-                        * Both a Handle and a relative Pathname
-                        */
+                       /* Both a Handle and a relative Pathname */
+
                        status = acpi_ns_evaluate_relative(pathname, &info);
                }
        }
@@ -296,6 +296,7 @@ acpi_evaluate_object(acpi_handle handle,
                                    acpi_ut_get_object_size(info.return_object,
                                                            &buffer_space_needed);
                                if (ACPI_SUCCESS(status)) {
+
                                        /* Validate/Allocate/Clear caller buffer */
 
                                        status =
@@ -304,7 +305,8 @@ acpi_evaluate_object(acpi_handle handle,
                                             buffer_space_needed);
                                        if (ACPI_FAILURE(status)) {
                                                /*
-                                                * Caller's buffer is too small or a new one can't be allocated
+                                                * Caller's buffer is too small or a new one can't
+                                                * be allocated
                                                 */
                                                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                                                  "Needed buffer size %X, %s\n",
@@ -313,9 +315,8 @@ acpi_evaluate_object(acpi_handle handle,
                                                                  acpi_format_exception
                                                                  (status)));
                                        } else {
-                                               /*
-                                                *  We have enough space for the object, build it
-                                                */
+                                               /* We have enough space for the object, build it */
+
                                                status =
                                                    acpi_ut_copy_iobject_to_eobject
                                                    (info.return_object,
@@ -342,10 +343,10 @@ acpi_evaluate_object(acpi_handle handle,
                }
        }
 
-       /*
-        * Free the input parameter list (if we created one),
-        */
+       /* Free the input parameter list (if we created one) */
+
        if (info.parameters) {
+
                /* Free the allocated parameter block */
 
                acpi_ut_delete_internal_object_list(info.parameters);
@@ -354,7 +355,7 @@ acpi_evaluate_object(acpi_handle handle,
        return_ACPI_STATUS(status);
 }
 
-EXPORT_SYMBOL(acpi_evaluate_object);
+ACPI_EXPORT_SYMBOL(acpi_evaluate_object)
 
 /*******************************************************************************
  *
@@ -385,7 +386,6 @@ EXPORT_SYMBOL(acpi_evaluate_object);
  *              function, etc.
  *
  ******************************************************************************/
-
 acpi_status
 acpi_walk_namespace(acpi_object_type type,
                    acpi_handle start_object,
@@ -399,7 +399,7 @@ acpi_walk_namespace(acpi_object_type type,
 
        /* Parameter validation */
 
-       if ((type > ACPI_TYPE_EXTERNAL_MAX) || (!max_depth) || (!user_function)) {
+       if ((type > ACPI_TYPE_LOCAL_MAX) || (!max_depth) || (!user_function)) {
                return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
 
@@ -422,7 +422,7 @@ acpi_walk_namespace(acpi_object_type type,
        return_ACPI_STATUS(status);
 }
 
-EXPORT_SYMBOL(acpi_walk_namespace);
+ACPI_EXPORT_SYMBOL(acpi_walk_namespace)
 
 /*******************************************************************************
  *
@@ -437,7 +437,6 @@ EXPORT_SYMBOL(acpi_walk_namespace);
  *              on that.
  *
  ******************************************************************************/
-
 static acpi_status
 acpi_ns_get_device_callback(acpi_handle obj_handle,
                            u32 nesting_level,
@@ -473,8 +472,9 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
                return (AE_CTRL_DEPTH);
        }
 
-       if (!(flags & 0x01)) {
-               /* Don't return at the device or children of the device if not there */
+       if (!(flags & ACPI_STA_DEVICE_PRESENT)) {
+
+               /* Don't examine children of the device if not present */
 
                return (AE_CTRL_DEPTH);
        }
@@ -490,6 +490,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
                }
 
                if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) {
+
                        /* Get the list of Compatible IDs */
 
                        status = acpi_ut_execute_CID(node, &cid);
@@ -506,11 +507,11 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
                                                 sizeof(struct
                                                        acpi_compatible_id)) !=
                                    0) {
-                                       ACPI_MEM_FREE(cid);
+                                       ACPI_FREE(cid);
                                        return (AE_OK);
                                }
                        }
-                       ACPI_MEM_FREE(cid);
+                       ACPI_FREE(cid);
                }
        }
 
@@ -564,9 +565,9 @@ acpi_get_devices(char *HID,
         * We're going to call their callback from OUR callback, so we need
         * to know what it is, and their context parameter.
         */
+       info.hid = HID;
        info.context = context;
        info.user_function = user_function;
-       info.hid = HID;
 
        /*
         * Lock the namespace around the walk.
@@ -579,9 +580,8 @@ acpi_get_devices(char *HID,
                return_ACPI_STATUS(status);
        }
 
-       status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE,
-                                       ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
-                                       ACPI_NS_WALK_UNLOCK,
+       status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+                                       ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
                                        acpi_ns_get_device_callback, &info,
                                        return_value);
 
@@ -589,7 +589,7 @@ acpi_get_devices(char *HID,
        return_ACPI_STATUS(status);
 }
 
-EXPORT_SYMBOL(acpi_get_devices);
+ACPI_EXPORT_SYMBOL(acpi_get_devices)
 
 /*******************************************************************************
  *
@@ -604,7 +604,6 @@ EXPORT_SYMBOL(acpi_get_devices);
  * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
  *
  ******************************************************************************/
-
 acpi_status
 acpi_attach_data(acpi_handle obj_handle,
                 acpi_object_handler handler, void *data)
@@ -638,6 +637,8 @@ acpi_attach_data(acpi_handle obj_handle,
        return (status);
 }
 
+ACPI_EXPORT_SYMBOL(acpi_attach_data)
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_detach_data
@@ -650,7 +651,6 @@ acpi_attach_data(acpi_handle obj_handle,
  * DESCRIPTION: Remove data that was previously attached to a node.
  *
  ******************************************************************************/
-
 acpi_status
 acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
 {
@@ -683,6 +683,8 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
        return (status);
 }
 
+ACPI_EXPORT_SYMBOL(acpi_detach_data)
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_get_data
@@ -696,7 +698,6 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
  * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
  *
  ******************************************************************************/
-
 acpi_status
 acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
 {
@@ -728,3 +729,5 @@ acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
        (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
        return (status);
 }
+
+ACPI_EXPORT_SYMBOL(acpi_get_data)