Pull events into release branch
[sfrench/cifs-2.6.git] / drivers / misc / asus-laptop.c
index 7798f590e5aab8c840b3f839d249926e67308343..7dce318df1bdb1751b061bbddc258ec4648743dc 100644 (file)
@@ -53,7 +53,6 @@
 #define ASUS_HOTK_NAME          "Asus Laptop Support"
 #define ASUS_HOTK_CLASS         "hotkey"
 #define ASUS_HOTK_DEVICE_NAME   "Hotkey"
-#define ASUS_HOTK_HID           "ATK0100"
 #define ASUS_HOTK_FILE          "asus-laptop"
 #define ASUS_HOTK_PREFIX        "\\_SB.ATKD."
 
@@ -197,12 +196,18 @@ static struct asus_hotk *hotk;
 /*
  * The hotkey driver declaration
  */
+static const struct acpi_device_id asus_device_ids[] = {
+       {"ATK0100", 0},
+       {"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
 static struct acpi_driver asus_hotk_driver = {
        .name = ASUS_HOTK_NAME,
        .class = ASUS_HOTK_CLASS,
-       .ids = ASUS_HOTK_HID,
+       .ids = asus_device_ids,
        .ops = {
                .add = asus_hotk_add,
                .remove = asus_hotk_remove,
@@ -727,7 +732,7 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
                lcd_blank(FB_BLANK_POWERDOWN);
        }
 
-       acpi_bus_generate_event(hotk->device, event,
+       acpi_bus_generate_proc_event(hotk->device, event,
                                hotk->event_count[event % 128]++);
 
        return;
@@ -979,10 +984,9 @@ static int asus_hotk_add(struct acpi_device *device)
        printk(ASUS_NOTICE "Asus Laptop Support version %s\n",
               ASUS_LAPTOP_VERSION);
 
-       hotk = kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
+       hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL);
        if (!hotk)
                return -ENOMEM;
-       memset(hotk, 0, sizeof(struct asus_hotk));
 
        hotk->handle = device->handle;
        strcpy(acpi_device_name(device), ASUS_HOTK_DEVICE_NAME);
@@ -1068,19 +1072,17 @@ static void asus_backlight_exit(void)
 }
 
 #define  ASUS_LED_UNREGISTER(object)                           \
-       if(object##_led.class_dev                               \
-          && !IS_ERR(object##_led.class_dev))                  \
+       if (object##_led.dev)                                   \
                led_classdev_unregister(&object##_led)
 
 static void asus_led_exit(void)
 {
+       destroy_workqueue(led_workqueue);
        ASUS_LED_UNREGISTER(mled);
        ASUS_LED_UNREGISTER(tled);
        ASUS_LED_UNREGISTER(pled);
        ASUS_LED_UNREGISTER(rled);
        ASUS_LED_UNREGISTER(gled);
-
-       destroy_workqueue(led_workqueue);
 }
 
 static void __exit asus_laptop_exit(void)
@@ -1136,29 +1138,42 @@ static int asus_led_init(struct device *dev)
 
        rv = ASUS_LED_REGISTER(mled, dev);
        if (rv)
-               return rv;
+               goto out;
 
        rv = ASUS_LED_REGISTER(tled, dev);
        if (rv)
-               return rv;
+               goto out1;
 
        rv = ASUS_LED_REGISTER(rled, dev);
        if (rv)
-               return rv;
+               goto out2;
 
        rv = ASUS_LED_REGISTER(pled, dev);
        if (rv)
-               return rv;
+               goto out3;
 
        rv = ASUS_LED_REGISTER(gled, dev);
        if (rv)
-               return rv;
+               goto out4;
 
        led_workqueue = create_singlethread_workqueue("led_workqueue");
        if (!led_workqueue)
-               return -ENOMEM;
+               goto out5;
 
        return 0;
+out5:
+       rv = -ENOMEM;
+       ASUS_LED_UNREGISTER(gled);
+out4:
+       ASUS_LED_UNREGISTER(pled);
+out3:
+       ASUS_LED_UNREGISTER(rled);
+out2:
+       ASUS_LED_UNREGISTER(tled);
+out1:
+       ASUS_LED_UNREGISTER(mled);
+out:
+       return rv;
 }
 
 static int __init asus_laptop_init(void)