drm: DRM: fix memset size error
[linux-2.6.git] / drivers / acpi / asus_acpi.c
index c613a43..d915fec 100644 (file)
@@ -26,7 +26,7 @@
  *  Pontus Fuchs   - Helper functions, cleanup
  *  Johann Wiesner - Small compile fixes
  *  John Belmonte  - ACPI code for Toshiba laptop was a good starting point.
- *  Éric Burghard  - LED display support for W1N
+ *  �ic Burghard  - LED display support for W1N
  *
  */
 
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
+#include <linux/backlight.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 #include <asm/uaccess.h>
@@ -45,6 +46,7 @@
 #define PROC_MLED       "mled"
 #define PROC_WLED       "wled"
 #define PROC_TLED       "tled"
+#define PROC_BT         "bluetooth"
 #define PROC_LEDD       "ledd"
 #define PROC_INFO       "info"
 #define PROC_LCD        "lcd"
@@ -54,7 +56,6 @@
 #define ACPI_HOTK_NAME          "Asus Laptop ACPI Extras Driver"
 #define ACPI_HOTK_CLASS         "hotkey"
 #define ACPI_HOTK_DEVICE_NAME   "Hotkey"
-#define ACPI_HOTK_HID           "ATK0100"
 
 /*
  * Some events we use, same for all Asus
 /*
  * Flags for hotk status
  */
-#define MLED_ON     0x01       //is MLED ON ?
-#define WLED_ON     0x02
-#define TLED_ON     0x04
+#define MLED_ON     0x01       //mail LED
+#define WLED_ON     0x02       //wireless LED
+#define TLED_ON     0x04       //touchpad LED
+#define BT_ON       0x08       //internal Bluetooth
 
 MODULE_AUTHOR("Julien Lerouge, Karol Kozimor");
 MODULE_DESCRIPTION(ACPI_HOTK_NAME);
@@ -91,7 +93,9 @@ struct model_data {
        char *mt_tled;          //method to handle tled_____________R
        char *tled_status;      //node to handle tled reading_______A
        char *mt_ledd;          //method to handle LED display______R
-       char *mt_lcd_switch;    //method to turn LCD ON/OFF_________A
+       char *mt_bt_switch;     //method to switch Bluetooth on/off_R
+       char *bt_status;        //no model currently supports this__?
+       char *mt_lcd_switch;    //method to turn LCD on/off_________A
        char *lcd_status;       //node to read LCD panel state______A
        char *brightness_up;    //method to set brightness up_______A
        char *brightness_down;  //guess what ?______________________A
@@ -121,7 +125,7 @@ struct asus_hotk {
                L2D,            //L2000D
                L3C,            //L3800C
                L3D,            //L3400D
-               L3H,            //L3H, but also L2000E
+               L3H,            //L3H, L2000E, L5D
                L4R,            //L4500R
                L5x,            //L5800C 
                L8L,            //L8400L
@@ -133,7 +137,10 @@ struct asus_hotk {
                S1x,            //S1300A, but also L1400B and M2400A (L84F)
                S2x,            //S200 (J1 reported), Victor MP-XP7210
                W1N,            //W1000N
+               W5A,            //W5A
+               W3V,            //W3030V
                xxN,            //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N
+               A4S,            //Z81sp
                //(Centrino)
                END_MODEL
        } model;                //Models currently supported
@@ -305,7 +312,8 @@ static struct model_data model_conf[END_MODEL] = {
         .brightness_set = "SPLV",
         .brightness_get = "GPLV",
         .display_set = "SDSP",
-        .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
+        .display_get = "\\SSTE"},
+
        {
         .name = "M6R",
         .mt_mled = "MLED",
@@ -315,7 +323,7 @@ static struct model_data model_conf[END_MODEL] = {
         .brightness_set = "SPLV",
         .brightness_get = "GPLV",
         .display_set = "SDSP",
-        .display_get = "\\SSTE"},
+        .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
 
        {
         .name = "P30",
@@ -360,6 +368,27 @@ static struct model_data model_conf[END_MODEL] = {
         .display_get = "\\ADVG"},
 
        {
+        .name = "W5A",
+        .mt_bt_switch = "BLED",
+        .mt_wled = "WLED",
+        .mt_lcd_switch = xxN_PREFIX "_Q10",
+        .brightness_set = "SPLV",
+        .brightness_get = "GPLV",
+        .display_set = "SDSP",
+        .display_get = "\\ADVG"},
+
+       {
+        .name = "W3V",
+        .mt_mled = "MLED",
+        .mt_wled = "WLED",
+        .mt_lcd_switch = xxN_PREFIX "_Q10",
+        .lcd_status = "\\BKLT",
+        .brightness_set = "SPLV",
+        .brightness_get = "GPLV",
+        .display_set = "SDSP",
+        .display_get = "\\INFB"},
+
+       {
         .name = "xxN",
         .mt_mled = "MLED",
 /* WLED present, but not controlled by ACPI */
@@ -368,12 +397,23 @@ static struct model_data model_conf[END_MODEL] = {
         .brightness_set = "SPLV",
         .brightness_get = "GPLV",
         .display_set = "SDSP",
-        .display_get = "\\ADVG"}
+       .display_get = "\\ADVG"},
+
+       {
+               .name              = "A4S",
+               .brightness_set    = "SPLV",
+               .brightness_get    = "GPLV",
+               .mt_bt_switch      = "BLED",
+               .mt_wled           = "WLED"
+       }
+
 };
 
 /* procdir we use */
 static struct proc_dir_entry *asus_proc_dir;
 
+static struct backlight_device *asus_backlight_device;
+
 /*
  * This header is made available to allow proper configuration given model,
  * revision number , ... this info cannot go in struct asus_hotk because it is
@@ -385,14 +425,20 @@ static struct acpi_table_header *asus_info;
 static struct asus_hotk *hotk;
 
 /*
- * The hotkey driver declaration
+ * The hotkey driver and autoloading declaration
  */
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
+static const struct acpi_device_id asus_device_ids[] = {
+       {"ATK0100", 0},
+       {"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static struct acpi_driver asus_hotk_driver = {
-       .name = ACPI_HOTK_NAME,
+       .name = "asus_acpi",
        .class = ACPI_HOTK_CLASS,
-       .ids = ACPI_HOTK_HID,
+       .ids = asus_device_ids,
        .ops = {
                .add = asus_hotk_add,
                .remove = asus_hotk_remove,
@@ -539,11 +585,11 @@ static int
 write_led(const char __user * buffer, unsigned long count,
          char *ledname, int ledmask, int invert)
 {
-       int value;
+       int rv, value;
        int led_out = 0;
 
-       count = parse_arg(buffer, count, &value);
-       if (count > 0)
+       rv = parse_arg(buffer, count, &value);
+       if (rv > 0)
                led_out = value ? 1 : 0;
 
        hotk->status =
@@ -556,7 +602,7 @@ write_led(const char __user * buffer, unsigned long count,
                printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
                       ledname);
 
-       return count;
+       return rv;
 }
 
 /*
@@ -591,20 +637,18 @@ static int
 proc_write_ledd(struct file *file, const char __user * buffer,
                unsigned long count, void *data)
 {
-       int value;
+       int rv, value;
 
-       count = parse_arg(buffer, count, &value);
-       if (count > 0) {
+       rv = parse_arg(buffer, count, &value);
+       if (rv > 0) {
                if (!write_acpi_int
                    (hotk->handle, hotk->methods->mt_ledd, value, NULL))
                        printk(KERN_WARNING
                               "Asus ACPI: LED display write failed\n");
                else
                        hotk->ledd_status = (u32) value;
-       } else if (count < 0)
-               printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
-
-       return count;
+       }
+       return rv;
 }
 
 /*
@@ -626,6 +670,25 @@ proc_write_wled(struct file *file, const char __user * buffer,
 }
 
 /*
+ * Proc handlers for Bluetooth
+ */
+static int
+proc_read_bluetooth(char *page, char **start, off_t off, int count, int *eof,
+                   void *data)
+{
+       return sprintf(page, "%d\n", read_led(hotk->methods->bt_status, BT_ON));
+}
+
+static int
+proc_write_bluetooth(struct file *file, const char __user * buffer,
+                    unsigned long count, void *data)
+{
+       /* Note: mt_bt_switch controls both internal Bluetooth adapter's 
+          presence and its LED */
+       return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0);
+}
+
+/*
  * Proc handlers for TLED
  */
 static int
@@ -726,15 +789,15 @@ static int
 proc_write_lcd(struct file *file, const char __user * buffer,
               unsigned long count, void *data)
 {
-       int value;
+       int rv, value;
 
-       count = parse_arg(buffer, count, &value);
-       if (count > 0)
+       rv = parse_arg(buffer, count, &value);
+       if (rv > 0)
                set_lcd_state(value);
-       return count;
+       return rv;
 }
 
-static int read_brightness(void)
+static int read_brightness(struct backlight_device *bd)
 {
        int value;
 
@@ -756,9 +819,10 @@ static int read_brightness(void)
 /*
  * Change the brightness level
  */
-static void set_brightness(int value)
+static int set_brightness(int value)
 {
        acpi_status status = 0;
+       int ret = 0;
 
        /* SPLV laptop */
        if (hotk->methods->brightness_set) {
@@ -766,11 +830,12 @@ static void set_brightness(int value)
                                    value, NULL))
                        printk(KERN_WARNING
                               "Asus ACPI: Error changing brightness\n");
-               return;
+                       ret = -EIO;
+               goto out;
        }
 
        /* No SPLV method if we are here, act as appropriate */
-       value -= read_brightness();
+       value -= read_brightness(NULL);
        while (value != 0) {
                status = acpi_evaluate_object(NULL, (value > 0) ?
                                              hotk->methods->brightness_up :
@@ -780,33 +845,37 @@ static void set_brightness(int value)
                if (ACPI_FAILURE(status))
                        printk(KERN_WARNING
                               "Asus ACPI: Error changing brightness\n");
+                       ret = -EIO;
        }
-       return;
+out:
+       return ret;
+}
+
+static int set_brightness_status(struct backlight_device *bd)
+{
+       return set_brightness(bd->props.brightness);
 }
 
 static int
 proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
              void *data)
 {
-       return sprintf(page, "%d\n", read_brightness());
+       return sprintf(page, "%d\n", read_brightness(NULL));
 }
 
 static int
 proc_write_brn(struct file *file, const char __user * buffer,
               unsigned long count, void *data)
 {
-       int value;
+       int rv, value;
 
-       count = parse_arg(buffer, count, &value);
-       if (count > 0) {
+       rv = parse_arg(buffer, count, &value);
+       if (rv > 0) {
                value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
                /* 0 <= value <= 15 */
                set_brightness(value);
-       } else if (count < 0) {
-               printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
        }
-
-       return count;
+       return rv;
 }
 
 static void set_display(int value)
@@ -845,15 +914,12 @@ static int
 proc_write_disp(struct file *file, const char __user * buffer,
                unsigned long count, void *data)
 {
-       int value;
+       int rv, value;
 
-       count = parse_arg(buffer, count, &value);
-       if (count > 0)
+       rv = parse_arg(buffer, count, &value);
+       if (rv > 0)
                set_display(value);
-       else if (count < 0)
-               printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
-
-       return count;
+       return rv;
 }
 
 typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,
@@ -936,6 +1002,11 @@ static int asus_hotk_add_fs(struct acpi_device *device)
                              mode, device);
        }
 
+       if (hotk->methods->mt_bt_switch) {
+               asus_proc_add(PROC_BT, &proc_write_bluetooth,
+                             &proc_read_bluetooth, mode, device);
+       }
+
        /* 
         * We need both read node and write method as LCD switch is also accessible
         * from keyboard 
@@ -971,6 +1042,8 @@ static int asus_hotk_remove_fs(struct acpi_device *device)
                        remove_proc_entry(PROC_TLED, acpi_device_dir(device));
                if (hotk->methods->mt_ledd)
                        remove_proc_entry(PROC_LEDD, acpi_device_dir(device));
+               if (hotk->methods->mt_bt_switch)
+                       remove_proc_entry(PROC_BT, acpi_device_dir(device));
                if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status)
                        remove_proc_entry(PROC_LCD, acpi_device_dir(device));
                if ((hotk->methods->brightness_up
@@ -996,22 +1069,85 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
                hotk->brightness = (event & ~((u32) BR_DOWN));
        }
 
-       acpi_bus_generate_event(hotk->device, event,
+       acpi_bus_generate_proc_event(hotk->device, event,
                                hotk->event_count[event % 128]++);
 
        return;
 }
 
 /*
+ * Match the model string to the list of supported models. Return END_MODEL if
+ * no match or model is NULL.
+ */
+static int asus_model_match(char *model)
+{
+       if (model == NULL)
+               return END_MODEL;
+
+       if (strncmp(model, "L3D", 3) == 0)
+               return L3D;
+       else if (strncmp(model, "L2E", 3) == 0 ||
+                strncmp(model, "L3H", 3) == 0 || strncmp(model, "L5D", 3) == 0)
+               return L3H;
+       else if (strncmp(model, "L3", 2) == 0 || strncmp(model, "L2B", 3) == 0)
+               return L3C;
+       else if (strncmp(model, "L8L", 3) == 0)
+               return L8L;
+       else if (strncmp(model, "L4R", 3) == 0)
+               return L4R;
+       else if (strncmp(model, "M6N", 3) == 0 || strncmp(model, "W3N", 3) == 0)
+               return M6N;
+       else if (strncmp(model, "M6R", 3) == 0 || strncmp(model, "A3G", 3) == 0)
+               return M6R;
+       else if (strncmp(model, "M2N", 3) == 0 ||
+                strncmp(model, "M3N", 3) == 0 ||
+                strncmp(model, "M5N", 3) == 0 ||
+                strncmp(model, "M6N", 3) == 0 ||
+                strncmp(model, "S1N", 3) == 0 ||
+                strncmp(model, "S5N", 3) == 0 || strncmp(model, "W1N", 3) == 0)
+               return xxN;
+       else if (strncmp(model, "M1", 2) == 0)
+               return M1A;
+       else if (strncmp(model, "M2", 2) == 0 || strncmp(model, "L4E", 3) == 0)
+               return M2E;
+       else if (strncmp(model, "L2", 2) == 0)
+               return L2D;
+       else if (strncmp(model, "L8", 2) == 0)
+               return S1x;
+       else if (strncmp(model, "D1", 2) == 0)
+               return D1x;
+       else if (strncmp(model, "A1", 2) == 0)
+               return A1x;
+       else if (strncmp(model, "A2", 2) == 0)
+               return A2x;
+       else if (strncmp(model, "J1", 2) == 0)
+               return S2x;
+       else if (strncmp(model, "L5", 2) == 0)
+               return L5x;
+       else if (strncmp(model, "A4G", 3) == 0)
+               return A4G;
+       else if (strncmp(model, "W1N", 3) == 0)
+               return W1N;
+       else if (strncmp(model, "W3V", 3) == 0)
+               return W3V;
+       else if (strncmp(model, "W5A", 3) == 0)
+               return W5A;
+       else if (strncmp(model, "A4S", 3) == 0)
+               return A4S;
+       else
+               return END_MODEL;
+}
+
+/*
  * This function is used to initialize the hotk with right values. In this
  * method, we can make all the detection we want, and modify the hotk struct
  */
 static int asus_hotk_get_info(void)
 {
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-       struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *model = NULL;
        int bsts_result;
+       char *string = NULL;
        acpi_status status;
 
        /*
@@ -1022,11 +1158,9 @@ static int asus_hotk_get_info(void)
         * HID), this bit will be moved. A global variable asus_info contains
         * the DSDT header.
         */
-       status = acpi_get_table(ACPI_TABLE_ID_DSDT, 1, &dsdt);
+       status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus_info);
        if (ACPI_FAILURE(status))
                printk(KERN_WARNING "  Couldn't get the DSDT table header\n");
-       else
-               asus_info = (struct acpi_table_header *)dsdt.pointer;
 
        /* We have to write 0 on init this far for all ASUS models */
        if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
@@ -1041,116 +1175,68 @@ static int asus_hotk_get_info(void)
                printk(KERN_NOTICE "  BSTS called, 0x%02x returned\n",
                       bsts_result);
 
-       /* This is unlikely with implicit return */
-       if (buffer.pointer == NULL)
-               return -EINVAL;
-
-       model = (union acpi_object *)buffer.pointer;
        /*
-        * Samsung P30 has a device with a valid _HID whose INIT does not 
-        * return anything. It used to be possible to catch this exception,
-        * but the implicit return code will now happily confuse the 
-        * driver. We assume that every ACPI_TYPE_STRING is a valid model
-        * identifier but it's still possible to get completely bogus data.
+        * Try to match the object returned by INIT to the specific model.
+        * Handle every possible object (or the lack of thereof) the DSDT 
+        * writers might throw at us. When in trouble, we pass NULL to 
+        * asus_model_match() and try something completely different.
         */
-       if (model->type == ACPI_TYPE_STRING) {
-               printk(KERN_NOTICE "  %s model detected, ",
-                      model->string.pointer);
-       } else {
-               if (asus_info &&        /* Samsung P30 */
+       if (buffer.pointer) {
+               model = buffer.pointer;
+               switch (model->type) {
+               case ACPI_TYPE_STRING:
+                       string = model->string.pointer;
+                       break;
+               case ACPI_TYPE_BUFFER:
+                       string = model->buffer.pointer;
+                       break;
+               default:
+                       kfree(model);
+                       model = NULL;
+                       break;
+               }
+       }
+       hotk->model = asus_model_match(string);
+       if (hotk->model == END_MODEL) { /* match failed */
+               if (asus_info &&
                    strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) {
                        hotk->model = P30;
                        printk(KERN_NOTICE
                               "  Samsung P30 detected, supported\n");
                } else {
                        hotk->model = M2E;
-                       printk(KERN_WARNING "  no string returned by INIT\n");
-                       printk(KERN_WARNING "  trying default values, supply "
-                              "the developers with your DSDT\n");
+                       printk(KERN_NOTICE "  unsupported model %s, trying "
+                              "default values\n", string);
+                       printk(KERN_NOTICE
+                              "  send /proc/acpi/dsdt to the developers\n");
                }
                hotk->methods = &model_conf[hotk->model];
-
-               kfree(model);
-
                return AE_OK;
        }
-
-       hotk->model = END_MODEL;
-       if (strncmp(model->string.pointer, "L3D", 3) == 0)
-               hotk->model = L3D;
-       else if (strncmp(model->string.pointer, "L3H", 3) == 0 ||
-                strncmp(model->string.pointer, "L2E", 3) == 0)
-               hotk->model = L3H;
-       else if (strncmp(model->string.pointer, "L3", 2) == 0 ||
-                strncmp(model->string.pointer, "L2B", 3) == 0)
-               hotk->model = L3C;
-       else if (strncmp(model->string.pointer, "L8L", 3) == 0)
-               hotk->model = L8L;
-       else if (strncmp(model->string.pointer, "L4R", 3) == 0)
-               hotk->model = L4R;
-       else if (strncmp(model->string.pointer, "M6N", 3) == 0 ||
-                strncmp(model->string.pointer, "W3N", 3) == 0)
-               hotk->model = M6N;
-       else if (strncmp(model->string.pointer, "M6R", 3) == 0 ||
-                strncmp(model->string.pointer, "A3G", 3) == 0)
-               hotk->model = M6R;
-       else if (strncmp(model->string.pointer, "M2N", 3) == 0 ||
-                strncmp(model->string.pointer, "M3N", 3) == 0 ||
-                strncmp(model->string.pointer, "M5N", 3) == 0 ||
-                strncmp(model->string.pointer, "M6N", 3) == 0 ||
-                strncmp(model->string.pointer, "S1N", 3) == 0 ||
-                strncmp(model->string.pointer, "S5N", 3) == 0)
-               hotk->model = xxN;
-       else if (strncmp(model->string.pointer, "M1", 2) == 0)
-               hotk->model = M1A;
-       else if (strncmp(model->string.pointer, "M2", 2) == 0 ||
-                strncmp(model->string.pointer, "L4E", 3) == 0)
-               hotk->model = M2E;
-       else if (strncmp(model->string.pointer, "L2", 2) == 0)
-               hotk->model = L2D;
-       else if (strncmp(model->string.pointer, "L8", 2) == 0)
-               hotk->model = S1x;
-       else if (strncmp(model->string.pointer, "D1", 2) == 0)
-               hotk->model = D1x;
-       else if (strncmp(model->string.pointer, "A1", 2) == 0)
-               hotk->model = A1x;
-       else if (strncmp(model->string.pointer, "A2", 2) == 0)
-               hotk->model = A2x;
-       else if (strncmp(model->string.pointer, "J1", 2) == 0)
-               hotk->model = S2x;
-       else if (strncmp(model->string.pointer, "L5", 2) == 0)
-               hotk->model = L5x;
-       else if (strncmp(model->string.pointer, "A4G", 3) == 0)
-               hotk->model = A4G;
-       else if (strncmp(model->string.pointer, "W1N", 3) == 0)
-               hotk->model = W1N;
-
-       if (hotk->model == END_MODEL) {
-               printk("unsupported, trying default values, supply the "
-                      "developers with your DSDT\n");
-               hotk->model = M2E;
-       } else {
-               printk("supported\n");
-       }
-
        hotk->methods = &model_conf[hotk->model];
+       printk(KERN_NOTICE "  %s model detected, supported\n", string);
 
        /* Sort of per-model blacklist */
-       if (strncmp(model->string.pointer, "L2B", 3) == 0)
+       if (strncmp(string, "L2B", 3) == 0)
                hotk->methods->lcd_status = NULL;
        /* L2B is similar enough to L3C to use its settings, with this only 
           exception */
-       else if (strncmp(model->string.pointer, "A3G", 3) == 0)
+       else if (strncmp(string, "A3G", 3) == 0)
                hotk->methods->lcd_status = "\\BLFG";
        /* A3G is like M6R */
-       else if (strncmp(model->string.pointer, "S5N", 3) == 0 ||
-                strncmp(model->string.pointer, "M5N", 3) == 0 ||
-                strncmp(model->string.pointer, "W3N", 3) == 0)
+       else if (strncmp(string, "S5N", 3) == 0 ||
+                strncmp(string, "M5N", 3) == 0 ||
+                strncmp(string, "W3N", 3) == 0)
                hotk->methods->mt_mled = NULL;
        /* S5N, M5N and W3N have no MLED */
-       else if (strncmp(model->string.pointer, "M2N", 3) == 0)
+       else if (strncmp(string, "L5D", 3) == 0)
+               hotk->methods->mt_wled = NULL;
+       /* L5D's WLED is not controlled by ACPI */
+       else if (strncmp(string, "M2N", 3) == 0 ||
+                strncmp(string, "W3V", 3) == 0 ||
+                strncmp(string, "S1N", 3) == 0)
                hotk->methods->mt_wled = "WLED";
-       /* M2N has a usable WLED */
+       /* M2N, S1N and W3V have a usable WLED */
        else if (asus_info) {
                if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
                        hotk->methods->mled_status = NULL;
@@ -1193,11 +1279,9 @@ static int asus_hotk_add(struct acpi_device *device)
        printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
               ASUS_ACPI_VERSION);
 
-       hotk =
-           (struct asus_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), ACPI_HOTK_DEVICE_NAME);
@@ -1274,6 +1358,22 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
        return 0;
 }
 
+static struct backlight_ops asus_backlight_data = {
+        .get_brightness = read_brightness,
+        .update_status  = set_brightness_status,
+};
+
+static void asus_acpi_exit(void)
+{
+       if (asus_backlight_device)
+               backlight_device_unregister(asus_backlight_device);
+
+       acpi_bus_unregister_driver(&asus_hotk_driver);
+       remove_proc_entry(PROC_ASUS, acpi_root_dir);
+
+       return;
+}
+
 static int __init asus_acpi_init(void)
 {
        int result;
@@ -1281,10 +1381,6 @@ static int __init asus_acpi_init(void)
        if (acpi_disabled)
                return -ENODEV;
 
-       if (!acpi_specific_hotkey_enabled) {
-               printk(KERN_ERR "Using generic hotkey driver\n");
-               return -ENODEV;
-       }
        asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
        if (!asus_proc_dir) {
                printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
@@ -1308,20 +1404,20 @@ static int __init asus_acpi_init(void)
        if (!asus_hotk_found) {
                acpi_bus_unregister_driver(&asus_hotk_driver);
                remove_proc_entry(PROC_ASUS, acpi_root_dir);
-               return result;
+               return -ENODEV;
        }
 
-       return 0;
-}
-
-static void __exit asus_acpi_exit(void)
-{
-       acpi_bus_unregister_driver(&asus_hotk_driver);
-       remove_proc_entry(PROC_ASUS, acpi_root_dir);
-
-       kfree(asus_info);
+       asus_backlight_device = backlight_device_register("asus",NULL,NULL,
+                                                         &asus_backlight_data);
+        if (IS_ERR(asus_backlight_device)) {
+               printk(KERN_ERR "Could not register asus backlight device\n");
+               asus_backlight_device = NULL;
+               asus_acpi_exit();
+               return -ENODEV;
+       }
+        asus_backlight_device->props.max_brightness = 15;
 
-       return;
+       return 0;
 }
 
 module_init(asus_acpi_init);