ACPI: replace kmalloc+memset with kzalloc
[linux-2.6.git] / drivers / acpi / video.c
index cee9a50..36b37d7 100644 (file)
@@ -3,6 +3,7 @@
  *
  *  Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
  *  Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
+ *  Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
 #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT  0x83
 #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT  0x84
 
-#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS     0x82
-#define        ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS        0x83
-#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS       0x84
-#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS      0x85
-#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF          0x86
+#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS     0x85
+#define        ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS        0x86
+#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS       0x87
+#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS      0x88
+#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF          0x89
 
 #define ACPI_VIDEO_HEAD_INVALID                (~0u - 1)
 #define ACPI_VIDEO_HEAD_END            (~0u)
@@ -117,7 +118,6 @@ struct acpi_video_enumerated_device {
 };
 
 struct acpi_video_bus {
-       acpi_handle handle;
        struct acpi_device *device;
        u8 dos_setting;
        struct acpi_video_enumerated_device *attached_array;
@@ -156,7 +156,6 @@ struct acpi_video_device_brightness {
 };
 
 struct acpi_video_device {
-       acpi_handle handle;
        unsigned long device_id;
        struct acpi_video_device_flags flags;
        struct acpi_video_device_cap cap;
@@ -273,7 +272,8 @@ static int
 acpi_video_device_query(struct acpi_video_device *device, unsigned long *state)
 {
        int status;
-       status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
+
+       status = acpi_evaluate_integer(device->dev->handle, "_DGS", NULL, state);
 
        return status;
 }
@@ -284,8 +284,7 @@ acpi_video_device_get_state(struct acpi_video_device *device,
 {
        int status;
 
-
-       status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state);
+       status = acpi_evaluate_integer(device->dev->handle, "_DCS", NULL, state);
 
        return status;
 }
@@ -300,7 +299,7 @@ acpi_video_device_set_state(struct acpi_video_device *device, int state)
 
 
        arg0.integer.value = state;
-       status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret);
+       status = acpi_evaluate_integer(device->dev->handle, "_DSS", &args, &ret);
 
        return status;
 }
@@ -316,7 +315,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
 
        *levels = NULL;
 
-       status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
+       status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer);
        if (!ACPI_SUCCESS(status))
                return status;
        obj = (union acpi_object *)buffer.pointer;
@@ -345,7 +344,7 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
 
 
        arg0.integer.value = level;
-       status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL);
+       status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
 
        printk(KERN_DEBUG "set_level status: %x\n", status);
        return status;
@@ -357,7 +356,7 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
 {
        int status;
 
-       status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
+       status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level);
 
        return status;
 }
@@ -384,11 +383,11 @@ acpi_video_device_EDID(struct acpi_video_device *device,
        else
                return -EINVAL;
 
-       status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer);
+       status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer);
        if (ACPI_FAILURE(status))
                return -ENODEV;
 
-       obj = (union acpi_object *)buffer.pointer;
+       obj = buffer.pointer;
 
        if (obj && obj->type == ACPI_TYPE_BUFFER)
                *edid = obj;
@@ -414,7 +413,7 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
 
        arg0.integer.value = option;
 
-       status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp);
+       status = acpi_evaluate_integer(video->device->handle, "_SPD", &args, &tmp);
        if (ACPI_SUCCESS(status))
                status = tmp ? (-EINVAL) : (AE_OK);
 
@@ -426,8 +425,7 @@ acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
 {
        int status;
 
-
-       status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id);
+       status = acpi_evaluate_integer(video->device->handle, "_GPD", NULL, id);
 
        return status;
 }
@@ -438,7 +436,7 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video,
 {
        int status;
 
-       status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
+       status = acpi_evaluate_integer(video->device->handle, "_VPO", NULL, options);
        *options &= 3;
 
        return status;
@@ -479,7 +477,7 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
        }
        arg0.integer.value = (lcd_flag << 2) | bios_flag;
        video->dos_setting = arg0.integer.value;
-       acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
+       acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL);
 
       Failed:
        return status;
@@ -507,25 +505,25 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
 
        memset(&device->cap, 0, 4);
 
-       if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) {
                device->cap._ADR = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCL", &h_dummy1))) {
                device->cap._BCL = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) {
                device->cap._BCM = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) {
                device->cap._DDC = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DCS", &h_dummy1))) {
                device->cap._DCS = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DGS", &h_dummy1))) {
                device->cap._DGS = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DSS", &h_dummy1))) {
                device->cap._DSS = 1;
        }
 
@@ -535,11 +533,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                int count = 0;
                union acpi_object *o;
 
-               br = kmalloc(sizeof(*br), GFP_KERNEL);
+               br = kzalloc(sizeof(*br), GFP_KERNEL);
                if (!br) {
                        printk(KERN_ERR "can't allocate memory\n");
                } else {
-                       memset(br, 0, sizeof(*br));
                        br->levels = kmalloc(obj->package.count *
                                             sizeof *(br->levels), GFP_KERNEL);
                        if (!br->levels)
@@ -589,22 +586,22 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
        acpi_handle h_dummy1;
 
        memset(&video->cap, 0, 4);
-       if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOS", &h_dummy1))) {
                video->cap._DOS = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOD", &h_dummy1))) {
                video->cap._DOD = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_ROM", &h_dummy1))) {
                video->cap._ROM = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_GPD", &h_dummy1))) {
                video->cap._GPD = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_SPD", &h_dummy1))) {
                video->cap._SPD = 1;
        }
-       if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) {
+       if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_VPO", &h_dummy1))) {
                video->cap._VPO = 1;
        }
 }
@@ -657,8 +654,7 @@ static struct proc_dir_entry *acpi_video_dir;
 
 static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
 {
-       struct acpi_video_device *dev =
-           (struct acpi_video_device *)seq->private;
+       struct acpi_video_device *dev = seq->private;
 
 
        if (!dev)
@@ -691,8 +687,7 @@ acpi_video_device_info_open_fs(struct inode *inode, struct file *file)
 static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
 {
        int status;
-       struct acpi_video_device *dev =
-           (struct acpi_video_device *)seq->private;
+       struct acpi_video_device *dev = seq->private;
        unsigned long state;
 
 
@@ -730,8 +725,8 @@ acpi_video_device_write_state(struct file *file,
                              size_t count, loff_t * data)
 {
        int status;
-       struct seq_file *m = (struct seq_file *)file->private_data;
-       struct acpi_video_device *dev = (struct acpi_video_device *)m->private;
+       struct seq_file *m = file->private_data;
+       struct acpi_video_device *dev = m->private;
        char str[12] = { 0 };
        u32 state = 0;
 
@@ -757,8 +752,7 @@ acpi_video_device_write_state(struct file *file,
 static int
 acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
 {
-       struct acpi_video_device *dev =
-           (struct acpi_video_device *)seq->private;
+       struct acpi_video_device *dev = seq->private;
        int i;
 
 
@@ -787,8 +781,8 @@ acpi_video_device_write_brightness(struct file *file,
                                   const char __user * buffer,
                                   size_t count, loff_t * data)
 {
-       struct seq_file *m = (struct seq_file *)file->private_data;
-       struct acpi_video_device *dev = (struct acpi_video_device *)m->private;
+       struct seq_file *m = file->private_data;
+       struct acpi_video_device *dev = m->private;
        char str[4] = { 0 };
        unsigned int level = 0;
        int i;
@@ -820,8 +814,7 @@ acpi_video_device_write_brightness(struct file *file,
 
 static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
 {
-       struct acpi_video_device *dev =
-           (struct acpi_video_device *)seq->private;
+       struct acpi_video_device *dev = seq->private;
        int status;
        int i;
        union acpi_object *edid = NULL;
@@ -869,7 +862,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
        if (!device)
                return -ENODEV;
 
-       vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
+       vid_dev = acpi_driver_data(device);
        if (!vid_dev)
                return -ENODEV;
 
@@ -934,7 +927,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device)
 {
        struct acpi_video_device *vid_dev;
 
-       vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
+       vid_dev = acpi_driver_data(device);
        if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
                return -ENODEV;
 
@@ -953,7 +946,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device)
 /* video bus */
 static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
 {
-       struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
+       struct acpi_video_bus *video = seq->private;
 
 
        if (!video)
@@ -978,7 +971,7 @@ static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
 
 static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
 {
-       struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
+       struct acpi_video_bus *video = seq->private;
 
 
        if (!video)
@@ -998,7 +991,7 @@ static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
 
 static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
 {
-       struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
+       struct acpi_video_bus *video = seq->private;
        unsigned long options;
        int status;
 
@@ -1036,7 +1029,7 @@ acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file)
 
 static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
 {
-       struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
+       struct acpi_video_bus *video = seq->private;
        int status;
        unsigned long id;
 
@@ -1057,7 +1050,7 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
 
 static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
 {
-       struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
+       struct acpi_video_bus *video = seq->private;
 
 
        seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
@@ -1082,8 +1075,8 @@ acpi_video_bus_write_POST(struct file *file,
                          size_t count, loff_t * data)
 {
        int status;
-       struct seq_file *m = (struct seq_file *)file->private_data;
-       struct acpi_video_bus *video = (struct acpi_video_bus *)m->private;
+       struct seq_file *m = file->private_data;
+       struct acpi_video_bus *video = m->private;
        char str[12] = { 0 };
        unsigned long opt, options;
 
@@ -1122,8 +1115,8 @@ acpi_video_bus_write_DOS(struct file *file,
                         size_t count, loff_t * data)
 {
        int status;
-       struct seq_file *m = (struct seq_file *)file->private_data;
-       struct acpi_video_bus *video = (struct acpi_video_bus *)m->private;
+       struct seq_file *m = file->private_data;
+       struct acpi_video_bus *video = m->private;
        char str[12] = { 0 };
        unsigned long opt;
 
@@ -1153,7 +1146,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
        struct acpi_video_bus *video;
 
 
-       video = (struct acpi_video_bus *)acpi_driver_data(device);
+       video = acpi_driver_data(device);
 
        if (!acpi_device_dir(device)) {
                acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
@@ -1229,7 +1222,7 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device)
        struct acpi_video_bus *video;
 
 
-       video = (struct acpi_video_bus *)acpi_driver_data(device);
+       video = acpi_driver_data(device);
 
        if (acpi_device_dir(device)) {
                remove_proc_entry("info", acpi_device_dir(device));
@@ -1266,13 +1259,10 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
            acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
        if (ACPI_SUCCESS(status)) {
 
-               data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
+               data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
                if (!data)
                        return -ENOMEM;
 
-               memset(data, 0, sizeof(struct acpi_video_device));
-
-               data->handle = device->handle;
                strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
                strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
                acpi_driver_data(device) = data;
@@ -1299,7 +1289,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
                acpi_video_device_bind(video, data);
                acpi_video_device_find_cap(data);
 
-               status = acpi_install_notify_handler(data->handle,
+               status = acpi_install_notify_handler(device->handle,
                                                     ACPI_DEVICE_NOTIFY,
                                                     acpi_video_device_notify,
                                                     data);
@@ -1401,14 +1391,13 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
        union acpi_object *dod = NULL;
        union acpi_object *obj;
 
-
-       status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer);
+       status = acpi_evaluate_object(video->device->handle, "_DOD", NULL, &buffer);
        if (!ACPI_SUCCESS(status)) {
                ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
                return status;
        }
 
-       dod = (union acpi_object *)buffer.pointer;
+       dod = buffer.pointer;
        if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
                ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
                status = -EFAULT;
@@ -1431,7 +1420,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
 
        count = 0;
        for (i = 0; i < dod->package.count; i++) {
-               obj = (union acpi_object *)&dod->package.elements[i];
+               obj = &dod->package.elements[i];
 
                if (obj->type != ACPI_TYPE_INTEGER) {
                        printk(KERN_ERR PREFIX "Invalid _DOD data\n");
@@ -1451,7 +1440,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
        video->attached_array = active_device_list;
        video->attached_count = count;
       out:
-       acpi_os_free(buffer.pointer);
+       kfree(buffer.pointer);
        return status;
 }
 
@@ -1514,8 +1503,34 @@ static int
 acpi_video_get_next_level(struct acpi_video_device *device,
                          u32 level_current, u32 event)
 {
-       /*Fix me */
-       return level_current;
+       int min, max, min_above, max_below, i, l;
+       max = max_below = 0;
+       min = min_above = 255;
+       for (i = 0; i < device->brightness->count; i++) {
+               l = device->brightness->levels[i];
+               if (l < min)
+                       min = l;
+               if (l > max)
+                       max = l;
+               if (l < min_above && l > level_current)
+                       min_above = l;
+               if (l > max_below && l < level_current)
+                       max_below = l;
+       }
+
+       switch (event) {
+       case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
+               return (level_current < max) ? min_above : min;
+       case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
+               return (level_current < max) ? min_above : max;
+       case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
+               return (level_current > min) ? max_below : min;
+       case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
+       case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
+               return 0;
+       default:
+               return level_current;
+       }
 }
 
 static void
@@ -1570,7 +1585,7 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
        up(&video->sem);
        acpi_video_device_remove_fs(device->dev);
 
-       status = acpi_remove_notify_handler(device->handle,
+       status = acpi_remove_notify_handler(device->dev->handle,
                                            ACPI_DEVICE_NOTIFY,
                                            acpi_video_device_notify);
 
@@ -1617,7 +1632,7 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
 
 static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
 {
-       struct acpi_video_bus *video = (struct acpi_video_bus *)data;
+       struct acpi_video_bus *video = data;
        struct acpi_device *device = NULL;
 
        printk("video bus notify\n");
@@ -1659,8 +1674,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
 
 static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
 {
-       struct acpi_video_device *video_device =
-           (struct acpi_video_device *)data;
+       struct acpi_video_device *video_device = data;
        struct acpi_device *device = NULL;
 
 
@@ -1701,12 +1715,10 @@ static int acpi_video_bus_add(struct acpi_device *device)
        if (!device)
                return -EINVAL;
 
-       video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
+       video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
        if (!video)
                return -ENOMEM;
-       memset(video, 0, sizeof(struct acpi_video_bus));
 
-       video->handle = device->handle;
        video->device = device;
        strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
        strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
@@ -1727,7 +1739,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
        acpi_video_bus_get_devices(video, device);
        acpi_video_bus_start_devices(video);
 
-       status = acpi_install_notify_handler(video->handle,
+       status = acpi_install_notify_handler(device->handle,
                                             ACPI_DEVICE_NOTIFY,
                                             acpi_video_bus_notify, video);
        if (ACPI_FAILURE(status)) {
@@ -1763,11 +1775,11 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
        if (!device || !acpi_driver_data(device))
                return -EINVAL;
 
-       video = (struct acpi_video_bus *)acpi_driver_data(device);
+       video = acpi_driver_data(device);
 
        acpi_video_bus_stop_devices(video);
 
-       status = acpi_remove_notify_handler(video->handle,
+       status = acpi_remove_notify_handler(video->device->handle,
                                            ACPI_DEVICE_NOTIFY,
                                            acpi_video_bus_notify);