]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/container.c
it8712f_wdt: Locking and coding style
[linux-2.6-omap-h63xx.git] / drivers / acpi / container.c
index b69a8cad82b7ca424f3915c1e0eca54e702be08a..3c25ec7a187142dc224c748dcb481601df626501 100644 (file)
@@ -35,7 +35,6 @@
 #include <acpi/acpi_drivers.h>
 #include <acpi/container.h>
 
-#define ACPI_CONTAINER_DRIVER_NAME     "ACPI container driver"
 #define ACPI_CONTAINER_DEVICE_NAME     "ACPI container device"
 #define ACPI_CONTAINER_CLASS           "container"
 
 
 #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,
@@ -73,17 +78,16 @@ static int is_device_present(acpi_handle handle)
        acpi_status status;
        unsigned long sta;
 
-       ACPI_FUNCTION_TRACE("is_device_present");
 
        status = acpi_get_handle(handle, "_STA", &temp);
        if (ACPI_FAILURE(status))
-               return_VALUE(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_VALUE(0);        /* Firmware error */
+               return 0;       /* Firmware error */
 
-       return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
+       return ((sta & ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT);
 }
 
 /*******************************************************************/
@@ -91,18 +95,16 @@ static int acpi_container_add(struct acpi_device *device)
 {
        struct acpi_container *container;
 
-       ACPI_FUNCTION_TRACE("acpi_container_add");
 
        if (!device) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "device is NULL\n"));
-               return_VALUE(-EINVAL);
+               printk(KERN_ERR PREFIX "device is NULL\n");
+               return -EINVAL;
        }
 
-       container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
+       container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL);
        if (!container)
-               return_VALUE(-ENOMEM);
+               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);
@@ -111,7 +113,7 @@ static int acpi_container_add(struct acpi_device *device)
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
                          acpi_device_name(device), acpi_device_bid(device)));
 
-       return_VALUE(0);
+       return 0;
 }
 
 static int acpi_container_remove(struct acpi_device *device, int type)
@@ -119,7 +121,7 @@ static int acpi_container_remove(struct acpi_device *device, int type)
        acpi_status status = AE_OK;
        struct acpi_container *pc = NULL;
 
-       pc = (struct acpi_container *)acpi_driver_data(device);
+       pc = acpi_driver_data(device);
        kfree(pc);
        return status;
 }
@@ -130,23 +132,22 @@ static int container_device_add(struct acpi_device **device, acpi_handle handle)
        struct acpi_device *pdev;
        int result;
 
-       ACPI_FUNCTION_TRACE("container_device_add");
 
        if (acpi_get_parent(handle, &phandle)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        if (acpi_bus_get_device(phandle, &pdev)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) {
-               return_VALUE(-ENODEV);
+               return -ENODEV;
        }
 
        result = acpi_bus_start(*device);
 
-       return_VALUE(result);
+       return result;
 }
 
 static void container_notify_cb(acpi_handle handle, u32 type, void *context)
@@ -156,7 +157,6 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
        int present;
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE("container_notify_cb");
 
        present = is_device_present(handle);
 
@@ -172,7 +172,7 @@ 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");
@@ -180,19 +180,19 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
                } 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:
                break;
        }
-       return_VOID;
+       return;
 }
 
 static acpi_status
@@ -205,11 +205,10 @@ container_walk_namespace_cb(acpi_handle handle,
        acpi_status status;
        int *action = context;
 
-       ACPI_FUNCTION_TRACE("container_walk_namespace_cb");
 
        status = acpi_get_object_info(handle, &buffer);
        if (ACPI_FAILURE(status) || !buffer.pointer) {
-               return_ACPI_STATUS(AE_OK);
+               return AE_OK;
        }
 
        info = buffer.pointer;
@@ -241,9 +240,9 @@ container_walk_namespace_cb(acpi_handle handle,
        }
 
       end:
-       acpi_os_free(buffer.pointer);
+       kfree(buffer.pointer);
 
-       return_ACPI_STATUS(AE_OK);
+       return AE_OK;
 }
 
 static int __init acpi_container_init(void)
@@ -269,7 +268,6 @@ static void __exit acpi_container_exit(void)
 {
        int action = UNINSTALL_NOTIFY_HANDLER;
 
-       ACPI_FUNCTION_TRACE("acpi_container_exit");
 
        acpi_walk_namespace(ACPI_TYPE_DEVICE,
                            ACPI_ROOT_OBJECT,
@@ -278,7 +276,7 @@ static void __exit acpi_container_exit(void)
 
        acpi_bus_unregister_driver(&acpi_container_driver);
 
-       return_VOID;
+       return;
 }
 
 module_init(acpi_container_init);