ACPICA: Restructure includes into public/private
[deliverable/linux.git] / drivers / acpi / namespace / nseval.c
index d369164e00b0bc16d594e8617e93be3ada99d95f..a8d7764c73b740a6aa7229ac90ea978e4e1034fb 100644 (file)
@@ -42,6 +42,7 @@
  */
 
 #include <acpi/acpi.h>
+#include <acpi/accommon.h>
 #include <acpi/acparser.h>
 #include <acpi/acinterp.h>
 #include <acpi/acnamesp.h>
@@ -78,6 +79,7 @@ ACPI_MODULE_NAME("nseval")
 acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
 {
        acpi_status status;
+       struct acpi_namespace_node *node;
 
        ACPI_FUNCTION_TRACE(ns_evaluate);
 
@@ -88,6 +90,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
        /* Initialize the return value to an invalid object */
 
        info->return_object = NULL;
+       info->param_count = 0;
 
        /*
         * Get the actual namespace node for the target object. Handles these cases:
@@ -117,6 +120,8 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
                          info->resolved_node,
                          acpi_ns_get_attached_object(info->resolved_node)));
 
+       node = info->resolved_node;
+
        /*
         * Two major cases here:
         *
@@ -138,40 +143,17 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
                        return_ACPI_STATUS(AE_NULL_OBJECT);
                }
 
-               /*
-                * Calculate the number of arguments being passed to the method
-                */
+               /* Count the number of arguments being passed to the method */
 
-               info->param_count = 0;
                if (info->parameters) {
-                       while (info->parameters[info->param_count])
+                       while (info->parameters[info->param_count]) {
+                               if (info->param_count > ACPI_METHOD_MAX_ARG) {
+                                       return_ACPI_STATUS(AE_LIMIT);
+                               }
                                info->param_count++;
+                       }
                }
 
-               /* Error if too few arguments were passed in */
-
-               if (info->param_count < info->obj_desc->method.param_count) {
-                       ACPI_ERROR((AE_INFO,
-                                   "Insufficient arguments - "
-                                   "method [%4.4s] needs %d, found %d",
-                                   acpi_ut_get_node_name(info->resolved_node),
-                                   info->obj_desc->method.param_count,
-                                   info->param_count));
-                       return_ACPI_STATUS(AE_MISSING_ARGUMENTS);
-               }
-
-               /* Just a warning if too many arguments */
-
-               else if (info->param_count >
-                               info->obj_desc->method.param_count) {
-                       ACPI_WARNING((AE_INFO,
-                                     "Excess arguments - "
-                                     "method [%4.4s] needs %d, found %d",
-                                     acpi_ut_get_node_name(info->
-                                                           resolved_node),
-                                     info->obj_desc->method.param_count,
-                                     info->param_count));
-               }
 
                ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:",
                                   ACPI_LV_INFO, _COMPONENT);
@@ -195,7 +177,28 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
        } else {
                /*
                 * 2) Object is not a method, return its current value
+                *
+                * Disallow certain object types. For these, "evaluation" is undefined.
                 */
+               switch (info->resolved_node->type) {
+               case ACPI_TYPE_DEVICE:
+               case ACPI_TYPE_EVENT:
+               case ACPI_TYPE_MUTEX:
+               case ACPI_TYPE_REGION:
+               case ACPI_TYPE_THERMAL:
+               case ACPI_TYPE_LOCAL_SCOPE:
+
+                       ACPI_ERROR((AE_INFO,
+                                   "[%4.4s] Evaluation of object type [%s] is not supported",
+                                   info->resolved_node->name.ascii,
+                                   acpi_ut_get_type_name(info->resolved_node->
+                                                         type)));
+
+                       return_ACPI_STATUS(AE_TYPE);
+
+               default:
+                       break;
+               }
 
                /*
                 * Objects require additional resolution steps (e.g., the Node may be
@@ -240,8 +243,15 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
        }
 
        /*
-        * Check if there is a return value that must be dealt with
+        * Check input argument count against the ASL-defined count for a method.
+        * Also check predefined names: argument count and return value against
+        * the ACPI specification. Some incorrect return value types are repaired.
         */
+       (void)acpi_ns_check_predefined_names(node, info->param_count,
+               status, &info->return_object);
+
+       /* Check if there is a return value that must be dealt with */
+
        if (status == AE_CTRL_RETURN_VALUE) {
 
                /* If caller does not want the return value, delete it */
This page took 0.02625 seconds and 5 git commands to generate.