tunnels: fix netns vs proto registration ordering
[safe/jmp/linux-2.6] / drivers / acpi / container.c
index a153817..5faf6c2 100644 (file)
 #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("acpi_container")
+ACPI_MODULE_NAME("container");
 
-    MODULE_AUTHOR("Anil S Keshavamurthy");
-MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME);
+MODULE_AUTHOR("Anil S Keshavamurthy");
+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 +77,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);
 }
 
 /*******************************************************************/
@@ -96,15 +102,14 @@ static int acpi_container_add(struct acpi_device *device)
                return -EINVAL;
        }
 
-       container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
+       container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL);
        if (!container)
                return -ENOMEM;
 
-       memset(container, 0, sizeof(struct acpi_container));
        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)));
@@ -160,7 +165,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);
@@ -168,21 +173,22 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
                        if (ACPI_FAILURE(status) || !device) {
                                result = container_device_add(&device, handle);
                                if (!result)
-                                       kobject_uevent(&device->kobj,
+                                       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)) {
                                /* device exist and this is a remove request */
-                               kobject_uevent(&device->kobj, KOBJ_OFFLINE);
+                               kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
                        }
                }
                break;
        case ACPI_NOTIFY_EJECT_REQUEST:
                if (!acpi_bus_get_device(handle, &device) && device) {
-                       kobject_uevent(&device->kobj, KOBJ_OFFLINE);
+                       kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
                }
                break;
        default:
@@ -196,20 +202,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;
@@ -236,7 +239,7 @@ container_walk_namespace_cb(acpi_handle handle,
        }
 
       end:
-       kfree(buffer.pointer);
+       kfree(info);
 
        return AE_OK;
 }
@@ -255,7 +258,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);
 }
@@ -268,7 +271,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);