diff --git a/[refs] b/[refs] index bfbbae0086d2..62a93bc995b7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b2f71bade430d468398167d696731bf770de2db8 +refs/heads/master: 2df8386cec47520b76822cb39d96709f5d353cf8 diff --git a/trunk/drivers/acpi/ac.c b/trunk/drivers/acpi/ac.c index 4537ae4838c4..36ca365bcead 100644 --- a/trunk/drivers/acpi/ac.c +++ b/trunk/drivers/acpi/ac.c @@ -65,7 +65,7 @@ static struct acpi_driver acpi_ac_driver = { }; struct acpi_ac { - struct acpi_device * device; + acpi_handle handle; unsigned long state; }; @@ -88,7 +88,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac) if (!ac) return -EINVAL; - status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL, &ac->state); + status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state")); ac->state = ACPI_AC_STATUS_UNKNOWN; @@ -191,7 +191,9 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) if (!ac) return; - device = ac->device; + if (acpi_bus_get_device(ac->handle, &device)) + return; + switch (event) { case ACPI_AC_NOTIFY_STATUS: acpi_ac_get_state(ac); @@ -221,7 +223,7 @@ static int acpi_ac_add(struct acpi_device *device) return -ENOMEM; memset(ac, 0, sizeof(struct acpi_ac)); - ac->device = device; + ac->handle = device->handle; strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_AC_CLASS); acpi_driver_data(device) = ac; @@ -234,7 +236,7 @@ static int acpi_ac_add(struct acpi_device *device) if (result) goto end; - status = acpi_install_notify_handler(device->handle, + status = acpi_install_notify_handler(ac->handle, ACPI_DEVICE_NOTIFY, acpi_ac_notify, ac); if (ACPI_FAILURE(status)) { @@ -266,7 +268,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type) ac = (struct acpi_ac *)acpi_driver_data(device); - status = acpi_remove_notify_handler(device->handle, + status = acpi_remove_notify_handler(ac->handle, ACPI_DEVICE_NOTIFY, acpi_ac_notify); acpi_ac_remove_fs(device); diff --git a/trunk/drivers/acpi/acpi_memhotplug.c b/trunk/drivers/acpi/acpi_memhotplug.c index 81e970adeab3..84a68965c11a 100644 --- a/trunk/drivers/acpi/acpi_memhotplug.c +++ b/trunk/drivers/acpi/acpi_memhotplug.c @@ -80,7 +80,7 @@ struct acpi_memory_info { }; struct acpi_memory_device { - struct acpi_device * device; + acpi_handle handle; unsigned int state; /* State of the memory device */ struct list_head res_list; }; @@ -129,7 +129,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) struct acpi_memory_info *info, *n; - status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS, + status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS, acpi_memory_get_resource, mem_device); if (ACPI_FAILURE(status)) { list_for_each_entry_safe(info, n, &mem_device->res_list, list) @@ -192,7 +192,7 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device) /* Get device present/absent information from the _STA */ - if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle, "_STA", + if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA", NULL, ¤t_status))) return -ENODEV; /* @@ -222,7 +222,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) return result; } - node = acpi_get_node(mem_device->device->handle); + node = acpi_get_node(mem_device->handle); /* * Tell the VM there is more memory here... * Note: Assume that this function returns zero on success @@ -269,7 +269,7 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) arg_list.pointer = &arg; arg.type = ACPI_TYPE_INTEGER; arg.integer.value = 1; - status = acpi_evaluate_object(mem_device->device->handle, + status = acpi_evaluate_object(mem_device->handle, "_EJ0", &arg_list, NULL); /* Return on _EJ0 failure */ if (ACPI_FAILURE(status)) { @@ -278,7 +278,7 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) } /* Evalute _STA to check if the device is disabled */ - status = acpi_evaluate_integer(mem_device->device->handle, "_STA", + status = acpi_evaluate_integer(mem_device->handle, "_STA", NULL, ¤t_status); if (ACPI_FAILURE(status)) return -ENODEV; @@ -398,7 +398,7 @@ static int acpi_memory_device_add(struct acpi_device *device) memset(mem_device, 0, sizeof(struct acpi_memory_device)); INIT_LIST_HEAD(&mem_device->res_list); - mem_device->device = device; + mem_device->handle = device->handle; sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME); sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS); acpi_driver_data(device) = mem_device; diff --git a/trunk/drivers/acpi/asus_acpi.c b/trunk/drivers/acpi/asus_acpi.c index eb0b8fb837c6..e9ee4c52a5f6 100644 --- a/trunk/drivers/acpi/asus_acpi.c +++ b/trunk/drivers/acpi/asus_acpi.c @@ -2,7 +2,7 @@ * asus_acpi.c - Asus Laptop ACPI Extras * * - * Copyright (C) 2002, 2003, 2004 Julien Lerouge, Karol Kozimor + * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,11 +26,8 @@ * 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 * - * TODO: - * add Fn key status - * Add mode selection on module loading (parameter) -> still necessary? - * Complete display switching -- may require dirty hacks or calling _DOS? */ #include @@ -42,12 +39,14 @@ #include #include -#define ASUS_ACPI_VERSION "0.29" +#define ASUS_ACPI_VERSION "0.30" #define PROC_ASUS "asus" //the directory #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" #define PROC_BRN "brn" @@ -67,9 +66,10 @@ /* * 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); @@ -92,7 +92,10 @@ struct model_data { char *wled_status; //node to handle wled reading_______A char *mt_tled; //method to handle tled_____________R char *tled_status; //node to handle tled reading_______A - char *mt_lcd_switch; //method to turn LCD ON/OFF_________A + char *mt_ledd; //method to handle LED display______R + 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 @@ -111,27 +114,31 @@ struct asus_hotk { struct acpi_device *device; //the device we are in acpi_handle handle; //the handle of the hotk device char status; //status of the hotk, for LEDs, ... + u32 ledd_status; //status of the LED display struct model_data *methods; //methods available on the laptop u8 brightness; //brightness level enum { A1x = 0, //A1340D, A1300F A2x, //A2500H + A4G, //A4700G D1x, //D1 L2D, //L2000D L3C, //L3800C L3D, //L3400D - L3H, //L3H, but also L2000E + L3H, //L3H, L2000E, L5D L4R, //L4500R L5x, //L5800C L8L, //L8400L M1A, //M1300A M2E, //M2400E, L4400L - M6N, //M6800N - M6R, //M6700R + M6N, //M6800N, W3400N + M6R, //M6700R, A3000G P30, //Samsung P30 S1x, //S1300A, but also L1400B and M2400A (L84F) S2x, //S200 (J1 reported), Victor MP-XP7210 - xxN, //M2400N, M3700N, M5200N, S1300N, S5200N, W1OOON + W1N, //W1000N + W5A, //W5A + xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N //(Centrino) END_MODEL } model; //Models currently supported @@ -149,17 +156,8 @@ struct asus_hotk { static struct model_data model_conf[END_MODEL] = { /* - * Those pathnames are relative to the HOTK / ATKD device : - * - mt_mled - * - mt_wled - * - brightness_set - * - brightness_get - * - display_set - * - display_get - * * TODO I have seen a SWBX and AIBX method on some models, like L1400B, * it seems to be a kind of switch, but what for ? - * */ { @@ -183,6 +181,16 @@ static struct model_data model_conf[END_MODEL] = { .display_set = "SDSP", .display_get = "\\INFB"}, + { + .name = "A4G", + .mt_mled = "MLED", +/* WLED present, but not controlled by ACPI */ + .mt_lcd_switch = xxN_PREFIX "_Q10", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .display_get = "\\ADVG"}, + { .name = "D1x", .mt_mled = "MLED", @@ -302,7 +310,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", @@ -312,7 +321,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", @@ -344,6 +353,28 @@ static struct model_data model_conf[END_MODEL] = { .brightness_up = S2x_PREFIX "_Q0B", .brightness_down = S2x_PREFIX "_Q0A"}, + { + .name = "W1N", + .mt_mled = "MLED", + .mt_wled = "WLED", + .mt_ledd = "SLCM", + .mt_lcd_switch = xxN_PREFIX "_Q10", + .lcd_status = "\\BKLT", + .brightness_set = "SPLV", + .brightness_get = "GPLV", + .display_set = "SDSP", + .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 = "xxN", .mt_mled = "MLED", @@ -562,6 +593,36 @@ proc_write_mled(struct file *file, const char __user * buffer, return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1); } +/* + * Proc handlers for LED display + */ +static int +proc_read_ledd(char *page, char **start, off_t off, int count, int *eof, + void *data) +{ + return sprintf(page, "0x%08x\n", hotk->ledd_status); +} + +static int +proc_write_ledd(struct file *file, const char __user * buffer, + unsigned long count, void *data) +{ + int value; + + count = parse_arg(buffer, count, &value); + if (count > 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; +} + /* * Proc handlers for WLED */ @@ -580,6 +641,25 @@ proc_write_wled(struct file *file, const char __user * buffer, return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0); } +/* + * 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 */ @@ -876,6 +956,11 @@ static int asus_hotk_add_fs(struct acpi_device *device) mode, device); } + if (hotk->methods->mt_ledd) { + asus_proc_add(PROC_LEDD, &proc_write_ledd, &proc_read_ledd, + mode, device); + } + if (hotk->methods->mt_mled) { asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled, mode, device); @@ -886,6 +971,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 @@ -919,6 +1009,10 @@ static int asus_hotk_remove_fs(struct acpi_device *device) remove_proc_entry(PROC_MLED, acpi_device_dir(device)); if (hotk->methods->mt_tled) 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 @@ -950,6 +1044,65 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) 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, "W5A", 3) == 0) + return W5A; + 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 @@ -960,6 +1113,7 @@ static int asus_hotk_get_info(void) struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *model = NULL; int bsts_result; + char *string = NULL; acpi_status status; /* @@ -989,107 +1143,66 @@ 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 = (union acpi_object *)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); + 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) - hotk->model = M6N; - else if (strncmp(model->string.pointer, "M6R", 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 || - strncmp(model->string.pointer, "W1N", 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; - - 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, "S5N", 3) == 0 || - strncmp(model->string.pointer, "M5N", 3) == 0) + else if (strncmp(string, "A3G", 3) == 0) + hotk->methods->lcd_status = "\\BLFG"; + /* A3G is like M6R */ + else if (strncmp(string, "S5N", 3) == 0 || + strncmp(string, "M5N", 3) == 0 || + strncmp(string, "W3N", 3) == 0) hotk->methods->mt_mled = NULL; - /* S5N and M5N have no MLED */ - else if (strncmp(model->string.pointer, "M2N", 3) == 0 || - strncmp(model->string.pointer, "W1N", 3) == 0) + /* S5N, M5N and W3N have no MLED */ + 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, "S1N", 3) == 0) hotk->methods->mt_wled = "WLED"; - /* M2N and W1N have a usable WLED */ + /* M2N and S1N have a usable WLED */ else if (asus_info) { if (strncmp(asus_info->oem_table_id, "L1", 2) == 0) hotk->methods->mled_status = NULL; @@ -1164,8 +1277,7 @@ static int asus_hotk_add(struct acpi_device *device) /* For laptops without GPLV: init the hotk->brightness value */ if ((!hotk->methods->brightness_get) && (!hotk->methods->brightness_status) - && (hotk->methods->brightness_up - && hotk->methods->brightness_down)) { + && (hotk->methods->brightness_up && hotk->methods->brightness_down)) { status = acpi_evaluate_object(NULL, hotk->methods->brightness_down, NULL, NULL); @@ -1184,6 +1296,9 @@ static int asus_hotk_add(struct acpi_device *device) asus_hotk_found = 1; + /* LED display is off by default */ + hotk->ledd_status = 0xFFF; + end: if (result) { kfree(hotk); diff --git a/trunk/drivers/acpi/battery.c b/trunk/drivers/acpi/battery.c index 2b8aab560b58..7d92f73b265f 100644 --- a/trunk/drivers/acpi/battery.c +++ b/trunk/drivers/acpi/battery.c @@ -108,7 +108,7 @@ struct acpi_battery_trips { }; struct acpi_battery { - struct acpi_device * device; + acpi_handle handle; struct acpi_battery_flags flags; struct acpi_battery_trips trips; unsigned long alarm; @@ -138,7 +138,7 @@ acpi_battery_get_info(struct acpi_battery *battery, /* Evalute _BIF */ - status = acpi_evaluate_object(battery->device->handle, "_BIF", NULL, &buffer); + status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); return -ENODEV; @@ -198,7 +198,7 @@ acpi_battery_get_status(struct acpi_battery *battery, /* Evalute _BST */ - status = acpi_evaluate_object(battery->device->handle, "_BST", NULL, &buffer); + status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); return -ENODEV; @@ -255,7 +255,7 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm) arg0.integer.value = alarm; - status = acpi_evaluate_object(battery->device->handle, "_BTP", &arg_list, NULL); + status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL); if (ACPI_FAILURE(status)) return -ENODEV; @@ -278,7 +278,9 @@ static int acpi_battery_check(struct acpi_battery *battery) if (!battery) return -EINVAL; - device = battery->device; + result = acpi_bus_get_device(battery->handle, &device); + if (result) + return result; result = acpi_bus_get_status(device); if (result) @@ -303,7 +305,7 @@ static int acpi_battery_check(struct acpi_battery *battery) /* See if alarms are supported, and if so, set default */ - status = acpi_get_handle(battery->device->handle, "_BTP", &handle); + status = acpi_get_handle(battery->handle, "_BTP", &handle); if (ACPI_SUCCESS(status)) { battery->flags.alarm = 1; acpi_battery_set_alarm(battery, battery->trips.warning); @@ -660,7 +662,8 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) if (!battery) return; - device = battery->device; + if (acpi_bus_get_device(handle, &device)) + return; switch (event) { case ACPI_BATTERY_NOTIFY_STATUS: @@ -692,7 +695,7 @@ static int acpi_battery_add(struct acpi_device *device) return -ENOMEM; memset(battery, 0, sizeof(struct acpi_battery)); - battery->device = device; + battery->handle = device->handle; strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); acpi_driver_data(device) = battery; @@ -705,7 +708,7 @@ static int acpi_battery_add(struct acpi_device *device) if (result) goto end; - status = acpi_install_notify_handler(device->handle, + status = acpi_install_notify_handler(battery->handle, ACPI_DEVICE_NOTIFY, acpi_battery_notify, battery); if (ACPI_FAILURE(status)) { @@ -737,7 +740,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type) battery = (struct acpi_battery *)acpi_driver_data(device); - status = acpi_remove_notify_handler(device->handle, + status = acpi_remove_notify_handler(battery->handle, ACPI_DEVICE_NOTIFY, acpi_battery_notify); diff --git a/trunk/drivers/acpi/button.c b/trunk/drivers/acpi/button.c index fd1ba05eab68..02594639c4d9 100644 --- a/trunk/drivers/acpi/button.c +++ b/trunk/drivers/acpi/button.c @@ -82,6 +82,7 @@ static struct acpi_driver acpi_button_driver = { }; struct acpi_button { + acpi_handle handle; struct acpi_device *device; /* Fixed button kludge */ u8 type; unsigned long pushed; @@ -136,7 +137,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) if (!button || !button->device) return 0; - status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state); + status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state); if (ACPI_FAILURE(status)) { seq_printf(seq, "state: unsupported\n"); } else { @@ -281,7 +282,7 @@ static acpi_status acpi_button_notify_fixed(void *data) if (!button) return AE_BAD_PARAMETER; - acpi_button_notify(button->device->handle, ACPI_BUTTON_NOTIFY_STATUS, button); + acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); return AE_OK; } @@ -302,6 +303,7 @@ static int acpi_button_add(struct acpi_device *device) memset(button, 0, sizeof(struct acpi_button)); button->device = device; + button->handle = device->handle; acpi_driver_data(device) = button; /* @@ -360,7 +362,7 @@ static int acpi_button_add(struct acpi_device *device) button); break; default: - status = acpi_install_notify_handler(device->handle, + status = acpi_install_notify_handler(button->handle, ACPI_DEVICE_NOTIFY, acpi_button_notify, button); @@ -418,7 +420,7 @@ static int acpi_button_remove(struct acpi_device *device, int type) acpi_button_notify_fixed); break; default: - status = acpi_remove_notify_handler(device->handle, + status = acpi_remove_notify_handler(button->handle, ACPI_DEVICE_NOTIFY, acpi_button_notify); break; diff --git a/trunk/drivers/acpi/fan.c b/trunk/drivers/acpi/fan.c index daed2460924d..38acc69b21bc 100644 --- a/trunk/drivers/acpi/fan.c +++ b/trunk/drivers/acpi/fan.c @@ -64,7 +64,7 @@ static struct acpi_driver acpi_fan_driver = { }; struct acpi_fan { - struct acpi_device * device; + acpi_handle handle; }; /* -------------------------------------------------------------------------- @@ -80,7 +80,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset) if (fan) { - if (acpi_bus_get_power(fan->device->handle, &state)) + if (acpi_bus_get_power(fan->handle, &state)) seq_printf(seq, "status: ERROR\n"); else seq_printf(seq, "status: %s\n", @@ -112,7 +112,7 @@ acpi_fan_write_state(struct file *file, const char __user * buffer, state_string[count] = '\0'; - result = acpi_bus_set_power(fan->device->handle, + result = acpi_bus_set_power(fan->handle, simple_strtoul(state_string, NULL, 0)); if (result) return result; @@ -191,12 +191,12 @@ static int acpi_fan_add(struct acpi_device *device) return -ENOMEM; memset(fan, 0, sizeof(struct acpi_fan)); - fan->device = device; + fan->handle = device->handle; strcpy(acpi_device_name(device), "Fan"); strcpy(acpi_device_class(device), ACPI_FAN_CLASS); acpi_driver_data(device) = fan; - result = acpi_bus_get_power(device->handle, &state); + result = acpi_bus_get_power(fan->handle, &state); if (result) { printk(KERN_ERR PREFIX "Reading power state\n"); goto end; diff --git a/trunk/drivers/acpi/pci_link.c b/trunk/drivers/acpi/pci_link.c index 8197c0e40769..1badce27a83f 100644 --- a/trunk/drivers/acpi/pci_link.c +++ b/trunk/drivers/acpi/pci_link.c @@ -83,6 +83,7 @@ struct acpi_pci_link_irq { struct acpi_pci_link { struct list_head node; struct acpi_device *device; + acpi_handle handle; struct acpi_pci_link_irq irq; int refcnt; }; @@ -174,7 +175,7 @@ static int acpi_pci_link_get_possible(struct acpi_pci_link *link) if (!link) return -EINVAL; - status = acpi_walk_resources(link->device->handle, METHOD_NAME__PRS, + status = acpi_walk_resources(link->handle, METHOD_NAME__PRS, acpi_pci_link_check_possible, link); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRS")); @@ -248,7 +249,8 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link) acpi_status status = AE_OK; int irq = 0; - if (!link) + + if (!link || !link->handle) return -EINVAL; link->irq.active = 0; @@ -272,7 +274,7 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link) * Query and parse _CRS to get the current IRQ assignment. */ - status = acpi_walk_resources(link->device->handle, METHOD_NAME__CRS, + status = acpi_walk_resources(link->handle, METHOD_NAME__CRS, acpi_pci_link_check_current, &irq); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Evaluating _CRS")); @@ -358,7 +360,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) resource->end.type = ACPI_RESOURCE_TYPE_END_TAG; /* Attempt to set the resource */ - status = acpi_set_current_resources(link->device->handle, &buffer); + status = acpi_set_current_resources(link->handle, &buffer); /* check for total failure */ if (ACPI_FAILURE(status)) { @@ -697,7 +699,7 @@ int acpi_pci_link_free_irq(acpi_handle handle) acpi_device_bid(link->device))); if (link->refcnt == 0) { - acpi_ut_evaluate_object(link->device->handle, "_DIS", 0, NULL); + acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); } mutex_unlock(&acpi_link_lock); return (link->irq.active); @@ -724,6 +726,7 @@ static int acpi_pci_link_add(struct acpi_device *device) memset(link, 0, sizeof(struct acpi_pci_link)); link->device = device; + link->handle = device->handle; strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS); acpi_driver_data(device) = link; @@ -762,7 +765,7 @@ static int acpi_pci_link_add(struct acpi_device *device) end: /* disable all links -- to be activated on use */ - acpi_ut_evaluate_object(device->handle, "_DIS", 0, NULL); + acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); mutex_unlock(&acpi_link_lock); if (result) diff --git a/trunk/drivers/acpi/pci_root.c b/trunk/drivers/acpi/pci_root.c index 0984a1ee24ed..8f10442119f0 100644 --- a/trunk/drivers/acpi/pci_root.c +++ b/trunk/drivers/acpi/pci_root.c @@ -58,7 +58,7 @@ static struct acpi_driver acpi_pci_root_driver = { struct acpi_pci_root { struct list_head node; - struct acpi_device * device; + acpi_handle handle; struct acpi_pci_id id; struct pci_bus *bus; }; @@ -83,7 +83,7 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver) list_for_each(entry, &acpi_pci_roots) { struct acpi_pci_root *root; root = list_entry(entry, struct acpi_pci_root, node); - driver->add(root->device->handle); + driver->add(root->handle); n++; } @@ -110,7 +110,7 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) list_for_each(entry, &acpi_pci_roots) { struct acpi_pci_root *root; root = list_entry(entry, struct acpi_pci_root, node); - driver->remove(root->device->handle); + driver->remove(root->handle); } } @@ -170,7 +170,7 @@ static int acpi_pci_root_add(struct acpi_device *device) memset(root, 0, sizeof(struct acpi_pci_root)); INIT_LIST_HEAD(&root->node); - root->device = device; + root->handle = device->handle; strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); acpi_driver_data(device) = root; @@ -185,7 +185,7 @@ static int acpi_pci_root_add(struct acpi_device *device) * ------- * Obtained via _SEG, if exists, otherwise assumed to be zero (0). */ - status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL, + status = acpi_evaluate_integer(root->handle, METHOD_NAME__SEG, NULL, &value); switch (status) { case AE_OK: @@ -207,7 +207,7 @@ static int acpi_pci_root_add(struct acpi_device *device) * --- * Obtained via _BBN, if exists, otherwise assumed to be zero (0). */ - status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, NULL, + status = acpi_evaluate_integer(root->handle, METHOD_NAME__BBN, NULL, &value); switch (status) { case AE_OK: @@ -234,7 +234,7 @@ static int acpi_pci_root_add(struct acpi_device *device) "Wrong _BBN value, reboot" " and use option 'pci=noacpi'\n"); - status = try_get_root_bridge_busnr(device->handle, &bus); + status = try_get_root_bridge_busnr(root->handle, &bus); if (ACPI_FAILURE(status)) break; if (bus != root->id.bus) { @@ -294,9 +294,9 @@ static int acpi_pci_root_add(struct acpi_device *device) * ----------------- * Evaluate and parse _PRT, if exists. */ - status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); + status = acpi_get_handle(root->handle, METHOD_NAME__PRT, &handle); if (ACPI_SUCCESS(status)) - result = acpi_pci_irq_add_prt(device->handle, root->id.segment, + result = acpi_pci_irq_add_prt(root->handle, root->id.segment, root->id.bus); end: @@ -315,7 +315,7 @@ static int acpi_pci_root_start(struct acpi_device *device) list_for_each_entry(root, &acpi_pci_roots, node) { - if (root->device == device) { + if (root->handle == device->handle) { pci_bus_add_devices(root->bus); return 0; } diff --git a/trunk/drivers/acpi/power.c b/trunk/drivers/acpi/power.c index 5d3447f4582c..224f729f700e 100644 --- a/trunk/drivers/acpi/power.c +++ b/trunk/drivers/acpi/power.c @@ -70,7 +70,7 @@ static struct acpi_driver acpi_power_driver = { }; struct acpi_power_resource { - struct acpi_device * device; + acpi_handle handle; acpi_bus_id name; u32 system_level; u32 order; @@ -124,7 +124,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource) if (!resource) return -EINVAL; - status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta); + status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) return -ENODEV; @@ -192,7 +192,7 @@ static int acpi_power_on(acpi_handle handle) return 0; } - status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); + status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL); if (ACPI_FAILURE(status)) return -ENODEV; @@ -203,8 +203,10 @@ static int acpi_power_on(acpi_handle handle) return -ENOEXEC; /* Update the power resource's _device_ power state */ - device = resource->device; - resource->device->power.state = ACPI_STATE_D0; + result = acpi_bus_get_device(resource->handle, &device); + if (result) + return result; + device->power.state = ACPI_STATE_D0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", resource->name)); @@ -240,7 +242,7 @@ static int acpi_power_off_device(acpi_handle handle) return 0; } - status = acpi_evaluate_object(resource->device->handle, "_OFF", NULL, NULL); + status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) return -ENODEV; @@ -251,7 +253,9 @@ static int acpi_power_off_device(acpi_handle handle) return -ENOEXEC; /* Update the power resource's _device_ power state */ - device = resource->device; + result = acpi_bus_get_device(resource->handle, &device); + if (result) + return result; device->power.state = ACPI_STATE_D3; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", @@ -540,14 +544,14 @@ static int acpi_power_add(struct acpi_device *device) return -ENOMEM; memset(resource, 0, sizeof(struct acpi_power_resource)); - resource->device = device; + resource->handle = device->handle; strcpy(resource->name, device->pnp.bus_id); strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_POWER_CLASS); acpi_driver_data(device) = resource; /* Evalute the object to get the system level and resource order. */ - status = acpi_evaluate_object(device->handle, NULL, NULL, &buffer); + status = acpi_evaluate_object(resource->handle, NULL, NULL, &buffer); if (ACPI_FAILURE(status)) { result = -ENODEV; goto end; diff --git a/trunk/drivers/acpi/thermal.c b/trunk/drivers/acpi/thermal.c index 503c0b99db12..c855f4446b5f 100644 --- a/trunk/drivers/acpi/thermal.c +++ b/trunk/drivers/acpi/thermal.c @@ -162,7 +162,7 @@ struct acpi_thermal_flags { }; struct acpi_thermal { - struct acpi_device * device; + acpi_handle handle; acpi_bus_id name; unsigned long temperature; unsigned long last_temperature; @@ -229,7 +229,7 @@ static int acpi_thermal_get_temperature(struct acpi_thermal *tz) tz->last_temperature = tz->temperature; status = - acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tz->temperature); + acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); if (ACPI_FAILURE(status)) return -ENODEV; @@ -248,7 +248,7 @@ static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) return -EINVAL; status = - acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, + acpi_evaluate_integer(tz->handle, "_TZP", NULL, &tz->polling_frequency); if (ACPI_FAILURE(status)) return -ENODEV; @@ -285,7 +285,7 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) if (!tz) return -EINVAL; - status = acpi_get_handle(tz->device->handle, "_SCP", &handle); + status = acpi_get_handle(tz->handle, "_SCP", &handle); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); return -ENODEV; @@ -316,7 +316,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) /* Critical Shutdown (required) */ - status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, + status = acpi_evaluate_integer(tz->handle, "_CRT", NULL, &tz->trips.critical.temperature); if (ACPI_FAILURE(status)) { tz->trips.critical.flags.valid = 0; @@ -332,7 +332,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) /* Critical Sleep (optional) */ status = - acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, + acpi_evaluate_integer(tz->handle, "_HOT", NULL, &tz->trips.hot.temperature); if (ACPI_FAILURE(status)) { tz->trips.hot.flags.valid = 0; @@ -346,7 +346,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) /* Passive: Processors (optional) */ status = - acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, + acpi_evaluate_integer(tz->handle, "_PSV", NULL, &tz->trips.passive.temperature); if (ACPI_FAILURE(status)) { tz->trips.passive.flags.valid = 0; @@ -355,25 +355,25 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) tz->trips.passive.flags.valid = 1; status = - acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, + acpi_evaluate_integer(tz->handle, "_TC1", NULL, &tz->trips.passive.tc1); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; status = - acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, + acpi_evaluate_integer(tz->handle, "_TC2", NULL, &tz->trips.passive.tc2); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; status = - acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, + acpi_evaluate_integer(tz->handle, "_TSP", NULL, &tz->trips.passive.tsp); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; status = - acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, + acpi_evaluate_reference(tz->handle, "_PSL", NULL, &tz->trips.passive.devices); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; @@ -393,14 +393,14 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; status = - acpi_evaluate_integer(tz->device->handle, name, NULL, + acpi_evaluate_integer(tz->handle, name, NULL, &tz->trips.active[i].temperature); if (ACPI_FAILURE(status)) break; name[2] = 'L'; status = - acpi_evaluate_reference(tz->device->handle, name, NULL, + acpi_evaluate_reference(tz->handle, name, NULL, &tz->trips.active[i].devices); if (ACPI_SUCCESS(status)) { tz->trips.active[i].flags.valid = 1; @@ -424,7 +424,7 @@ static int acpi_thermal_get_devices(struct acpi_thermal *tz) return -EINVAL; status = - acpi_evaluate_reference(tz->device->handle, "_TZD", NULL, &tz->devices); + acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); if (ACPI_FAILURE(status)) return -ENODEV; @@ -453,6 +453,10 @@ static int acpi_thermal_call_usermode(char *path) static int acpi_thermal_critical(struct acpi_thermal *tz) { + int result = 0; + struct acpi_device *device = NULL; + + if (!tz || !tz->trips.critical.flags.valid) return -EINVAL; @@ -462,10 +466,14 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) } else if (tz->trips.critical.flags.enabled) tz->trips.critical.flags.enabled = 0; + result = acpi_bus_get_device(tz->handle, &device); + if (result) + return result; + printk(KERN_EMERG "Critical temperature reached (%ld C), shutting down.\n", KELVIN_TO_CELSIUS(tz->temperature)); - acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, + acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); @@ -475,6 +483,10 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) static int acpi_thermal_hot(struct acpi_thermal *tz) { + int result = 0; + struct acpi_device *device = NULL; + + if (!tz || !tz->trips.hot.flags.valid) return -EINVAL; @@ -484,7 +496,11 @@ static int acpi_thermal_hot(struct acpi_thermal *tz) } else if (tz->trips.hot.flags.enabled) tz->trips.hot.flags.enabled = 0; - acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, + result = acpi_bus_get_device(tz->handle, &device); + if (result) + return result; + + acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); /* TBD: Call user-mode "sleep(S4)" function */ @@ -1177,7 +1193,8 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) if (!tz) return; - device = tz->device; + if (acpi_bus_get_device(tz->handle, &device)) + return; switch (event) { case ACPI_THERMAL_NOTIFY_TEMPERATURE: @@ -1276,7 +1293,7 @@ static int acpi_thermal_add(struct acpi_device *device) return -ENOMEM; memset(tz, 0, sizeof(struct acpi_thermal)); - tz->device = device; + tz->handle = device->handle; strcpy(tz->name, device->pnp.bus_id); strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); @@ -1294,7 +1311,7 @@ static int acpi_thermal_add(struct acpi_device *device) acpi_thermal_check(tz); - status = acpi_install_notify_handler(device->handle, + status = acpi_install_notify_handler(tz->handle, ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz); if (ACPI_FAILURE(status)) { @@ -1335,7 +1352,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) /* deferred task may reinsert timer */ del_timer_sync(&(tz->timer)); - status = acpi_remove_notify_handler(device->handle, + status = acpi_remove_notify_handler(tz->handle, ACPI_DEVICE_NOTIFY, acpi_thermal_notify); diff --git a/trunk/drivers/acpi/video.c b/trunk/drivers/acpi/video.c index 56666a982476..1f3ffb353299 100644 --- a/trunk/drivers/acpi/video.c +++ b/trunk/drivers/acpi/video.c @@ -117,7 +117,7 @@ struct acpi_video_enumerated_device { }; struct acpi_video_bus { - struct acpi_device *device; + acpi_handle handle; u8 dos_setting; struct acpi_video_enumerated_device *attached_array; u8 attached_count; @@ -155,6 +155,7 @@ 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; @@ -271,8 +272,7 @@ static int acpi_video_device_query(struct acpi_video_device *device, unsigned long *state) { int status; - - status = acpi_evaluate_integer(device->dev->handle, "_DGS", NULL, state); + status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state); return status; } @@ -283,7 +283,8 @@ acpi_video_device_get_state(struct acpi_video_device *device, { int status; - status = acpi_evaluate_integer(device->dev->handle, "_DCS", NULL, state); + + status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state); return status; } @@ -298,7 +299,7 @@ acpi_video_device_set_state(struct acpi_video_device *device, int state) arg0.integer.value = state; - status = acpi_evaluate_integer(device->dev->handle, "_DSS", &args, &ret); + status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret); return status; } @@ -314,7 +315,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, *levels = NULL; - status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer); + status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer); if (!ACPI_SUCCESS(status)) return status; obj = (union acpi_object *)buffer.pointer; @@ -343,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->dev->handle, "_BCM", &args, NULL); + status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL); printk(KERN_DEBUG "set_level status: %x\n", status); return status; @@ -355,7 +356,7 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, { int status; - status = acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, level); + status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level); return status; } @@ -382,7 +383,7 @@ acpi_video_device_EDID(struct acpi_video_device *device, else return -EINVAL; - status = acpi_evaluate_object(device->dev->handle, "_DDC", &args, &buffer); + status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer); if (ACPI_FAILURE(status)) return -ENODEV; @@ -412,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->device->handle, "_SPD", &args, &tmp); + status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp); if (ACPI_SUCCESS(status)) status = tmp ? (-EINVAL) : (AE_OK); @@ -424,7 +425,8 @@ acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id) { int status; - status = acpi_evaluate_integer(video->device->handle, "_GPD", NULL, id); + + status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id); return status; } @@ -435,7 +437,7 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video, { int status; - status = acpi_evaluate_integer(video->device->handle, "_VPO", NULL, options); + status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options); *options &= 3; return status; @@ -476,7 +478,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->device->handle, "_DOS", &args, NULL); + acpi_evaluate_object(video->handle, "_DOS", &args, NULL); Failed: return status; @@ -504,25 +506,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->dev->handle, "_ADR", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) { device->cap._ADR = 1; } - if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCL", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) { device->cap._BCL = 1; } - if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) { device->cap._BCM = 1; } - if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) { device->cap._DDC = 1; } - if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DCS", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) { device->cap._DCS = 1; } - if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DGS", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) { device->cap._DGS = 1; } - if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DSS", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) { device->cap._DSS = 1; } @@ -586,22 +588,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->device->handle, "_DOS", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) { video->cap._DOS = 1; } - if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOD", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) { video->cap._DOD = 1; } - if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_ROM", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) { video->cap._ROM = 1; } - if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_GPD", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) { video->cap._GPD = 1; } - if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_SPD", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) { video->cap._SPD = 1; } - if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_VPO", &h_dummy1))) { + if (ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) { video->cap._VPO = 1; } } @@ -1269,6 +1271,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device, 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; @@ -1295,7 +1298,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(device->handle, + status = acpi_install_notify_handler(data->handle, ACPI_DEVICE_NOTIFY, acpi_video_device_notify, data); @@ -1397,7 +1400,8 @@ 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->device->handle, "_DOD", NULL, &buffer); + + status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer); if (!ACPI_SUCCESS(status)) { ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD")); return status; @@ -1565,7 +1569,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->dev->handle, + status = acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_video_device_notify); @@ -1620,7 +1624,8 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) if (!video) return; - device = video->device; + if (acpi_bus_get_device(handle, &device)) + return; switch (event) { case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur, @@ -1663,7 +1668,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) if (!video_device) return; - device = video_device->dev; + if (acpi_bus_get_device(handle, &device)) + return; switch (event) { case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ @@ -1701,7 +1707,7 @@ static int acpi_video_bus_add(struct acpi_device *device) return -ENOMEM; memset(video, 0, sizeof(struct acpi_video_bus)); - video->device = device; + video->handle = device->handle; strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); acpi_driver_data(device) = video; @@ -1721,7 +1727,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(device->handle, + status = acpi_install_notify_handler(video->handle, ACPI_DEVICE_NOTIFY, acpi_video_bus_notify, video); if (ACPI_FAILURE(status)) { @@ -1761,7 +1767,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type) acpi_video_bus_stop_devices(video); - status = acpi_remove_notify_handler(video->device->handle, + status = acpi_remove_notify_handler(video->handle, ACPI_DEVICE_NOTIFY, acpi_video_bus_notify);