Merge master.kernel.org:/pub/scm/linux/kernel/git/lenb/to-linus

+635 -310
+3 -2
drivers/acpi/Kconfig
··· 133 133 depends on ACPI_INTERPRETER 134 134 depends on EXPERIMENTAL 135 135 depends on !IA64_SGI_SN 136 - default m 136 + default n 137 137 help 138 - ACPI generic hotkey 138 + Experimental consolidated hotkey driver. 139 + If you are unsure, say N. 139 140 140 141 config ACPI_FAN 141 142 tristate "Fan"
+205 -1
drivers/acpi/button.c
··· 26 26 #include <linux/kernel.h> 27 27 #include <linux/module.h> 28 28 #include <linux/init.h> 29 + #include <linux/types.h> 30 + #include <linux/proc_fs.h> 31 + #include <linux/seq_file.h> 29 32 #include <acpi/acpi_bus.h> 30 33 #include <acpi/acpi_drivers.h> 31 34 ··· 36 33 #define ACPI_BUTTON_COMPONENT 0x00080000 37 34 #define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" 38 35 #define ACPI_BUTTON_CLASS "button" 36 + #define ACPI_BUTTON_FILE_INFO "info" 37 + #define ACPI_BUTTON_FILE_STATE "state" 38 + #define ACPI_BUTTON_TYPE_UNKNOWN 0x00 39 39 #define ACPI_BUTTON_NOTIFY_STATUS 0x80 40 40 41 41 #define ACPI_BUTTON_SUBCLASS_POWER "power" ··· 70 64 71 65 static int acpi_button_add (struct acpi_device *device); 72 66 static int acpi_button_remove (struct acpi_device *device, int type); 67 + static int acpi_button_info_open_fs(struct inode *inode, struct file *file); 68 + static int acpi_button_state_open_fs(struct inode *inode, struct file *file); 73 69 74 70 static struct acpi_driver acpi_button_driver = { 75 71 .name = ACPI_BUTTON_DRIVER_NAME, ··· 89 81 u8 type; 90 82 unsigned long pushed; 91 83 }; 84 + 85 + static struct file_operations acpi_button_info_fops = { 86 + .open = acpi_button_info_open_fs, 87 + .read = seq_read, 88 + .llseek = seq_lseek, 89 + .release = single_release, 90 + }; 91 + 92 + static struct file_operations acpi_button_state_fops = { 93 + .open = acpi_button_state_open_fs, 94 + .read = seq_read, 95 + .llseek = seq_lseek, 96 + .release = single_release, 97 + }; 98 + /* -------------------------------------------------------------------------- 99 + FS Interface (/proc) 100 + -------------------------------------------------------------------------- */ 101 + 102 + static struct proc_dir_entry *acpi_button_dir; 103 + 104 + static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) 105 + { 106 + struct acpi_button *button = (struct acpi_button *) seq->private; 107 + 108 + ACPI_FUNCTION_TRACE("acpi_button_info_seq_show"); 109 + 110 + if (!button || !button->device) 111 + return_VALUE(0); 112 + 113 + seq_printf(seq, "type: %s\n", 114 + acpi_device_name(button->device)); 115 + 116 + return_VALUE(0); 117 + } 118 + 119 + static int acpi_button_info_open_fs(struct inode *inode, struct file *file) 120 + { 121 + return single_open(file, acpi_button_info_seq_show, PDE(inode)->data); 122 + } 123 + 124 + static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) 125 + { 126 + struct acpi_button *button = (struct acpi_button *) seq->private; 127 + acpi_status status; 128 + unsigned long state; 129 + 130 + ACPI_FUNCTION_TRACE("acpi_button_state_seq_show"); 131 + 132 + if (!button || !button->device) 133 + return_VALUE(0); 134 + 135 + status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state); 136 + if (ACPI_FAILURE(status)) { 137 + seq_printf(seq, "state: unsupported\n"); 138 + } 139 + else{ 140 + seq_printf(seq, "state: %s\n", (state ? "open" : "closed")); 141 + } 142 + 143 + return_VALUE(0); 144 + } 145 + 146 + static int acpi_button_state_open_fs(struct inode *inode, struct file *file) 147 + { 148 + return single_open(file, acpi_button_state_seq_show, PDE(inode)->data); 149 + } 150 + 151 + static struct proc_dir_entry *acpi_power_dir; 152 + static struct proc_dir_entry *acpi_sleep_dir; 153 + static struct proc_dir_entry *acpi_lid_dir; 154 + 155 + static int 156 + acpi_button_add_fs ( 157 + struct acpi_device *device) 158 + { 159 + struct proc_dir_entry *entry = NULL; 160 + struct acpi_button *button = NULL; 161 + 162 + ACPI_FUNCTION_TRACE("acpi_button_add_fs"); 163 + 164 + if (!device || !acpi_driver_data(device)) 165 + return_VALUE(-EINVAL); 166 + 167 + button = acpi_driver_data(device); 168 + 169 + switch (button->type) { 170 + case ACPI_BUTTON_TYPE_POWER: 171 + case ACPI_BUTTON_TYPE_POWERF: 172 + if (!acpi_power_dir) 173 + acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, 174 + acpi_button_dir); 175 + entry = acpi_power_dir; 176 + break; 177 + case ACPI_BUTTON_TYPE_SLEEP: 178 + case ACPI_BUTTON_TYPE_SLEEPF: 179 + if (!acpi_sleep_dir) 180 + acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, 181 + acpi_button_dir); 182 + entry = acpi_sleep_dir; 183 + break; 184 + case ACPI_BUTTON_TYPE_LID: 185 + if (!acpi_lid_dir) 186 + acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, 187 + acpi_button_dir); 188 + entry = acpi_lid_dir; 189 + break; 190 + } 191 + 192 + if (!entry) 193 + return_VALUE(-ENODEV); 194 + entry->owner = THIS_MODULE; 195 + 196 + acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); 197 + if (!acpi_device_dir(device)) 198 + return_VALUE(-ENODEV); 199 + acpi_device_dir(device)->owner = THIS_MODULE; 200 + 201 + /* 'info' [R] */ 202 + entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, 203 + S_IRUGO, acpi_device_dir(device)); 204 + if (!entry) 205 + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 206 + "Unable to create '%s' fs entry\n", 207 + ACPI_BUTTON_FILE_INFO)); 208 + else { 209 + entry->proc_fops = &acpi_button_info_fops; 210 + entry->data = acpi_driver_data(device); 211 + entry->owner = THIS_MODULE; 212 + } 213 + 214 + /* show lid state [R] */ 215 + if (button->type == ACPI_BUTTON_TYPE_LID) { 216 + entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, 217 + S_IRUGO, acpi_device_dir(device)); 218 + if (!entry) 219 + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 220 + "Unable to create '%s' fs entry\n", 221 + ACPI_BUTTON_FILE_INFO)); 222 + else { 223 + entry->proc_fops = &acpi_button_state_fops; 224 + entry->data = acpi_driver_data(device); 225 + entry->owner = THIS_MODULE; 226 + } 227 + } 228 + 229 + return_VALUE(0); 230 + } 231 + 232 + 233 + static int 234 + acpi_button_remove_fs ( 235 + struct acpi_device *device) 236 + { 237 + struct acpi_button *button = NULL; 238 + 239 + ACPI_FUNCTION_TRACE("acpi_button_remove_fs"); 240 + 241 + button = acpi_driver_data(device); 242 + if (acpi_device_dir(device)) { 243 + if (button->type == ACPI_BUTTON_TYPE_LID) 244 + remove_proc_entry(ACPI_BUTTON_FILE_STATE, 245 + acpi_device_dir(device)); 246 + remove_proc_entry(ACPI_BUTTON_FILE_INFO, 247 + acpi_device_dir(device)); 248 + 249 + remove_proc_entry(acpi_device_bid(device), 250 + acpi_device_dir(device)->parent); 251 + acpi_device_dir(device) = NULL; 252 + } 253 + 254 + return_VALUE(0); 255 + } 256 + 92 257 93 258 /* -------------------------------------------------------------------------- 94 259 Driver Interface ··· 302 121 303 122 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); 304 123 305 - BUG_ON(!button); 124 + if (!button) 125 + return_ACPI_STATUS(AE_BAD_PARAMETER); 306 126 307 127 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); 308 128 ··· 379 197 goto end; 380 198 } 381 199 200 + result = acpi_button_add_fs(device); 201 + if (result) 202 + goto end; 203 + 382 204 switch (button->type) { 383 205 case ACPI_BUTTON_TYPE_POWERF: 384 206 status = acpi_install_fixed_event_handler ( ··· 426 240 427 241 end: 428 242 if (result) { 243 + acpi_button_remove_fs(device); 429 244 kfree(button); 430 245 } 431 246 ··· 467 280 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 468 281 "Error removing notify handler\n")); 469 282 283 + acpi_button_remove_fs(device); 284 + 470 285 kfree(button); 471 286 472 287 return_VALUE(0); ··· 482 293 483 294 ACPI_FUNCTION_TRACE("acpi_button_init"); 484 295 296 + acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); 297 + if (!acpi_button_dir) 298 + return_VALUE(-ENODEV); 299 + acpi_button_dir->owner = THIS_MODULE; 485 300 result = acpi_bus_register_driver(&acpi_button_driver); 486 301 if (result < 0) { 302 + remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 487 303 return_VALUE(-ENODEV); 488 304 } 489 305 490 306 return_VALUE(0); 491 307 } 308 + 492 309 493 310 static void __exit 494 311 acpi_button_exit (void) ··· 503 308 504 309 acpi_bus_unregister_driver(&acpi_button_driver); 505 310 311 + if (acpi_power_dir) 312 + remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir); 313 + if (acpi_sleep_dir) 314 + remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir); 315 + if (acpi_lid_dir) 316 + remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); 317 + remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 318 + 506 319 return_VOID; 507 320 } 321 + 508 322 509 323 module_init(acpi_button_init); 510 324 module_exit(acpi_button_exit);
+19 -5
drivers/acpi/ec.c
··· 76 76 static int acpi_ec_start (struct acpi_device *device); 77 77 static int acpi_ec_stop (struct acpi_device *device, int type); 78 78 static int acpi_ec_burst_add ( struct acpi_device *device); 79 + static int acpi_ec_polling_add ( struct acpi_device *device); 79 80 80 81 static struct acpi_driver acpi_ec_driver = { 81 82 .name = ACPI_EC_DRIVER_NAME, 82 83 .class = ACPI_EC_CLASS, 83 84 .ids = ACPI_EC_HID, 84 85 .ops = { 85 - .add = acpi_ec_burst_add, 86 + .add = acpi_ec_polling_add, 86 87 .remove = acpi_ec_remove, 87 88 .start = acpi_ec_start, 88 89 .stop = acpi_ec_stop, ··· 165 164 166 165 /* External interfaces use first EC only, so remember */ 167 166 static struct acpi_device *first_ec; 168 - static int acpi_ec_polling_mode; 167 + static int acpi_ec_polling_mode = EC_POLLING; 169 168 170 169 /* -------------------------------------------------------------------------- 171 170 Transaction Management ··· 1711 1710 acpi_fake_ecdt_enabled = 1; 1712 1711 return 0; 1713 1712 } 1713 + 1714 1714 __setup("acpi_fake_ecdt", acpi_fake_ecdt_setup); 1715 1715 static int __init acpi_ec_set_polling_mode(char *str) 1716 1716 { 1717 - acpi_ec_polling_mode = EC_POLLING; 1718 - acpi_ec_driver.ops.add = acpi_ec_polling_add; 1717 + int burst; 1718 + 1719 + if (!get_option(&str, &burst)) 1720 + return 0; 1721 + 1722 + if (burst) { 1723 + acpi_ec_polling_mode = EC_BURST; 1724 + acpi_ec_driver.ops.add = acpi_ec_burst_add; 1725 + } else { 1726 + acpi_ec_polling_mode = EC_POLLING; 1727 + acpi_ec_driver.ops.add = acpi_ec_polling_add; 1728 + } 1729 + printk(KERN_INFO PREFIX "EC %s mode.\n", 1730 + burst ? "burst": "polling"); 1719 1731 return 0; 1720 1732 } 1721 - __setup("ec_polling", acpi_ec_set_polling_mode); 1733 + __setup("ec_burst=", acpi_ec_set_polling_mode);
+394 -298
drivers/acpi/hotkey.c
··· 1 - /* 2 - * hotkey.c - ACPI Hotkey Driver ($Revision:$) 1 + /* 2 + * hotkey.c - ACPI Hotkey Driver ($Revision: 0.2 $) 3 3 * 4 4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> 5 5 * ··· 51 51 #define ACPI_HOTKEY_POLLING 0x2 52 52 #define ACPI_UNDEFINED_EVENT 0xf 53 53 54 - #define MAX_CONFIG_RECORD_LEN 80 55 - #define MAX_NAME_PATH_LEN 80 56 - #define MAX_CALL_PARM 80 54 + #define RESULT_STR_LEN 80 57 55 58 - #define IS_EVENT(e) 0xff /* ((e) & 0x40000000) */ 59 - #define IS_POLL(e) 0xff /* (~((e) & 0x40000000)) */ 56 + #define ACTION_METHOD 0 57 + #define POLL_METHOD 1 60 58 59 + #define IS_EVENT(e) ((e) <= 10000 && (e) >0) 60 + #define IS_POLL(e) ((e) > 10000) 61 + #define IS_OTHERS(e) ((e)<=0 || (e)>=20000) 61 62 #define _COMPONENT ACPI_HOTKEY_COMPONENT 62 63 ACPI_MODULE_NAME("acpi_hotkey") 63 64 64 - MODULE_AUTHOR("luming.yu@intel.com"); 65 + MODULE_AUTHOR("luming.yu@intel.com"); 65 66 MODULE_DESCRIPTION(ACPI_HOTK_NAME); 66 67 MODULE_LICENSE("GPL"); 67 68 ··· 115 114 char *action_method; /* action method */ 116 115 }; 117 116 118 - /* 117 + /* 119 118 * There are two ways to poll status 120 119 * 1. directy call read_xxx method, without any arguments passed in 121 120 * 2. call write_xxx method, with arguments passed in, you need ··· 132 131 char *poll_method; /* poll method */ 133 132 acpi_handle action_handle; /* acpi handle attached action method */ 134 133 char *action_method; /* action method */ 135 - void *poll_result; /* polling_result */ 134 + union acpi_object *poll_result; /* polling_result */ 136 135 struct proc_dir_entry *proc; 137 136 }; 138 137 ··· 163 162 }, 164 163 }; 165 164 165 + static void free_hotkey_device(union acpi_hotkey *key); 166 + static void free_hotkey_buffer(union acpi_hotkey *key); 167 + static void free_poll_hotkey_buffer(union acpi_hotkey *key); 166 168 static int hotkey_open_config(struct inode *inode, struct file *file); 169 + static int hotkey_poll_open_config(struct inode *inode, struct file *file); 167 170 static ssize_t hotkey_write_config(struct file *file, 168 171 const char __user * buffer, 169 172 size_t count, loff_t * data); 170 - static ssize_t hotkey_write_poll_config(struct file *file, 171 - const char __user * buffer, 172 - size_t count, loff_t * data); 173 173 static int hotkey_info_open_fs(struct inode *inode, struct file *file); 174 174 static int hotkey_action_open_fs(struct inode *inode, struct file *file); 175 175 static ssize_t hotkey_execute_aml_method(struct file *file, 176 176 const char __user * buffer, 177 177 size_t count, loff_t * data); 178 178 static int hotkey_config_seq_show(struct seq_file *seq, void *offset); 179 + static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset); 179 180 static int hotkey_polling_open_fs(struct inode *inode, struct file *file); 181 + static union acpi_hotkey *get_hotkey_by_event(struct 182 + acpi_hotkey_list 183 + *hotkey_list, int event); 180 184 181 185 /* event based config */ 182 186 static struct file_operations hotkey_config_fops = { ··· 194 188 195 189 /* polling based config */ 196 190 static struct file_operations hotkey_poll_config_fops = { 197 - .open = hotkey_open_config, 191 + .open = hotkey_poll_open_config, 198 192 .read = seq_read, 199 - .write = hotkey_write_poll_config, 193 + .write = hotkey_write_config, 200 194 .llseek = seq_lseek, 201 195 .release = single_release, 202 196 }; ··· 233 227 { 234 228 ACPI_FUNCTION_TRACE("hotkey_info_seq_show"); 235 229 236 - seq_printf(seq, "Hotkey generic driver ver: %s", HOTKEY_ACPI_VERSION); 230 + seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION); 237 231 238 232 return_VALUE(0); 239 233 } ··· 245 239 246 240 static char *format_result(union acpi_object *object) 247 241 { 248 - char *buf = (char *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 249 - 250 - memset(buf, 0, sizeof(union acpi_object)); 242 + char *buf = NULL; 243 + 244 + buf = (char *)kmalloc(RESULT_STR_LEN, GFP_KERNEL); 245 + if (buf) 246 + memset(buf, 0, RESULT_STR_LEN); 247 + else 248 + goto do_fail; 251 249 252 250 /* Now, just support integer type */ 253 251 if (object->type == ACPI_TYPE_INTEGER) 254 - sprintf(buf, "%d", (u32) object->integer.value); 255 - 256 - return buf; 252 + sprintf(buf, "%d\n", (u32) object->integer.value); 253 + do_fail: 254 + return (buf); 257 255 } 258 256 259 257 static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) 260 258 { 261 259 struct acpi_polling_hotkey *poll_hotkey = 262 260 (struct acpi_polling_hotkey *)seq->private; 261 + char *buf; 263 262 264 263 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show"); 265 264 266 - if (poll_hotkey->poll_result) 267 - seq_printf(seq, "%s", format_result(poll_hotkey->poll_result)); 268 - 265 + if (poll_hotkey->poll_result){ 266 + buf = format_result(poll_hotkey->poll_result); 267 + if(buf) 268 + seq_printf(seq, "%s", buf); 269 + kfree(buf); 270 + } 269 271 return_VALUE(0); 270 272 } 271 273 ··· 290 276 /* Mapping external hotkey number to standardized hotkey event num */ 291 277 static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list) 292 278 { 293 - struct list_head *entries, *next; 294 - int val = 0; 279 + struct list_head *entries; 280 + int val = -1; 295 281 296 282 ACPI_FUNCTION_TRACE("hotkey_get_internal_event"); 297 283 298 - list_for_each_safe(entries, next, list->entries) { 284 + list_for_each(entries, list->entries) { 299 285 union acpi_hotkey *key = 300 286 container_of(entries, union acpi_hotkey, entries); 301 287 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT 302 - && key->event_hotkey.external_hotkey_num == event) 288 + && key->event_hotkey.external_hotkey_num == event){ 303 289 val = key->link.hotkey_standard_num; 304 - else 305 - val = -1; 290 + break; 291 + } 306 292 } 307 293 308 294 return_VALUE(val); ··· 320 306 return_VOID; 321 307 322 308 internal_event = hotkey_get_internal_event(event, &global_hotkey_list); 323 - acpi_bus_generate_event(device, event, 0); 309 + acpi_bus_generate_event(device, internal_event, 0); 324 310 325 311 return_VOID; 326 312 } ··· 343 329 static int create_polling_proc(union acpi_hotkey *device) 344 330 { 345 331 struct proc_dir_entry *proc; 332 + char proc_name[80]; 346 333 mode_t mode; 347 334 348 335 ACPI_FUNCTION_TRACE("create_polling_proc"); 349 336 mode = S_IFREG | S_IRUGO | S_IWUGO; 350 337 351 - proc = create_proc_entry(device->poll_hotkey.action_method, 352 - mode, hotkey_proc_dir); 338 + sprintf(proc_name, "%d", device->link.hotkey_standard_num); 339 + /* 340 + strcat(proc_name, device->poll_hotkey.poll_method); 341 + */ 342 + proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); 353 343 354 344 if (!proc) { 355 345 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, ··· 371 353 return_VALUE(0); 372 354 } 373 355 374 - static int is_valid_acpi_path(const char *pathname) 375 - { 376 - acpi_handle handle; 377 - acpi_status status; 378 - ACPI_FUNCTION_TRACE("is_valid_acpi_path"); 379 - 380 - status = acpi_get_handle(NULL, (char *)pathname, &handle); 381 - return_VALUE(!ACPI_FAILURE(status)); 382 - } 383 - 384 - static int is_valid_hotkey(union acpi_hotkey *device) 385 - { 386 - ACPI_FUNCTION_TRACE("is_valid_hotkey"); 387 - /* Implement valid check */ 388 - return_VALUE(1); 389 - } 390 - 391 356 static int hotkey_add(union acpi_hotkey *device) 392 357 { 393 358 int status = 0; ··· 379 378 ACPI_FUNCTION_TRACE("hotkey_add"); 380 379 381 380 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) { 382 - status = 383 - acpi_bus_get_device(device->event_hotkey.bus_handle, &dev); 384 - if (status) 385 - return_VALUE(status); 386 - 381 + acpi_bus_get_device(device->event_hotkey.bus_handle, &dev); 387 382 status = acpi_install_notify_handler(dev->handle, 388 - ACPI_SYSTEM_NOTIFY, 383 + ACPI_DEVICE_NOTIFY, 389 384 acpi_hotkey_notify_handler, 390 - device); 385 + dev); 391 386 } else /* Add polling hotkey */ 392 387 create_polling_proc(device); 393 388 ··· 406 409 if (key->link.hotkey_standard_num == 407 410 device->link.hotkey_standard_num) { 408 411 list_del(&key->link.entries); 409 - remove_proc_entry(key->poll_hotkey.action_method, 410 - hotkey_proc_dir); 412 + free_hotkey_device(key); 411 413 global_hotkey_list.count--; 412 414 break; 413 415 } 414 416 } 417 + kfree(device); 415 418 return_VALUE(0); 416 419 } 417 420 418 - static void hotkey_update(union acpi_hotkey *key) 421 + static int hotkey_update(union acpi_hotkey *key) 419 422 { 420 - struct list_head *entries, *next; 423 + struct list_head *entries; 421 424 422 425 ACPI_FUNCTION_TRACE("hotkey_update"); 423 426 424 - list_for_each_safe(entries, next, global_hotkey_list.entries) { 425 - union acpi_hotkey *key = 427 + list_for_each(entries, global_hotkey_list.entries) { 428 + union acpi_hotkey *tmp= 426 429 container_of(entries, union acpi_hotkey, entries); 427 - if (key->link.hotkey_standard_num == 430 + if (tmp->link.hotkey_standard_num == 428 431 key->link.hotkey_standard_num) { 429 - key->event_hotkey.bus_handle = 430 - key->event_hotkey.bus_handle; 431 - key->event_hotkey.external_hotkey_num = 432 - key->event_hotkey.external_hotkey_num; 433 - key->event_hotkey.action_handle = 434 - key->event_hotkey.action_handle; 435 - key->event_hotkey.action_method = 436 - key->event_hotkey.action_method; 432 + if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { 433 + free_hotkey_buffer(tmp); 434 + tmp->event_hotkey.bus_handle = 435 + key->event_hotkey.bus_handle; 436 + tmp->event_hotkey.external_hotkey_num = 437 + key->event_hotkey.external_hotkey_num; 438 + tmp->event_hotkey.action_handle = 439 + key->event_hotkey.action_handle; 440 + tmp->event_hotkey.action_method = 441 + key->event_hotkey.action_method; 442 + kfree(key); 443 + } else { 444 + /* 445 + char proc_name[80]; 446 + 447 + sprintf(proc_name, "%d", tmp->link.hotkey_standard_num); 448 + strcat(proc_name, tmp->poll_hotkey.poll_method); 449 + remove_proc_entry(proc_name,hotkey_proc_dir); 450 + */ 451 + free_poll_hotkey_buffer(tmp); 452 + tmp->poll_hotkey.poll_handle = 453 + key->poll_hotkey.poll_handle; 454 + tmp->poll_hotkey.poll_method = 455 + key->poll_hotkey.poll_method; 456 + tmp->poll_hotkey.action_handle = 457 + key->poll_hotkey.action_handle; 458 + tmp->poll_hotkey.action_method = 459 + key->poll_hotkey.action_method; 460 + tmp->poll_hotkey.poll_result = 461 + key->poll_hotkey.poll_result; 462 + /* 463 + create_polling_proc(tmp); 464 + */ 465 + kfree(key); 466 + } 467 + return_VALUE(0); 437 468 break; 438 469 } 439 470 } 440 471 441 - return_VOID; 472 + return_VALUE(-ENODEV); 442 473 } 443 474 444 475 static void free_hotkey_device(union acpi_hotkey *key) 445 476 { 446 477 struct acpi_device *dev; 447 - int status; 448 478 449 479 ACPI_FUNCTION_TRACE("free_hotkey_device"); 450 480 451 481 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { 452 - status = 453 - acpi_bus_get_device(key->event_hotkey.bus_handle, &dev); 482 + acpi_bus_get_device(key->event_hotkey.bus_handle, &dev); 454 483 if (dev->handle) 455 484 acpi_remove_notify_handler(dev->handle, 456 - ACPI_SYSTEM_NOTIFY, 485 + ACPI_DEVICE_NOTIFY, 457 486 acpi_hotkey_notify_handler); 458 - } else 459 - remove_proc_entry(key->poll_hotkey.action_method, 460 - hotkey_proc_dir); 487 + free_hotkey_buffer(key); 488 + } else { 489 + char proc_name[80]; 490 + 491 + sprintf(proc_name, "%d", key->link.hotkey_standard_num); 492 + /* 493 + strcat(proc_name, key->poll_hotkey.poll_method); 494 + */ 495 + remove_proc_entry(proc_name,hotkey_proc_dir); 496 + free_poll_hotkey_buffer(key); 497 + } 461 498 kfree(key); 462 499 return_VOID; 463 500 } 464 501 502 + static void 503 + free_hotkey_buffer(union acpi_hotkey *key) 504 + { 505 + kfree(key->event_hotkey.action_method); 506 + } 507 + 508 + static void 509 + free_poll_hotkey_buffer(union acpi_hotkey *key) 510 + { 511 + kfree(key->poll_hotkey.action_method); 512 + kfree(key->poll_hotkey.poll_method); 513 + kfree(key->poll_hotkey.poll_result); 514 + } 465 515 static int 466 516 init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str, 467 517 char *method, int std_num, int external_num) 468 518 { 519 + acpi_handle tmp_handle; 520 + acpi_status status = AE_OK; 521 + 469 522 ACPI_FUNCTION_TRACE("init_hotkey_device"); 523 + 524 + if(std_num < 0 || IS_POLL(std_num) || !key ) 525 + goto do_fail; 526 + 527 + if(!bus_str || !action_str || !method) 528 + goto do_fail; 470 529 471 530 key->link.hotkey_type = ACPI_HOTKEY_EVENT; 472 531 key->link.hotkey_standard_num = std_num; 473 532 key->event_hotkey.flag = 0; 474 - if (is_valid_acpi_path(bus_str)) 475 - acpi_get_handle((acpi_handle) 0, 476 - bus_str, &(key->event_hotkey.bus_handle)); 477 - else 478 - return_VALUE(-ENODEV); 479 - key->event_hotkey.external_hotkey_num = external_num; 480 - if (is_valid_acpi_path(action_str)) 481 - acpi_get_handle((acpi_handle) 0, 482 - action_str, &(key->event_hotkey.action_handle)); 483 - key->event_hotkey.action_method = kmalloc(sizeof(method), GFP_KERNEL); 484 - strcpy(key->event_hotkey.action_method, method); 533 + key->event_hotkey.action_method = method; 485 534 486 - return_VALUE(!is_valid_hotkey(key)); 535 + status = acpi_get_handle(NULL,bus_str, &(key->event_hotkey.bus_handle)); 536 + if(ACPI_FAILURE(status)) 537 + goto do_fail; 538 + key->event_hotkey.external_hotkey_num = external_num; 539 + status = acpi_get_handle(NULL,action_str, &(key->event_hotkey.action_handle)); 540 + if(ACPI_FAILURE(status)) 541 + goto do_fail; 542 + status = acpi_get_handle(key->event_hotkey.action_handle, 543 + method, &tmp_handle); 544 + if (ACPI_FAILURE(status)) 545 + goto do_fail; 546 + return_VALUE(AE_OK); 547 + do_fail: 548 + return_VALUE(-ENODEV); 487 549 } 488 550 489 551 static int ··· 551 495 char *poll_method, 552 496 char *action_str, char *action_method, int std_num) 553 497 { 498 + acpi_status status = AE_OK; 499 + acpi_handle tmp_handle; 500 + 554 501 ACPI_FUNCTION_TRACE("init_poll_hotkey_device"); 502 + 503 + if(std_num < 0 || IS_EVENT(std_num) || !key) 504 + goto do_fail; 505 + 506 + if(!poll_str || !poll_method || !action_str || !action_method) 507 + goto do_fail; 555 508 556 509 key->link.hotkey_type = ACPI_HOTKEY_POLLING; 557 510 key->link.hotkey_standard_num = std_num; 558 511 key->poll_hotkey.flag = 0; 559 - if (is_valid_acpi_path(poll_str)) 560 - acpi_get_handle((acpi_handle) 0, 561 - poll_str, &(key->poll_hotkey.poll_handle)); 562 - else 563 - return_VALUE(-ENODEV); 564 512 key->poll_hotkey.poll_method = poll_method; 565 - if (is_valid_acpi_path(action_str)) 566 - acpi_get_handle((acpi_handle) 0, 567 - action_str, &(key->poll_hotkey.action_handle)); 568 - key->poll_hotkey.action_method = 569 - kmalloc(sizeof(action_method), GFP_KERNEL); 570 - strcpy(key->poll_hotkey.action_method, action_method); 513 + key->poll_hotkey.action_method = action_method; 514 + 515 + status = acpi_get_handle(NULL,poll_str, &(key->poll_hotkey.poll_handle)); 516 + if(ACPI_FAILURE(status)) 517 + goto do_fail; 518 + status = acpi_get_handle(key->poll_hotkey.poll_handle, 519 + poll_method, &tmp_handle); 520 + if (ACPI_FAILURE(status)) 521 + goto do_fail; 522 + status = acpi_get_handle(NULL,action_str, &(key->poll_hotkey.action_handle)); 523 + if (ACPI_FAILURE(status)) 524 + goto do_fail; 525 + status = acpi_get_handle(key->poll_hotkey.action_handle, 526 + action_method, &tmp_handle); 527 + if (ACPI_FAILURE(status)) 528 + goto do_fail; 571 529 key->poll_hotkey.poll_result = 572 530 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 573 - return_VALUE(is_valid_hotkey(key)); 531 + if(!key->poll_hotkey.poll_result) 532 + goto do_fail; 533 + return_VALUE(AE_OK); 534 + do_fail: 535 + return_VALUE(-ENODEV); 574 536 } 575 537 576 - static int check_hotkey_valid(union acpi_hotkey *key, 577 - struct acpi_hotkey_list *list) 578 - { 579 - ACPI_FUNCTION_TRACE("check_hotkey_valid"); 580 - return_VALUE(0); 581 - } 582 538 583 539 static int hotkey_open_config(struct inode *inode, struct file *file) 584 540 { ··· 599 531 (file, hotkey_config_seq_show, PDE(inode)->data)); 600 532 } 601 533 534 + static int hotkey_poll_open_config(struct inode *inode, struct file *file) 535 + { 536 + ACPI_FUNCTION_TRACE("hotkey_poll_open_config"); 537 + return_VALUE(single_open 538 + (file, hotkey_poll_config_seq_show, PDE(inode)->data)); 539 + } 540 + 602 541 static int hotkey_config_seq_show(struct seq_file *seq, void *offset) 603 542 { 604 543 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; 605 - struct list_head *entries, *next; 544 + struct list_head *entries; 606 545 char bus_name[ACPI_PATHNAME_MAX] = { 0 }; 607 546 char action_name[ACPI_PATHNAME_MAX] = { 0 }; 608 547 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; ··· 617 542 618 543 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show")); 619 544 620 - if (!hotkey_list) 621 - goto end; 622 - 623 - list_for_each_safe(entries, next, hotkey_list->entries) { 545 + list_for_each(entries, hotkey_list->entries) { 624 546 union acpi_hotkey *key = 625 547 container_of(entries, union acpi_hotkey, entries); 626 548 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { ··· 625 553 ACPI_NAME_TYPE_MAX, &bus); 626 554 acpi_get_name(key->event_hotkey.action_handle, 627 555 ACPI_NAME_TYPE_MAX, &act); 628 - seq_printf(seq, "%s:%s:%s:%d:%d", bus_name, 556 + seq_printf(seq, "%s:%s:%s:%d:%d\n", bus_name, 629 557 action_name, 630 558 key->event_hotkey.action_method, 631 559 key->link.hotkey_standard_num, 632 560 key->event_hotkey.external_hotkey_num); 633 - } /* ACPI_HOTKEY_POLLING */ 634 - else { 561 + } 562 + } 563 + seq_puts(seq, "\n"); 564 + return_VALUE(0); 565 + } 566 + 567 + static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) 568 + { 569 + struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; 570 + struct list_head *entries; 571 + char bus_name[ACPI_PATHNAME_MAX] = { 0 }; 572 + char action_name[ACPI_PATHNAME_MAX] = { 0 }; 573 + struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; 574 + struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; 575 + 576 + ACPI_FUNCTION_TRACE(("hotkey_config_seq_show")); 577 + 578 + list_for_each(entries, hotkey_list->entries) { 579 + union acpi_hotkey *key = 580 + container_of(entries, union acpi_hotkey, entries); 581 + if (key->link.hotkey_type == ACPI_HOTKEY_POLLING) { 635 582 acpi_get_name(key->poll_hotkey.poll_handle, 636 583 ACPI_NAME_TYPE_MAX, &bus); 637 584 acpi_get_name(key->poll_hotkey.action_handle, 638 585 ACPI_NAME_TYPE_MAX, &act); 639 - seq_printf(seq, "%s:%s:%s:%s:%d", bus_name, 586 + seq_printf(seq, "%s:%s:%s:%s:%d\n", bus_name, 640 587 key->poll_hotkey.poll_method, 641 588 action_name, 642 589 key->poll_hotkey.action_method, ··· 663 572 } 664 573 } 665 574 seq_puts(seq, "\n"); 666 - end: 667 575 return_VALUE(0); 668 576 } 669 577 670 578 static int 671 579 get_parms(char *config_record, 672 580 int *cmd, 673 - char *bus_handle, 674 - char *bus_method, 675 - char *action_handle, 676 - char *method, int *internal_event_num, int *external_event_num) 581 + char **bus_handle, 582 + char **bus_method, 583 + char **action_handle, 584 + char **method, int *internal_event_num, int *external_event_num) 677 585 { 678 - char *tmp, *tmp1; 586 + char *tmp, *tmp1, count; 679 587 ACPI_FUNCTION_TRACE(("get_parms")); 680 588 681 589 sscanf(config_record, "%d", cmd); 682 590 591 + if(*cmd == 1){ 592 + if(sscanf(config_record, "%d:%d", cmd, internal_event_num)!=2) 593 + goto do_fail; 594 + else 595 + return (6); 596 + } 683 597 tmp = strchr(config_record, ':'); 598 + if (!tmp) 599 + goto do_fail; 684 600 tmp++; 685 601 tmp1 = strchr(tmp, ':'); 686 - strncpy(bus_handle, tmp, tmp1 - tmp); 687 - bus_handle[tmp1 - tmp] = 0; 602 + if (!tmp1) 603 + goto do_fail; 604 + 605 + count = tmp1 - tmp; 606 + *bus_handle = (char *) kmalloc(count+1, GFP_KERNEL); 607 + if(!*bus_handle) 608 + goto do_fail; 609 + strncpy(*bus_handle, tmp, count); 610 + *(*bus_handle + count) = 0; 688 611 689 612 tmp = tmp1; 690 613 tmp++; 691 614 tmp1 = strchr(tmp, ':'); 692 - strncpy(bus_method, tmp, tmp1 - tmp); 693 - bus_method[tmp1 - tmp] = 0; 615 + if (!tmp1) 616 + goto do_fail; 617 + count = tmp1 - tmp; 618 + *bus_method = (char *) kmalloc(count+1, GFP_KERNEL); 619 + if(!*bus_method) 620 + goto do_fail; 621 + strncpy(*bus_method, tmp, count); 622 + *(*bus_method + count) = 0; 694 623 695 624 tmp = tmp1; 696 625 tmp++; 697 626 tmp1 = strchr(tmp, ':'); 698 - strncpy(action_handle, tmp, tmp1 - tmp); 699 - action_handle[tmp1 - tmp] = 0; 627 + if (!tmp1) 628 + goto do_fail; 629 + count = tmp1 - tmp; 630 + *action_handle = (char *) kmalloc(count+1, GFP_KERNEL); 631 + strncpy(*action_handle, tmp, count); 632 + *(*action_handle + count) = 0; 700 633 701 634 tmp = tmp1; 702 635 tmp++; 703 636 tmp1 = strchr(tmp, ':'); 704 - strncpy(method, tmp, tmp1 - tmp); 705 - method[tmp1 - tmp] = 0; 637 + if (!tmp1) 638 + goto do_fail; 639 + count = tmp1 - tmp; 640 + *method = (char *) kmalloc(count+1, GFP_KERNEL); 641 + if(!*method) 642 + goto do_fail; 643 + strncpy(*method, tmp, count); 644 + *(*method + count) = 0; 706 645 707 - sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num); 646 + if(sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num)<=0) 647 + goto do_fail; 648 + 708 649 return_VALUE(6); 650 + do_fail: 651 + return_VALUE(-1); 709 652 } 710 653 711 654 /* count is length for one input record */ ··· 747 622 const char __user * buffer, 748 623 size_t count, loff_t * data) 749 624 { 750 - struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; 751 - char config_record[MAX_CONFIG_RECORD_LEN]; 752 - char bus_handle[MAX_NAME_PATH_LEN]; 753 - char bus_method[MAX_NAME_PATH_LEN]; 754 - char action_handle[MAX_NAME_PATH_LEN]; 755 - char method[20]; 625 + char *config_record = NULL; 626 + char *bus_handle = NULL; 627 + char *bus_method = NULL; 628 + char *action_handle = NULL; 629 + char *method = NULL; 756 630 int cmd, internal_event_num, external_event_num; 757 631 int ret = 0; 758 632 union acpi_hotkey *key = NULL; 759 633 760 634 ACPI_FUNCTION_TRACE(("hotkey_write_config")); 761 635 762 - if (!hotkey_list || count > MAX_CONFIG_RECORD_LEN) { 763 - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid arguments\n")); 764 - return_VALUE(-EINVAL); 765 - } 636 + config_record = (char *) kmalloc(count+1, GFP_KERNEL); 637 + if(!config_record) 638 + return_VALUE(-ENOMEM); 766 639 767 640 if (copy_from_user(config_record, buffer, count)) { 641 + kfree(config_record); 768 642 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n")); 769 643 return_VALUE(-EINVAL); 770 644 } 771 - config_record[count] = '\0'; 645 + config_record[count] = 0; 772 646 773 647 ret = get_parms(config_record, 774 648 &cmd, 775 - bus_handle, 776 - bus_method, 777 - action_handle, 778 - method, &internal_event_num, &external_event_num); 649 + &bus_handle, 650 + &bus_method, 651 + &action_handle, 652 + &method, &internal_event_num, &external_event_num); 653 + 654 + kfree(config_record); 655 + if(IS_OTHERS(internal_event_num)) 656 + goto do_fail; 779 657 if (ret != 6) { 658 + do_fail: 659 + kfree(bus_handle); 660 + kfree(bus_method); 661 + kfree(action_handle); 662 + kfree(method); 780 663 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 781 664 "Invalid data format ret=%d\n", ret)); 782 665 return_VALUE(-EINVAL); 783 666 } 784 667 785 668 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); 786 - ret = init_hotkey_device(key, bus_handle, action_handle, method, 669 + if(!key) 670 + goto do_fail; 671 + memset(key, 0, sizeof(union acpi_hotkey)); 672 + if(cmd == 1) { 673 + union acpi_hotkey *tmp = NULL; 674 + tmp = get_hotkey_by_event(&global_hotkey_list, 675 + internal_event_num); 676 + if(!tmp) 677 + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key")); 678 + else 679 + memcpy(key, tmp, sizeof(union acpi_hotkey)); 680 + goto cont_cmd; 681 + } 682 + if (IS_EVENT(internal_event_num)) { 683 + kfree(bus_method); 684 + ret = init_hotkey_device(key, bus_handle, action_handle, method, 787 685 internal_event_num, external_event_num); 788 - 789 - if (ret || check_hotkey_valid(key, hotkey_list)) { 790 - kfree(key); 791 - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n")); 792 - return_VALUE(-EINVAL); 793 - } 794 - switch (cmd) { 795 - case 0: 796 - hotkey_add(key); 797 - break; 798 - case 1: 799 - hotkey_remove(key); 800 - free_hotkey_device(key); 801 - break; 802 - case 2: 803 - hotkey_update(key); 804 - break; 805 - default: 806 - break; 807 - } 808 - return_VALUE(count); 809 - } 810 - 811 - /* count is length for one input record */ 812 - static ssize_t hotkey_write_poll_config(struct file *file, 813 - const char __user * buffer, 814 - size_t count, loff_t * data) 815 - { 816 - struct seq_file *m = (struct seq_file *)file->private_data; 817 - struct acpi_hotkey_list *hotkey_list = 818 - (struct acpi_hotkey_list *)m->private; 819 - 820 - char config_record[MAX_CONFIG_RECORD_LEN]; 821 - char polling_handle[MAX_NAME_PATH_LEN]; 822 - char action_handle[MAX_NAME_PATH_LEN]; 823 - char poll_method[20], action_method[20]; 824 - int ret, internal_event_num, cmd, external_event_num; 825 - union acpi_hotkey *key = NULL; 826 - 827 - ACPI_FUNCTION_TRACE("hotkey_write_poll_config"); 828 - 829 - if (!hotkey_list || count > MAX_CONFIG_RECORD_LEN) { 830 - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid arguments\n")); 831 - return_VALUE(-EINVAL); 832 - } 833 - 834 - if (copy_from_user(config_record, buffer, count)) { 835 - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n")); 836 - return_VALUE(-EINVAL); 837 - } 838 - config_record[count] = '\0'; 839 - 840 - ret = get_parms(config_record, 841 - &cmd, 842 - polling_handle, 843 - poll_method, 844 - action_handle, 845 - action_method, 846 - &internal_event_num, &external_event_num); 847 - 848 - if (ret != 6) { 849 - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); 850 - return_VALUE(-EINVAL); 851 - } 852 - 853 - key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); 854 - ret = init_poll_hotkey_device(key, polling_handle, poll_method, 855 - action_handle, action_method, 686 + } else 687 + ret = init_poll_hotkey_device(key, bus_handle, bus_method, 688 + action_handle, method, 856 689 internal_event_num); 857 - if (ret || check_hotkey_valid(key, hotkey_list)) { 690 + if (ret) { 691 + kfree(bus_handle); 692 + kfree(action_handle); 693 + if(IS_EVENT(internal_event_num)) 694 + free_hotkey_buffer(key); 695 + else 696 + free_poll_hotkey_buffer(key); 858 697 kfree(key); 859 698 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n")); 860 699 return_VALUE(-EINVAL); 861 700 } 701 + 702 + cont_cmd: 703 + kfree(bus_handle); 704 + kfree(action_handle); 705 + 862 706 switch (cmd) { 863 707 case 0: 864 - hotkey_add(key); 708 + if(get_hotkey_by_event(&global_hotkey_list,key->link.hotkey_standard_num)) 709 + goto fail_out; 710 + else 711 + hotkey_add(key); 865 712 break; 866 713 case 1: 867 714 hotkey_remove(key); 868 715 break; 869 716 case 2: 870 - hotkey_update(key); 717 + if(hotkey_update(key)) 718 + goto fail_out; 871 719 break; 872 720 default: 721 + goto fail_out; 873 722 break; 874 723 } 875 724 return_VALUE(count); 725 + fail_out: 726 + if(IS_EVENT(internal_event_num)) 727 + free_hotkey_buffer(key); 728 + else 729 + free_poll_hotkey_buffer(key); 730 + kfree(key); 731 + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "invalid key\n")); 732 + return_VALUE(-EINVAL); 876 733 } 877 734 878 - /* 735 + /* 879 736 * This function evaluates an ACPI method, given an int as parameter, the 880 737 * method is searched within the scope of the handle, can be NULL. The output 881 738 * of the method is written is output, which can also be NULL ··· 882 775 return_VALUE(status == AE_OK); 883 776 } 884 777 885 - static int read_acpi_int(acpi_handle handle, const char *method, int *val) 778 + static int read_acpi_int(acpi_handle handle, const char *method, union acpi_object *val) 886 779 { 887 780 struct acpi_buffer output; 888 781 union acpi_object out_obj; ··· 893 786 output.pointer = &out_obj; 894 787 895 788 status = acpi_evaluate_object(handle, (char *)method, NULL, &output); 896 - *val = out_obj.integer.value; 789 + if(val){ 790 + val->integer.value = out_obj.integer.value; 791 + val->type = out_obj.type; 792 + } else 793 + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "null val pointer")); 897 794 return_VALUE((status == AE_OK) 898 795 && (out_obj.type == ACPI_TYPE_INTEGER)); 899 796 } 900 797 901 - static acpi_handle 902 - get_handle_from_hotkeylist(struct acpi_hotkey_list *hotkey_list, int event_num) 798 + static union acpi_hotkey *get_hotkey_by_event(struct 799 + acpi_hotkey_list 800 + *hotkey_list, int event) 903 801 { 904 - struct list_head *entries, *next; 802 + struct list_head *entries; 905 803 906 - list_for_each_safe(entries, next, hotkey_list->entries) { 804 + list_for_each(entries, hotkey_list->entries) { 907 805 union acpi_hotkey *key = 908 806 container_of(entries, union acpi_hotkey, entries); 909 - if (key->link.hotkey_type == ACPI_HOTKEY_EVENT 910 - && key->link.hotkey_standard_num == event_num) { 911 - return (key->event_hotkey.action_handle); 807 + if (key->link.hotkey_standard_num == event) { 808 + return(key); 912 809 } 913 810 } 914 - return (NULL); 811 + return(NULL); 915 812 } 916 813 917 - static 918 - char *get_method_from_hotkeylist(struct acpi_hotkey_list *hotkey_list, 919 - int event_num) 920 - { 921 - struct list_head *entries, *next; 922 - 923 - list_for_each_safe(entries, next, hotkey_list->entries) { 924 - union acpi_hotkey *key = 925 - container_of(entries, union acpi_hotkey, entries); 926 - 927 - if (key->link.hotkey_type == ACPI_HOTKEY_EVENT && 928 - key->link.hotkey_standard_num == event_num) 929 - return (key->event_hotkey.action_method); 930 - } 931 - return (NULL); 932 - } 933 - 934 - static struct acpi_polling_hotkey *get_hotkey_by_event(struct 935 - acpi_hotkey_list 936 - *hotkey_list, int event) 937 - { 938 - struct list_head *entries, *next; 939 - 940 - list_for_each_safe(entries, next, hotkey_list->entries) { 941 - union acpi_hotkey *key = 942 - container_of(entries, union acpi_hotkey, entries); 943 - if (key->link.hotkey_type == ACPI_HOTKEY_POLLING 944 - && key->link.hotkey_standard_num == event) { 945 - return (&key->poll_hotkey); 946 - } 947 - } 948 - return (NULL); 949 - } 950 - 951 - /* 814 + /* 952 815 * user call AML method interface: 953 816 * Call convention: 954 817 * echo "event_num: arg type : value" ··· 931 854 size_t count, loff_t * data) 932 855 { 933 856 struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; 934 - char arg[MAX_CALL_PARM]; 935 - int event, type, value; 936 - 937 - char *method; 938 - acpi_handle handle; 857 + char *arg; 858 + int event,method_type,type, value; 859 + union acpi_hotkey *key; 939 860 940 861 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method"); 941 862 942 - if (!hotkey_list || count > MAX_CALL_PARM) { 943 - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 1")); 944 - return_VALUE(-EINVAL); 945 - } 863 + arg = (char *) kmalloc(count+1, GFP_KERNEL); 864 + if(!arg) 865 + return_VALUE(-ENOMEM); 866 + arg[count]=0; 946 867 947 868 if (copy_from_user(arg, buffer, count)) { 869 + kfree(arg); 948 870 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2")); 949 871 return_VALUE(-EINVAL); 950 872 } 951 873 952 - arg[count] = '\0'; 953 - 954 - if (sscanf(arg, "%d:%d:%d", &event, &type, &value) != 3) { 874 + if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 4) { 875 + kfree(arg); 955 876 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3")); 956 877 return_VALUE(-EINVAL); 957 878 } 958 - 879 + kfree(arg); 959 880 if (type == ACPI_TYPE_INTEGER) { 960 - handle = get_handle_from_hotkeylist(hotkey_list, event); 961 - method = (char *)get_method_from_hotkeylist(hotkey_list, event); 881 + key = get_hotkey_by_event(hotkey_list, event); 882 + if(!key) 883 + goto do_fail; 962 884 if (IS_EVENT(event)) 963 - write_acpi_int(handle, method, value, NULL); 885 + write_acpi_int(key->event_hotkey.action_handle, 886 + key->event_hotkey.action_method, value, NULL); 964 887 else if (IS_POLL(event)) { 965 - struct acpi_polling_hotkey *key; 966 - key = (struct acpi_polling_hotkey *) 967 - get_hotkey_by_event(hotkey_list, event); 968 - read_acpi_int(handle, method, key->poll_result); 888 + if ( method_type == POLL_METHOD ) 889 + read_acpi_int(key->poll_hotkey.poll_handle, 890 + key->poll_hotkey.poll_method, 891 + key->poll_hotkey.poll_result); 892 + else if ( method_type == ACTION_METHOD ) 893 + write_acpi_int(key->poll_hotkey.action_handle, 894 + key->poll_hotkey.action_method, value, NULL); 895 + else 896 + goto do_fail; 897 + 969 898 } 970 899 } else { 971 900 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported")); 972 901 return_VALUE(-EINVAL); 973 902 } 974 - 975 903 return_VALUE(count); 904 + do_fail: 905 + return_VALUE(-EINVAL); 906 + 976 907 } 977 908 978 909 static int __init hotkey_init(void) ··· 1013 928 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1014 929 "Hotkey: Unable to create %s entry\n", 1015 930 HOTKEY_EV_CONFIG)); 1016 - return (-ENODEV); 931 + goto do_fail1; 1017 932 } else { 1018 933 hotkey_config->proc_fops = &hotkey_config_fops; 1019 934 hotkey_config->data = &global_hotkey_list; ··· 1028 943 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1029 944 "Hotkey: Unable to create %s entry\n", 1030 945 HOTKEY_EV_CONFIG)); 1031 - return (-ENODEV); 946 + 947 + goto do_fail2; 1032 948 } else { 1033 949 hotkey_poll_config->proc_fops = &hotkey_poll_config_fops; 1034 950 hotkey_poll_config->data = &global_hotkey_list; ··· 1043 957 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1044 958 "Hotkey: Unable to create %s entry\n", 1045 959 HOTKEY_ACTION)); 1046 - return (-ENODEV); 960 + goto do_fail3; 1047 961 } else { 1048 962 hotkey_action->proc_fops = &hotkey_action_fops; 1049 963 hotkey_action->owner = THIS_MODULE; ··· 1056 970 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1057 971 "Hotkey: Unable to create %s entry\n", 1058 972 HOTKEY_INFO)); 1059 - return (-ENODEV); 973 + goto do_fail4; 1060 974 } else { 1061 975 hotkey_info->proc_fops = &hotkey_info_fops; 1062 976 hotkey_info->owner = THIS_MODULE; ··· 1065 979 } 1066 980 1067 981 result = acpi_bus_register_driver(&hotkey_driver); 1068 - if (result < 0) { 1069 - remove_proc_entry(HOTKEY_PROC, acpi_root_dir); 1070 - return (-ENODEV); 1071 - } 982 + if (result < 0) 983 + goto do_fail5; 1072 984 global_hotkey_list.count = 0; 1073 985 global_hotkey_list.entries = &hotkey_entries; 1074 986 1075 987 INIT_LIST_HEAD(&hotkey_entries); 1076 988 1077 989 return (0); 990 + 991 + do_fail5: 992 + remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir); 993 + do_fail4: 994 + remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir); 995 + do_fail3: 996 + remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir); 997 + do_fail2: 998 + remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir); 999 + do_fail1: 1000 + remove_proc_entry(HOTKEY_PROC, acpi_root_dir); 1001 + return (-ENODEV); 1078 1002 } 1079 1003 1080 1004 static void __exit hotkey_exit(void) 1081 1005 { 1082 1006 struct list_head *entries, *next; 1083 1007 1084 - ACPI_FUNCTION_TRACE("hotkey_remove"); 1008 + ACPI_FUNCTION_TRACE("hotkey_exit"); 1085 1009 1086 1010 list_for_each_safe(entries, next, global_hotkey_list.entries) { 1087 1011 union acpi_hotkey *key =
+11
drivers/acpi/pci_link.c
··· 692 692 return_VALUE(-1); 693 693 } 694 694 695 + #ifdef FUTURE_USE 696 + /* 697 + * The Link reference count allows us to _DISable an unused link 698 + * and suspend time, and set it again on resume. 699 + * However, 2.6.12 still has irq_router.resume 700 + * which blindly restores the link state. 701 + * So we disable the reference count method 702 + * to prevent duplicate acpi_pci_link_set() 703 + * which would harm some systems 704 + */ 695 705 link->refcnt --; 706 + #endif 696 707 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 697 708 "Link %s is dereferenced\n", acpi_device_bid(link->device))); 698 709
+3 -4
drivers/acpi/processor_idle.c
··· 86 86 if (max_cstate > ACPI_PROCESSOR_MAX_POWER) 87 87 return 0; 88 88 89 - printk(KERN_NOTICE PREFIX "%s detected - %s disabled." 89 + printk(KERN_NOTICE PREFIX "%s detected - limiting to C%ld max_cstate." 90 90 " Override with \"processor.max_cstate=%d\"\n", id->ident, 91 - ((int)id->driver_data == 1)? "C2,C3":"C3", 92 - ACPI_PROCESSOR_MAX_POWER + 1); 91 + (long)id->driver_data, ACPI_PROCESSOR_MAX_POWER + 1); 93 92 94 - max_cstate = (int)id->driver_data; 93 + max_cstate = (long)id->driver_data; 95 94 96 95 return 0; 97 96 }