ACPI: delete extra #defines in /drivers/acpi/ drivers
[safe/jmp/linux-2.6] / drivers / acpi / power.c
index 224f729..92f80ba 100644 (file)
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT             ACPI_POWER_COMPONENT
-ACPI_MODULE_NAME("acpi_power")
+ACPI_MODULE_NAME("power");
 #define ACPI_POWER_COMPONENT           0x00800000
 #define ACPI_POWER_CLASS               "power_resource"
-#define ACPI_POWER_DRIVER_NAME         "ACPI Power Resource Driver"
 #define ACPI_POWER_DEVICE_NAME         "Power Resource"
 #define ACPI_POWER_FILE_INFO           "info"
 #define ACPI_POWER_FILE_STATUS         "state"
@@ -60,7 +59,7 @@ static int acpi_power_remove(struct acpi_device *device, int type);
 static int acpi_power_open_fs(struct inode *inode, struct file *file);
 
 static struct acpi_driver acpi_power_driver = {
-       .name = ACPI_POWER_DRIVER_NAME,
+       .name = "power",
        .class = ACPI_POWER_CLASS,
        .ids = ACPI_POWER_HID,
        .ops = {
@@ -70,7 +69,7 @@ static struct acpi_driver acpi_power_driver = {
 };
 
 struct acpi_power_resource {
-       acpi_handle handle;
+       struct acpi_device * device;
        acpi_bus_id name;
        u32 system_level;
        u32 order;
@@ -80,7 +79,7 @@ struct acpi_power_resource {
 
 static struct list_head acpi_power_resource_list;
 
-static struct file_operations acpi_power_fops = {
+static const struct file_operations acpi_power_fops = {
        .open = acpi_power_open_fs,
        .read = seq_read,
        .llseek = seq_lseek,
@@ -108,7 +107,7 @@ acpi_power_get_context(acpi_handle handle,
                return result;
        }
 
-       *resource = (struct acpi_power_resource *)acpi_driver_data(device);
+       *resource = acpi_driver_data(device);
        if (!resource)
                return -ENODEV;
 
@@ -124,7 +123,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
        if (!resource)
                return -EINVAL;
 
-       status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta);
+       status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta);
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
@@ -192,7 +191,7 @@ static int acpi_power_on(acpi_handle handle)
                return 0;
        }
 
-       status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL);
+       status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL);
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
@@ -203,10 +202,8 @@ static int acpi_power_on(acpi_handle handle)
                return -ENOEXEC;
 
        /* Update the power resource's _device_ power state */
-       result = acpi_bus_get_device(resource->handle, &device);
-       if (result)
-               return result;
-       device->power.state = ACPI_STATE_D0;
+       device = resource->device;
+       resource->device->power.state = ACPI_STATE_D0;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n",
                          resource->name));
@@ -218,10 +215,8 @@ static int acpi_power_off_device(acpi_handle handle)
 {
        int result = 0;
        acpi_status status = AE_OK;
-       struct acpi_device *device = NULL;
        struct acpi_power_resource *resource = NULL;
 
-
        result = acpi_power_get_context(handle, &resource);
        if (result)
                return result;
@@ -232,17 +227,17 @@ static int acpi_power_off_device(acpi_handle handle)
        if (resource->references) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                                  "Resource [%s] is still in use, dereferencing\n",
-                                 device->pnp.bus_id));
+                                 resource->device->pnp.bus_id));
                return 0;
        }
 
        if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
-                                 device->pnp.bus_id));
+                                 resource->device->pnp.bus_id));
                return 0;
        }
 
-       status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL);
+       status = acpi_evaluate_object(resource->device->handle, "_OFF", NULL, NULL);
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
@@ -253,10 +248,7 @@ static int acpi_power_off_device(acpi_handle handle)
                return -ENOEXEC;
 
        /* Update the power resource's _device_ power state */
-       result = acpi_bus_get_device(resource->handle, &device);
-       if (result)
-               return result;
-       device->power.state = ACPI_STATE_D3;
+       resource->device->power.state = ACPI_STATE_D3;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
                          resource->name));
@@ -449,7 +441,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
        struct acpi_power_resource *resource = NULL;
 
 
-       resource = (struct acpi_power_resource *)seq->private;
+       resource = seq->private;
 
        if (!resource)
                goto end;
@@ -539,19 +531,18 @@ static int acpi_power_add(struct acpi_device *device)
        if (!device)
                return -EINVAL;
 
-       resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
+       resource = kzalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
        if (!resource)
                return -ENOMEM;
-       memset(resource, 0, sizeof(struct acpi_power_resource));
 
-       resource->handle = device->handle;
+       resource->device = device;
        strcpy(resource->name, device->pnp.bus_id);
        strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
        acpi_driver_data(device) = resource;
 
        /* Evalute the object to get the system level and resource order. */
-       status = acpi_evaluate_object(resource->handle, NULL, NULL, &buffer);
+       status = acpi_evaluate_object(device->handle, NULL, NULL, &buffer);
        if (ACPI_FAILURE(status)) {
                result = -ENODEV;
                goto end;
@@ -597,7 +588,7 @@ static int acpi_power_remove(struct acpi_device *device, int type)
        if (!device || !acpi_driver_data(device))
                return -EINVAL;
 
-       resource = (struct acpi_power_resource *)acpi_driver_data(device);
+       resource = acpi_driver_data(device);
 
        acpi_power_remove_fs(device);