toshiba_acpi: return on a fail path
[safe/jmp/linux-2.6] / drivers / acpi / power.c
index e88edc0..d74365d 100644 (file)
@@ -44,9 +44,8 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
-#define _COMPONENT             ACPI_POWER_COMPONENT
+#define _COMPONENT                     ACPI_POWER_COMPONENT
 ACPI_MODULE_NAME("power");
-#define ACPI_POWER_COMPONENT           0x00800000
 #define ACPI_POWER_CLASS               "power_resource"
 #define ACPI_POWER_DEVICE_NAME         "Power Resource"
 #define ACPI_POWER_FILE_INFO           "info"
@@ -55,10 +54,6 @@ ACPI_MODULE_NAME("power");
 #define ACPI_POWER_RESOURCE_STATE_ON   0x01
 #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF
 
-#ifdef MODULE_PARAM_PREFIX
-#undef MODULE_PARAM_PREFIX
-#endif
-#define MODULE_PARAM_PREFIX "acpi."
 int acpi_power_nocheck;
 module_param_named(power_nocheck, acpi_power_nocheck, bool, 000);
 
@@ -139,7 +134,9 @@ acpi_power_get_context(acpi_handle handle,
 static int acpi_power_get_state(acpi_handle handle, int *state)
 {
        acpi_status status = AE_OK;
-       unsigned long sta = 0;
+       unsigned long long sta = 0;
+       char node_name[5];
+       struct acpi_buffer buffer = { sizeof(node_name), node_name };
 
 
        if (!handle || !state)
@@ -152,8 +149,11 @@ static int acpi_power_get_state(acpi_handle handle, int *state)
        *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON:
                              ACPI_POWER_RESOURCE_STATE_OFF;
 
+       acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
+
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
-                         acpi_ut_get_node_name(handle), state ? "on" : "off"));
+                         node_name,
+                               *state ? "on" : "off"));
 
        return 0;
 }
@@ -194,7 +194,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
 
 static int acpi_power_on(acpi_handle handle, struct acpi_device *dev)
 {
-       int result = 0, state;
+       int result = 0;
        int found = 0;
        acpi_status status = AE_OK;
        struct acpi_power_resource *resource = NULL;
@@ -236,18 +236,6 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev)
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
-       if (!acpi_power_nocheck) {
-               /*
-                * If acpi_power_nocheck is set, it is unnecessary to check
-                * the power state after power transition.
-                */
-               result = acpi_power_get_state(resource->device->handle,
-                               &state);
-               if (result)
-                       return result;
-               if (state != ACPI_POWER_RESOURCE_STATE_ON)
-                       return -ENOEXEC;
-       }
        /* Update the power resource's _device_ power state */
        resource->device->power.state = ACPI_STATE_D0;
 
@@ -258,7 +246,7 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev)
 
 static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev)
 {
-       int result = 0, state;
+       int result = 0;
        acpi_status status = AE_OK;
        struct acpi_power_resource *resource = NULL;
        struct list_head *node, *next;
@@ -293,18 +281,6 @@ static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev)
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
-       if (!acpi_power_nocheck) {
-               /*
-                * If acpi_power_nocheck is set, it is unnecessary to check
-                * the power state after power transition.
-                */
-               result = acpi_power_get_state(handle, &state);
-               if (result)
-                       return result;
-               if (state != ACPI_POWER_RESOURCE_STATE_OFF)
-                       return -ENOEXEC;
-       }
-
        /* Update the power resource's _device_ power state */
        resource->device->power.state = ACPI_STATE_D3;
 
@@ -516,11 +492,6 @@ int acpi_power_transition(struct acpi_device *device, int state)
        cl = &device->power.states[device->power.state].resources;
        tl = &device->power.states[state].resources;
 
-       if (!cl->count && !tl->count) {
-               result = -ENODEV;
-               goto end;
-       }
-
        /* TBD: Resources must be ordered. */
 
        /*
@@ -774,14 +745,10 @@ static int acpi_power_resume(struct acpi_device *device)
        return 0;
 }
 
-static int __init acpi_power_init(void)
+int __init acpi_power_init(void)
 {
        int result = 0;
 
-
-       if (acpi_disabled)
-               return 0;
-
        INIT_LIST_HEAD(&acpi_power_resource_list);
 
        acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir);
@@ -796,5 +763,3 @@ static int __init acpi_power_init(void)
 
        return 0;
 }
-
-subsys_initcall(acpi_power_init);