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:
ACPI: ACPI_DOCK: Initialize the atomic notifier list
ACPI: acpi_os_allocate() fixes
ACPI: SBS: fix initialization, sem2mutex
ACPI: add 'const' to several ACPI file_operations
ACPI: delete some defaults from ACPI Kconfig
ACPI: "Device `[%s]' is not power manageable" make message debug only
ACPI: ACPI_DOCK Kconfig
Revert "Revert "ACPI: dock driver""
ACPI: acpi_os_get_thread_id() returns current
ACPI: ACPICA 20060707

+1086 -228
+7
drivers/acpi/Kconfig
··· 132 132 This driver adds support for ACPI fan devices, allowing user-mode 133 133 applications to perform basic fan control (on, off, status). 134 134 135 + config ACPI_DOCK 136 + tristate "Dock" 137 + depends on EXPERIMENTAL 138 + help 139 + This driver adds support for ACPI controlled docking stations 140 + 135 141 config ACPI_PROCESSOR 136 142 tristate "Processor" 137 143 default y ··· 212 206 config ACPI_IBM_DOCK 213 207 bool "Legacy Docking Station Support" 214 208 depends on ACPI_IBM 209 + depends on ACPI_DOCK=n 215 210 default n 216 211 ---help--- 217 212 Allows the ibm_acpi driver to handle docking station events.
+1
drivers/acpi/Makefile
··· 42 42 obj-$(CONFIG_ACPI_BUTTON) += button.o 43 43 obj-$(CONFIG_ACPI_EC) += ec.o 44 44 obj-$(CONFIG_ACPI_FAN) += fan.o 45 + obj-$(CONFIG_ACPI_DOCK) += dock.o 45 46 obj-$(CONFIG_ACPI_VIDEO) += video.o 46 47 obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o 47 48 obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
+1 -1
drivers/acpi/ac.c
··· 72 72 unsigned long state; 73 73 }; 74 74 75 - static struct file_operations acpi_ac_fops = { 75 + static const struct file_operations acpi_ac_fops = { 76 76 .open = acpi_ac_open_fs, 77 77 .read = seq_read, 78 78 .llseek = seq_lseek,
+3 -3
drivers/acpi/battery.c
··· 557 557 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data); 558 558 } 559 559 560 - static struct file_operations acpi_battery_info_ops = { 560 + static const struct file_operations acpi_battery_info_ops = { 561 561 .open = acpi_battery_info_open_fs, 562 562 .read = seq_read, 563 563 .llseek = seq_lseek, ··· 565 565 .owner = THIS_MODULE, 566 566 }; 567 567 568 - static struct file_operations acpi_battery_state_ops = { 568 + static const struct file_operations acpi_battery_state_ops = { 569 569 .open = acpi_battery_state_open_fs, 570 570 .read = seq_read, 571 571 .llseek = seq_lseek, ··· 573 573 .owner = THIS_MODULE, 574 574 }; 575 575 576 - static struct file_operations acpi_battery_alarm_ops = { 576 + static const struct file_operations acpi_battery_alarm_ops = { 577 577 .open = acpi_battery_alarm_open_fs, 578 578 .read = seq_read, 579 579 .write = acpi_battery_write_alarm,
+2 -2
drivers/acpi/bus.c
··· 192 192 /* Make sure this is a valid target state */ 193 193 194 194 if (!device->flags.power_manageable) { 195 - printk(KERN_DEBUG "Device `[%s]' is not power manageable", 196 - device->kobj.name); 195 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device `[%s]' is not power manageable", 196 + device->kobj.name)); 197 197 return -ENODEV; 198 198 } 199 199 /*
+2 -2
drivers/acpi/button.c
··· 87 87 unsigned long pushed; 88 88 }; 89 89 90 - static struct file_operations acpi_button_info_fops = { 90 + static const struct file_operations acpi_button_info_fops = { 91 91 .open = acpi_button_info_open_fs, 92 92 .read = seq_read, 93 93 .llseek = seq_lseek, 94 94 .release = single_release, 95 95 }; 96 96 97 - static struct file_operations acpi_button_state_fops = { 97 + static const struct file_operations acpi_button_state_fops = { 98 98 .open = acpi_button_state_open_fs, 99 99 .read = seq_read, 100 100 .llseek = seq_lseek,
+14 -32
drivers/acpi/cm_sbs.c
··· 39 39 static struct proc_dir_entry *acpi_ac_dir; 40 40 static struct proc_dir_entry *acpi_battery_dir; 41 41 42 - static struct semaphore cm_sbs_sem; 42 + static DEFINE_MUTEX(cm_sbs_mutex); 43 43 44 - static int lock_ac_dir_cnt = 0; 45 - static int lock_battery_dir_cnt = 0; 44 + static int lock_ac_dir_cnt; 45 + static int lock_battery_dir_cnt; 46 46 47 47 struct proc_dir_entry *acpi_lock_ac_dir(void) 48 48 { 49 - 50 - down(&cm_sbs_sem); 51 - if (!acpi_ac_dir) { 49 + mutex_lock(&cm_sbs_mutex); 50 + if (!acpi_ac_dir) 52 51 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); 53 - } 54 52 if (acpi_ac_dir) { 55 53 lock_ac_dir_cnt++; 56 54 } else { 57 55 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 58 56 "Cannot create %s\n", ACPI_AC_CLASS)); 59 57 } 60 - up(&cm_sbs_sem); 58 + mutex_unlock(&cm_sbs_mutex); 61 59 return acpi_ac_dir; 62 60 } 63 - 64 61 EXPORT_SYMBOL(acpi_lock_ac_dir); 65 62 66 63 void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param) 67 64 { 68 - 69 - down(&cm_sbs_sem); 70 - if (acpi_ac_dir_param) { 65 + mutex_lock(&cm_sbs_mutex); 66 + if (acpi_ac_dir_param) 71 67 lock_ac_dir_cnt--; 72 - } 73 68 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) { 74 69 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); 75 70 acpi_ac_dir = 0; 76 71 } 77 - up(&cm_sbs_sem); 72 + mutex_unlock(&cm_sbs_mutex); 78 73 } 79 - 80 74 EXPORT_SYMBOL(acpi_unlock_ac_dir); 81 75 82 76 struct proc_dir_entry *acpi_lock_battery_dir(void) 83 77 { 84 - 85 - down(&cm_sbs_sem); 78 + mutex_lock(&cm_sbs_mutex); 86 79 if (!acpi_battery_dir) { 87 80 acpi_battery_dir = 88 81 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); ··· 86 93 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 87 94 "Cannot create %s\n", ACPI_BATTERY_CLASS)); 88 95 } 89 - up(&cm_sbs_sem); 96 + mutex_unlock(&cm_sbs_mutex); 90 97 return acpi_battery_dir; 91 98 } 92 - 93 99 EXPORT_SYMBOL(acpi_lock_battery_dir); 94 100 95 101 void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param) 96 102 { 97 - 98 - down(&cm_sbs_sem); 99 - if (acpi_battery_dir_param) { 103 + mutex_lock(&cm_sbs_mutex); 104 + if (acpi_battery_dir_param) 100 105 lock_battery_dir_cnt--; 101 - } 102 106 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param 103 107 && acpi_battery_dir) { 104 108 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); 105 109 acpi_battery_dir = 0; 106 110 } 107 - up(&cm_sbs_sem); 111 + mutex_unlock(&cm_sbs_mutex); 108 112 return; 109 113 } 110 - 111 114 EXPORT_SYMBOL(acpi_unlock_battery_dir); 112 115 113 116 static int __init acpi_cm_sbs_init(void) 114 117 { 115 - 116 - if (acpi_disabled) 117 - return 0; 118 - 119 - init_MUTEX(&cm_sbs_sem); 120 - 121 118 return 0; 122 119 } 123 - 124 120 subsys_initcall(acpi_cm_sbs_init);
-10
drivers/acpi/dispatcher/dsinit.c
··· 116 116 117 117 case ACPI_TYPE_METHOD: 118 118 119 - /* 120 - * Set the execution data width (32 or 64) based upon the 121 - * revision number of the parent ACPI table. 122 - * TBD: This is really for possible future support of integer width 123 - * on a per-table basis. Currently, we just use a global for the width. 124 - */ 125 - if (info->table_desc->pointer->revision == 1) { 126 - node->flags |= ANOBJ_DATA_WIDTH_32; 127 - } 128 - 129 119 info->method_count++; 130 120 break; 131 121
+4 -19
drivers/acpi/dispatcher/dsmethod.c
··· 134 134 union acpi_operand_object *mutex_desc; 135 135 acpi_status status; 136 136 137 - ACPI_FUNCTION_NAME(ds_create_method_mutex); 137 + ACPI_FUNCTION_TRACE(ds_create_method_mutex); 138 138 139 139 /* Create the new mutex object */ 140 140 ··· 493 493 494 494 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 495 495 "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", 496 - (char *)&walk_state->method_node->name, 496 + acpi_ut_get_node_name(walk_state->method_node), 497 497 walk_state->method_call_op, return_desc)); 498 498 499 499 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, ··· 610 610 611 611 acpi_os_release_mutex(method_desc->method.mutex->mutex. 612 612 os_mutex); 613 + method_desc->method.mutex->mutex.owner_thread = NULL; 613 614 } 614 615 } 615 616 ··· 621 620 */ 622 621 method_node = walk_state->method_node; 623 622 624 - /* Lock namespace for possible update */ 625 - 626 - status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 627 - if (ACPI_FAILURE(status)) { 628 - return_VOID; 629 - } 630 - 631 623 /* 632 - * Delete any namespace entries created immediately underneath 633 - * the method 634 - */ 635 - if (method_node && method_node->child) { 636 - acpi_ns_delete_namespace_subtree(method_node); 637 - } 638 - 639 - /* 640 - * Delete any namespace entries created anywhere else within 624 + * Delete any namespace objects created anywhere within 641 625 * the namespace by the execution of this method 642 626 */ 643 627 acpi_ns_delete_namespace_by_owner(method_desc->method.owner_id); 644 - status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 645 628 } 646 629 647 630 /* Decrement the thread count on the method */
+2 -2
drivers/acpi/dispatcher/dswexec.c
··· 313 313 case AML_CLASS_EXECUTE: 314 314 case AML_CLASS_CREATE: 315 315 /* 316 - * Most operators with arguments. 316 + * Most operators with arguments (except create_xxx_field operators) 317 317 * Start a new result/operand state 318 318 */ 319 - if (walk_state->opcode != AML_CREATE_FIELD_OP) { 319 + if (walk_state->op_info->object_type != ACPI_TYPE_BUFFER_FIELD) { 320 320 status = acpi_ds_result_stack_push(walk_state); 321 321 } 322 322 break;
+740
drivers/acpi/dock.c
··· 1 + /* 2 + * dock.c - ACPI dock station driver 3 + * 4 + * Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com> 5 + * 6 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License as published by 10 + * the Free Software Foundation; either version 2 of the License, or (at 11 + * your option) any later version. 12 + * 13 + * This program is distributed in the hope that it will be useful, but 14 + * WITHOUT ANY WARRANTY; without even the implied warranty of 15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 + * General Public License for more details. 17 + * 18 + * You should have received a copy of the GNU General Public License along 19 + * with this program; if not, write to the Free Software Foundation, Inc., 20 + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 21 + * 22 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 + */ 24 + 25 + #include <linux/kernel.h> 26 + #include <linux/module.h> 27 + #include <linux/init.h> 28 + #include <linux/types.h> 29 + #include <linux/notifier.h> 30 + #include <acpi/acpi_bus.h> 31 + #include <acpi/acpi_drivers.h> 32 + 33 + #define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver" 34 + 35 + ACPI_MODULE_NAME("dock") 36 + MODULE_AUTHOR("Kristen Carlson Accardi"); 37 + MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME); 38 + MODULE_LICENSE("GPL"); 39 + 40 + static struct atomic_notifier_head dock_notifier_list; 41 + 42 + struct dock_station { 43 + acpi_handle handle; 44 + unsigned long last_dock_time; 45 + u32 flags; 46 + spinlock_t dd_lock; 47 + spinlock_t hp_lock; 48 + struct list_head dependent_devices; 49 + struct list_head hotplug_devices; 50 + }; 51 + 52 + struct dock_dependent_device { 53 + struct list_head list; 54 + struct list_head hotplug_list; 55 + acpi_handle handle; 56 + acpi_notify_handler handler; 57 + void *context; 58 + }; 59 + 60 + #define DOCK_DOCKING 0x00000001 61 + #define DOCK_EVENT KOBJ_DOCK 62 + #define UNDOCK_EVENT KOBJ_UNDOCK 63 + 64 + static struct dock_station *dock_station; 65 + 66 + /***************************************************************************** 67 + * Dock Dependent device functions * 68 + *****************************************************************************/ 69 + /** 70 + * alloc_dock_dependent_device - allocate and init a dependent device 71 + * @handle: the acpi_handle of the dependent device 72 + * 73 + * Allocate memory for a dependent device structure for a device referenced 74 + * by the acpi handle 75 + */ 76 + static struct dock_dependent_device * 77 + alloc_dock_dependent_device(acpi_handle handle) 78 + { 79 + struct dock_dependent_device *dd; 80 + 81 + dd = kzalloc(sizeof(*dd), GFP_KERNEL); 82 + if (dd) { 83 + dd->handle = handle; 84 + INIT_LIST_HEAD(&dd->list); 85 + INIT_LIST_HEAD(&dd->hotplug_list); 86 + } 87 + return dd; 88 + } 89 + 90 + /** 91 + * add_dock_dependent_device - associate a device with the dock station 92 + * @ds: The dock station 93 + * @dd: The dependent device 94 + * 95 + * Add the dependent device to the dock's dependent device list. 96 + */ 97 + static void 98 + add_dock_dependent_device(struct dock_station *ds, 99 + struct dock_dependent_device *dd) 100 + { 101 + spin_lock(&ds->dd_lock); 102 + list_add_tail(&dd->list, &ds->dependent_devices); 103 + spin_unlock(&ds->dd_lock); 104 + } 105 + 106 + /** 107 + * dock_add_hotplug_device - associate a hotplug handler with the dock station 108 + * @ds: The dock station 109 + * @dd: The dependent device struct 110 + * 111 + * Add the dependent device to the dock's hotplug device list 112 + */ 113 + static void 114 + dock_add_hotplug_device(struct dock_station *ds, 115 + struct dock_dependent_device *dd) 116 + { 117 + spin_lock(&ds->hp_lock); 118 + list_add_tail(&dd->hotplug_list, &ds->hotplug_devices); 119 + spin_unlock(&ds->hp_lock); 120 + } 121 + 122 + /** 123 + * dock_del_hotplug_device - remove a hotplug handler from the dock station 124 + * @ds: The dock station 125 + * @dd: the dependent device struct 126 + * 127 + * Delete the dependent device from the dock's hotplug device list 128 + */ 129 + static void 130 + dock_del_hotplug_device(struct dock_station *ds, 131 + struct dock_dependent_device *dd) 132 + { 133 + spin_lock(&ds->hp_lock); 134 + list_del(&dd->hotplug_list); 135 + spin_unlock(&ds->hp_lock); 136 + } 137 + 138 + /** 139 + * find_dock_dependent_device - get a device dependent on this dock 140 + * @ds: the dock station 141 + * @handle: the acpi_handle of the device we want 142 + * 143 + * iterate over the dependent device list for this dock. If the 144 + * dependent device matches the handle, return. 145 + */ 146 + static struct dock_dependent_device * 147 + find_dock_dependent_device(struct dock_station *ds, acpi_handle handle) 148 + { 149 + struct dock_dependent_device *dd; 150 + 151 + spin_lock(&ds->dd_lock); 152 + list_for_each_entry(dd, &ds->dependent_devices, list) { 153 + if (handle == dd->handle) { 154 + spin_unlock(&ds->dd_lock); 155 + return dd; 156 + } 157 + } 158 + spin_unlock(&ds->dd_lock); 159 + return NULL; 160 + } 161 + 162 + /***************************************************************************** 163 + * Dock functions * 164 + *****************************************************************************/ 165 + /** 166 + * is_dock - see if a device is a dock station 167 + * @handle: acpi handle of the device 168 + * 169 + * If an acpi object has a _DCK method, then it is by definition a dock 170 + * station, so return true. 171 + */ 172 + static int is_dock(acpi_handle handle) 173 + { 174 + acpi_status status; 175 + acpi_handle tmp; 176 + 177 + status = acpi_get_handle(handle, "_DCK", &tmp); 178 + if (ACPI_FAILURE(status)) 179 + return 0; 180 + return 1; 181 + } 182 + 183 + /** 184 + * is_dock_device - see if a device is on a dock station 185 + * @handle: acpi handle of the device 186 + * 187 + * If this device is either the dock station itself, 188 + * or is a device dependent on the dock station, then it 189 + * is a dock device 190 + */ 191 + int is_dock_device(acpi_handle handle) 192 + { 193 + if (!dock_station) 194 + return 0; 195 + 196 + if (is_dock(handle) || find_dock_dependent_device(dock_station, handle)) 197 + return 1; 198 + 199 + return 0; 200 + } 201 + 202 + EXPORT_SYMBOL_GPL(is_dock_device); 203 + 204 + /** 205 + * dock_present - see if the dock station is present. 206 + * @ds: the dock station 207 + * 208 + * execute the _STA method. note that present does not 209 + * imply that we are docked. 210 + */ 211 + static int dock_present(struct dock_station *ds) 212 + { 213 + unsigned long sta; 214 + acpi_status status; 215 + 216 + if (ds) { 217 + status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta); 218 + if (ACPI_SUCCESS(status) && sta) 219 + return 1; 220 + } 221 + return 0; 222 + } 223 + 224 + 225 + 226 + /** 227 + * dock_create_acpi_device - add new devices to acpi 228 + * @handle - handle of the device to add 229 + * 230 + * This function will create a new acpi_device for the given 231 + * handle if one does not exist already. This should cause 232 + * acpi to scan for drivers for the given devices, and call 233 + * matching driver's add routine. 234 + * 235 + * Returns a pointer to the acpi_device corresponding to the handle. 236 + */ 237 + static struct acpi_device * dock_create_acpi_device(acpi_handle handle) 238 + { 239 + struct acpi_device *device = NULL; 240 + struct acpi_device *parent_device; 241 + acpi_handle parent; 242 + int ret; 243 + 244 + if (acpi_bus_get_device(handle, &device)) { 245 + /* 246 + * no device created for this object, 247 + * so we should create one. 248 + */ 249 + acpi_get_parent(handle, &parent); 250 + if (acpi_bus_get_device(parent, &parent_device)) 251 + parent_device = NULL; 252 + 253 + ret = acpi_bus_add(&device, parent_device, handle, 254 + ACPI_BUS_TYPE_DEVICE); 255 + if (ret) { 256 + pr_debug("error adding bus, %x\n", 257 + -ret); 258 + return NULL; 259 + } 260 + } 261 + return device; 262 + } 263 + 264 + /** 265 + * dock_remove_acpi_device - remove the acpi_device struct from acpi 266 + * @handle - the handle of the device to remove 267 + * 268 + * Tell acpi to remove the acpi_device. This should cause any loaded 269 + * driver to have it's remove routine called. 270 + */ 271 + static void dock_remove_acpi_device(acpi_handle handle) 272 + { 273 + struct acpi_device *device; 274 + int ret; 275 + 276 + if (!acpi_bus_get_device(handle, &device)) { 277 + ret = acpi_bus_trim(device, 1); 278 + if (ret) 279 + pr_debug("error removing bus, %x\n", -ret); 280 + } 281 + } 282 + 283 + 284 + /** 285 + * hotplug_dock_devices - insert or remove devices on the dock station 286 + * @ds: the dock station 287 + * @event: either bus check or eject request 288 + * 289 + * Some devices on the dock station need to have drivers called 290 + * to perform hotplug operations after a dock event has occurred. 291 + * Traverse the list of dock devices that have registered a 292 + * hotplug handler, and call the handler. 293 + */ 294 + static void hotplug_dock_devices(struct dock_station *ds, u32 event) 295 + { 296 + struct dock_dependent_device *dd; 297 + 298 + spin_lock(&ds->hp_lock); 299 + 300 + /* 301 + * First call driver specific hotplug functions 302 + */ 303 + list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) { 304 + if (dd->handler) 305 + dd->handler(dd->handle, event, dd->context); 306 + } 307 + 308 + /* 309 + * Now make sure that an acpi_device is created for each 310 + * dependent device, or removed if this is an eject request. 311 + * This will cause acpi_drivers to be stopped/started if they 312 + * exist 313 + */ 314 + list_for_each_entry(dd, &ds->dependent_devices, list) { 315 + if (event == ACPI_NOTIFY_EJECT_REQUEST) 316 + dock_remove_acpi_device(dd->handle); 317 + else 318 + dock_create_acpi_device(dd->handle); 319 + } 320 + spin_unlock(&ds->hp_lock); 321 + } 322 + 323 + static void dock_event(struct dock_station *ds, u32 event, int num) 324 + { 325 + struct acpi_device *device; 326 + 327 + device = dock_create_acpi_device(ds->handle); 328 + if (device) 329 + kobject_uevent(&device->kobj, num); 330 + } 331 + 332 + /** 333 + * eject_dock - respond to a dock eject request 334 + * @ds: the dock station 335 + * 336 + * This is called after _DCK is called, to execute the dock station's 337 + * _EJ0 method. 338 + */ 339 + static void eject_dock(struct dock_station *ds) 340 + { 341 + struct acpi_object_list arg_list; 342 + union acpi_object arg; 343 + acpi_status status; 344 + acpi_handle tmp; 345 + 346 + /* all dock devices should have _EJ0, but check anyway */ 347 + status = acpi_get_handle(ds->handle, "_EJ0", &tmp); 348 + if (ACPI_FAILURE(status)) { 349 + pr_debug("No _EJ0 support for dock device\n"); 350 + return; 351 + } 352 + 353 + arg_list.count = 1; 354 + arg_list.pointer = &arg; 355 + arg.type = ACPI_TYPE_INTEGER; 356 + arg.integer.value = 1; 357 + 358 + if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", 359 + &arg_list, NULL))) 360 + pr_debug("Failed to evaluate _EJ0!\n"); 361 + } 362 + 363 + /** 364 + * handle_dock - handle a dock event 365 + * @ds: the dock station 366 + * @dock: to dock, or undock - that is the question 367 + * 368 + * Execute the _DCK method in response to an acpi event 369 + */ 370 + static void handle_dock(struct dock_station *ds, int dock) 371 + { 372 + acpi_status status; 373 + struct acpi_object_list arg_list; 374 + union acpi_object arg; 375 + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 376 + struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 377 + union acpi_object *obj; 378 + 379 + acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer); 380 + obj = name_buffer.pointer; 381 + 382 + printk(KERN_INFO PREFIX "%s\n", dock ? "docking" : "undocking"); 383 + 384 + /* _DCK method has one argument */ 385 + arg_list.count = 1; 386 + arg_list.pointer = &arg; 387 + arg.type = ACPI_TYPE_INTEGER; 388 + arg.integer.value = dock; 389 + status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); 390 + if (ACPI_FAILURE(status)) 391 + pr_debug("%s: failed to execute _DCK\n", obj->string.pointer); 392 + kfree(buffer.pointer); 393 + kfree(name_buffer.pointer); 394 + } 395 + 396 + static inline void dock(struct dock_station *ds) 397 + { 398 + handle_dock(ds, 1); 399 + } 400 + 401 + static inline void undock(struct dock_station *ds) 402 + { 403 + handle_dock(ds, 0); 404 + } 405 + 406 + static inline void begin_dock(struct dock_station *ds) 407 + { 408 + ds->flags |= DOCK_DOCKING; 409 + } 410 + 411 + static inline void complete_dock(struct dock_station *ds) 412 + { 413 + ds->flags &= ~(DOCK_DOCKING); 414 + ds->last_dock_time = jiffies; 415 + } 416 + 417 + /** 418 + * dock_in_progress - see if we are in the middle of handling a dock event 419 + * @ds: the dock station 420 + * 421 + * Sometimes while docking, false dock events can be sent to the driver 422 + * because good connections aren't made or some other reason. Ignore these 423 + * if we are in the middle of doing something. 424 + */ 425 + static int dock_in_progress(struct dock_station *ds) 426 + { 427 + if ((ds->flags & DOCK_DOCKING) || 428 + time_before(jiffies, (ds->last_dock_time + HZ))) 429 + return 1; 430 + return 0; 431 + } 432 + 433 + /** 434 + * register_dock_notifier - add yourself to the dock notifier list 435 + * @nb: the callers notifier block 436 + * 437 + * If a driver wishes to be notified about dock events, they can 438 + * use this function to put a notifier block on the dock notifier list. 439 + * this notifier call chain will be called after a dock event, but 440 + * before hotplugging any new devices. 441 + */ 442 + int register_dock_notifier(struct notifier_block *nb) 443 + { 444 + return atomic_notifier_chain_register(&dock_notifier_list, nb); 445 + } 446 + 447 + EXPORT_SYMBOL_GPL(register_dock_notifier); 448 + 449 + /** 450 + * unregister_dock_notifier - remove yourself from the dock notifier list 451 + * @nb: the callers notifier block 452 + */ 453 + void unregister_dock_notifier(struct notifier_block *nb) 454 + { 455 + atomic_notifier_chain_unregister(&dock_notifier_list, nb); 456 + } 457 + 458 + EXPORT_SYMBOL_GPL(unregister_dock_notifier); 459 + 460 + /** 461 + * register_hotplug_dock_device - register a hotplug function 462 + * @handle: the handle of the device 463 + * @handler: the acpi_notifier_handler to call after docking 464 + * @context: device specific data 465 + * 466 + * If a driver would like to perform a hotplug operation after a dock 467 + * event, they can register an acpi_notifiy_handler to be called by 468 + * the dock driver after _DCK is executed. 469 + */ 470 + int 471 + register_hotplug_dock_device(acpi_handle handle, acpi_notify_handler handler, 472 + void *context) 473 + { 474 + struct dock_dependent_device *dd; 475 + 476 + if (!dock_station) 477 + return -ENODEV; 478 + 479 + /* 480 + * make sure this handle is for a device dependent on the dock, 481 + * this would include the dock station itself 482 + */ 483 + dd = find_dock_dependent_device(dock_station, handle); 484 + if (dd) { 485 + dd->handler = handler; 486 + dd->context = context; 487 + dock_add_hotplug_device(dock_station, dd); 488 + return 0; 489 + } 490 + 491 + return -EINVAL; 492 + } 493 + 494 + EXPORT_SYMBOL_GPL(register_hotplug_dock_device); 495 + 496 + /** 497 + * unregister_hotplug_dock_device - remove yourself from the hotplug list 498 + * @handle: the acpi handle of the device 499 + */ 500 + void unregister_hotplug_dock_device(acpi_handle handle) 501 + { 502 + struct dock_dependent_device *dd; 503 + 504 + if (!dock_station) 505 + return; 506 + 507 + dd = find_dock_dependent_device(dock_station, handle); 508 + if (dd) 509 + dock_del_hotplug_device(dock_station, dd); 510 + } 511 + 512 + EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); 513 + 514 + /** 515 + * dock_notify - act upon an acpi dock notification 516 + * @handle: the dock station handle 517 + * @event: the acpi event 518 + * @data: our driver data struct 519 + * 520 + * If we are notified to dock, then check to see if the dock is 521 + * present and then dock. Notify all drivers of the dock event, 522 + * and then hotplug and devices that may need hotplugging. For undock 523 + * check to make sure the dock device is still present, then undock 524 + * and hotremove all the devices that may need removing. 525 + */ 526 + static void dock_notify(acpi_handle handle, u32 event, void *data) 527 + { 528 + struct dock_station *ds = (struct dock_station *)data; 529 + 530 + switch (event) { 531 + case ACPI_NOTIFY_BUS_CHECK: 532 + if (!dock_in_progress(ds) && dock_present(ds)) { 533 + begin_dock(ds); 534 + dock(ds); 535 + if (!dock_present(ds)) { 536 + printk(KERN_ERR PREFIX "Unable to dock!\n"); 537 + break; 538 + } 539 + atomic_notifier_call_chain(&dock_notifier_list, 540 + event, NULL); 541 + hotplug_dock_devices(ds, event); 542 + complete_dock(ds); 543 + dock_event(ds, event, DOCK_EVENT); 544 + } 545 + break; 546 + case ACPI_NOTIFY_DEVICE_CHECK: 547 + /* 548 + * According to acpi spec 3.0a, if a DEVICE_CHECK notification 549 + * is sent and _DCK is present, it is assumed to mean an 550 + * undock request. This notify routine will only be called 551 + * for objects defining _DCK, so we will fall through to eject 552 + * request here. However, we will pass an eject request through 553 + * to the driver who wish to hotplug. 554 + */ 555 + case ACPI_NOTIFY_EJECT_REQUEST: 556 + if (!dock_in_progress(ds) && dock_present(ds)) { 557 + /* 558 + * here we need to generate the undock 559 + * event prior to actually doing the undock 560 + * so that the device struct still exists. 561 + */ 562 + dock_event(ds, event, UNDOCK_EVENT); 563 + hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); 564 + undock(ds); 565 + eject_dock(ds); 566 + if (dock_present(ds)) 567 + printk(KERN_ERR PREFIX "Unable to undock!\n"); 568 + } 569 + break; 570 + default: 571 + printk(KERN_ERR PREFIX "Unknown dock event %d\n", event); 572 + } 573 + } 574 + 575 + /** 576 + * find_dock_devices - find devices on the dock station 577 + * @handle: the handle of the device we are examining 578 + * @lvl: unused 579 + * @context: the dock station private data 580 + * @rv: unused 581 + * 582 + * This function is called by acpi_walk_namespace. It will 583 + * check to see if an object has an _EJD method. If it does, then it 584 + * will see if it is dependent on the dock station. 585 + */ 586 + static acpi_status 587 + find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) 588 + { 589 + acpi_status status; 590 + acpi_handle tmp; 591 + struct dock_station *ds = (struct dock_station *)context; 592 + struct dock_dependent_device *dd; 593 + 594 + status = acpi_bus_get_ejd(handle, &tmp); 595 + if (ACPI_FAILURE(status)) 596 + return AE_OK; 597 + 598 + if (tmp == ds->handle) { 599 + dd = alloc_dock_dependent_device(handle); 600 + if (dd) 601 + add_dock_dependent_device(ds, dd); 602 + } 603 + 604 + return AE_OK; 605 + } 606 + 607 + /** 608 + * dock_add - add a new dock station 609 + * @handle: the dock station handle 610 + * 611 + * allocated and initialize a new dock station device. Find all devices 612 + * that are on the dock station, and register for dock event notifications. 613 + */ 614 + static int dock_add(acpi_handle handle) 615 + { 616 + int ret; 617 + acpi_status status; 618 + struct dock_dependent_device *dd; 619 + 620 + /* allocate & initialize the dock_station private data */ 621 + dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL); 622 + if (!dock_station) 623 + return -ENOMEM; 624 + dock_station->handle = handle; 625 + dock_station->last_dock_time = jiffies - HZ; 626 + INIT_LIST_HEAD(&dock_station->dependent_devices); 627 + INIT_LIST_HEAD(&dock_station->hotplug_devices); 628 + spin_lock_init(&dock_station->dd_lock); 629 + spin_lock_init(&dock_station->hp_lock); 630 + ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); 631 + 632 + /* Find dependent devices */ 633 + acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 634 + ACPI_UINT32_MAX, find_dock_devices, dock_station, 635 + NULL); 636 + 637 + /* add the dock station as a device dependent on itself */ 638 + dd = alloc_dock_dependent_device(handle); 639 + if (!dd) { 640 + kfree(dock_station); 641 + return -ENOMEM; 642 + } 643 + add_dock_dependent_device(dock_station, dd); 644 + 645 + /* register for dock events */ 646 + status = acpi_install_notify_handler(dock_station->handle, 647 + ACPI_SYSTEM_NOTIFY, 648 + dock_notify, dock_station); 649 + 650 + if (ACPI_FAILURE(status)) { 651 + printk(KERN_ERR PREFIX "Error installing notify handler\n"); 652 + ret = -ENODEV; 653 + goto dock_add_err; 654 + } 655 + 656 + printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_NAME); 657 + 658 + return 0; 659 + 660 + dock_add_err: 661 + kfree(dock_station); 662 + kfree(dd); 663 + return ret; 664 + } 665 + 666 + /** 667 + * dock_remove - free up resources related to the dock station 668 + */ 669 + static int dock_remove(void) 670 + { 671 + struct dock_dependent_device *dd, *tmp; 672 + acpi_status status; 673 + 674 + if (!dock_station) 675 + return 0; 676 + 677 + /* remove dependent devices */ 678 + list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices, 679 + list) 680 + kfree(dd); 681 + 682 + /* remove dock notify handler */ 683 + status = acpi_remove_notify_handler(dock_station->handle, 684 + ACPI_SYSTEM_NOTIFY, 685 + dock_notify); 686 + if (ACPI_FAILURE(status)) 687 + printk(KERN_ERR "Error removing notify handler\n"); 688 + 689 + /* free dock station memory */ 690 + kfree(dock_station); 691 + return 0; 692 + } 693 + 694 + /** 695 + * find_dock - look for a dock station 696 + * @handle: acpi handle of a device 697 + * @lvl: unused 698 + * @context: counter of dock stations found 699 + * @rv: unused 700 + * 701 + * This is called by acpi_walk_namespace to look for dock stations. 702 + */ 703 + static acpi_status 704 + find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) 705 + { 706 + int *count = (int *)context; 707 + acpi_status status = AE_OK; 708 + 709 + if (is_dock(handle)) { 710 + if (dock_add(handle) >= 0) { 711 + (*count)++; 712 + status = AE_CTRL_TERMINATE; 713 + } 714 + } 715 + return status; 716 + } 717 + 718 + static int __init dock_init(void) 719 + { 720 + int num = 0; 721 + 722 + dock_station = NULL; 723 + 724 + /* look for a dock station */ 725 + acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 726 + ACPI_UINT32_MAX, find_dock, &num, NULL); 727 + 728 + if (!num) 729 + return -ENODEV; 730 + 731 + return 0; 732 + } 733 + 734 + static void __exit dock_exit(void) 735 + { 736 + dock_remove(); 737 + } 738 + 739 + postcore_initcall(dock_init); 740 + module_exit(dock_exit);
+1 -1
drivers/acpi/ec.c
··· 929 929 return single_open(file, acpi_ec_read_info, PDE(inode)->data); 930 930 } 931 931 932 - static struct file_operations acpi_ec_info_ops = { 932 + static const struct file_operations acpi_ec_info_ops = { 933 933 .open = acpi_ec_info_open_fs, 934 934 .read = seq_read, 935 935 .llseek = seq_lseek,
+1 -1
drivers/acpi/event.c
··· 99 99 return 0; 100 100 } 101 101 102 - static struct file_operations acpi_system_event_ops = { 102 + static const struct file_operations acpi_system_event_ops = { 103 103 .open = acpi_system_open_event, 104 104 .read = acpi_system_read_event, 105 105 .release = acpi_system_close_event,
+25 -19
drivers/acpi/events/evregion.c
··· 528 528 } 529 529 } 530 530 531 - /* Call the setup handler with the deactivate notification */ 531 + /* 532 + * If the region has been activated, call the setup handler 533 + * with the deactivate notification 534 + */ 535 + if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { 536 + region_setup = handler_obj->address_space.setup; 537 + status = 538 + region_setup(region_obj, 539 + ACPI_REGION_DEACTIVATE, 540 + handler_obj->address_space. 541 + context, region_context); 532 542 533 - region_setup = handler_obj->address_space.setup; 534 - status = 535 - region_setup(region_obj, ACPI_REGION_DEACTIVATE, 536 - handler_obj->address_space.context, 537 - region_context); 543 + /* Init routine may fail, Just ignore errors */ 538 544 539 - /* Init routine may fail, Just ignore errors */ 545 + if (ACPI_FAILURE(status)) { 546 + ACPI_EXCEPTION((AE_INFO, status, 547 + "from region handler - deactivate, [%s]", 548 + acpi_ut_get_region_name 549 + (region_obj->region. 550 + space_id))); 551 + } 540 552 541 - if (ACPI_FAILURE(status)) { 542 - ACPI_EXCEPTION((AE_INFO, status, 543 - "from region init, [%s]", 544 - acpi_ut_get_region_name 545 - (region_obj->region.space_id))); 553 + region_obj->region.flags &= 554 + ~(AOPOBJ_SETUP_COMPLETE); 546 555 } 547 - 548 - region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); 549 556 550 557 /* 551 558 * Remove handler reference in the region 552 559 * 553 - * NOTE: this doesn't mean that the region goes away 554 - * The region is just inaccessible as indicated to 555 - * the _REG method 560 + * NOTE: this doesn't mean that the region goes away, the region 561 + * is just inaccessible as indicated to the _REG method 556 562 * 557 - * If the region is on the handler's list 558 - * this better be the region's handler 563 + * If the region is on the handler's list, this must be the 564 + * region's handler 559 565 */ 560 566 region_obj->region.handler = NULL; 561 567 acpi_ut_remove_reference(handler_obj);
+26 -18
drivers/acpi/events/evxface.c
··· 428 428 node = acpi_ns_map_handle_to_node(device); 429 429 if (!node) { 430 430 status = AE_BAD_PARAMETER; 431 - goto unlock; 431 + goto unlock_and_exit; 432 432 } 433 433 434 434 /* Root Object */ ··· 442 442 ((handler_type & ACPI_DEVICE_NOTIFY) && 443 443 !acpi_gbl_device_notify.handler)) { 444 444 status = AE_NOT_EXIST; 445 - goto unlock; 445 + goto unlock_and_exit; 446 446 } 447 447 448 448 /* Make sure all deferred tasks are completed */ ··· 474 474 475 475 if (!acpi_ev_is_notify_object(node)) { 476 476 status = AE_TYPE; 477 - goto unlock; 477 + goto unlock_and_exit; 478 478 } 479 479 480 480 /* Check for an existing internal object */ ··· 482 482 obj_desc = acpi_ns_get_attached_object(node); 483 483 if (!obj_desc) { 484 484 status = AE_NOT_EXIST; 485 - goto unlock; 485 + goto unlock_and_exit; 486 486 } 487 487 488 488 /* Object exists - make sure there's an existing handler */ 489 489 490 490 if (handler_type & ACPI_SYSTEM_NOTIFY) { 491 491 notify_obj = obj_desc->common_notify.system_notify; 492 - if ((!notify_obj) || 493 - (notify_obj->notify.handler != handler)) { 492 + if (!notify_obj) { 493 + status = AE_NOT_EXIST; 494 + goto unlock_and_exit; 495 + } 496 + 497 + if (notify_obj->notify.handler != handler) { 494 498 status = AE_BAD_PARAMETER; 495 - goto unlock; 499 + goto unlock_and_exit; 496 500 } 497 501 /* Make sure all deferred tasks are completed */ 498 502 ··· 514 510 515 511 if (handler_type & ACPI_DEVICE_NOTIFY) { 516 512 notify_obj = obj_desc->common_notify.device_notify; 517 - if ((!notify_obj) || 518 - (notify_obj->notify.handler != handler)) { 513 + if (!notify_obj) { 514 + status = AE_NOT_EXIST; 515 + goto unlock_and_exit; 516 + } 517 + 518 + if (notify_obj->notify.handler != handler) { 519 519 status = AE_BAD_PARAMETER; 520 - goto unlock; 520 + goto unlock_and_exit; 521 521 } 522 522 /* Make sure all deferred tasks are completed */ 523 523 ··· 538 530 } 539 531 } 540 532 541 - unlock: 533 + unlock_and_exit: 542 534 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 543 - exit: 535 + exit: 544 536 if (ACPI_FAILURE(status)) 545 537 ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler")); 546 538 return_ACPI_STATUS(status); ··· 594 586 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 595 587 if (!gpe_event_info) { 596 588 status = AE_BAD_PARAMETER; 597 - goto unlock; 589 + goto unlock_and_exit; 598 590 } 599 591 600 592 /* Make sure that there isn't a handler there already */ ··· 602 594 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 603 595 ACPI_GPE_DISPATCH_HANDLER) { 604 596 status = AE_ALREADY_EXISTS; 605 - goto unlock; 597 + goto unlock_and_exit; 606 598 } 607 599 608 600 /* Allocate and init handler object */ ··· 610 602 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); 611 603 if (!handler) { 612 604 status = AE_NO_MEMORY; 613 - goto unlock; 605 + goto unlock_and_exit; 614 606 } 615 607 616 608 handler->address = address; ··· 621 613 622 614 status = acpi_ev_disable_gpe(gpe_event_info); 623 615 if (ACPI_FAILURE(status)) { 624 - goto unlock; 616 + goto unlock_and_exit; 625 617 } 626 618 627 619 /* Install the handler */ ··· 636 628 637 629 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 638 630 639 - unlock: 631 + unlock_and_exit: 640 632 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 641 - exit: 633 + exit: 642 634 if (ACPI_FAILURE(status)) 643 635 ACPI_EXCEPTION((AE_INFO, status, 644 636 "Installing notify handler failed"));
+12 -1
drivers/acpi/events/evxfregn.c
··· 155 155 /* Convert and validate the device handle */ 156 156 157 157 node = acpi_ns_map_handle_to_node(device); 158 - if (!node) { 158 + if (!node || 159 + ((node->type != ACPI_TYPE_DEVICE) && 160 + (node->type != ACPI_TYPE_PROCESSOR) && 161 + (node->type != ACPI_TYPE_THERMAL) && 162 + (node != acpi_gbl_root_node))) { 159 163 status = AE_BAD_PARAMETER; 160 164 goto unlock_and_exit; 161 165 } ··· 181 177 /* We have a handler, see if user requested this one */ 182 178 183 179 if (handler_obj->address_space.space_id == space_id) { 180 + 181 + /* Handler must be the same as the installed handler */ 182 + 183 + if (handler_obj->address_space.handler != handler) { 184 + status = AE_BAD_PARAMETER; 185 + goto unlock_and_exit; 186 + } 184 187 185 188 /* Matched space_id, first dereference this in the Regions */ 186 189
-1
drivers/acpi/executer/exconfig.c
··· 502 502 * (Offset contains the table_id) 503 503 */ 504 504 acpi_ns_delete_namespace_by_owner(table_info->owner_id); 505 - acpi_ut_release_owner_id(&table_info->owner_id); 506 505 507 506 /* Delete the table itself */ 508 507
+3
drivers/acpi/executer/exconvrt.c
··· 170 170 return_ACPI_STATUS(AE_NO_MEMORY); 171 171 } 172 172 173 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", 174 + ACPI_FORMAT_UINT64(result))); 175 + 173 176 /* Save the Result */ 174 177 175 178 return_desc->integer.value = result;
+2 -2
drivers/acpi/executer/exmutex.c
··· 267 267 && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) { 268 268 ACPI_ERROR((AE_INFO, 269 269 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X", 270 - walk_state->thread->thread_id, 270 + (u32) walk_state->thread->thread_id, 271 271 acpi_ut_get_node_name(obj_desc->mutex.node), 272 - obj_desc->mutex.owner_thread->thread_id)); 272 + (u32) obj_desc->mutex.owner_thread->thread_id)); 273 273 return_ACPI_STATUS(AE_AML_NOT_OWNER); 274 274 } 275 275
+4 -4
drivers/acpi/executer/exsystem.c
··· 60 60 * 61 61 * DESCRIPTION: Implements a semaphore wait with a check to see if the 62 62 * semaphore is available immediately. If it is not, the 63 - * interpreter is released. 63 + * interpreter is released before waiting. 64 64 * 65 65 ******************************************************************************/ 66 66 acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) ··· 110 110 * 111 111 * RETURN: Status 112 112 * 113 - * DESCRIPTION: Implements a semaphore wait with a check to see if the 114 - * semaphore is available immediately. If it is not, the 115 - * interpreter is released. 113 + * DESCRIPTION: Implements a mutex wait with a check to see if the 114 + * mutex is available immediately. If it is not, the 115 + * interpreter is released before waiting. 116 116 * 117 117 ******************************************************************************/ 118 118
+1 -1
drivers/acpi/fan.c
··· 120 120 return count; 121 121 } 122 122 123 - static struct file_operations acpi_fan_state_ops = { 123 + static const struct file_operations acpi_fan_state_ops = { 124 124 .open = acpi_fan_state_open_fs, 125 125 .read = seq_read, 126 126 .write = acpi_fan_write_state,
+5 -5
drivers/acpi/hotkey.c
··· 184 184 *hotkey_list, int event); 185 185 186 186 /* event based config */ 187 - static struct file_operations hotkey_config_fops = { 187 + static const struct file_operations hotkey_config_fops = { 188 188 .open = hotkey_open_config, 189 189 .read = seq_read, 190 190 .write = hotkey_write_config, ··· 193 193 }; 194 194 195 195 /* polling based config */ 196 - static struct file_operations hotkey_poll_config_fops = { 196 + static const struct file_operations hotkey_poll_config_fops = { 197 197 .open = hotkey_poll_open_config, 198 198 .read = seq_read, 199 199 .write = hotkey_write_config, ··· 202 202 }; 203 203 204 204 /* hotkey driver info */ 205 - static struct file_operations hotkey_info_fops = { 205 + static const struct file_operations hotkey_info_fops = { 206 206 .open = hotkey_info_open_fs, 207 207 .read = seq_read, 208 208 .llseek = seq_lseek, ··· 210 210 }; 211 211 212 212 /* action */ 213 - static struct file_operations hotkey_action_fops = { 213 + static const struct file_operations hotkey_action_fops = { 214 214 .open = hotkey_action_open_fs, 215 215 .read = seq_read, 216 216 .write = hotkey_execute_aml_method, ··· 219 219 }; 220 220 221 221 /* polling results */ 222 - static struct file_operations hotkey_polling_fops = { 222 + static const struct file_operations hotkey_polling_fops = { 223 223 .open = hotkey_polling_open_fs, 224 224 .read = seq_read, 225 225 .llseek = seq_lseek,
+12 -1
drivers/acpi/namespace/nsalloc.c
··· 386 386 * specific ID. Used to delete entire ACPI tables. All 387 387 * reference counts are updated. 388 388 * 389 + * MUTEX: Locks namespace during deletion walk. 390 + * 389 391 ******************************************************************************/ 390 392 391 393 void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id) 392 394 { 393 395 struct acpi_namespace_node *child_node; 394 396 struct acpi_namespace_node *deletion_node; 395 - u32 level; 396 397 struct acpi_namespace_node *parent_node; 398 + u32 level; 399 + acpi_status status; 397 400 398 401 ACPI_FUNCTION_TRACE_U32(ns_delete_namespace_by_owner, owner_id); 399 402 400 403 if (owner_id == 0) { 404 + return_VOID; 405 + } 406 + 407 + /* Lock namespace for possible update */ 408 + 409 + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 410 + if (ACPI_FAILURE(status)) { 401 411 return_VOID; 402 412 } 403 413 ··· 479 469 } 480 470 } 481 471 472 + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 482 473 return_VOID; 483 474 }
-30
drivers/acpi/osl.c
··· 136 136 #endif 137 137 } 138 138 139 - 140 - extern int acpi_in_resume; 141 - void *acpi_os_allocate(acpi_size size) 142 - { 143 - if (acpi_in_resume) 144 - return kmalloc(size, GFP_ATOMIC); 145 - else 146 - return kmalloc(size, GFP_KERNEL); 147 - } 148 - 149 139 acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) 150 140 { 151 141 if (efi_enabled) { ··· 1103 1113 { 1104 1114 kmem_cache_free(cache, object); 1105 1115 return (AE_OK); 1106 - } 1107 - 1108 - /******************************************************************************* 1109 - * 1110 - * FUNCTION: acpi_os_acquire_object 1111 - * 1112 - * PARAMETERS: Cache - Handle to cache object 1113 - * ReturnObject - Where the object is returned 1114 - * 1115 - * RETURN: Status 1116 - * 1117 - * DESCRIPTION: Return a zero-filled object. 1118 - * 1119 - ******************************************************************************/ 1120 - 1121 - void *acpi_os_acquire_object(acpi_cache_t * cache) 1122 - { 1123 - void *object = kmem_cache_zalloc(cache, GFP_KERNEL); 1124 - WARN_ON(!object); 1125 - return object; 1126 1116 } 1127 1117 1128 1118 /******************************************************************************
-2
drivers/acpi/parser/psutils.c
··· 139 139 /* The generic op (default) is by far the most common (16 to 1) */ 140 140 141 141 op = acpi_os_acquire_object(acpi_gbl_ps_node_cache); 142 - memset(op, 0, sizeof(struct acpi_parse_obj_common)); 143 142 } else { 144 143 /* Extended parseop */ 145 144 146 145 op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache); 147 - memset(op, 0, sizeof(struct acpi_parse_obj_named)); 148 146 } 149 147 150 148 /* Initialize the Op */
-7
drivers/acpi/pci_link.c
··· 780 780 return 0; 781 781 } 782 782 783 - /* 784 - * FIXME: this is a workaround to avoid nasty warning. It will be removed 785 - * after every device calls pci_disable_device in .resume. 786 - */ 787 - int acpi_in_resume; 788 783 static int irqrouter_resume(struct sys_device *dev) 789 784 { 790 785 struct list_head *node = NULL; ··· 789 794 /* Make sure SCI is enabled again (Apple firmware bug?) */ 790 795 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK); 791 796 792 - acpi_in_resume = 1; 793 797 list_for_each(node, &acpi_link.entries) { 794 798 link = list_entry(node, struct acpi_pci_link, node); 795 799 if (!link) { ··· 797 803 } 798 804 acpi_pci_link_resume(link); 799 805 } 800 - acpi_in_resume = 0; 801 806 return 0; 802 807 } 803 808
+1 -1
drivers/acpi/power.c
··· 80 80 81 81 static struct list_head acpi_power_resource_list; 82 82 83 - static struct file_operations acpi_power_fops = { 83 + static const struct file_operations acpi_power_fops = { 84 84 .open = acpi_power_open_fs, 85 85 .read = seq_read, 86 86 .llseek = seq_lseek,
+1 -1
drivers/acpi/processor_core.c
··· 102 102 #define INSTALL_NOTIFY_HANDLER 1 103 103 #define UNINSTALL_NOTIFY_HANDLER 2 104 104 105 - static struct file_operations acpi_processor_info_fops = { 105 + static const struct file_operations acpi_processor_info_fops = { 106 106 .open = acpi_processor_info_open_fs, 107 107 .read = seq_read, 108 108 .llseek = seq_lseek,
+1 -1
drivers/acpi/processor_idle.c
··· 1070 1070 PDE(inode)->data); 1071 1071 } 1072 1072 1073 - static struct file_operations acpi_processor_power_fops = { 1073 + static const struct file_operations acpi_processor_power_fops = { 1074 1074 .open = acpi_processor_power_open_fs, 1075 1075 .read = seq_read, 1076 1076 .llseek = seq_lseek,
+23
drivers/acpi/scan.c
··· 663 663 Device Enumeration 664 664 -------------------------------------------------------------------------- */ 665 665 666 + acpi_status 667 + acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd) 668 + { 669 + acpi_status status; 670 + acpi_handle tmp; 671 + struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 672 + union acpi_object *obj; 673 + 674 + status = acpi_get_handle(handle, "_EJD", &tmp); 675 + if (ACPI_FAILURE(status)) 676 + return status; 677 + 678 + status = acpi_evaluate_object(handle, "_EJD", NULL, &buffer); 679 + if (ACPI_SUCCESS(status)) { 680 + obj = buffer.pointer; 681 + status = acpi_get_handle(NULL, obj->string.pointer, ejd); 682 + kfree(buffer.pointer); 683 + } 684 + return status; 685 + } 686 + EXPORT_SYMBOL_GPL(acpi_bus_get_ejd); 687 + 688 + 666 689 static int acpi_bus_get_flags(struct acpi_device *device) 667 690 { 668 691 acpi_status status = AE_OK;
+3 -3
drivers/acpi/sleep/proc.c
··· 434 434 PDE(inode)->data); 435 435 } 436 436 437 - static struct file_operations acpi_system_wakeup_device_fops = { 437 + static const struct file_operations acpi_system_wakeup_device_fops = { 438 438 .open = acpi_system_wakeup_device_open_fs, 439 439 .read = seq_read, 440 440 .write = acpi_system_write_wakeup_device, ··· 443 443 }; 444 444 445 445 #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 446 - static struct file_operations acpi_system_sleep_fops = { 446 + static const struct file_operations acpi_system_sleep_fops = { 447 447 .open = acpi_system_sleep_open_fs, 448 448 .read = seq_read, 449 449 .write = acpi_system_write_sleep, ··· 452 452 }; 453 453 #endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 454 454 455 - static struct file_operations acpi_system_alarm_fops = { 455 + static const struct file_operations acpi_system_alarm_fops = { 456 456 .open = acpi_system_alarm_open_fs, 457 457 .read = seq_read, 458 458 .write = acpi_system_write_alarm,
+3 -3
drivers/acpi/system.c
··· 57 57 return single_open(file, acpi_system_read_info, PDE(inode)->data); 58 58 } 59 59 60 - static struct file_operations acpi_system_info_ops = { 60 + static const struct file_operations acpi_system_info_ops = { 61 61 .open = acpi_system_info_open_fs, 62 62 .read = seq_read, 63 63 .llseek = seq_lseek, ··· 67 67 static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, 68 68 loff_t *); 69 69 70 - static struct file_operations acpi_system_dsdt_ops = { 70 + static const struct file_operations acpi_system_dsdt_ops = { 71 71 .read = acpi_system_read_dsdt, 72 72 }; 73 73 ··· 94 94 static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, 95 95 loff_t *); 96 96 97 - static struct file_operations acpi_system_fadt_ops = { 97 + static const struct file_operations acpi_system_fadt_ops = { 98 98 .read = acpi_system_read_fadt, 99 99 }; 100 100
+11 -1
drivers/acpi/tables/tbget.c
··· 320 320 321 321 ACPI_FUNCTION_TRACE(tb_get_this_table); 322 322 323 + /* Validate minimum length */ 324 + 325 + if (header->length < sizeof(struct acpi_table_header)) { 326 + ACPI_ERROR((AE_INFO, 327 + "Table length (%X) is smaller than minimum (%X)", 328 + header->length, sizeof(struct acpi_table_header))); 329 + 330 + return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 331 + } 332 + 323 333 /* 324 334 * Flags contains the current processor mode (Virtual or Physical 325 335 * addressing) The pointer_type is either Logical or Physical ··· 366 356 */ 367 357 status = acpi_os_map_memory(address->pointer.physical, 368 358 (acpi_size) header->length, 369 - (void *)&full_table); 359 + ACPI_CAST_PTR(void, &full_table)); 370 360 if (ACPI_FAILURE(status)) { 371 361 ACPI_ERROR((AE_INFO, 372 362 "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X",
+18 -3
drivers/acpi/tables/tbinstal.c
··· 256 256 257 257 status = acpi_ut_allocate_owner_id(&table_desc->owner_id); 258 258 if (ACPI_FAILURE(status)) { 259 - return_ACPI_STATUS(status); 259 + goto error_exit1; 260 260 } 261 261 262 262 /* Install the table into the global data structure */ ··· 274 274 * at this location, so return an error. 275 275 */ 276 276 if (list_head->next) { 277 - ACPI_FREE(table_desc); 278 - return_ACPI_STATUS(AE_ALREADY_EXISTS); 277 + status = AE_ALREADY_EXISTS; 278 + goto error_exit2; 279 279 } 280 280 281 281 table_desc->next = list_head->next; ··· 335 335 table_info->owner_id = table_desc->owner_id; 336 336 table_info->installed_desc = table_desc; 337 337 return_ACPI_STATUS(AE_OK); 338 + 339 + /* Error exit with cleanup */ 340 + 341 + error_exit2: 342 + 343 + acpi_ut_release_owner_id(&table_desc->owner_id); 344 + 345 + error_exit1: 346 + 347 + ACPI_FREE(table_desc); 348 + return_ACPI_STATUS(status); 338 349 } 339 350 340 351 /******************************************************************************* ··· 535 524 /* Free the memory allocated for the table itself */ 536 525 537 526 acpi_tb_delete_single_table(table_desc); 527 + 528 + /* Free the owner ID associated with this table */ 529 + 530 + acpi_ut_release_owner_id(&table_desc->owner_id); 538 531 539 532 /* Free the table descriptor */ 540 533
+23 -4
drivers/acpi/tables/tbrsdt.c
··· 183 183 184 184 ACPI_FUNCTION_ENTRY(); 185 185 186 + /* Validate minimum length */ 187 + 188 + if (table_ptr->length < sizeof(struct acpi_table_header)) { 189 + ACPI_ERROR((AE_INFO, 190 + "RSDT/XSDT length (%X) is smaller than minimum (%X)", 191 + table_ptr->length, 192 + sizeof(struct acpi_table_header))); 193 + 194 + return (AE_INVALID_TABLE_LENGTH); 195 + } 196 + 186 197 /* Search for appropriate signature, RSDT or XSDT */ 187 198 188 199 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { ··· 221 210 ACPI_ERROR((AE_INFO, "Looking for XSDT")); 222 211 } 223 212 224 - ACPI_DUMP_BUFFER((char *)table_ptr, 48); 213 + ACPI_DUMP_BUFFER(ACPI_CAST_PTR(char, table_ptr), 48); 225 214 return (AE_BAD_SIGNATURE); 226 215 } 227 216 ··· 269 258 270 259 status = acpi_tb_validate_rsdt(table_info.pointer); 271 260 if (ACPI_FAILURE(status)) { 272 - return_ACPI_STATUS(status); 261 + goto error_cleanup; 273 262 } 274 263 275 264 /* Get the number of tables defined in the RSDT or XSDT */ ··· 281 270 282 271 status = acpi_tb_convert_to_xsdt(&table_info); 283 272 if (ACPI_FAILURE(status)) { 284 - return_ACPI_STATUS(status); 273 + goto error_cleanup; 285 274 } 286 275 287 276 /* Save the table pointers and allocation info */ 288 277 289 278 status = acpi_tb_init_table_descriptor(ACPI_TABLE_ID_XSDT, &table_info); 290 279 if (ACPI_FAILURE(status)) { 291 - return_ACPI_STATUS(status); 280 + goto error_cleanup; 292 281 } 293 282 294 283 acpi_gbl_XSDT = 295 284 ACPI_CAST_PTR(struct xsdt_descriptor, table_info.pointer); 296 285 297 286 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT)); 287 + return_ACPI_STATUS(status); 288 + 289 + error_cleanup: 290 + 291 + /* Free table allocated by acpi_tb_get_table */ 292 + 293 + acpi_tb_delete_single_table(&table_info); 294 + 298 295 return_ACPI_STATUS(status); 299 296 }
+19 -13
drivers/acpi/tables/tbxface.c
··· 134 134 * RETURN: Status 135 135 * 136 136 * DESCRIPTION: This function is called to load a table from the caller's 137 - * buffer. The buffer must contain an entire ACPI Table including 138 - * a valid header. The header fields will be verified, and if it 137 + * buffer. The buffer must contain an entire ACPI Table including 138 + * a valid header. The header fields will be verified, and if it 139 139 * is determined that the table is invalid, the call will fail. 140 140 * 141 141 ******************************************************************************/ ··· 245 245 /* Find all tables of the requested type */ 246 246 247 247 table_desc = acpi_gbl_table_lists[table_type].next; 248 + if (!table_desc) { 249 + return_ACPI_STATUS(AE_NOT_EXIST); 250 + } 251 + 248 252 while (table_desc) { 249 253 /* 250 - * Delete all namespace entries owned by this table. Note that these 251 - * entries can appear anywhere in the namespace by virtue of the AML 252 - * "Scope" operator. Thus, we need to track ownership by an ID, not 254 + * Delete all namespace objects owned by this table. Note that these 255 + * objects can appear anywhere in the namespace by virtue of the AML 256 + * "Scope" operator. Thus, we need to track ownership by an ID, not 253 257 * simply a position within the hierarchy 254 258 */ 255 259 acpi_ns_delete_namespace_by_owner(table_desc->owner_id); 256 - acpi_ut_release_owner_id(&table_desc->owner_id); 257 260 table_desc = table_desc->next; 258 261 } 259 262 ··· 278 275 * see acpi_gbl_acpi_table_flag 279 276 * out_table_header - pointer to the struct acpi_table_header if successful 280 277 * 281 - * DESCRIPTION: This function is called to get an ACPI table header. The caller 278 + * DESCRIPTION: This function is called to get an ACPI table header. The caller 282 279 * supplies an pointer to a data area sufficient to contain an ACPI 283 280 * struct acpi_table_header structure. 284 281 * 285 282 * The header contains a length field that can be used to determine 286 - * the size of the buffer needed to contain the entire table. This 283 + * the size of the buffer needed to contain the entire table. This 287 284 * function is not valid for the RSD PTR table since it does not 288 285 * have a standard header and is fixed length. 289 286 * ··· 325 322 326 323 /* Copy the header to the caller's buffer */ 327 324 328 - ACPI_MEMCPY((void *)out_table_header, (void *)tbl_ptr, 325 + ACPI_MEMCPY(ACPI_CAST_PTR(void, out_table_header), 326 + ACPI_CAST_PTR(void, tbl_ptr), 329 327 sizeof(struct acpi_table_header)); 330 328 331 329 return_ACPI_STATUS(status); ··· 348 344 * 349 345 * RETURN: Status 350 346 * 351 - * DESCRIPTION: This function is called to get an ACPI table. The caller 347 + * DESCRIPTION: This function is called to get an ACPI table. The caller 352 348 * supplies an out_buffer large enough to contain the entire ACPI 353 - * table. The caller should call the acpi_get_table_header function 354 - * first to determine the buffer size needed. Upon completion 349 + * table. The caller should call the acpi_get_table_header function 350 + * first to determine the buffer size needed. Upon completion 355 351 * the out_buffer->Length field will indicate the number of bytes 356 352 * copied into the out_buffer->buf_ptr buffer. This table will be 357 353 * a complete table including the header. ··· 421 417 422 418 /* Copy the table to the buffer */ 423 419 424 - ACPI_MEMCPY((void *)ret_buffer->pointer, (void *)tbl_ptr, table_length); 420 + ACPI_MEMCPY(ACPI_CAST_PTR(void, ret_buffer->pointer), 421 + ACPI_CAST_PTR(void, tbl_ptr), table_length); 422 + 425 423 return_ACPI_STATUS(AE_OK); 426 424 } 427 425
+5 -5
drivers/acpi/thermal.c
··· 176 176 struct timer_list timer; 177 177 }; 178 178 179 - static struct file_operations acpi_thermal_state_fops = { 179 + static const struct file_operations acpi_thermal_state_fops = { 180 180 .open = acpi_thermal_state_open_fs, 181 181 .read = seq_read, 182 182 .llseek = seq_lseek, 183 183 .release = single_release, 184 184 }; 185 185 186 - static struct file_operations acpi_thermal_temp_fops = { 186 + static const struct file_operations acpi_thermal_temp_fops = { 187 187 .open = acpi_thermal_temp_open_fs, 188 188 .read = seq_read, 189 189 .llseek = seq_lseek, 190 190 .release = single_release, 191 191 }; 192 192 193 - static struct file_operations acpi_thermal_trip_fops = { 193 + static const struct file_operations acpi_thermal_trip_fops = { 194 194 .open = acpi_thermal_trip_open_fs, 195 195 .read = seq_read, 196 196 .write = acpi_thermal_write_trip_points, ··· 198 198 .release = single_release, 199 199 }; 200 200 201 - static struct file_operations acpi_thermal_cooling_fops = { 201 + static const struct file_operations acpi_thermal_cooling_fops = { 202 202 .open = acpi_thermal_cooling_open_fs, 203 203 .read = seq_read, 204 204 .write = acpi_thermal_write_cooling_mode, ··· 206 206 .release = single_release, 207 207 }; 208 208 209 - static struct file_operations acpi_thermal_polling_fops = { 209 + static const struct file_operations acpi_thermal_polling_fops = { 210 210 .open = acpi_thermal_polling_open_fs, 211 211 .read = seq_read, 212 212 .write = acpi_thermal_write_polling,
+2
drivers/acpi/utilities/utalloc.c
··· 285 285 return (status); 286 286 } 287 287 288 + #ifdef NOT_USED_BY_LINUX 288 289 /******************************************************************************* 289 290 * 290 291 * FUNCTION: acpi_ut_allocate ··· 361 360 362 361 return (allocation); 363 362 } 363 + #endif
+2 -2
drivers/acpi/utilities/utdebug.c
··· 47 47 ACPI_MODULE_NAME("utdebug") 48 48 49 49 #ifdef ACPI_DEBUG_OUTPUT 50 - static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF; 50 + static acpi_thread_id acpi_gbl_prev_thread_id; 51 51 static char *acpi_gbl_fn_entry_str = "----Entry"; 52 52 static char *acpi_gbl_fn_exit_str = "----Exit-"; 53 53 ··· 181 181 if (ACPI_LV_THREADS & acpi_dbg_level) { 182 182 acpi_os_printf 183 183 ("\n**** Context Switch from TID %X to TID %X ****\n\n", 184 - acpi_gbl_prev_thread_id, thread_id); 184 + (u32) acpi_gbl_prev_thread_id, (u32) thread_id); 185 185 } 186 186 187 187 acpi_gbl_prev_thread_id = thread_id;
+9 -4
drivers/acpi/utilities/utdelete.c
··· 447 447 */ 448 448 switch (ACPI_GET_OBJECT_TYPE(object)) { 449 449 case ACPI_TYPE_DEVICE: 450 + case ACPI_TYPE_PROCESSOR: 451 + case ACPI_TYPE_POWER: 452 + case ACPI_TYPE_THERMAL: 450 453 451 - acpi_ut_update_ref_count(object->device.system_notify, 452 - action); 453 - acpi_ut_update_ref_count(object->device.device_notify, 454 - action); 454 + /* Update the notify objects for these types (if present) */ 455 + 456 + acpi_ut_update_ref_count(object->common_notify. 457 + system_notify, action); 458 + acpi_ut_update_ref_count(object->common_notify. 459 + device_notify, action); 455 460 break; 456 461 457 462 case ACPI_TYPE_PACKAGE:
+19 -6
drivers/acpi/utilities/utmisc.c
··· 65 65 u8 acpi_ut_is_aml_table(struct acpi_table_header *table) 66 66 { 67 67 68 - /* Ignore tables that contain AML */ 68 + /* These are the only tables that contain executable AML */ 69 69 70 70 if (ACPI_COMPARE_NAME(table->signature, DSDT_SIG) || 71 71 ACPI_COMPARE_NAME(table->signature, PSDT_SIG) || ··· 419 419 { 420 420 421 421 if (revision <= 1) { 422 + 423 + /* 32-bit case */ 424 + 422 425 acpi_gbl_integer_bit_width = 32; 423 426 acpi_gbl_integer_nybble_width = 8; 424 427 acpi_gbl_integer_byte_width = 4; 425 428 } else { 429 + /* 64-bit case (ACPI 2.0+) */ 430 + 426 431 acpi_gbl_integer_bit_width = 64; 427 432 acpi_gbl_integer_nybble_width = 16; 428 433 acpi_gbl_integer_byte_width = 8; ··· 507 502 * FUNCTION: acpi_ut_valid_acpi_char 508 503 * 509 504 * PARAMETERS: Char - The character to be examined 505 + * Position - Byte position (0-3) 510 506 * 511 507 * RETURN: TRUE if the character is valid, FALSE otherwise 512 508 * ··· 615 609 * 616 610 * RETURN: Status and Converted value 617 611 * 618 - * DESCRIPTION: Convert a string into an unsigned value. 612 + * DESCRIPTION: Convert a string into an unsigned value. Performs either a 613 + * 32-bit or 64-bit conversion, depending on the current mode 614 + * of the interpreter. 619 615 * NOTE: Does not support Octal strings, not needed. 620 616 * 621 617 ******************************************************************************/ ··· 635 627 u8 sign_of0x = 0; 636 628 u8 term = 0; 637 629 638 - ACPI_FUNCTION_TRACE(ut_stroul64); 630 + ACPI_FUNCTION_TRACE_STR(ut_stroul64, string); 639 631 640 632 switch (base) { 641 633 case ACPI_ANY_BASE: ··· 683 675 } 684 676 } 685 677 678 + /* 679 + * Perform a 32-bit or 64-bit conversion, depending upon the current 680 + * execution mode of the interpreter 681 + */ 686 682 dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; 687 683 688 - /* At least one character in the string here */ 689 - 690 - /* Main loop: convert the string to a 64-bit integer */ 684 + /* Main loop: convert the string to a 32- or 64-bit integer */ 691 685 692 686 while (*string) { 693 687 if (ACPI_IS_DIGIT(*string)) { ··· 763 753 /* All done, normal exit */ 764 754 765 755 all_done: 756 + 757 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", 758 + ACPI_FORMAT_UINT64(return_value))); 766 759 767 760 *ret_integer = return_value; 768 761 return_ACPI_STATUS(AE_OK);
+4 -4
drivers/acpi/utilities/utmutex.c
··· 244 244 245 245 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 246 246 "Thread %X attempting to acquire Mutex [%s]\n", 247 - this_thread_id, acpi_ut_get_mutex_name(mutex_id))); 247 + (u32) this_thread_id, acpi_ut_get_mutex_name(mutex_id))); 248 248 249 249 status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, 250 250 ACPI_WAIT_FOREVER); 251 251 if (ACPI_SUCCESS(status)) { 252 252 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 253 253 "Thread %X acquired Mutex [%s]\n", 254 - this_thread_id, 254 + (u32) this_thread_id, 255 255 acpi_ut_get_mutex_name(mutex_id))); 256 256 257 257 acpi_gbl_mutex_info[mutex_id].use_count++; ··· 259 259 } else { 260 260 ACPI_EXCEPTION((AE_INFO, status, 261 261 "Thread %X could not acquire Mutex [%X]", 262 - this_thread_id, mutex_id)); 262 + (u32) this_thread_id, mutex_id)); 263 263 } 264 264 265 265 return (status); ··· 285 285 286 286 this_thread_id = acpi_os_get_thread_id(); 287 287 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 288 - "Thread %X releasing Mutex [%s]\n", this_thread_id, 288 + "Thread %X releasing Mutex [%s]\n", (u32) this_thread_id, 289 289 acpi_ut_get_mutex_name(mutex_id))); 290 290 291 291 if (mutex_id > ACPI_MAX_MUTEX) {
+7
drivers/acpi/utilities/utstate.c
··· 199 199 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_THREAD; 200 200 state->thread.thread_id = acpi_os_get_thread_id(); 201 201 202 + /* Check for invalid thread ID - zero is very bad, it will break things */ 203 + 204 + if (!state->thread.thread_id) { 205 + ACPI_ERROR((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId")); 206 + state->thread.thread_id = (acpi_thread_id) 1; 207 + } 208 + 202 209 return_PTR((struct acpi_thread_state *)state); 203 210 } 204 211
+1 -1
drivers/pci/hotplug/Kconfig
··· 76 76 77 77 config HOTPLUG_PCI_ACPI 78 78 tristate "ACPI PCI Hotplug driver" 79 - depends on ACPI && HOTPLUG_PCI 79 + depends on ACPI_DOCK && HOTPLUG_PCI 80 80 help 81 81 Say Y here if you have a system that supports PCI Hotplug using 82 82 ACPI.
+1 -1
include/acpi/acconfig.h
··· 63 63 64 64 /* Current ACPICA subsystem version in YYYYMMDD format */ 65 65 66 - #define ACPI_CA_VERSION 0x20060623 66 + #define ACPI_CA_VERSION 0x20060707 67 67 68 68 /* 69 69 * OS name, used for the _OS object. The _OS object is essentially obsolete,
+7 -3
include/acpi/acinterp.h
··· 53 53 #define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_exdump_info)) 54 54 55 55 /* 56 - * If possible, pack the following structure to byte alignment, since we 57 - * don't care about performance for debug output 56 + * If possible, pack the following structures to byte alignment, since we 57 + * don't care about performance for debug output. Two cases where we cannot 58 + * pack the structures: 59 + * 60 + * 1) Hardware does not support misaligned memory transfers 61 + * 2) Compiler does not support pointers within packed structures 58 62 */ 59 - #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED 63 + #if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) 60 64 #pragma pack(1) 61 65 #endif 62 66
+2 -2
include/acpi/aclocal.h
··· 127 127 128 128 /* This Thread ID means that the mutex is not in use (unlocked) */ 129 129 130 - #define ACPI_MUTEX_NOT_ACQUIRED (u32) -1 130 + #define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0 131 131 132 132 /* Table for the global mutexes */ 133 133 ··· 204 204 /* Namespace Node flags */ 205 205 206 206 #define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ 207 - #define ANOBJ_DATA_WIDTH_32 0x02 /* Parent table uses 32-bit math */ 207 + #define ANOBJ_RESERVED 0x02 /* Available for future use */ 208 208 #define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ 209 209 #define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ 210 210 #define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */
+7 -1
include/acpi/acmacros.h
··· 724 724 725 725 /* Memory allocation */ 726 726 727 + #ifndef ACPI_ALLOCATE 727 728 #define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) 729 + #endif 730 + #ifndef ACPI_ALLOCATE_ZEROED 728 731 #define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) 729 - #define ACPI_FREE(a) kfree(a) 732 + #endif 733 + #ifndef ACPI_FREE 734 + #define ACPI_FREE(a) acpio_os_free(a) 735 + #endif 730 736 #define ACPI_MEM_TRACKING(a) 731 737 732 738 #else
+1 -1
include/acpi/acpi_bus.h
··· 334 334 acpi_handle handle, int type); 335 335 int acpi_bus_trim(struct acpi_device *start, int rmdevice); 336 336 int acpi_bus_start(struct acpi_device *device); 337 - 337 + acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd); 338 338 int acpi_match_ids(struct acpi_device *device, char *ids); 339 339 int acpi_create_dir(struct acpi_device *); 340 340 void acpi_remove_dir(struct acpi_device *);
+17
include/acpi/acpi_drivers.h
··· 110 110 111 111 extern int acpi_specific_hotkey_enabled; 112 112 113 + /*-------------------------------------------------------------------------- 114 + Dock Station 115 + -------------------------------------------------------------------------- */ 116 + #if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE) 117 + extern int is_dock_device(acpi_handle handle); 118 + extern int register_dock_notifier(struct notifier_block *nb); 119 + extern void unregister_dock_notifier(struct notifier_block *nb); 120 + extern int register_hotplug_dock_device(acpi_handle handle, 121 + acpi_notify_handler handler, void *context); 122 + extern void unregister_hotplug_dock_device(acpi_handle handle); 123 + #else 124 + #define is_dock_device(h) (0) 125 + #define register_dock_notifier(nb) (-ENODEV) 126 + #define unregister_dock_notifier(nb) do { } while(0) 127 + #define register_hotplug_dock_device(h1, h2, c) (-ENODEV) 128 + #define unregister_hotplug_dock_device(h) do { } while(0) 129 + #endif 113 130 #endif /*__ACPI_DRIVERS_H__*/
+6 -2
include/acpi/acresrc.h
··· 50 50 51 51 /* 52 52 * If possible, pack the following structures to byte alignment, since we 53 - * don't care about performance for debug output 53 + * don't care about performance for debug output. Two cases where we cannot 54 + * pack the structures: 55 + * 56 + * 1) Hardware does not support misaligned memory transfers 57 + * 2) Compiler does not support pointers within packed structures 54 58 */ 55 - #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED 59 + #if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) 56 60 #pragma pack(1) 57 61 #endif 58 62
+25 -2
include/acpi/platform/aclinux.h
··· 59 59 #include <asm/acpi.h> 60 60 #include <linux/slab.h> 61 61 #include <linux/spinlock_types.h> 62 + #include <asm/current.h> 62 63 63 64 /* Host-dependent types and defines */ 64 65 ··· 101 100 102 101 #define acpi_cpu_flags unsigned long 103 102 104 - #define acpi_thread_id u32 103 + #define acpi_thread_id struct task_struct * 105 104 106 - static inline acpi_thread_id acpi_os_get_thread_id(void) { return 0; } 105 + static inline acpi_thread_id acpi_os_get_thread_id(void) { return current; } 106 + 107 + /* 108 + * The irqs_disabled() check is for resume from RAM. 109 + * Interrupts are off during resume, just like they are for boot. 110 + * However, boot has (system_state != SYSTEM_RUNNING) 111 + * to quiet __might_sleep() in kmalloc() and resume does not. 112 + */ 113 + #include <acpi/actypes.h> 114 + static inline void *acpi_os_allocate(acpi_size size) { 115 + return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); 116 + } 117 + static inline void *acpi_os_allocate_zeroed(acpi_size size) { 118 + return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); 119 + } 120 + 121 + static inline void *acpi_os_acquire_object(acpi_cache_t * cache) { 122 + return kmem_cache_zalloc(cache, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); 123 + } 124 + 125 + #define ACPI_ALLOCATE(a) acpi_os_allocate(a) 126 + #define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a) 127 + #define ACPI_FREE(a) kfree(a) 107 128 108 129 #endif /* __ACLINUX_H__ */