ACPI: allow a native cpuidle driver to displace ACPI
[safe/jmp/linux-2.6] / drivers / acpi / container.c
index f3e59af..45cd03b 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/acpi.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/container.h>
 
-#define ACPI_CONTAINER_DRIVER_NAME     "ACPI container driver"
+#define PREFIX "ACPI: "
+
 #define ACPI_CONTAINER_DEVICE_NAME     "ACPI container device"
 #define ACPI_CONTAINER_CLASS           "container"
 
 #define INSTALL_NOTIFY_HANDLER         1
 #define UNINSTALL_NOTIFY_HANDLER       2
 
-#define ACPI_CONTAINER_COMPONENT       0x01000000
 #define _COMPONENT                     ACPI_CONTAINER_COMPONENT
 ACPI_MODULE_NAME("container");
 
 MODULE_AUTHOR("Anil S Keshavamurthy");
-MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME);
+MODULE_DESCRIPTION("ACPI container driver");
 MODULE_LICENSE("GPL");
 
-#define ACPI_STA_PRESENT               (0x00000001)
-
 static int acpi_container_add(struct acpi_device *device);
 static int acpi_container_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id container_device_ids[] = {
+       {"ACPI0004", 0},
+       {"PNP0A05", 0},
+       {"PNP0A06", 0},
+       {"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, container_device_ids);
+
 static struct acpi_driver acpi_container_driver = {
-       .name = ACPI_CONTAINER_DRIVER_NAME,
+       .name = "container",
        .class = ACPI_CONTAINER_CLASS,
-       .ids = "ACPI0004,PNP0A05,PNP0A06",
+       .ids = container_device_ids,
        .ops = {
                .add = acpi_container_add,
                .remove = acpi_container_remove,
@@ -71,18 +78,18 @@ static int is_device_present(acpi_handle handle)
 {
        acpi_handle temp;
        acpi_status status;
-       unsigned long sta;
+       unsigned long long sta;
 
 
        status = acpi_get_handle(handle, "_STA", &temp);
        if (ACPI_FAILURE(status))
-               return 1;       /* _STA not found, assmue device present */
+               return 1;       /* _STA not found, assume device present */
 
        status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
        if (ACPI_FAILURE(status))
                return 0;       /* Firmware error */
 
-       return ((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
+       return ((sta & ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT);
 }
 
 /*******************************************************************/
@@ -103,7 +110,7 @@ static int acpi_container_add(struct acpi_device *device)
        container->handle = device->handle;
        strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS);
-       acpi_driver_data(device) = container;
+       device->driver_data = container;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
                          acpi_device_name(device), acpi_device_bid(device)));
@@ -159,7 +166,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
        case ACPI_NOTIFY_BUS_CHECK:
                /* Fall through */
        case ACPI_NOTIFY_DEVICE_CHECK:
-               printk("Container driver received %s event\n",
+               printk(KERN_WARNING "Container driver received %s event\n",
                       (type == ACPI_NOTIFY_BUS_CHECK) ?
                       "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
                status = acpi_bus_get_device(handle, &device);
@@ -170,7 +177,8 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
                                        kobject_uevent(&device->dev.kobj,
                                                       KOBJ_ONLINE);
                                else
-                                       printk("Failed to add container\n");
+                                       printk(KERN_WARNING
+                                              "Failed to add container\n");
                        }
                } else {
                        if (ACPI_SUCCESS(status)) {
@@ -195,20 +203,17 @@ container_walk_namespace_cb(acpi_handle handle,
                            u32 lvl, void *context, void **rv)
 {
        char *hid = NULL;
-       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_device_info *info;
        acpi_status status;
        int *action = context;
 
-
-       status = acpi_get_object_info(handle, &buffer);
-       if (ACPI_FAILURE(status) || !buffer.pointer) {
+       status = acpi_get_object_info(handle, &info);
+       if (ACPI_FAILURE(status)) {
                return AE_OK;
        }
 
-       info = buffer.pointer;
        if (info->valid & ACPI_VALID_HID)
-               hid = info->hardware_id.value;
+               hid = info->hardware_id.string;
 
        if (hid == NULL) {
                goto end;
@@ -235,7 +240,7 @@ container_walk_namespace_cb(acpi_handle handle,
        }
 
       end:
-       kfree(buffer.pointer);
+       kfree(info);
 
        return AE_OK;
 }
@@ -254,7 +259,7 @@ static int __init acpi_container_init(void)
        acpi_walk_namespace(ACPI_TYPE_DEVICE,
                            ACPI_ROOT_OBJECT,
                            ACPI_UINT32_MAX,
-                           container_walk_namespace_cb, &action, NULL);
+                           container_walk_namespace_cb, NULL, &action, NULL);
 
        return (0);
 }
@@ -267,7 +272,7 @@ static void __exit acpi_container_exit(void)
        acpi_walk_namespace(ACPI_TYPE_DEVICE,
                            ACPI_ROOT_OBJECT,
                            ACPI_UINT32_MAX,
-                           container_walk_namespace_cb, &action, NULL);
+                           container_walk_namespace_cb, NULL, &action, NULL);
 
        acpi_bus_unregister_driver(&acpi_container_driver);