Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (32 commits)
ACPI: i2c-scmi: don't use acpi_device_uid()
ACPI: simplify building device HID/CID list
ACPI: remove acpi_device_uid() and related stuff
ACPI: remove acpi_device.flags.hardware_id
ACPI: remove acpi_device.flags.compatible_ids
ACPI: maintain a single list of _HID and _CID IDs
ACPI: make sure every acpi_device has an ID
ACPI: use acpi_device_hid() when possible
ACPI: fix synthetic HID for \_SB_
ACPI: handle re-enumeration, when acpi_devices might already exist
ACPI: factor out device type and status checking
ACPI: add acpi_bus_get_status_handle()
ACPI: use acpi_walk_namespace() to enumerate devices
ACPI: identify device tree root by null parent pointer, not ACPI_BUS_TYPE
ACPI: enumerate namespace before adding functional fixed hardware devices
ACPI: convert acpi_bus_scan() to operate on an acpi_handle
ACPI: add acpi_bus_get_parent() and remove "parent" arguments
ACPI: remove unnecessary argument checking
ACPI: remove redundant "type" arguments
ACPI: remove acpi_device_set_context() "type" argument
...

+780 -723
+27 -21
Documentation/laptops/thinkpad-acpi.txt
··· 199 199 200 200 Not all bits in the mask can be modified. Not all bits that can be 201 201 modified do anything. Not all hot keys can be individually controlled 202 - by the mask. Some models do not support the mask at all, and in those 203 - models, hot keys cannot be controlled individually. The behaviour of 204 - the mask is, therefore, highly dependent on the ThinkPad model. 202 + by the mask. Some models do not support the mask at all. The behaviour 203 + of the mask is, therefore, highly dependent on the ThinkPad model. 204 + 205 + The driver will filter out any unmasked hotkeys, so even if the firmware 206 + doesn't allow disabling an specific hotkey, the driver will not report 207 + events for unmasked hotkeys. 205 208 206 209 Note that unmasking some keys prevents their default behavior. For 207 210 example, if Fn+F5 is unmasked, that key will no longer enable/disable 208 - Bluetooth by itself. 211 + Bluetooth by itself in firmware. 209 212 210 - Note also that not all Fn key combinations are supported through ACPI. 211 - For example, on the X40, the brightness, volume and "Access IBM" buttons 212 - do not generate ACPI events even with this driver. They *can* be used 213 - through the "ThinkPad Buttons" utility, see http://www.nongnu.org/tpb/ 213 + Note also that not all Fn key combinations are supported through ACPI 214 + depending on the ThinkPad model and firmware version. On those 215 + ThinkPads, it is still possible to support some extra hotkeys by 216 + polling the "CMOS NVRAM" at least 10 times per second. The driver 217 + attempts to enables this functionality automatically when required. 214 218 215 219 procfs notes: 216 220 ··· 259 255 1: does nothing 260 256 261 257 hotkey_mask: 262 - bit mask to enable driver-handling (and depending on 258 + bit mask to enable reporting (and depending on 263 259 the firmware, ACPI event generation) for each hot key 264 260 (see above). Returns the current status of the hot keys 265 261 mask, and allows one to modify it. 266 - 267 - Note: when NVRAM polling is active, the firmware mask 268 - will be different from the value returned by 269 - hotkey_mask. The driver will retain enabled bits for 270 - hotkeys that are under NVRAM polling even if the 271 - firmware refuses them, and will not set these bits on 272 - the firmware hot key mask. 273 262 274 263 hotkey_all_mask: 275 264 bit mask that should enable event reporting for all ··· 276 279 bit mask that should enable event reporting for all 277 280 supported hot keys, except those which are always 278 281 handled by the firmware anyway. Echo it to 279 - hotkey_mask above, to use. 282 + hotkey_mask above, to use. This is the default mask 283 + used by the driver. 280 284 281 285 hotkey_source_mask: 282 286 bit mask that selects which hot keys will the driver ··· 285 287 based on the capabilities reported by the ACPI firmware, 286 288 but it can be overridden at runtime. 287 289 288 - Hot keys whose bits are set in both hotkey_source_mask 289 - and also on hotkey_mask are polled for in NVRAM. Only a 290 - few hot keys are available through CMOS NVRAM polling. 290 + Hot keys whose bits are set in hotkey_source_mask are 291 + polled for in NVRAM, and reported as hotkey events if 292 + enabled in hotkey_mask. Only a few hot keys are 293 + available through CMOS NVRAM polling. 291 294 292 295 Warning: when in NVRAM mode, the volume up/down/mute 293 296 keys are synthesized according to changes in the mixer, ··· 524 525 0x2305 System is waking up from suspend to eject bay 525 526 0x2404 System is waking up from hibernation to undock 526 527 0x2405 System is waking up from hibernation to eject bay 528 + 0x5010 Brightness level changed/control event 527 529 528 530 The above events are never propagated by the driver. 529 531 ··· 532 532 0x4003 Undocked (see 0x2x04), can sleep again 533 533 0x500B Tablet pen inserted into its storage bay 534 534 0x500C Tablet pen removed from its storage bay 535 - 0x5010 Brightness level changed (newer Lenovo BIOSes) 536 535 537 536 The above events are propagated by the driver. 538 537 ··· 620 621 2. Do *NOT* load up ACPI video, enable the hotkeys in thinkpad-acpi, 621 622 and map them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN. Process 622 623 these keys on userspace somehow (e.g. by calling xbacklight). 624 + The driver will do this automatically if it detects that ACPI video 625 + has been disabled. 623 626 624 627 625 628 Bluetooth ··· 1460 1459 0x020400: Marker for 16 LEDs support. Also, LEDs that are known 1461 1460 to not exist in a given model are not registered with 1462 1461 the LED sysfs class anymore. 1462 + 1463 + 0x020500: Updated hotkey driver, hotkey_mask is always available 1464 + and it is always able to disable hot keys. Very old 1465 + thinkpads are properly supported. hotkey_bios_mask 1466 + is deprecated and marked for removal.
+23 -28
drivers/acpi/bus.c
··· 94 94 95 95 EXPORT_SYMBOL(acpi_bus_get_device); 96 96 97 + acpi_status acpi_bus_get_status_handle(acpi_handle handle, 98 + unsigned long long *sta) 99 + { 100 + acpi_status status; 101 + 102 + status = acpi_evaluate_integer(handle, "_STA", NULL, sta); 103 + if (ACPI_SUCCESS(status)) 104 + return AE_OK; 105 + 106 + if (status == AE_NOT_FOUND) { 107 + *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | 108 + ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; 109 + return AE_OK; 110 + } 111 + return status; 112 + } 113 + 97 114 int acpi_bus_get_status(struct acpi_device *device) 98 115 { 99 - acpi_status status = AE_OK; 100 - unsigned long long sta = 0; 116 + acpi_status status; 117 + unsigned long long sta; 101 118 119 + status = acpi_bus_get_status_handle(device->handle, &sta); 120 + if (ACPI_FAILURE(status)) 121 + return -ENODEV; 102 122 103 - if (!device) 104 - return -EINVAL; 105 - 106 - /* 107 - * Evaluate _STA if present. 108 - */ 109 - if (device->flags.dynamic_status) { 110 - status = 111 - acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); 112 - if (ACPI_FAILURE(status)) 113 - return -ENODEV; 114 - STRUCT_TO_INT(device->status) = (int)sta; 115 - } 116 - 117 - /* 118 - * According to ACPI spec some device can be present and functional 119 - * even if the parent is not present but functional. 120 - * In such conditions the child device should not inherit the status 121 - * from the parent. 122 - */ 123 - else 124 - STRUCT_TO_INT(device->status) = 125 - ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | 126 - ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; 123 + STRUCT_TO_INT(device->status) = (int) sta; 127 124 128 125 if (device->status.functional && !device->status.present) { 129 126 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " ··· 132 135 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", 133 136 device->pnp.bus_id, 134 137 (u32) STRUCT_TO_INT(device->status))); 135 - 136 138 return 0; 137 139 } 138 - 139 140 EXPORT_SYMBOL(acpi_bus_get_status); 140 141 141 142 void acpi_bus_private_data_handler(acpi_handle handle,
+280 -441
drivers/acpi/scan.c
··· 22 22 #define ACPI_BUS_HID "LNXSYBUS" 23 23 #define ACPI_BUS_DEVICE_NAME "System Bus" 24 24 25 + #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) 26 + 25 27 static LIST_HEAD(acpi_device_list); 26 28 static LIST_HEAD(acpi_bus_id_list); 27 29 DEFINE_MUTEX(acpi_device_lock); ··· 45 43 { 46 44 int len; 47 45 int count; 48 - 49 - if (!acpi_dev->flags.hardware_id && !acpi_dev->flags.compatible_ids) 50 - return -ENODEV; 46 + struct acpi_hardware_id *id; 51 47 52 48 len = snprintf(modalias, size, "acpi:"); 53 49 size -= len; 54 50 55 - if (acpi_dev->flags.hardware_id) { 56 - count = snprintf(&modalias[len], size, "%s:", 57 - acpi_dev->pnp.hardware_id); 51 + list_for_each_entry(id, &acpi_dev->pnp.ids, list) { 52 + count = snprintf(&modalias[len], size, "%s:", id->id); 58 53 if (count < 0 || count >= size) 59 54 return -EINVAL; 60 55 len += count; 61 56 size -= count; 62 - } 63 - 64 - if (acpi_dev->flags.compatible_ids) { 65 - struct acpica_device_id_list *cid_list; 66 - int i; 67 - 68 - cid_list = acpi_dev->pnp.cid_list; 69 - for (i = 0; i < cid_list->count; i++) { 70 - count = snprintf(&modalias[len], size, "%s:", 71 - cid_list->ids[i].string); 72 - if (count < 0 || count >= size) { 73 - printk(KERN_ERR PREFIX "%s cid[%i] exceeds event buffer size", 74 - acpi_dev->pnp.device_name, i); 75 - break; 76 - } 77 - len += count; 78 - size -= count; 79 - } 80 57 } 81 58 82 59 modalias[len] = '\0'; ··· 164 183 acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) { 165 184 struct acpi_device *acpi_dev = to_acpi_device(dev); 166 185 167 - return sprintf(buf, "%s\n", acpi_dev->pnp.hardware_id); 186 + return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev)); 168 187 } 169 188 static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL); 170 189 ··· 200 219 goto end; 201 220 } 202 221 203 - if (dev->flags.hardware_id) { 204 - result = device_create_file(&dev->dev, &dev_attr_hid); 205 - if (result) 206 - goto end; 207 - } 222 + result = device_create_file(&dev->dev, &dev_attr_hid); 223 + if (result) 224 + goto end; 208 225 209 - if (dev->flags.hardware_id || dev->flags.compatible_ids) { 210 - result = device_create_file(&dev->dev, &dev_attr_modalias); 211 - if (result) 212 - goto end; 213 - } 226 + result = device_create_file(&dev->dev, &dev_attr_modalias); 227 + if (result) 228 + goto end; 214 229 215 230 /* 216 231 * If device has _EJ0, 'eject' file is created that is used to trigger ··· 232 255 if (ACPI_SUCCESS(status)) 233 256 device_remove_file(&dev->dev, &dev_attr_eject); 234 257 235 - if (dev->flags.hardware_id || dev->flags.compatible_ids) 236 - device_remove_file(&dev->dev, &dev_attr_modalias); 237 - 238 - if (dev->flags.hardware_id) 239 - device_remove_file(&dev->dev, &dev_attr_hid); 258 + device_remove_file(&dev->dev, &dev_attr_modalias); 259 + device_remove_file(&dev->dev, &dev_attr_hid); 240 260 if (dev->handle) 241 261 device_remove_file(&dev->dev, &dev_attr_path); 242 262 } ··· 245 271 const struct acpi_device_id *ids) 246 272 { 247 273 const struct acpi_device_id *id; 274 + struct acpi_hardware_id *hwid; 248 275 249 276 /* 250 277 * If the device is not present, it is unnecessary to load device ··· 254 279 if (!device->status.present) 255 280 return -ENODEV; 256 281 257 - if (device->flags.hardware_id) { 258 - for (id = ids; id->id[0]; id++) { 259 - if (!strcmp((char*)id->id, device->pnp.hardware_id)) 282 + for (id = ids; id->id[0]; id++) 283 + list_for_each_entry(hwid, &device->pnp.ids, list) 284 + if (!strcmp((char *) id->id, hwid->id)) 260 285 return 0; 261 - } 262 - } 263 - 264 - if (device->flags.compatible_ids) { 265 - struct acpica_device_id_list *cid_list = device->pnp.cid_list; 266 - int i; 267 - 268 - for (id = ids; id->id[0]; id++) { 269 - /* compare multiple _CID entries against driver ids */ 270 - for (i = 0; i < cid_list->count; i++) { 271 - if (!strcmp((char*)id->id, 272 - cid_list->ids[i].string)) 273 - return 0; 274 - } 275 - } 276 - } 277 286 278 287 return -ENOENT; 279 288 } 280 289 EXPORT_SYMBOL(acpi_match_device_ids); 281 290 291 + static void acpi_free_ids(struct acpi_device *device) 292 + { 293 + struct acpi_hardware_id *id, *tmp; 294 + 295 + list_for_each_entry_safe(id, tmp, &device->pnp.ids, list) { 296 + kfree(id->id); 297 + kfree(id); 298 + } 299 + } 300 + 282 301 static void acpi_device_release(struct device *dev) 283 302 { 284 303 struct acpi_device *acpi_dev = to_acpi_device(dev); 285 304 286 - kfree(acpi_dev->pnp.cid_list); 287 - if (acpi_dev->flags.hardware_id) 288 - kfree(acpi_dev->pnp.hardware_id); 289 - if (acpi_dev->flags.unique_id) 290 - kfree(acpi_dev->pnp.unique_id); 305 + acpi_free_ids(acpi_dev); 291 306 kfree(acpi_dev); 292 307 } 293 308 ··· 343 378 static int acpi_device_install_notify_handler(struct acpi_device *device) 344 379 { 345 380 acpi_status status; 346 - char *hid; 347 381 348 - hid = acpi_device_hid(device); 349 - if (!strcmp(hid, ACPI_BUTTON_HID_POWERF)) 382 + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) 350 383 status = 351 384 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 352 385 acpi_device_notify_fixed, 353 386 device); 354 - else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) 387 + else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) 355 388 status = 356 389 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 357 390 acpi_device_notify_fixed, ··· 367 404 368 405 static void acpi_device_remove_notify_handler(struct acpi_device *device) 369 406 { 370 - if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) 407 + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) 371 408 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 372 409 acpi_device_notify_fixed); 373 - else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) 410 + else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) 374 411 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 375 412 acpi_device_notify_fixed); 376 413 else ··· 437 474 .uevent = acpi_device_uevent, 438 475 }; 439 476 440 - static int acpi_device_register(struct acpi_device *device, 441 - struct acpi_device *parent) 477 + static int acpi_device_register(struct acpi_device *device) 442 478 { 443 479 int result; 444 480 struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id; 445 481 int found = 0; 482 + 446 483 /* 447 484 * Linkage 448 485 * ------- ··· 464 501 * If failed, create one and link it into acpi_bus_id_list 465 502 */ 466 503 list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) { 467 - if(!strcmp(acpi_device_bus_id->bus_id, device->flags.hardware_id? device->pnp.hardware_id : "device")) { 468 - acpi_device_bus_id->instance_no ++; 504 + if (!strcmp(acpi_device_bus_id->bus_id, 505 + acpi_device_hid(device))) { 506 + acpi_device_bus_id->instance_no++; 469 507 found = 1; 470 508 kfree(new_bus_id); 471 509 break; ··· 474 510 } 475 511 if (!found) { 476 512 acpi_device_bus_id = new_bus_id; 477 - strcpy(acpi_device_bus_id->bus_id, device->flags.hardware_id ? device->pnp.hardware_id : "device"); 513 + strcpy(acpi_device_bus_id->bus_id, acpi_device_hid(device)); 478 514 acpi_device_bus_id->instance_no = 0; 479 515 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); 480 516 } ··· 488 524 mutex_unlock(&acpi_device_lock); 489 525 490 526 if (device->parent) 491 - device->dev.parent = &parent->dev; 527 + device->dev.parent = &device->parent->dev; 492 528 device->dev.bus = &acpi_bus_type; 493 529 device->dev.release = &acpi_device_release; 494 530 result = device_register(&device->dev); ··· 628 664 /* -------------------------------------------------------------------------- 629 665 Device Enumeration 630 666 -------------------------------------------------------------------------- */ 667 + static struct acpi_device *acpi_bus_get_parent(acpi_handle handle) 668 + { 669 + acpi_status status; 670 + int ret; 671 + struct acpi_device *device; 672 + 673 + /* 674 + * Fixed hardware devices do not appear in the namespace and do not 675 + * have handles, but we fabricate acpi_devices for them, so we have 676 + * to deal with them specially. 677 + */ 678 + if (handle == NULL) 679 + return acpi_root; 680 + 681 + do { 682 + status = acpi_get_parent(handle, &handle); 683 + if (status == AE_NULL_ENTRY) 684 + return NULL; 685 + if (ACPI_FAILURE(status)) 686 + return acpi_root; 687 + 688 + ret = acpi_bus_get_device(handle, &device); 689 + if (ret == 0) 690 + return device; 691 + } while (1); 692 + } 693 + 631 694 acpi_status 632 695 acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd) 633 696 { ··· 867 876 if (ACPI_SUCCESS(status)) 868 877 device->flags.dynamic_status = 1; 869 878 870 - /* Presence of _CID indicates 'compatible_ids' */ 871 - status = acpi_get_handle(device->handle, "_CID", &temp); 872 - if (ACPI_SUCCESS(status)) 873 - device->flags.compatible_ids = 1; 874 - 875 879 /* Presence of _RMV indicates 'removable' */ 876 880 status = acpi_get_handle(device->handle, "_RMV", &temp); 877 881 if (ACPI_SUCCESS(status)) ··· 904 918 return 0; 905 919 } 906 920 907 - static void acpi_device_get_busid(struct acpi_device *device, 908 - acpi_handle handle, int type) 921 + static void acpi_device_get_busid(struct acpi_device *device) 909 922 { 910 923 char bus_id[5] = { '?', 0 }; 911 924 struct acpi_buffer buffer = { sizeof(bus_id), bus_id }; ··· 916 931 * The device's Bus ID is simply the object name. 917 932 * TBD: Shouldn't this value be unique (within the ACPI namespace)? 918 933 */ 919 - switch (type) { 920 - case ACPI_BUS_TYPE_SYSTEM: 934 + if (ACPI_IS_ROOT_DEVICE(device)) { 921 935 strcpy(device->pnp.bus_id, "ACPI"); 922 - break; 936 + return; 937 + } 938 + 939 + switch (device->device_type) { 923 940 case ACPI_BUS_TYPE_POWER_BUTTON: 924 941 strcpy(device->pnp.bus_id, "PWRF"); 925 942 break; ··· 929 942 strcpy(device->pnp.bus_id, "SLPF"); 930 943 break; 931 944 default: 932 - acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer); 945 + acpi_get_name(device->handle, ACPI_SINGLE_NAME, &buffer); 933 946 /* Clean up trailing underscores (if any) */ 934 947 for (i = 3; i > 1; i--) { 935 948 if (bus_id[i] == '_') ··· 987 1000 return acpi_get_handle(device->handle, "_DCK", &tmp); 988 1001 } 989 1002 990 - static struct acpica_device_id_list* 991 - acpi_add_cid( 992 - struct acpi_device_info *info, 993 - struct acpica_device_id *new_cid) 1003 + char *acpi_device_hid(struct acpi_device *device) 994 1004 { 995 - struct acpica_device_id_list *cid; 996 - char *next_id_string; 997 - acpi_size cid_length; 998 - acpi_size new_cid_length; 999 - u32 i; 1005 + struct acpi_hardware_id *hid; 1000 1006 1007 + hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list); 1008 + return hid->id; 1009 + } 1010 + EXPORT_SYMBOL(acpi_device_hid); 1001 1011 1002 - /* Allocate new CID list with room for the new CID */ 1012 + static void acpi_add_id(struct acpi_device *device, const char *dev_id) 1013 + { 1014 + struct acpi_hardware_id *id; 1003 1015 1004 - if (!new_cid) 1005 - new_cid_length = info->compatible_id_list.list_size; 1006 - else if (info->compatible_id_list.list_size) 1007 - new_cid_length = info->compatible_id_list.list_size + 1008 - new_cid->length + sizeof(struct acpica_device_id); 1009 - else 1010 - new_cid_length = sizeof(struct acpica_device_id_list) + new_cid->length; 1016 + id = kmalloc(sizeof(*id), GFP_KERNEL); 1017 + if (!id) 1018 + return; 1011 1019 1012 - cid = ACPI_ALLOCATE_ZEROED(new_cid_length); 1013 - if (!cid) { 1014 - return NULL; 1020 + id->id = kmalloc(strlen(dev_id) + 1, GFP_KERNEL); 1021 + if (!id->id) { 1022 + kfree(id); 1023 + return; 1015 1024 } 1016 1025 1017 - cid->list_size = new_cid_length; 1018 - cid->count = info->compatible_id_list.count; 1019 - if (new_cid) 1020 - cid->count++; 1021 - next_id_string = (char *) cid->ids + (cid->count * sizeof(struct acpica_device_id)); 1022 - 1023 - /* Copy all existing CIDs */ 1024 - 1025 - for (i = 0; i < info->compatible_id_list.count; i++) { 1026 - cid_length = info->compatible_id_list.ids[i].length; 1027 - cid->ids[i].string = next_id_string; 1028 - cid->ids[i].length = cid_length; 1029 - 1030 - ACPI_MEMCPY(next_id_string, info->compatible_id_list.ids[i].string, 1031 - cid_length); 1032 - 1033 - next_id_string += cid_length; 1034 - } 1035 - 1036 - /* Append the new CID */ 1037 - 1038 - if (new_cid) { 1039 - cid->ids[i].string = next_id_string; 1040 - cid->ids[i].length = new_cid->length; 1041 - 1042 - ACPI_MEMCPY(next_id_string, new_cid->string, new_cid->length); 1043 - } 1044 - 1045 - return cid; 1026 + strcpy(id->id, dev_id); 1027 + list_add_tail(&id->list, &device->pnp.ids); 1046 1028 } 1047 1029 1048 - static void acpi_device_set_id(struct acpi_device *device, 1049 - struct acpi_device *parent, acpi_handle handle, 1050 - int type) 1030 + static void acpi_device_set_id(struct acpi_device *device) 1051 1031 { 1052 - struct acpi_device_info *info = NULL; 1053 - char *hid = NULL; 1054 - char *uid = NULL; 1055 - struct acpica_device_id_list *cid_list = NULL; 1056 - char *cid_add = NULL; 1057 1032 acpi_status status; 1033 + struct acpi_device_info *info; 1034 + struct acpica_device_id_list *cid_list; 1035 + int i; 1058 1036 1059 - switch (type) { 1037 + switch (device->device_type) { 1060 1038 case ACPI_BUS_TYPE_DEVICE: 1061 - status = acpi_get_object_info(handle, &info); 1039 + if (ACPI_IS_ROOT_DEVICE(device)) { 1040 + acpi_add_id(device, ACPI_SYSTEM_HID); 1041 + break; 1042 + } else if (ACPI_IS_ROOT_DEVICE(device->parent)) { 1043 + /* \_SB_, the only root-level namespace device */ 1044 + acpi_add_id(device, ACPI_BUS_HID); 1045 + strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); 1046 + strcpy(device->pnp.device_class, ACPI_BUS_CLASS); 1047 + break; 1048 + } 1049 + 1050 + status = acpi_get_object_info(device->handle, &info); 1062 1051 if (ACPI_FAILURE(status)) { 1063 1052 printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__); 1064 1053 return; 1065 1054 } 1066 1055 1067 1056 if (info->valid & ACPI_VALID_HID) 1068 - hid = info->hardware_id.string; 1069 - if (info->valid & ACPI_VALID_UID) 1070 - uid = info->unique_id.string; 1071 - if (info->valid & ACPI_VALID_CID) 1057 + acpi_add_id(device, info->hardware_id.string); 1058 + if (info->valid & ACPI_VALID_CID) { 1072 1059 cid_list = &info->compatible_id_list; 1060 + for (i = 0; i < cid_list->count; i++) 1061 + acpi_add_id(device, cid_list->ids[i].string); 1062 + } 1073 1063 if (info->valid & ACPI_VALID_ADR) { 1074 1064 device->pnp.bus_address = info->address; 1075 1065 device->flags.bus_address = 1; 1076 1066 } 1077 1067 1078 - /* If we have a video/bay/dock device, add our selfdefined 1079 - HID to the CID list. Like that the video/bay/dock drivers 1080 - will get autoloaded and the device might still match 1081 - against another driver. 1082 - */ 1068 + /* 1069 + * Some devices don't reliably have _HIDs & _CIDs, so add 1070 + * synthetic HIDs to make sure drivers can find them. 1071 + */ 1083 1072 if (acpi_is_video_device(device)) 1084 - cid_add = ACPI_VIDEO_HID; 1073 + acpi_add_id(device, ACPI_VIDEO_HID); 1085 1074 else if (ACPI_SUCCESS(acpi_bay_match(device))) 1086 - cid_add = ACPI_BAY_HID; 1075 + acpi_add_id(device, ACPI_BAY_HID); 1087 1076 else if (ACPI_SUCCESS(acpi_dock_match(device))) 1088 - cid_add = ACPI_DOCK_HID; 1077 + acpi_add_id(device, ACPI_DOCK_HID); 1089 1078 1090 1079 break; 1091 1080 case ACPI_BUS_TYPE_POWER: 1092 - hid = ACPI_POWER_HID; 1081 + acpi_add_id(device, ACPI_POWER_HID); 1093 1082 break; 1094 1083 case ACPI_BUS_TYPE_PROCESSOR: 1095 - hid = ACPI_PROCESSOR_OBJECT_HID; 1096 - break; 1097 - case ACPI_BUS_TYPE_SYSTEM: 1098 - hid = ACPI_SYSTEM_HID; 1084 + acpi_add_id(device, ACPI_PROCESSOR_OBJECT_HID); 1099 1085 break; 1100 1086 case ACPI_BUS_TYPE_THERMAL: 1101 - hid = ACPI_THERMAL_HID; 1087 + acpi_add_id(device, ACPI_THERMAL_HID); 1102 1088 break; 1103 1089 case ACPI_BUS_TYPE_POWER_BUTTON: 1104 - hid = ACPI_BUTTON_HID_POWERF; 1090 + acpi_add_id(device, ACPI_BUTTON_HID_POWERF); 1105 1091 break; 1106 1092 case ACPI_BUS_TYPE_SLEEP_BUTTON: 1107 - hid = ACPI_BUTTON_HID_SLEEPF; 1093 + acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF); 1108 1094 break; 1109 1095 } 1110 1096 1111 1097 /* 1112 - * \_SB 1113 - * ---- 1114 - * Fix for the system root bus device -- the only root-level device. 1098 + * We build acpi_devices for some objects that don't have _HID or _CID, 1099 + * e.g., PCI bridges and slots. Drivers can't bind to these objects, 1100 + * but we do use them indirectly by traversing the acpi_device tree. 1101 + * This generic ID isn't useful for driver binding, but it provides 1102 + * the useful property that "every acpi_device has an ID." 1115 1103 */ 1116 - if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { 1117 - hid = ACPI_BUS_HID; 1118 - strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); 1119 - strcpy(device->pnp.device_class, ACPI_BUS_CLASS); 1120 - } 1121 - 1122 - if (hid) { 1123 - device->pnp.hardware_id = ACPI_ALLOCATE_ZEROED(strlen (hid) + 1); 1124 - if (device->pnp.hardware_id) { 1125 - strcpy(device->pnp.hardware_id, hid); 1126 - device->flags.hardware_id = 1; 1127 - } 1128 - } 1129 - if (!device->flags.hardware_id) 1130 - device->pnp.hardware_id = ""; 1131 - 1132 - if (uid) { 1133 - device->pnp.unique_id = ACPI_ALLOCATE_ZEROED(strlen (uid) + 1); 1134 - if (device->pnp.unique_id) { 1135 - strcpy(device->pnp.unique_id, uid); 1136 - device->flags.unique_id = 1; 1137 - } 1138 - } 1139 - if (!device->flags.unique_id) 1140 - device->pnp.unique_id = ""; 1141 - 1142 - if (cid_list || cid_add) { 1143 - struct acpica_device_id_list *list; 1144 - 1145 - if (cid_add) { 1146 - struct acpica_device_id cid; 1147 - cid.length = strlen (cid_add) + 1; 1148 - cid.string = cid_add; 1149 - 1150 - list = acpi_add_cid(info, &cid); 1151 - } else { 1152 - list = acpi_add_cid(info, NULL); 1153 - } 1154 - 1155 - if (list) { 1156 - device->pnp.cid_list = list; 1157 - if (cid_add) 1158 - device->flags.compatible_ids = 1; 1159 - } 1160 - } 1161 - 1162 - kfree(info); 1104 + if (list_empty(&device->pnp.ids)) 1105 + acpi_add_id(device, "device"); 1163 1106 } 1164 1107 1165 - static int acpi_device_set_context(struct acpi_device *device, int type) 1108 + static int acpi_device_set_context(struct acpi_device *device) 1166 1109 { 1167 - acpi_status status = AE_OK; 1168 - int result = 0; 1110 + acpi_status status; 1111 + 1169 1112 /* 1170 1113 * Context 1171 1114 * ------- 1172 1115 * Attach this 'struct acpi_device' to the ACPI object. This makes 1173 - * resolutions from handle->device very efficient. Note that we need 1174 - * to be careful with fixed-feature devices as they all attach to the 1175 - * root object. 1116 + * resolutions from handle->device very efficient. Fixed hardware 1117 + * devices have no handles, so we skip them. 1176 1118 */ 1177 - if (type != ACPI_BUS_TYPE_POWER_BUTTON && 1178 - type != ACPI_BUS_TYPE_SLEEP_BUTTON) { 1179 - status = acpi_attach_data(device->handle, 1180 - acpi_bus_data_handler, device); 1119 + if (!device->handle) 1120 + return 0; 1181 1121 1182 - if (ACPI_FAILURE(status)) { 1183 - printk(KERN_ERR PREFIX "Error attaching device data\n"); 1184 - result = -ENODEV; 1185 - } 1186 - } 1187 - return result; 1122 + status = acpi_attach_data(device->handle, 1123 + acpi_bus_data_handler, device); 1124 + if (ACPI_SUCCESS(status)) 1125 + return 0; 1126 + 1127 + printk(KERN_ERR PREFIX "Error attaching device data\n"); 1128 + return -ENODEV; 1188 1129 } 1189 1130 1190 1131 static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) ··· 1138 1223 return 0; 1139 1224 } 1140 1225 1141 - static int 1142 - acpi_add_single_object(struct acpi_device **child, 1143 - struct acpi_device *parent, acpi_handle handle, int type, 1144 - struct acpi_bus_ops *ops) 1226 + static int acpi_add_single_object(struct acpi_device **child, 1227 + acpi_handle handle, int type, 1228 + unsigned long long sta, 1229 + struct acpi_bus_ops *ops) 1145 1230 { 1146 - int result = 0; 1147 - struct acpi_device *device = NULL; 1148 - 1149 - 1150 - if (!child) 1151 - return -EINVAL; 1231 + int result; 1232 + struct acpi_device *device; 1233 + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 1152 1234 1153 1235 device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL); 1154 1236 if (!device) { ··· 1153 1241 return -ENOMEM; 1154 1242 } 1155 1243 1244 + INIT_LIST_HEAD(&device->pnp.ids); 1245 + device->device_type = type; 1156 1246 device->handle = handle; 1157 - device->parent = parent; 1247 + device->parent = acpi_bus_get_parent(handle); 1158 1248 device->bus_ops = *ops; /* workround for not call .start */ 1249 + STRUCT_TO_INT(device->status) = sta; 1159 1250 1160 - 1161 - acpi_device_get_busid(device, handle, type); 1251 + acpi_device_get_busid(device); 1162 1252 1163 1253 /* 1164 1254 * Flags 1165 1255 * ----- 1166 - * Get prior to calling acpi_bus_get_status() so we know whether 1167 - * or not _STA is present. Note that we only look for object 1168 - * handles -- cannot evaluate objects until we know the device is 1169 - * present and properly initialized. 1256 + * Note that we only look for object handles -- cannot evaluate objects 1257 + * until we know the device is present and properly initialized. 1170 1258 */ 1171 1259 result = acpi_bus_get_flags(device); 1172 1260 if (result) 1173 1261 goto end; 1174 1262 1175 1263 /* 1176 - * Status 1177 - * ------ 1178 - * See if the device is present. We always assume that non-Device 1179 - * and non-Processor objects (e.g. thermal zones, power resources, 1180 - * etc.) are present, functioning, etc. (at least when parent object 1181 - * is present). Note that _STA has a different meaning for some 1182 - * objects (e.g. power resources) so we need to be careful how we use 1183 - * it. 1184 - */ 1185 - switch (type) { 1186 - case ACPI_BUS_TYPE_PROCESSOR: 1187 - case ACPI_BUS_TYPE_DEVICE: 1188 - result = acpi_bus_get_status(device); 1189 - if (ACPI_FAILURE(result)) { 1190 - result = -ENODEV; 1191 - goto end; 1192 - } 1193 - /* 1194 - * When the device is neither present nor functional, the 1195 - * device should not be added to Linux ACPI device tree. 1196 - * When the status of the device is not present but functinal, 1197 - * it should be added to Linux ACPI tree. For example : bay 1198 - * device , dock device. 1199 - * In such conditions it is unncessary to check whether it is 1200 - * bay device or dock device. 1201 - */ 1202 - if (!device->status.present && !device->status.functional) { 1203 - result = -ENODEV; 1204 - goto end; 1205 - } 1206 - break; 1207 - default: 1208 - STRUCT_TO_INT(device->status) = 1209 - ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | 1210 - ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; 1211 - break; 1212 - } 1213 - 1214 - /* 1215 1264 * Initialize Device 1216 1265 * ----------------- 1217 1266 * TBD: Synch with Core's enumeration/initialization process. 1218 1267 */ 1219 - 1220 - /* 1221 - * Hardware ID, Unique ID, & Bus Address 1222 - * ------------------------------------- 1223 - */ 1224 - acpi_device_set_id(device, parent, handle, type); 1268 + acpi_device_set_id(device); 1225 1269 1226 1270 /* 1227 1271 * Power Management ··· 1209 1341 goto end; 1210 1342 } 1211 1343 1212 - if ((result = acpi_device_set_context(device, type))) 1344 + if ((result = acpi_device_set_context(device))) 1213 1345 goto end; 1214 1346 1215 - result = acpi_device_register(device, parent); 1347 + result = acpi_device_register(device); 1216 1348 1217 1349 /* 1218 1350 * Bind _ADR-Based Devices when hot add ··· 1223 1355 } 1224 1356 1225 1357 end: 1226 - if (!result) 1358 + if (!result) { 1359 + acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 1360 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1361 + "Adding %s [%s] parent %s\n", dev_name(&device->dev), 1362 + (char *) buffer.pointer, 1363 + device->parent ? dev_name(&device->parent->dev) : 1364 + "(null)")); 1365 + kfree(buffer.pointer); 1227 1366 *child = device; 1228 - else 1367 + } else 1229 1368 acpi_device_release(&device->dev); 1230 1369 1231 1370 return result; 1232 1371 } 1233 1372 1234 - static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) 1373 + #define ACPI_STA_DEFAULT (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | \ 1374 + ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING) 1375 + 1376 + static int acpi_bus_type_and_status(acpi_handle handle, int *type, 1377 + unsigned long long *sta) 1235 1378 { 1236 - acpi_status status = AE_OK; 1237 - struct acpi_device *parent = NULL; 1238 - struct acpi_device *child = NULL; 1239 - acpi_handle phandle = NULL; 1240 - acpi_handle chandle = NULL; 1241 - acpi_object_type type = 0; 1242 - u32 level = 1; 1379 + acpi_status status; 1380 + acpi_object_type acpi_type; 1243 1381 1382 + status = acpi_get_type(handle, &acpi_type); 1383 + if (ACPI_FAILURE(status)) 1384 + return -ENODEV; 1244 1385 1245 - if (!start) 1246 - return -EINVAL; 1247 - 1248 - parent = start; 1249 - phandle = start->handle; 1250 - 1251 - /* 1252 - * Parse through the ACPI namespace, identify all 'devices', and 1253 - * create a new 'struct acpi_device' for each. 1254 - */ 1255 - while ((level > 0) && parent) { 1256 - 1257 - status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, 1258 - chandle, &chandle); 1259 - 1260 - /* 1261 - * If this scope is exhausted then move our way back up. 1262 - */ 1263 - if (ACPI_FAILURE(status)) { 1264 - level--; 1265 - chandle = phandle; 1266 - acpi_get_parent(phandle, &phandle); 1267 - if (parent->parent) 1268 - parent = parent->parent; 1269 - continue; 1270 - } 1271 - 1272 - status = acpi_get_type(chandle, &type); 1386 + switch (acpi_type) { 1387 + case ACPI_TYPE_ANY: /* for ACPI_ROOT_OBJECT */ 1388 + case ACPI_TYPE_DEVICE: 1389 + *type = ACPI_BUS_TYPE_DEVICE; 1390 + status = acpi_bus_get_status_handle(handle, sta); 1273 1391 if (ACPI_FAILURE(status)) 1274 - continue; 1275 - 1276 - /* 1277 - * If this is a scope object then parse it (depth-first). 1278 - */ 1279 - if (type == ACPI_TYPE_LOCAL_SCOPE) { 1280 - level++; 1281 - phandle = chandle; 1282 - chandle = NULL; 1283 - continue; 1284 - } 1285 - 1286 - /* 1287 - * We're only interested in objects that we consider 'devices'. 1288 - */ 1289 - switch (type) { 1290 - case ACPI_TYPE_DEVICE: 1291 - type = ACPI_BUS_TYPE_DEVICE; 1292 - break; 1293 - case ACPI_TYPE_PROCESSOR: 1294 - type = ACPI_BUS_TYPE_PROCESSOR; 1295 - break; 1296 - case ACPI_TYPE_THERMAL: 1297 - type = ACPI_BUS_TYPE_THERMAL; 1298 - break; 1299 - case ACPI_TYPE_POWER: 1300 - type = ACPI_BUS_TYPE_POWER; 1301 - break; 1302 - default: 1303 - continue; 1304 - } 1305 - 1306 - if (ops->acpi_op_add) 1307 - status = acpi_add_single_object(&child, parent, 1308 - chandle, type, ops); 1309 - else 1310 - status = acpi_bus_get_device(chandle, &child); 1311 - 1392 + return -ENODEV; 1393 + break; 1394 + case ACPI_TYPE_PROCESSOR: 1395 + *type = ACPI_BUS_TYPE_PROCESSOR; 1396 + status = acpi_bus_get_status_handle(handle, sta); 1312 1397 if (ACPI_FAILURE(status)) 1313 - continue; 1314 - 1315 - if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1316 - status = acpi_start_single_object(child); 1317 - if (ACPI_FAILURE(status)) 1318 - continue; 1319 - } 1320 - 1321 - /* 1322 - * If the device is present, enabled, and functioning then 1323 - * parse its scope (depth-first). Note that we need to 1324 - * represent absent devices to facilitate PnP notifications 1325 - * -- but only the subtree head (not all of its children, 1326 - * which will be enumerated when the parent is inserted). 1327 - * 1328 - * TBD: Need notifications and other detection mechanisms 1329 - * in place before we can fully implement this. 1330 - */ 1331 - /* 1332 - * When the device is not present but functional, it is also 1333 - * necessary to scan the children of this device. 1334 - */ 1335 - if (child->status.present || (!child->status.present && 1336 - child->status.functional)) { 1337 - status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, 1338 - NULL, NULL); 1339 - if (ACPI_SUCCESS(status)) { 1340 - level++; 1341 - phandle = chandle; 1342 - chandle = NULL; 1343 - parent = child; 1344 - } 1345 - } 1398 + return -ENODEV; 1399 + break; 1400 + case ACPI_TYPE_THERMAL: 1401 + *type = ACPI_BUS_TYPE_THERMAL; 1402 + *sta = ACPI_STA_DEFAULT; 1403 + break; 1404 + case ACPI_TYPE_POWER: 1405 + *type = ACPI_BUS_TYPE_POWER; 1406 + *sta = ACPI_STA_DEFAULT; 1407 + break; 1408 + default: 1409 + return -ENODEV; 1346 1410 } 1347 1411 1412 + return 0; 1413 + } 1414 + 1415 + static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, 1416 + void *context, void **return_value) 1417 + { 1418 + struct acpi_bus_ops *ops = context; 1419 + int type; 1420 + unsigned long long sta; 1421 + struct acpi_device *device; 1422 + acpi_status status; 1423 + int result; 1424 + 1425 + result = acpi_bus_type_and_status(handle, &type, &sta); 1426 + if (result) 1427 + return AE_OK; 1428 + 1429 + if (!(sta & ACPI_STA_DEVICE_PRESENT) && 1430 + !(sta & ACPI_STA_DEVICE_FUNCTIONING)) 1431 + return AE_CTRL_DEPTH; 1432 + 1433 + /* 1434 + * We may already have an acpi_device from a previous enumeration. If 1435 + * so, we needn't add it again, but we may still have to start it. 1436 + */ 1437 + device = NULL; 1438 + acpi_bus_get_device(handle, &device); 1439 + if (ops->acpi_op_add && !device) 1440 + acpi_add_single_object(&device, handle, type, sta, ops); 1441 + 1442 + if (!device) 1443 + return AE_CTRL_DEPTH; 1444 + 1445 + if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1446 + status = acpi_start_single_object(device); 1447 + if (ACPI_FAILURE(status)) 1448 + return AE_CTRL_DEPTH; 1449 + } 1450 + 1451 + if (!*return_value) 1452 + *return_value = device; 1453 + return AE_OK; 1454 + } 1455 + 1456 + static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, 1457 + struct acpi_device **child) 1458 + { 1459 + acpi_status status; 1460 + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 1461 + void *device = NULL; 1462 + 1463 + acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 1464 + printk(KERN_INFO PREFIX "Enumerating devices from [%s]\n", 1465 + (char *) buffer.pointer); 1466 + 1467 + status = acpi_bus_check_add(handle, 0, ops, &device); 1468 + if (ACPI_SUCCESS(status)) 1469 + acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 1470 + acpi_bus_check_add, ops, &device); 1471 + 1472 + if (child) 1473 + *child = device; 1348 1474 return 0; 1349 1475 } 1350 1476 ··· 1346 1484 acpi_bus_add(struct acpi_device **child, 1347 1485 struct acpi_device *parent, acpi_handle handle, int type) 1348 1486 { 1349 - int result; 1350 1487 struct acpi_bus_ops ops; 1351 1488 1352 1489 memset(&ops, 0, sizeof(ops)); 1353 1490 ops.acpi_op_add = 1; 1354 1491 1355 - result = acpi_add_single_object(child, parent, handle, type, &ops); 1356 - if (!result) 1357 - result = acpi_bus_scan(*child, &ops); 1358 - 1359 - return result; 1492 + acpi_bus_scan(handle, &ops, child); 1493 + return 0; 1360 1494 } 1361 1495 EXPORT_SYMBOL(acpi_bus_add); 1362 1496 1363 1497 int acpi_bus_start(struct acpi_device *device) 1364 1498 { 1365 - int result; 1366 1499 struct acpi_bus_ops ops; 1367 1500 1501 + memset(&ops, 0, sizeof(ops)); 1502 + ops.acpi_op_start = 1; 1368 1503 1369 - if (!device) 1370 - return -EINVAL; 1371 - 1372 - result = acpi_start_single_object(device); 1373 - if (!result) { 1374 - memset(&ops, 0, sizeof(ops)); 1375 - ops.acpi_op_start = 1; 1376 - result = acpi_bus_scan(device, &ops); 1377 - } 1378 - return result; 1504 + acpi_bus_scan(device->handle, &ops, NULL); 1505 + return 0; 1379 1506 } 1380 1507 EXPORT_SYMBOL(acpi_bus_start); 1381 1508 ··· 1423 1572 } 1424 1573 EXPORT_SYMBOL_GPL(acpi_bus_trim); 1425 1574 1426 - static int acpi_bus_scan_fixed(struct acpi_device *root) 1575 + static int acpi_bus_scan_fixed(void) 1427 1576 { 1428 1577 int result = 0; 1429 1578 struct acpi_device *device = NULL; 1430 1579 struct acpi_bus_ops ops; 1431 - 1432 - if (!root) 1433 - return -ENODEV; 1434 1580 1435 1581 memset(&ops, 0, sizeof(ops)); 1436 1582 ops.acpi_op_add = 1; ··· 1437 1589 * Enumerate all fixed-feature devices. 1438 1590 */ 1439 1591 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1440 - result = acpi_add_single_object(&device, acpi_root, 1441 - NULL, 1592 + result = acpi_add_single_object(&device, NULL, 1442 1593 ACPI_BUS_TYPE_POWER_BUTTON, 1594 + ACPI_STA_DEFAULT, 1443 1595 &ops); 1444 1596 } 1445 1597 1446 1598 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1447 - result = acpi_add_single_object(&device, acpi_root, 1448 - NULL, 1599 + result = acpi_add_single_object(&device, NULL, 1449 1600 ACPI_BUS_TYPE_SLEEP_BUTTON, 1601 + ACPI_STA_DEFAULT, 1450 1602 &ops); 1451 1603 } 1452 1604 ··· 1469 1621 } 1470 1622 1471 1623 /* 1472 - * Create the root device in the bus's device tree 1473 - */ 1474 - result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT, 1475 - ACPI_BUS_TYPE_SYSTEM, &ops); 1476 - if (result) 1477 - goto Done; 1478 - 1479 - /* 1480 1624 * Enumerate devices in the ACPI namespace. 1481 1625 */ 1482 - result = acpi_bus_scan_fixed(acpi_root); 1626 + result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root); 1483 1627 1484 1628 if (!result) 1485 - result = acpi_bus_scan(acpi_root, &ops); 1629 + result = acpi_bus_scan_fixed(); 1486 1630 1487 1631 if (result) 1488 1632 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1489 1633 1490 - Done: 1491 1634 return result; 1492 1635 }
+2 -3
drivers/i2c/busses/i2c-scmi.c
··· 369 369 goto err; 370 370 371 371 snprintf(smbus_cmi->adapter.name, sizeof(smbus_cmi->adapter.name), 372 - "SMBus CMI adapter %s (%s)", 373 - acpi_device_name(device), 374 - acpi_device_uid(device)); 372 + "SMBus CMI adapter %s", 373 + acpi_device_name(device)); 375 374 smbus_cmi->adapter.owner = THIS_MODULE; 376 375 smbus_cmi->adapter.algo = &acpi_smbus_cmi_algorithm; 377 376 smbus_cmi->adapter.algo_data = smbus_cmi;
-1
drivers/pci/hotplug/acpiphp_ibm.c
··· 406 406 __func__, status); 407 407 return retval; 408 408 } 409 - info->hardware_id.string[sizeof(info->hardware_id.length) - 1] = '\0'; 410 409 411 410 if (info->current_status && (info->valid & ACPI_VALID_HID) && 412 411 (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) ||
+427 -207
drivers/platform/x86/thinkpad_acpi.c
··· 22 22 */ 23 23 24 24 #define TPACPI_VERSION "0.23" 25 - #define TPACPI_SYSFS_VERSION 0x020400 25 + #define TPACPI_SYSFS_VERSION 0x020500 26 26 27 27 /* 28 28 * Changelog: ··· 143 143 TP_ACPI_WGSV_STATE_BLTHBIOSOFF = 0x0008, /* BLTH disabled in BIOS */ 144 144 TP_ACPI_WGSV_STATE_UWBEXIST = 0x0010, /* UWB hw available */ 145 145 TP_ACPI_WGSV_STATE_UWBPWR = 0x0020, /* UWB radio enabled */ 146 + }; 147 + 148 + /* HKEY events */ 149 + enum tpacpi_hkey_event_t { 150 + /* Hotkey-related */ 151 + TP_HKEY_EV_HOTKEY_BASE = 0x1001, /* first hotkey (FN+F1) */ 152 + TP_HKEY_EV_BRGHT_UP = 0x1010, /* Brightness up */ 153 + TP_HKEY_EV_BRGHT_DOWN = 0x1011, /* Brightness down */ 154 + TP_HKEY_EV_VOL_UP = 0x1015, /* Volume up or unmute */ 155 + TP_HKEY_EV_VOL_DOWN = 0x1016, /* Volume down or unmute */ 156 + TP_HKEY_EV_VOL_MUTE = 0x1017, /* Mixer output mute */ 157 + 158 + /* Reasons for waking up from S3/S4 */ 159 + TP_HKEY_EV_WKUP_S3_UNDOCK = 0x2304, /* undock requested, S3 */ 160 + TP_HKEY_EV_WKUP_S4_UNDOCK = 0x2404, /* undock requested, S4 */ 161 + TP_HKEY_EV_WKUP_S3_BAYEJ = 0x2305, /* bay ejection req, S3 */ 162 + TP_HKEY_EV_WKUP_S4_BAYEJ = 0x2405, /* bay ejection req, S4 */ 163 + TP_HKEY_EV_WKUP_S3_BATLOW = 0x2313, /* battery empty, S3 */ 164 + TP_HKEY_EV_WKUP_S4_BATLOW = 0x2413, /* battery empty, S4 */ 165 + 166 + /* Auto-sleep after eject request */ 167 + TP_HKEY_EV_BAYEJ_ACK = 0x3003, /* bay ejection complete */ 168 + TP_HKEY_EV_UNDOCK_ACK = 0x4003, /* undock complete */ 169 + 170 + /* Misc bay events */ 171 + TP_HKEY_EV_OPTDRV_EJ = 0x3006, /* opt. drive tray ejected */ 172 + 173 + /* User-interface events */ 174 + TP_HKEY_EV_LID_CLOSE = 0x5001, /* laptop lid closed */ 175 + TP_HKEY_EV_LID_OPEN = 0x5002, /* laptop lid opened */ 176 + TP_HKEY_EV_TABLET_TABLET = 0x5009, /* tablet swivel up */ 177 + TP_HKEY_EV_TABLET_NOTEBOOK = 0x500a, /* tablet swivel down */ 178 + TP_HKEY_EV_PEN_INSERTED = 0x500b, /* tablet pen inserted */ 179 + TP_HKEY_EV_PEN_REMOVED = 0x500c, /* tablet pen removed */ 180 + TP_HKEY_EV_BRGHT_CHANGED = 0x5010, /* backlight control event */ 181 + 182 + /* Thermal events */ 183 + TP_HKEY_EV_ALARM_BAT_HOT = 0x6011, /* battery too hot */ 184 + TP_HKEY_EV_ALARM_BAT_XHOT = 0x6012, /* battery critically hot */ 185 + TP_HKEY_EV_ALARM_SENSOR_HOT = 0x6021, /* sensor too hot */ 186 + TP_HKEY_EV_ALARM_SENSOR_XHOT = 0x6022, /* sensor critically hot */ 187 + TP_HKEY_EV_THM_TABLE_CHANGED = 0x6030, /* thermal table changed */ 188 + 189 + /* Misc */ 190 + TP_HKEY_EV_RFKILL_CHANGED = 0x7000, /* rfkill switch changed */ 146 191 }; 147 192 148 193 /**************************************************************************** ··· 1893 1848 * Hotkey subdriver 1894 1849 */ 1895 1850 1851 + /* 1852 + * ThinkPad firmware event model 1853 + * 1854 + * The ThinkPad firmware has two main event interfaces: normal ACPI 1855 + * notifications (which follow the ACPI standard), and a private event 1856 + * interface. 1857 + * 1858 + * The private event interface also issues events for the hotkeys. As 1859 + * the driver gained features, the event handling code ended up being 1860 + * built around the hotkey subdriver. This will need to be refactored 1861 + * to a more formal event API eventually. 1862 + * 1863 + * Some "hotkeys" are actually supposed to be used as event reports, 1864 + * such as "brightness has changed", "volume has changed", depending on 1865 + * the ThinkPad model and how the firmware is operating. 1866 + * 1867 + * Unlike other classes, hotkey-class events have mask/unmask control on 1868 + * non-ancient firmware. However, how it behaves changes a lot with the 1869 + * firmware model and version. 1870 + */ 1871 + 1896 1872 enum { /* hot key scan codes (derived from ACPI DSDT) */ 1897 1873 TP_ACPI_HOTKEYSCAN_FNF1 = 0, 1898 1874 TP_ACPI_HOTKEYSCAN_FNF2, ··· 1941 1875 TP_ACPI_HOTKEYSCAN_THINKPAD, 1942 1876 }; 1943 1877 1944 - enum { /* Keys available through NVRAM polling */ 1878 + enum { /* Keys/events available through NVRAM polling */ 1945 1879 TPACPI_HKEY_NVRAM_KNOWN_MASK = 0x00fb88c0U, 1946 1880 TPACPI_HKEY_NVRAM_GOOD_MASK = 0x00fb8000U, 1947 1881 }; ··· 1996 1930 static struct mutex hotkey_thread_mutex; 1997 1931 1998 1932 /* 1999 - * Acquire mutex to write poller control variables. 2000 - * Increment hotkey_config_change when changing them. 1933 + * Acquire mutex to write poller control variables as an 1934 + * atomic block. 1935 + * 1936 + * Increment hotkey_config_change when changing them if you 1937 + * want the kthread to forget old state. 2001 1938 * 2002 1939 * See HOTKEY_CONFIG_CRITICAL_START/HOTKEY_CONFIG_CRITICAL_END 2003 1940 */ ··· 2011 1942 * hotkey poller control variables 2012 1943 * 2013 1944 * Must be atomic or readers will also need to acquire mutex 1945 + * 1946 + * HOTKEY_CONFIG_CRITICAL_START/HOTKEY_CONFIG_CRITICAL_END 1947 + * should be used only when the changes need to be taken as 1948 + * a block, OR when one needs to force the kthread to forget 1949 + * old state. 2014 1950 */ 2015 1951 static u32 hotkey_source_mask; /* bit mask 0=ACPI,1=NVRAM */ 2016 1952 static unsigned int hotkey_poll_freq = 10; /* Hz */ ··· 2046 1972 2047 1973 static int hotkey_autosleep_ack; 2048 1974 2049 - static u32 hotkey_orig_mask; 2050 - static u32 hotkey_all_mask; 2051 - static u32 hotkey_reserved_mask; 2052 - static u32 hotkey_mask; 1975 + static u32 hotkey_orig_mask; /* events the BIOS had enabled */ 1976 + static u32 hotkey_all_mask; /* all events supported in fw */ 1977 + static u32 hotkey_reserved_mask; /* events better left disabled */ 1978 + static u32 hotkey_driver_mask; /* events needed by the driver */ 1979 + static u32 hotkey_user_mask; /* events visible to userspace */ 1980 + static u32 hotkey_acpi_mask; /* events enabled in firmware */ 2053 1981 2054 1982 static unsigned int hotkey_report_mode; 2055 1983 2056 1984 static u16 *hotkey_keycode_map; 2057 1985 2058 1986 static struct attribute_set *hotkey_dev_attributes; 1987 + 1988 + static void tpacpi_driver_event(const unsigned int hkey_event); 1989 + static void hotkey_driver_event(const unsigned int scancode); 2059 1990 2060 1991 /* HKEY.MHKG() return bits */ 2061 1992 #define TP_HOTKEY_TABLET_MASK (1 << 3) ··· 2096 2017 } 2097 2018 2098 2019 /* 2020 + * Reads current event mask from firmware, and updates 2021 + * hotkey_acpi_mask accordingly. Also resets any bits 2022 + * from hotkey_user_mask that are unavailable to be 2023 + * delivered (shadow requirement of the userspace ABI). 2024 + * 2099 2025 * Call with hotkey_mutex held 2100 2026 */ 2101 2027 static int hotkey_mask_get(void) 2102 2028 { 2103 - u32 m = 0; 2104 - 2105 2029 if (tp_features.hotkey_mask) { 2030 + u32 m = 0; 2031 + 2106 2032 if (!acpi_evalf(hkey_handle, &m, "DHKN", "d")) 2107 2033 return -EIO; 2034 + 2035 + hotkey_acpi_mask = m; 2036 + } else { 2037 + /* no mask support doesn't mean no event support... */ 2038 + hotkey_acpi_mask = hotkey_all_mask; 2108 2039 } 2109 - HOTKEY_CONFIG_CRITICAL_START 2110 - hotkey_mask = m | (hotkey_source_mask & hotkey_mask); 2111 - HOTKEY_CONFIG_CRITICAL_END 2040 + 2041 + /* sync userspace-visible mask */ 2042 + hotkey_user_mask &= (hotkey_acpi_mask | hotkey_source_mask); 2112 2043 2113 2044 return 0; 2114 2045 } 2115 2046 2047 + void static hotkey_mask_warn_incomplete_mask(void) 2048 + { 2049 + /* log only what the user can fix... */ 2050 + const u32 wantedmask = hotkey_driver_mask & 2051 + ~(hotkey_acpi_mask | hotkey_source_mask) & 2052 + (hotkey_all_mask | TPACPI_HKEY_NVRAM_KNOWN_MASK); 2053 + 2054 + if (wantedmask) 2055 + printk(TPACPI_NOTICE 2056 + "required events 0x%08x not enabled!\n", 2057 + wantedmask); 2058 + } 2059 + 2116 2060 /* 2061 + * Set the firmware mask when supported 2062 + * 2063 + * Also calls hotkey_mask_get to update hotkey_acpi_mask. 2064 + * 2065 + * NOTE: does not set bits in hotkey_user_mask, but may reset them. 2066 + * 2117 2067 * Call with hotkey_mutex held 2118 2068 */ 2119 2069 static int hotkey_mask_set(u32 mask) ··· 2150 2042 int i; 2151 2043 int rc = 0; 2152 2044 2153 - if (tp_features.hotkey_mask) { 2154 - if (!tp_warned.hotkey_mask_ff && 2155 - (mask == 0xffff || mask == 0xffffff || 2156 - mask == 0xffffffff)) { 2157 - tp_warned.hotkey_mask_ff = 1; 2158 - printk(TPACPI_NOTICE 2159 - "setting the hotkey mask to 0x%08x is likely " 2160 - "not the best way to go about it\n", mask); 2161 - printk(TPACPI_NOTICE 2162 - "please consider using the driver defaults, " 2163 - "and refer to up-to-date thinkpad-acpi " 2164 - "documentation\n"); 2165 - } 2045 + const u32 fwmask = mask & ~hotkey_source_mask; 2166 2046 2167 - HOTKEY_CONFIG_CRITICAL_START 2047 + if (tp_features.hotkey_mask) { 2168 2048 for (i = 0; i < 32; i++) { 2169 - u32 m = 1 << i; 2170 - /* enable in firmware mask only keys not in NVRAM 2171 - * mode, but enable the key in the cached hotkey_mask 2172 - * regardless of mode, or the key will end up 2173 - * disabled by hotkey_mask_get() */ 2174 2049 if (!acpi_evalf(hkey_handle, 2175 2050 NULL, "MHKM", "vdd", i + 1, 2176 - !!((mask & ~hotkey_source_mask) & m))) { 2051 + !!(mask & (1 << i)))) { 2177 2052 rc = -EIO; 2178 2053 break; 2179 - } else { 2180 - hotkey_mask = (hotkey_mask & ~m) | (mask & m); 2181 2054 } 2182 2055 } 2183 - HOTKEY_CONFIG_CRITICAL_END 2184 - 2185 - /* hotkey_mask_get must be called unconditionally below */ 2186 - if (!hotkey_mask_get() && !rc && 2187 - (hotkey_mask & ~hotkey_source_mask) != 2188 - (mask & ~hotkey_source_mask)) { 2189 - printk(TPACPI_NOTICE 2190 - "requested hot key mask 0x%08x, but " 2191 - "firmware forced it to 0x%08x\n", 2192 - mask, hotkey_mask); 2193 - } 2194 - } else { 2195 - #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL 2196 - HOTKEY_CONFIG_CRITICAL_START 2197 - hotkey_mask = mask & hotkey_source_mask; 2198 - HOTKEY_CONFIG_CRITICAL_END 2199 - hotkey_mask_get(); 2200 - if (hotkey_mask != mask) { 2201 - printk(TPACPI_NOTICE 2202 - "requested hot key mask 0x%08x, " 2203 - "forced to 0x%08x (NVRAM poll mask is " 2204 - "0x%08x): no firmware mask support\n", 2205 - mask, hotkey_mask, hotkey_source_mask); 2206 - } 2207 - #else 2208 - hotkey_mask_get(); 2209 - rc = -ENXIO; 2210 - #endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ 2211 2056 } 2057 + 2058 + /* 2059 + * We *must* make an inconditional call to hotkey_mask_get to 2060 + * refresh hotkey_acpi_mask and update hotkey_user_mask 2061 + * 2062 + * Take the opportunity to also log when we cannot _enable_ 2063 + * a given event. 2064 + */ 2065 + if (!hotkey_mask_get() && !rc && (fwmask & ~hotkey_acpi_mask)) { 2066 + printk(TPACPI_NOTICE 2067 + "asked for hotkey mask 0x%08x, but " 2068 + "firmware forced it to 0x%08x\n", 2069 + fwmask, hotkey_acpi_mask); 2070 + } 2071 + 2072 + hotkey_mask_warn_incomplete_mask(); 2073 + 2074 + return rc; 2075 + } 2076 + 2077 + /* 2078 + * Sets hotkey_user_mask and tries to set the firmware mask 2079 + * 2080 + * Call with hotkey_mutex held 2081 + */ 2082 + static int hotkey_user_mask_set(const u32 mask) 2083 + { 2084 + int rc; 2085 + 2086 + /* Give people a chance to notice they are doing something that 2087 + * is bound to go boom on their users sooner or later */ 2088 + if (!tp_warned.hotkey_mask_ff && 2089 + (mask == 0xffff || mask == 0xffffff || 2090 + mask == 0xffffffff)) { 2091 + tp_warned.hotkey_mask_ff = 1; 2092 + printk(TPACPI_NOTICE 2093 + "setting the hotkey mask to 0x%08x is likely " 2094 + "not the best way to go about it\n", mask); 2095 + printk(TPACPI_NOTICE 2096 + "please consider using the driver defaults, " 2097 + "and refer to up-to-date thinkpad-acpi " 2098 + "documentation\n"); 2099 + } 2100 + 2101 + /* Try to enable what the user asked for, plus whatever we need. 2102 + * this syncs everything but won't enable bits in hotkey_user_mask */ 2103 + rc = hotkey_mask_set((mask | hotkey_driver_mask) & ~hotkey_source_mask); 2104 + 2105 + /* Enable the available bits in hotkey_user_mask */ 2106 + hotkey_user_mask = mask & (hotkey_acpi_mask | hotkey_source_mask); 2107 + 2108 + return rc; 2109 + } 2110 + 2111 + /* 2112 + * Sets the driver hotkey mask. 2113 + * 2114 + * Can be called even if the hotkey subdriver is inactive 2115 + */ 2116 + static int tpacpi_hotkey_driver_mask_set(const u32 mask) 2117 + { 2118 + int rc; 2119 + 2120 + /* Do the right thing if hotkey_init has not been called yet */ 2121 + if (!tp_features.hotkey) { 2122 + hotkey_driver_mask = mask; 2123 + return 0; 2124 + } 2125 + 2126 + mutex_lock(&hotkey_mutex); 2127 + 2128 + HOTKEY_CONFIG_CRITICAL_START 2129 + hotkey_driver_mask = mask; 2130 + hotkey_source_mask |= (mask & ~hotkey_all_mask); 2131 + HOTKEY_CONFIG_CRITICAL_END 2132 + 2133 + rc = hotkey_mask_set((hotkey_acpi_mask | hotkey_driver_mask) & 2134 + ~hotkey_source_mask); 2135 + mutex_unlock(&hotkey_mutex); 2212 2136 2213 2137 return rc; 2214 2138 } ··· 2277 2137 } 2278 2138 } 2279 2139 2280 - static void tpacpi_input_send_key(unsigned int scancode) 2140 + /* Do NOT call without validating scancode first */ 2141 + static void tpacpi_input_send_key(const unsigned int scancode) 2281 2142 { 2282 - unsigned int keycode; 2283 - 2284 - keycode = hotkey_keycode_map[scancode]; 2143 + const unsigned int keycode = hotkey_keycode_map[scancode]; 2285 2144 2286 2145 if (keycode != KEY_RESERVED) { 2287 2146 mutex_lock(&tpacpi_inputdev_send_mutex); ··· 2301 2162 } 2302 2163 } 2303 2164 2165 + /* Do NOT call without validating scancode first */ 2166 + static void tpacpi_input_send_key_masked(const unsigned int scancode) 2167 + { 2168 + hotkey_driver_event(scancode); 2169 + if (hotkey_user_mask & (1 << scancode)) 2170 + tpacpi_input_send_key(scancode); 2171 + } 2172 + 2304 2173 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL 2305 2174 static struct tp_acpi_drv_struct ibm_hotkey_acpidriver; 2306 2175 2176 + /* Do NOT call without validating scancode first */ 2307 2177 static void tpacpi_hotkey_send_key(unsigned int scancode) 2308 2178 { 2309 - tpacpi_input_send_key(scancode); 2179 + tpacpi_input_send_key_masked(scancode); 2310 2180 if (hotkey_report_mode < 2) { 2311 2181 acpi_bus_generate_proc_event(ibm_hotkey_acpidriver.device, 2312 - 0x80, 0x1001 + scancode); 2182 + 0x80, TP_HKEY_EV_HOTKEY_BASE + scancode); 2313 2183 } 2314 2184 } 2315 2185 2316 - static void hotkey_read_nvram(struct tp_nvram_state *n, u32 m) 2186 + static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m) 2317 2187 { 2318 2188 u8 d; 2319 2189 ··· 2358 2210 } 2359 2211 } 2360 2212 2213 + static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn, 2214 + struct tp_nvram_state *newn, 2215 + const u32 event_mask) 2216 + { 2217 + 2361 2218 #define TPACPI_COMPARE_KEY(__scancode, __member) \ 2362 2219 do { \ 2363 - if ((mask & (1 << __scancode)) && \ 2220 + if ((event_mask & (1 << __scancode)) && \ 2364 2221 oldn->__member != newn->__member) \ 2365 - tpacpi_hotkey_send_key(__scancode); \ 2222 + tpacpi_hotkey_send_key(__scancode); \ 2366 2223 } while (0) 2367 2224 2368 2225 #define TPACPI_MAY_SEND_KEY(__scancode) \ 2369 - do { if (mask & (1 << __scancode)) \ 2370 - tpacpi_hotkey_send_key(__scancode); } while (0) 2226 + do { \ 2227 + if (event_mask & (1 << __scancode)) \ 2228 + tpacpi_hotkey_send_key(__scancode); \ 2229 + } while (0) 2371 2230 2372 - static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn, 2373 - struct tp_nvram_state *newn, 2374 - u32 mask) 2375 - { 2376 2231 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle); 2377 2232 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle); 2378 2233 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle); ··· 2421 2270 } 2422 2271 } 2423 2272 } 2424 - } 2425 2273 2426 2274 #undef TPACPI_COMPARE_KEY 2427 2275 #undef TPACPI_MAY_SEND_KEY 2276 + } 2428 2277 2278 + /* 2279 + * Polling driver 2280 + * 2281 + * We track all events in hotkey_source_mask all the time, since 2282 + * most of them are edge-based. We only issue those requested by 2283 + * hotkey_user_mask or hotkey_driver_mask, though. 2284 + */ 2429 2285 static int hotkey_kthread(void *data) 2430 2286 { 2431 2287 struct tp_nvram_state s[2]; 2432 - u32 mask; 2288 + u32 poll_mask, event_mask; 2433 2289 unsigned int si, so; 2434 2290 unsigned long t; 2435 2291 unsigned int change_detector, must_reset; ··· 2456 2298 /* Initial state for compares */ 2457 2299 mutex_lock(&hotkey_thread_data_mutex); 2458 2300 change_detector = hotkey_config_change; 2459 - mask = hotkey_source_mask & hotkey_mask; 2301 + poll_mask = hotkey_source_mask; 2302 + event_mask = hotkey_source_mask & 2303 + (hotkey_driver_mask | hotkey_user_mask); 2460 2304 poll_freq = hotkey_poll_freq; 2461 2305 mutex_unlock(&hotkey_thread_data_mutex); 2462 - hotkey_read_nvram(&s[so], mask); 2306 + hotkey_read_nvram(&s[so], poll_mask); 2463 2307 2464 2308 while (!kthread_should_stop()) { 2465 2309 if (t == 0) { ··· 2484 2324 t = 0; 2485 2325 change_detector = hotkey_config_change; 2486 2326 } 2487 - mask = hotkey_source_mask & hotkey_mask; 2327 + poll_mask = hotkey_source_mask; 2328 + event_mask = hotkey_source_mask & 2329 + (hotkey_driver_mask | hotkey_user_mask); 2488 2330 poll_freq = hotkey_poll_freq; 2489 2331 mutex_unlock(&hotkey_thread_data_mutex); 2490 2332 2491 - if (likely(mask)) { 2492 - hotkey_read_nvram(&s[si], mask); 2333 + if (likely(poll_mask)) { 2334 + hotkey_read_nvram(&s[si], poll_mask); 2493 2335 if (likely(si != so)) { 2494 2336 hotkey_compare_and_issue_event(&s[so], &s[si], 2495 - mask); 2337 + event_mask); 2496 2338 } 2497 2339 } 2498 2340 ··· 2526 2364 /* call with hotkey_mutex held */ 2527 2365 static void hotkey_poll_setup(bool may_warn) 2528 2366 { 2529 - u32 hotkeys_to_poll = hotkey_source_mask & hotkey_mask; 2367 + const u32 poll_driver_mask = hotkey_driver_mask & hotkey_source_mask; 2368 + const u32 poll_user_mask = hotkey_user_mask & hotkey_source_mask; 2530 2369 2531 - if (hotkeys_to_poll != 0 && hotkey_poll_freq > 0 && 2532 - (tpacpi_inputdev->users > 0 || hotkey_report_mode < 2)) { 2370 + if (hotkey_poll_freq > 0 && 2371 + (poll_driver_mask || 2372 + (poll_user_mask && tpacpi_inputdev->users > 0))) { 2533 2373 if (!tpacpi_hotkey_task) { 2534 2374 tpacpi_hotkey_task = kthread_run(hotkey_kthread, 2535 2375 NULL, TPACPI_NVRAM_KTHREAD_NAME); ··· 2544 2380 } 2545 2381 } else { 2546 2382 hotkey_poll_stop_sync(); 2547 - if (may_warn && hotkeys_to_poll != 0 && 2383 + if (may_warn && (poll_driver_mask || poll_user_mask) && 2548 2384 hotkey_poll_freq == 0) { 2549 2385 printk(TPACPI_NOTICE 2550 - "hot keys 0x%08x require polling, " 2551 - "which is currently disabled\n", 2552 - hotkeys_to_poll); 2386 + "hot keys 0x%08x and/or events 0x%08x " 2387 + "require polling, which is currently " 2388 + "disabled\n", 2389 + poll_user_mask, poll_driver_mask); 2553 2390 } 2554 2391 } 2555 2392 } ··· 2568 2403 if (!freq) 2569 2404 hotkey_poll_stop_sync(); 2570 2405 2571 - HOTKEY_CONFIG_CRITICAL_START 2572 2406 hotkey_poll_freq = freq; 2573 - HOTKEY_CONFIG_CRITICAL_END 2574 2407 } 2575 2408 2576 2409 #else /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ ··· 2603 2440 static void hotkey_inputdev_close(struct input_dev *dev) 2604 2441 { 2605 2442 /* disable hotkey polling when possible */ 2606 - if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING) 2443 + if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING && 2444 + !(hotkey_source_mask & hotkey_driver_mask)) 2607 2445 hotkey_poll_setup_safe(false); 2608 2446 } 2609 2447 ··· 2652 2488 struct device_attribute *attr, 2653 2489 char *buf) 2654 2490 { 2655 - int res; 2656 - 2657 - if (mutex_lock_killable(&hotkey_mutex)) 2658 - return -ERESTARTSYS; 2659 - res = hotkey_mask_get(); 2660 - mutex_unlock(&hotkey_mutex); 2661 - 2662 - return (res)? 2663 - res : snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_mask); 2491 + return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_user_mask); 2664 2492 } 2665 2493 2666 2494 static ssize_t hotkey_mask_store(struct device *dev, ··· 2668 2512 if (mutex_lock_killable(&hotkey_mutex)) 2669 2513 return -ERESTARTSYS; 2670 2514 2671 - res = hotkey_mask_set(t); 2515 + res = hotkey_user_mask_set(t); 2672 2516 2673 2517 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL 2674 2518 hotkey_poll_setup(true); ··· 2750 2594 const char *buf, size_t count) 2751 2595 { 2752 2596 unsigned long t; 2597 + u32 r_ev; 2598 + int rc; 2753 2599 2754 2600 if (parse_strtoul(buf, 0xffffffffUL, &t) || 2755 2601 ((t & ~TPACPI_HKEY_NVRAM_KNOWN_MASK) != 0)) ··· 2764 2606 hotkey_source_mask = t; 2765 2607 HOTKEY_CONFIG_CRITICAL_END 2766 2608 2609 + rc = hotkey_mask_set((hotkey_user_mask | hotkey_driver_mask) & 2610 + ~hotkey_source_mask); 2767 2611 hotkey_poll_setup(true); 2768 - hotkey_mask_set(hotkey_mask); 2612 + 2613 + /* check if events needed by the driver got disabled */ 2614 + r_ev = hotkey_driver_mask & ~(hotkey_acpi_mask & hotkey_all_mask) 2615 + & ~hotkey_source_mask & TPACPI_HKEY_NVRAM_KNOWN_MASK; 2769 2616 2770 2617 mutex_unlock(&hotkey_mutex); 2771 2618 2619 + if (rc < 0) 2620 + printk(TPACPI_ERR "hotkey_source_mask: failed to update the" 2621 + "firmware event mask!\n"); 2622 + 2623 + if (r_ev) 2624 + printk(TPACPI_NOTICE "hotkey_source_mask: " 2625 + "some important events were disabled: " 2626 + "0x%04x\n", r_ev); 2627 + 2772 2628 tpacpi_disclose_usertask("hotkey_source_mask", "set to 0x%08lx\n", t); 2773 2629 2774 - return count; 2630 + return (rc < 0) ? rc : count; 2775 2631 } 2776 2632 2777 2633 static struct device_attribute dev_attr_hotkey_source_mask = ··· 2903 2731 2904 2732 static void hotkey_wakeup_reason_notify_change(void) 2905 2733 { 2906 - if (tp_features.hotkey_mask) 2907 - sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, 2908 - "wakeup_reason"); 2734 + sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, 2735 + "wakeup_reason"); 2909 2736 } 2910 2737 2911 2738 /* sysfs wakeup hotunplug_complete (pollable) -------------------------- */ ··· 2921 2750 2922 2751 static void hotkey_wakeup_hotunplug_complete_notify_change(void) 2923 2752 { 2924 - if (tp_features.hotkey_mask) 2925 - sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, 2926 - "wakeup_hotunplug_complete"); 2753 + sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, 2754 + "wakeup_hotunplug_complete"); 2927 2755 } 2928 2756 2929 2757 /* --------------------------------------------------------------------- */ ··· 2930 2760 static struct attribute *hotkey_attributes[] __initdata = { 2931 2761 &dev_attr_hotkey_enable.attr, 2932 2762 &dev_attr_hotkey_bios_enabled.attr, 2763 + &dev_attr_hotkey_bios_mask.attr, 2933 2764 &dev_attr_hotkey_report_mode.attr, 2934 - #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL 2765 + &dev_attr_hotkey_wakeup_reason.attr, 2766 + &dev_attr_hotkey_wakeup_hotunplug_complete.attr, 2935 2767 &dev_attr_hotkey_mask.attr, 2936 2768 &dev_attr_hotkey_all_mask.attr, 2937 2769 &dev_attr_hotkey_recommended_mask.attr, 2770 + #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL 2938 2771 &dev_attr_hotkey_source_mask.attr, 2939 2772 &dev_attr_hotkey_poll_freq.attr, 2940 2773 #endif 2941 - }; 2942 - 2943 - static struct attribute *hotkey_mask_attributes[] __initdata = { 2944 - &dev_attr_hotkey_bios_mask.attr, 2945 - #ifndef CONFIG_THINKPAD_ACPI_HOTKEY_POLL 2946 - &dev_attr_hotkey_mask.attr, 2947 - &dev_attr_hotkey_all_mask.attr, 2948 - &dev_attr_hotkey_recommended_mask.attr, 2949 - #endif 2950 - &dev_attr_hotkey_wakeup_reason.attr, 2951 - &dev_attr_hotkey_wakeup_hotunplug_complete.attr, 2952 2774 }; 2953 2775 2954 2776 /* ··· 3005 2843 3006 2844 kfree(hotkey_keycode_map); 3007 2845 3008 - if (tp_features.hotkey) { 3009 - dbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_HKEY, 3010 - "restoring original hot key mask\n"); 3011 - /* no short-circuit boolean operator below! */ 3012 - if ((hotkey_mask_set(hotkey_orig_mask) | 3013 - hotkey_status_set(false)) != 0) 3014 - printk(TPACPI_ERR 3015 - "failed to restore hot key mask " 3016 - "to BIOS defaults\n"); 3017 - } 2846 + dbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_HKEY, 2847 + "restoring original HKEY status and mask\n"); 2848 + /* yes, there is a bitwise or below, we want the 2849 + * functions to be called even if one of them fail */ 2850 + if (((tp_features.hotkey_mask && 2851 + hotkey_mask_set(hotkey_orig_mask)) | 2852 + hotkey_status_set(false)) != 0) 2853 + printk(TPACPI_ERR 2854 + "failed to restore hot key mask " 2855 + "to BIOS defaults\n"); 3018 2856 } 3019 2857 3020 2858 static void __init hotkey_unmap(const unsigned int scancode) ··· 3025 2863 hotkey_keycode_map[scancode] = KEY_RESERVED; 3026 2864 } 3027 2865 } 2866 + 2867 + /* 2868 + * HKEY quirks: 2869 + * TPACPI_HK_Q_INIMASK: Supports FN+F3,FN+F4,FN+F12 2870 + */ 2871 + 2872 + #define TPACPI_HK_Q_INIMASK 0x0001 2873 + 2874 + static const struct tpacpi_quirk tpacpi_hotkey_qtable[] __initconst = { 2875 + TPACPI_Q_IBM('I', 'H', TPACPI_HK_Q_INIMASK), /* 600E */ 2876 + TPACPI_Q_IBM('I', 'N', TPACPI_HK_Q_INIMASK), /* 600E */ 2877 + TPACPI_Q_IBM('I', 'D', TPACPI_HK_Q_INIMASK), /* 770, 770E, 770ED */ 2878 + TPACPI_Q_IBM('I', 'W', TPACPI_HK_Q_INIMASK), /* A20m */ 2879 + TPACPI_Q_IBM('I', 'V', TPACPI_HK_Q_INIMASK), /* A20p */ 2880 + TPACPI_Q_IBM('1', '0', TPACPI_HK_Q_INIMASK), /* A21e, A22e */ 2881 + TPACPI_Q_IBM('K', 'U', TPACPI_HK_Q_INIMASK), /* A21e */ 2882 + TPACPI_Q_IBM('K', 'X', TPACPI_HK_Q_INIMASK), /* A21m, A22m */ 2883 + TPACPI_Q_IBM('K', 'Y', TPACPI_HK_Q_INIMASK), /* A21p, A22p */ 2884 + TPACPI_Q_IBM('1', 'B', TPACPI_HK_Q_INIMASK), /* A22e */ 2885 + TPACPI_Q_IBM('1', '3', TPACPI_HK_Q_INIMASK), /* A22m */ 2886 + TPACPI_Q_IBM('1', 'E', TPACPI_HK_Q_INIMASK), /* A30/p (0) */ 2887 + TPACPI_Q_IBM('1', 'C', TPACPI_HK_Q_INIMASK), /* R30 */ 2888 + TPACPI_Q_IBM('1', 'F', TPACPI_HK_Q_INIMASK), /* R31 */ 2889 + TPACPI_Q_IBM('I', 'Y', TPACPI_HK_Q_INIMASK), /* T20 */ 2890 + TPACPI_Q_IBM('K', 'Z', TPACPI_HK_Q_INIMASK), /* T21 */ 2891 + TPACPI_Q_IBM('1', '6', TPACPI_HK_Q_INIMASK), /* T22 */ 2892 + TPACPI_Q_IBM('I', 'Z', TPACPI_HK_Q_INIMASK), /* X20, X21 */ 2893 + TPACPI_Q_IBM('1', 'D', TPACPI_HK_Q_INIMASK), /* X22, X23, X24 */ 2894 + }; 3028 2895 3029 2896 static int __init hotkey_init(struct ibm_init_struct *iibm) 3030 2897 { ··· 3097 2906 KEY_UNKNOWN, /* 0x0D: FN+INSERT */ 3098 2907 KEY_UNKNOWN, /* 0x0E: FN+DELETE */ 3099 2908 3100 - /* brightness: firmware always reacts to them, unless 3101 - * X.org did some tricks in the radeon BIOS scratch 3102 - * registers of *some* models */ 2909 + /* brightness: firmware always reacts to them */ 3103 2910 KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */ 3104 2911 KEY_RESERVED, /* 0x10: FN+END (brightness down) */ 3105 2912 ··· 3172 2983 int status; 3173 2984 int hkeyv; 3174 2985 2986 + unsigned long quirks; 2987 + 3175 2988 vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY, 3176 2989 "initializing hotkey subdriver\n"); 3177 2990 ··· 3199 3008 if (!tp_features.hotkey) 3200 3009 return 1; 3201 3010 3011 + quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable, 3012 + ARRAY_SIZE(tpacpi_hotkey_qtable)); 3013 + 3202 3014 tpacpi_disable_brightness_delay(); 3203 3015 3204 - hotkey_dev_attributes = create_attr_set(13, NULL); 3016 + /* MUST have enough space for all attributes to be added to 3017 + * hotkey_dev_attributes */ 3018 + hotkey_dev_attributes = create_attr_set( 3019 + ARRAY_SIZE(hotkey_attributes) + 2, 3020 + NULL); 3205 3021 if (!hotkey_dev_attributes) 3206 3022 return -ENOMEM; 3207 3023 res = add_many_to_attr_set(hotkey_dev_attributes, ··· 3217 3019 if (res) 3218 3020 goto err_exit; 3219 3021 3220 - /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, 3022 + /* mask not supported on 600e/x, 770e, 770x, A21e, A2xm/p, 3221 3023 A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking 3222 3024 for HKEY interface version 0x100 */ 3223 3025 if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) { ··· 3231 3033 * MHKV 0x100 in A31, R40, R40e, 3232 3034 * T4x, X31, and later 3233 3035 */ 3234 - tp_features.hotkey_mask = 1; 3235 3036 vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY, 3236 3037 "firmware HKEY interface version: 0x%x\n", 3237 3038 hkeyv); 3039 + 3040 + /* Paranoia check AND init hotkey_all_mask */ 3041 + if (!acpi_evalf(hkey_handle, &hotkey_all_mask, 3042 + "MHKA", "qd")) { 3043 + printk(TPACPI_ERR 3044 + "missing MHKA handler, " 3045 + "please report this to %s\n", 3046 + TPACPI_MAIL); 3047 + /* Fallback: pre-init for FN+F3,F4,F12 */ 3048 + hotkey_all_mask = 0x080cU; 3049 + } else { 3050 + tp_features.hotkey_mask = 1; 3051 + } 3238 3052 } 3239 3053 } 3240 3054 ··· 3254 3044 "hotkey masks are %s\n", 3255 3045 str_supported(tp_features.hotkey_mask)); 3256 3046 3257 - if (tp_features.hotkey_mask) { 3258 - if (!acpi_evalf(hkey_handle, &hotkey_all_mask, 3259 - "MHKA", "qd")) { 3260 - printk(TPACPI_ERR 3261 - "missing MHKA handler, " 3262 - "please report this to %s\n", 3263 - TPACPI_MAIL); 3264 - /* FN+F12, FN+F4, FN+F3 */ 3265 - hotkey_all_mask = 0x080cU; 3266 - } 3267 - } 3047 + /* Init hotkey_all_mask if not initialized yet */ 3048 + if (!tp_features.hotkey_mask && !hotkey_all_mask && 3049 + (quirks & TPACPI_HK_Q_INIMASK)) 3050 + hotkey_all_mask = 0x080cU; /* FN+F12, FN+F4, FN+F3 */ 3268 3051 3269 - /* hotkey_source_mask *must* be zero for 3270 - * the first hotkey_mask_get */ 3052 + /* Init hotkey_acpi_mask and hotkey_orig_mask */ 3271 3053 if (tp_features.hotkey_mask) { 3054 + /* hotkey_source_mask *must* be zero for 3055 + * the first hotkey_mask_get to return hotkey_orig_mask */ 3272 3056 res = hotkey_mask_get(); 3273 3057 if (res) 3274 3058 goto err_exit; 3275 3059 3276 - hotkey_orig_mask = hotkey_mask; 3277 - res = add_many_to_attr_set( 3278 - hotkey_dev_attributes, 3279 - hotkey_mask_attributes, 3280 - ARRAY_SIZE(hotkey_mask_attributes)); 3281 - if (res) 3282 - goto err_exit; 3060 + hotkey_orig_mask = hotkey_acpi_mask; 3061 + } else { 3062 + hotkey_orig_mask = hotkey_all_mask; 3063 + hotkey_acpi_mask = hotkey_all_mask; 3283 3064 } 3284 3065 3285 3066 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES ··· 3384 3183 } 3385 3184 3386 3185 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL 3387 - if (tp_features.hotkey_mask) { 3388 - hotkey_source_mask = TPACPI_HKEY_NVRAM_GOOD_MASK 3389 - & ~hotkey_all_mask 3390 - & ~hotkey_reserved_mask; 3391 - } else { 3392 - hotkey_source_mask = TPACPI_HKEY_NVRAM_GOOD_MASK 3393 - & ~hotkey_reserved_mask; 3394 - } 3186 + hotkey_source_mask = TPACPI_HKEY_NVRAM_GOOD_MASK 3187 + & ~hotkey_all_mask 3188 + & ~hotkey_reserved_mask; 3395 3189 3396 3190 vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY, 3397 3191 "hotkey source mask 0x%08x, polling freq %u\n", ··· 3400 3204 hotkey_exit(); 3401 3205 return res; 3402 3206 } 3403 - res = hotkey_mask_set(((hotkey_all_mask | hotkey_source_mask) 3404 - & ~hotkey_reserved_mask) 3405 - | hotkey_orig_mask); 3207 + res = hotkey_mask_set(((hotkey_all_mask & ~hotkey_reserved_mask) 3208 + | hotkey_driver_mask) 3209 + & ~hotkey_source_mask); 3406 3210 if (res < 0 && res != -ENXIO) { 3407 3211 hotkey_exit(); 3408 3212 return res; 3409 3213 } 3214 + hotkey_user_mask = (hotkey_acpi_mask | hotkey_source_mask) 3215 + & ~hotkey_reserved_mask; 3216 + vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY, 3217 + "initial masks: user=0x%08x, fw=0x%08x, poll=0x%08x\n", 3218 + hotkey_user_mask, hotkey_acpi_mask, hotkey_source_mask); 3410 3219 3411 3220 dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY, 3412 3221 "legacy ibm/hotkey event reporting over procfs %s\n", ··· 3446 3245 if (scancode > 0 && scancode < 0x21) { 3447 3246 scancode--; 3448 3247 if (!(hotkey_source_mask & (1 << scancode))) { 3449 - tpacpi_input_send_key(scancode); 3248 + tpacpi_input_send_key_masked(scancode); 3450 3249 *send_acpi_ev = false; 3451 3250 } else { 3452 3251 *ignore_acpi_ev = true; ··· 3465 3264 *ignore_acpi_ev = false; 3466 3265 3467 3266 switch (hkey) { 3468 - case 0x2304: /* suspend, undock */ 3469 - case 0x2404: /* hibernation, undock */ 3267 + case TP_HKEY_EV_WKUP_S3_UNDOCK: /* suspend, undock */ 3268 + case TP_HKEY_EV_WKUP_S4_UNDOCK: /* hibernation, undock */ 3470 3269 hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK; 3471 3270 *ignore_acpi_ev = true; 3472 3271 break; 3473 3272 3474 - case 0x2305: /* suspend, bay eject */ 3475 - case 0x2405: /* hibernation, bay eject */ 3273 + case TP_HKEY_EV_WKUP_S3_BAYEJ: /* suspend, bay eject */ 3274 + case TP_HKEY_EV_WKUP_S4_BAYEJ: /* hibernation, bay eject */ 3476 3275 hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ; 3477 3276 *ignore_acpi_ev = true; 3478 3277 break; 3479 3278 3480 - case 0x2313: /* Battery on critical low level (S3) */ 3481 - case 0x2413: /* Battery on critical low level (S4) */ 3279 + case TP_HKEY_EV_WKUP_S3_BATLOW: /* Battery on critical low level/S3 */ 3280 + case TP_HKEY_EV_WKUP_S4_BATLOW: /* Battery on critical low level/S4 */ 3482 3281 printk(TPACPI_ALERT 3483 3282 "EMERGENCY WAKEUP: battery almost empty\n"); 3484 3283 /* how to auto-heal: */ ··· 3508 3307 *ignore_acpi_ev = false; 3509 3308 3510 3309 switch (hkey) { 3511 - case 0x5010: /* Lenovo new BIOS: brightness changed */ 3512 - case 0x500b: /* X61t: tablet pen inserted into bay */ 3513 - case 0x500c: /* X61t: tablet pen removed from bay */ 3310 + case TP_HKEY_EV_PEN_INSERTED: /* X61t: tablet pen inserted into bay */ 3311 + case TP_HKEY_EV_PEN_REMOVED: /* X61t: tablet pen removed from bay */ 3514 3312 return true; 3515 3313 3516 - case 0x5009: /* X41t-X61t: swivel up (tablet mode) */ 3517 - case 0x500a: /* X41t-X61t: swivel down (normal mode) */ 3314 + case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ 3315 + case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ 3518 3316 tpacpi_input_send_tabletsw(); 3519 3317 hotkey_tablet_mode_notify_change(); 3520 3318 *send_acpi_ev = false; 3521 3319 return true; 3522 3320 3523 - case 0x5001: 3524 - case 0x5002: 3525 - /* LID switch events. Do not propagate */ 3321 + case TP_HKEY_EV_LID_CLOSE: /* Lid closed */ 3322 + case TP_HKEY_EV_LID_OPEN: /* Lid opened */ 3323 + case TP_HKEY_EV_BRGHT_CHANGED: /* brightness changed */ 3324 + /* do not propagate these events */ 3526 3325 *ignore_acpi_ev = true; 3527 3326 return true; 3528 3327 ··· 3540 3339 *ignore_acpi_ev = false; 3541 3340 3542 3341 switch (hkey) { 3543 - case 0x6011: 3342 + case TP_HKEY_EV_ALARM_BAT_HOT: 3544 3343 printk(TPACPI_CRIT 3545 3344 "THERMAL ALARM: battery is too hot!\n"); 3546 3345 /* recommended action: warn user through gui */ 3547 3346 return true; 3548 - case 0x6012: 3347 + case TP_HKEY_EV_ALARM_BAT_XHOT: 3549 3348 printk(TPACPI_ALERT 3550 3349 "THERMAL EMERGENCY: battery is extremely hot!\n"); 3551 3350 /* recommended action: immediate sleep/hibernate */ 3552 3351 return true; 3553 - case 0x6021: 3352 + case TP_HKEY_EV_ALARM_SENSOR_HOT: 3554 3353 printk(TPACPI_CRIT 3555 3354 "THERMAL ALARM: " 3556 3355 "a sensor reports something is too hot!\n"); 3557 3356 /* recommended action: warn user through gui, that */ 3558 3357 /* some internal component is too hot */ 3559 3358 return true; 3560 - case 0x6022: 3359 + case TP_HKEY_EV_ALARM_SENSOR_XHOT: 3561 3360 printk(TPACPI_ALERT 3562 3361 "THERMAL EMERGENCY: " 3563 3362 "a sensor reports something is extremely hot!\n"); 3564 3363 /* recommended action: immediate sleep/hibernate */ 3565 3364 return true; 3566 - case 0x6030: 3365 + case TP_HKEY_EV_THM_TABLE_CHANGED: 3567 3366 printk(TPACPI_INFO 3568 3367 "EC reports that Thermal Table has changed\n"); 3569 3368 /* recommended action: do nothing, we don't have ··· 3621 3420 break; 3622 3421 case 3: 3623 3422 /* 0x3000-0x3FFF: bay-related wakeups */ 3624 - if (hkey == 0x3003) { 3423 + if (hkey == TP_HKEY_EV_BAYEJ_ACK) { 3625 3424 hotkey_autosleep_ack = 1; 3626 3425 printk(TPACPI_INFO 3627 3426 "bay ejected\n"); ··· 3633 3432 break; 3634 3433 case 4: 3635 3434 /* 0x4000-0x4FFF: dock-related wakeups */ 3636 - if (hkey == 0x4003) { 3435 + if (hkey == TP_HKEY_EV_UNDOCK_ACK) { 3637 3436 hotkey_autosleep_ack = 1; 3638 3437 printk(TPACPI_INFO 3639 3438 "undocked\n"); ··· 3655 3454 break; 3656 3455 case 7: 3657 3456 /* 0x7000-0x7FFF: misc */ 3658 - if (tp_features.hotkey_wlsw && hkey == 0x7000) { 3457 + if (tp_features.hotkey_wlsw && 3458 + hkey == TP_HKEY_EV_RFKILL_CHANGED) { 3659 3459 tpacpi_send_radiosw_update(); 3660 3460 send_acpi_ev = 0; 3661 3461 known_ev = true; ··· 3702 3500 { 3703 3501 tpacpi_disable_brightness_delay(); 3704 3502 3705 - if (hotkey_mask_get()) 3503 + if (hotkey_status_set(true) < 0 || 3504 + hotkey_mask_set(hotkey_acpi_mask) < 0) 3706 3505 printk(TPACPI_ERR 3707 - "error while trying to read hot key mask " 3708 - "from firmware\n"); 3506 + "error while attempting to reset the event " 3507 + "firmware interface\n"); 3508 + 3709 3509 tpacpi_send_radiosw_update(); 3710 3510 hotkey_tablet_mode_notify_change(); 3711 3511 hotkey_wakeup_reason_notify_change(); ··· 3736 3532 return res; 3737 3533 3738 3534 len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0)); 3739 - if (tp_features.hotkey_mask) { 3740 - len += sprintf(p + len, "mask:\t\t0x%08x\n", hotkey_mask); 3535 + if (hotkey_all_mask) { 3536 + len += sprintf(p + len, "mask:\t\t0x%08x\n", hotkey_user_mask); 3741 3537 len += sprintf(p + len, 3742 3538 "commands:\tenable, disable, reset, <mask>\n"); 3743 3539 } else { ··· 3774 3570 if (mutex_lock_killable(&hotkey_mutex)) 3775 3571 return -ERESTARTSYS; 3776 3572 3777 - mask = hotkey_mask; 3573 + mask = hotkey_user_mask; 3778 3574 3779 3575 res = 0; 3780 3576 while ((cmd = next_cmd(&buf))) { ··· 3796 3592 } 3797 3593 } 3798 3594 3799 - if (!res) 3595 + if (!res) { 3800 3596 tpacpi_disclose_usertask("procfs hotkey", 3801 3597 "set mask to 0x%08x\n", mask); 3802 - 3803 - if (!res && mask != hotkey_mask) 3804 - res = hotkey_mask_set(mask); 3598 + res = hotkey_user_mask_set(mask); 3599 + } 3805 3600 3806 3601 errexit: 3807 3602 mutex_unlock(&hotkey_mutex); ··· 6213 6010 TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL, 6214 6011 &ibm_backlight_data); 6215 6012 if (IS_ERR(ibm_backlight_device)) { 6013 + int rc = PTR_ERR(ibm_backlight_device); 6014 + ibm_backlight_device = NULL; 6216 6015 printk(TPACPI_ERR "Could not register backlight device\n"); 6217 - return PTR_ERR(ibm_backlight_device); 6016 + return rc; 6218 6017 } 6219 6018 vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_BRGHT, 6220 6019 "brightness is supported\n"); ··· 7703 7498 * 7704 7499 **************************************************************************** 7705 7500 ****************************************************************************/ 7501 + 7502 + /* 7503 + * HKEY event callout for other subdrivers go here 7504 + * (yes, it is ugly, but it is quick, safe, and gets the job done 7505 + */ 7506 + static void tpacpi_driver_event(const unsigned int hkey_event) 7507 + { 7508 + } 7509 + 7510 + 7511 + 7512 + static void hotkey_driver_event(const unsigned int scancode) 7513 + { 7514 + tpacpi_driver_event(TP_HKEY_EV_HOTKEY_BASE + scancode); 7515 + } 7706 7516 7707 7517 /* sysfs name ---------------------------------------------------------- */ 7708 7518 static ssize_t thinkpad_acpi_pdev_name_show(struct device *dev,
+9 -12
drivers/pnp/pnpacpi/core.c
··· 153 153 acpi_handle temp = NULL; 154 154 acpi_status status; 155 155 struct pnp_dev *dev; 156 + struct acpi_hardware_id *id; 156 157 157 158 /* 158 159 * If a PnPacpi device is not present , the device ··· 194 193 if (dev->capabilities & PNP_CONFIGURABLE) 195 194 pnpacpi_parse_resource_option_data(dev); 196 195 197 - if (device->flags.compatible_ids) { 198 - struct acpica_device_id_list *cid_list = device->pnp.cid_list; 199 - int i; 200 - 201 - for (i = 0; i < cid_list->count; i++) { 202 - if (!ispnpidacpi(cid_list->ids[i].string)) 203 - continue; 204 - pnp_add_id(dev, cid_list->ids[i].string); 205 - } 196 + list_for_each_entry(id, &device->pnp.ids, list) { 197 + if (!strcmp(id->id, acpi_device_hid(device))) 198 + continue; 199 + if (!ispnpidacpi(id->id)) 200 + continue; 201 + pnp_add_id(dev, id->id); 206 202 } 207 203 208 204 /* clear out the damaged flags */ ··· 230 232 struct pnp_dev *pnp = _pnp; 231 233 232 234 /* true means it matched */ 233 - return acpi->flags.hardware_id 234 - && !acpi_get_physical_device(acpi->handle) 235 - && compare_pnp_id(pnp->id, acpi->pnp.hardware_id); 235 + return !acpi_get_physical_device(acpi->handle) 236 + && compare_pnp_id(pnp->id, acpi_device_hid(acpi)); 236 237 } 237 238 238 239 static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle)
+12 -10
include/acpi/acpi_bus.h
··· 70 70 ACPI_BUS_TYPE_POWER, 71 71 ACPI_BUS_TYPE_PROCESSOR, 72 72 ACPI_BUS_TYPE_THERMAL, 73 - ACPI_BUS_TYPE_SYSTEM, 74 73 ACPI_BUS_TYPE_POWER_BUTTON, 75 74 ACPI_BUS_TYPE_SLEEP_BUTTON, 76 75 ACPI_BUS_DEVICE_TYPE_COUNT ··· 141 142 142 143 struct acpi_device_flags { 143 144 u32 dynamic_status:1; 144 - u32 hardware_id:1; 145 - u32 compatible_ids:1; 146 145 u32 bus_address:1; 147 - u32 unique_id:1; 148 146 u32 removable:1; 149 147 u32 ejectable:1; 150 148 u32 lockable:1; ··· 150 154 u32 performance_manageable:1; 151 155 u32 wake_capable:1; /* Wakeup(_PRW) supported? */ 152 156 u32 force_power_state:1; 153 - u32 reserved:19; 157 + u32 reserved:22; 154 158 }; 155 159 156 160 /* File System */ ··· 168 172 typedef char acpi_device_name[40]; 169 173 typedef char acpi_device_class[20]; 170 174 175 + struct acpi_hardware_id { 176 + struct list_head list; 177 + char *id; 178 + }; 179 + 171 180 struct acpi_device_pnp { 172 181 acpi_bus_id bus_id; /* Object name */ 173 182 acpi_bus_address bus_address; /* _ADR */ 174 - char *hardware_id; /* _HID */ 175 - struct acpica_device_id_list *cid_list; /* _CIDs */ 176 183 char *unique_id; /* _UID */ 184 + struct list_head ids; /* _HID and _CIDs */ 177 185 acpi_device_name device_name; /* Driver-determined */ 178 186 acpi_device_class device_class; /* " */ 179 187 }; 180 188 181 189 #define acpi_device_bid(d) ((d)->pnp.bus_id) 182 190 #define acpi_device_adr(d) ((d)->pnp.bus_address) 183 - #define acpi_device_hid(d) ((d)->pnp.hardware_id) 184 - #define acpi_device_uid(d) ((d)->pnp.unique_id) 191 + char *acpi_device_hid(struct acpi_device *device); 185 192 #define acpi_device_name(d) ((d)->pnp.device_name) 186 193 #define acpi_device_class(d) ((d)->pnp.device_class) 187 194 ··· 261 262 /* Device */ 262 263 263 264 struct acpi_device { 264 - acpi_handle handle; 265 + int device_type; 266 + acpi_handle handle; /* no handle for fixed hardware */ 265 267 struct acpi_device *parent; 266 268 struct list_head children; 267 269 struct list_head node; ··· 322 322 323 323 int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); 324 324 void acpi_bus_data_handler(acpi_handle handle, void *context); 325 + acpi_status acpi_bus_get_status_handle(acpi_handle handle, 326 + unsigned long long *sta); 325 327 int acpi_bus_get_status(struct acpi_device *device); 326 328 int acpi_bus_get_power(acpi_handle handle, int *state); 327 329 int acpi_bus_set_power(acpi_handle handle, int state);