GIT d684de2c4a498ec4edf4e6c3420b008c62be394c git+ssh://master.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git#test commit f9a6ee1afb84fd767508428ec5d1df4fb60a03ad Author: Rich Townsend Date: Mon Dec 19 23:07:00 2005 -0500 ACPI: replace spin_lock_irq with mutex for ec poll mode http://bugzilla.kernel.org/show_bug.cgi?id=5764 Signed-off-by: Luming Yu Signed-off-by: Len Brown commit 2860de93fc72d5bddc6693a9cde946c4a215aead Author: Alexey Starikovskiy Date: Fri May 5 03:23:00 2006 -0400 ACPI: execute Notify() handlers on new thread http://bugzilla.kernel.org/show_bug.cgi?id=5534 Thanks to Peter Wainwright for isolating the issue. Thanks to Andi Kleen and Bob Moore for feedback. Thanks to Richard Mace and others for testing. Updates by Konstantin Karasyov. Signed-off-by: Konstantin Karasyov Signed-off-by: Len Brown commit 74ce1468128e299fe6a85e7e78e528e45e72d6d9 Author: Konstantin Karasyov Date: Mon May 8 08:32:00 2006 -0400 ACPI: create acpi_thermal_resume() http://bugzilla.kernel.org/show_bug.cgi?id=4364 Signed-off-by: Konstantin Karasyov Signed-off-by: Len Brown commit 0feabb01d93e5801d1127416a66cfc3963280bca Author: Konstantin Karasyov Date: Mon May 8 00:00:00 2006 -0400 ACPI: create acpi_fan_suspend()/acpi_fan_resume() http://bugzilla.kernel.org/show_bug.cgi?id=5000 Signed-off-by: Len Brown commit 531881d665ca011326bb466b97b07c95dee8d0a1 Author: Len Brown Date: Mon May 15 03:06:41 2006 -0400 ACPI: pass pm_message_t from acpi_device_suspend() to root_suspend() in case we want to decode it for future use in acpi_op_suspend(..., state) also, inline new 1-liner static function http://bugzilla.kernel.org/show_bug.cgi?id=5000 Signed-off-by: Len Brown commit 5b3272655a8e8a9a6e2503bc5a88fc9d9c8292a4 Author: Patrick Mochel Date: Wed May 10 10:33:00 2006 -0400 ACPI: create acpi_device_suspend()/acpi_device_resume() updated and tested by Konstantin Karasyov http://bugzilla.kernel.org/show_bug.cgi?id=5000 Signed-off-by: Patrick Mochel Signed-off-by: Konstantin Karasyov Signed-off-by: Len Brown commit 9c576ff1bc9ab42d06457e68e39c121481138562 Author: KAMEZAWA Hiroyuki Date: Thu Apr 27 05:25:00 2006 -0400 ACPI add ia64 exports to build acpi_memhotplug as a module Signed-off-by: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 973bf491a55b825740f0d8d300b50bcd3d6fb8de Author: Yu, Luming Date: Thu Apr 27 05:25:00 2006 -0400 ACPI: fix potential memory leaks in driver/acpi/video.c acpi_video_bus_get_one_device() and other functions in driver/acpi/video.c do not release allocated memory on remove and on the error path. Signed-off-by: "Yu, Luming" Signed-off-by: Vasily Averin Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit ebd5f2ca811b75f7145fa487748f26430c584a72 Author: Andrew Morton Date: Sat May 13 22:56:00 2006 -0400 ACPI: asus_acpi_init(): propagate correct return value Cc: Bjorn Helgaas Acked-by: Francois Romieu Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 706b5a0cee2b4d5ee009cedb1bce25c115c9ae4d Author: Arnaud Patard Date: Thu Apr 27 05:25:00 2006 -0400 ACPI: suppress power button event on S3 resume Signed-off-by: Arnaud Patard Acked-by: "Yu, Luming" Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit b6835052a6aa00536343b6d2127fc65cd814a040 Author: Andreas Mohr Date: Thu Apr 27 05:25:00 2006 -0400 ACPI: apply "__read_mostly" to processor_idle.c loop module parameters and friends make pm_idle_save, nocst and bm_history __read_mostly remove initializer from static 'first_run'. Signed-off-by: Andreas Mohr Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 09047e75f69428dcfa977b326256085154068b65 Author: Vasily Averin Date: Thu Apr 27 05:25:00 2006 -0400 ACPI: fix memory leak in acpi_thermal_add() error path Signed-off-by: Vasily Averin Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 64385f2fd8bc9d8803c8d10dcd391871cb126b77 Author: Vasily Averin Date: Thu Apr 27 05:25:00 2006 -0400 ACPI: fix potential memory leak in acpi_evaluate_integer() error path Signed-off-by: Vasily Averin Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 561adfafb2dfd57c498a84efb720bb777d109134 Author: Bjorn Helgaas Date: Thu Apr 27 05:25:00 2006 -0400 ACPI: acpi_os_wait_semaphore(): silence complaint The ASL Acquire operator (17.5.1 in ACPI 3.0 spec) is allowed to time out and return True without acquiring the semaphore. There's no indication in the spec that this is an actual error, so this message should be debug-only, as the message for successful acquisition is. This used to be an ACPI_DEBUG_PRINT, but it was mis-classified as ACPI_DB_ERROR rather than ACPI_DB_MUTEX, so it got swept up in Thomas' recent patch to enable ACPI error messages even without CONFIG_ACPI_DEBUG. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 06ea8e08ae7e7e450b6a78e7ce5e10b3c5f954ea Author: Bjorn Helgaas Date: Thu Apr 27 05:25:00 2006 -0400 ACPI: acpi_bus_unregister_driver() returns void Nobody looks at the return value, and this brings it into line with pci_unregister_driver(), etc. Also removed validation of the driver pointer passed in to register and unregister. More consistent, and we'll find bugs faster if we fault rather than returning an error that's ignored. Also makes internal functions acpi_device_unregister() and acpi_driver_detach() void, since nobody uses their returns either. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 193de0c79da580eb33a66113b62e2378fc1fb629 Author: KAMEZAWA Hiroyuki Date: Thu Apr 27 05:25:00 2006 -0400 ACPI: use for_each_possible_cpu() instead of for_each_cpu() for_each_cpu() actually iterates across all possible CPUs. We've had mistakes in the past where people were using for_each_cpu() where they should have been iterating across only online or present CPUs. This is inefficient and possibly buggy. We're renaming for_each_cpu() to for_each_possible_cpu() to avoid this in the future. Signed-off-by: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 36e430951af0b0d1bdfd50ce22e70079d02646df Author: Ingo Molnar Date: Thu Apr 27 05:25:00 2006 -0400 sem2mutex: acpi, acpi_link_lock Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 415d320a2384bb80d2be98b1dfa41594e085012d Author: Len Brown Date: Sat May 13 21:35:56 2006 -0400 ACPI: delete unused acpi_bus_drivers_lock acpi_bus_drivers is protected by acpi_device_lock Signed-off-by: Len Brown commit 65c19bbd28cba587d9bd24feccf7272da18481a7 Author: Arjan van de Ven Date: Thu Apr 27 05:25:00 2006 -0400 sem2mutex: drivers/acpi/processor_perflib.c Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 5810452d00ae5fed7f720185d02d79ec9d15b91e Author: Len Brown Date: Sat May 13 01:12:15 2006 -0400 ACPI: silence ia64 build warning When building sim_defconfig, which does not define CONFIG_ACPI arch/ia64/kernel/acpi.c:71: warning: 'acpi_madt_rev' defined but not used really acpi.c should not be built when CONFIG_ACPI=n... Signed-off-by: Len Brown commit f1fc4c3c27cf7fb2df6a9fb32aa9e30960f89fc5 Author: Len Brown Date: Fri May 12 05:33:22 2006 -0400 ACPI: use kfree() on ia64 instead of acpi_os_free() Signed-off-by: Len Brown commit 26375665dd6ba2140790889f1761981dbda6efab Author: Len Brown Date: Fri May 12 04:19:11 2006 -0400 ACPI: repair damage from overzealous bus.c cleanup patch Signed-off-by: Len Brown commit e4218b8328d570082de636b865d6e874a451644d Author: Len Brown Date: Fri May 12 00:47:25 2006 -0400 ACPI: use kmalloc() and kzalloc(), delete acpi_os_allocate() Also skip acpi_ut_allocate(). In addition to deleting unnecessary code, this allows CONFIG_DEBUG_SLAB_LEAK to better track kmalloc users. Signed-off-by: Len Brown commit 6e1f1f6ef94d38b78f56ba728491a94de52cda0b Author: Len Brown Date: Thu May 11 01:43:04 2006 -0400 ACPI: delete acpi_in_resume workaround All this workaround does is silence the may_sleep warning. But that can be silenced by using global system states in resume, just they are used during boot. Signed-off-by: Len Brown commit 1b35d6f69aad8780fbe01d0b21497aa2d616f392 Author: Len Brown Date: Thu May 11 01:37:05 2006 -0400 ACPI: use kfree(), delete acpi_os_free() acpi_os_free() serves no purpose. Inside the ACPICA core, ACPI_FREE() is used. Outside the ACPICA core, native kfree() can be used. Signed-off-by: Len Brown commit a2412c16d852826365d2caf7238dea6fb356c3c7 Author: Len Brown Date: Thu May 11 01:17:16 2006 -0400 ACPI: disable ACPI_DBG_TRACK_ALLOCATIONS on debug kernel Signed-off-by: Len Brown commit 9011bff4bdc0fef1f9a782d7415c306ee61826c9 Author: Len Brown Date: Thu May 11 00:28:12 2006 -0400 ACPI: delete newly added debugging macros in processor_perflib.c Signed-off-by: Len Brown commit 5d882e684aafea30c508d86d235327d94e1d38ae Author: Len Brown Date: Tue May 9 10:55:56 2006 -0400 ACPI: delete remaining function tracing macros from drivers/acpi/*.c Signed-off-by: Len Brown commit 14394600cdfe0c952ce662a32a68c5c5524d32ac Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/ac.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit da95181baf3cf6a2bd81c0c8af1d4c6790703e4f Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/acpi_memhotplug.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit b128440ed11d108c375772b7fe9ad46d2ac07084 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/bus.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 61ce94e1f8b16b1694475adba9bf2e07fac02020 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/battery.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit a48142ea89e02ed0aba0a481ead1e9302e1a4160 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/button.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit d5c11d3ba31d6ead24f27de648dc2dcfde5092e3 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/debug.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit f6a08bf2cb06ee3d5be749cf20685b677619bc8e Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/container.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 2cb7f1704275905b7548eee299c554bcdc5cf357 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/fan.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 2ce2b16467f0d43d0f8933eb4821b2369b31888c Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/pci_bind.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 8ec0cbd9386a40a3afffad78334f4403b256dc4b Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/hotkey.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit ba8acc597cff47fcbbd7b9f0d73a59e784852d8b Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/motherboard.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 7e9e8344848d80c9b6e1b9eaf32dd498b48ca5bb Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/pci_irq.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit d2606159ffdf8e435f6a7714f8e8910672b944d5 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/pci_root.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 8fb1d47b74e2bad912f74783048b433a1e313799 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/power.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit f7c0fce6da5cb68b8b0e203df4ff8ef9b3265105 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/event.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 61e295946a248e43cf244cb24097e284d1d00e35 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/pci_link.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit a32283362a7a8e7cff608fe25299a59925daea4d Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/ec.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 4cd5611ca16348b3805ddcf89b97fe670e76faaa Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/processor_idle.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 529758bad4b0f9a8eec56fcc5cad342e9680ea36 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/processor_core.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 91afb9e683426ff238aab159e60f6d6e792e7488 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/processor_perflib.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 9f102deee398ea4dfcee3b2108dc00bc59ea877b Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/processor_thermal.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit e85eb9a47f19a26b636b58106e309f8db6b2415d Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/processor_throttling.c Signed-off-by: Len Brown commit 4597ac50598b85a09417df531849b80ce2e8e44b Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/system.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit 74951d613e758f9709d6f2173107be68f18f77f4 Author: Patrick Mochel Date: Mon Apr 17 21:22:00 2006 -0400 ACPI: Remove debugging macros from drivers/acpi/thermal.c Signed-off-by: Patrick Mochel Signed-off-by: Len Brown commit e6f1f3c54974a30c65ea0b699809d12f0aa04272 Author: Bjorn Helgaas Date: Mon Apr 3 13:14:00 2006 -0400 ACPI: Don't print internal BIOS names of wakeup devices Internal BIOS names like these should be exposed to the user as little as possible: ACPI wakeup devices: C069 C0CE C1D1 C0DE C1D4 Eventually, the "wakeup" property of a device should be exported via the device tree, not by a printk of an internal BIOS name. For the hard-core, these are still available in /proc/acpi/wakeup_devices, just not printed to dmesg. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown commit 144c87b4e03759214c362d267e01c2905f1ab095 Author: Len Brown Date: Sun Apr 2 00:15:39 2006 -0500 ACPI: ia64 buildfix arch/ia64/hp/common/sba_iommu.c used ACPI_MEM_FREE instead of kfree() Signed-off-by: Len Brown Date: Sat Apr 1 23:45:39 2006 -0500 ACPI: ia64 buildfix Signed-off-by: Len Brown commit c12ea918ee175ceb3a258cd81f1c43e897d0c0bc Author: Ashok Raj Date: Tue Mar 28 17:04:00 2006 -0500 x86_64: Remove stale lapic definition from apicdef.h Signed-off-by: Ashok Raj Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit eefa27a93a0490902f33837ac86dbcf344b3aa29 Author: Ashok Raj Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: Allow hot-add of ejected processor acpi_eject_store() didn't trim processors, causing subsequent hot-add to fail. Signed-off-by: Ashok Raj Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit ff2fc3e9e3edb918b6c6b288485c6cb267bc865e Author: Jiri Slaby Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: EC acpi-ecdt-uid-hack On some boxes ecdt uid may be equal to 0, so do not test for uids equality, so that fake handler will be unconditionally removed to allow loading the real one. See http://bugzilla.kernel.org/show_bug.cgi?id=6111 Signed-off-by: Jiri Slaby Cc: Luming Yu Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit df42baa0d8e54df18dd9366dd7c93d6be7d5d063 Author: Ashok Raj Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: build fix for u8 cpu_index Local apic entries are only 8 bits, but it seemed to not be caught with u8 return value result in the check cpu_index >= NR_CPUS becomming always false. drivers/acpi/processor_core.c: In function `acpi_processor_get_info': drivers/acpi/processor_core.c:483: warning: comparison is always false due to limited range of data type Signed-off-by: Ashok Raj Cc: Dave Jones Cc: Kenji Kaneshige Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 200739c179c63d21804e9e8e2ced265243831579 Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: remove __init/__exit from Asus .add()/.remove() methods Even though the devices claimed by asus_acpi.c can not be hot-plugged, the driver registration infrastructure allows the .add() and .remove() methods to be called at any time while the driver is registered. So remove __init and __exit from them. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 5e15b92d07fb11490c886c5dd7567f523ea43e2d Author: Davi Arnaut Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: acpi_os_acquire_object (GFP_KERNEL) called with IRQs disabled through suspend-resume acpi_os_acquire_object() gets called, with IRQs disabled, from: Debug: sleeping function called from invalid context at mm/slab.c:2499 in_atomic():0, irqs_disabled():1 [] kmem_cache_alloc+0x40/0x4f [] acpi_os_acquire_object+0xb/0x3c [] acpi_ut_allocate_object_desc_dbg+0x13/0x49 [] acpi_ut_create_internal_object_dbg+0xf/0x5e [] acpi_rs_set_srs_method_data+0x3d/0xb9 [] acpi_pci_link_set+0x102/0x17b [] irqrouter_resume+0x1e/0x3c [] __sysdev_resume+0x11/0x6b [] sysdev_resume+0x34/0x52 [] device_power_up+0x5/0xa [] suspend_enter+0x44/0x46 [] suspend_prepare+0x63/0xc1 [] enter_state+0x5e/0x7c [] state_store+0x81/0x8f [] state_store+0x0/0x8f [] subsys_attr_store+0x1e/0x22 [] flush_write_buffer+0x22/0x28 [] sysfs_write_file+0x4c/0x71 [] sysfs_write_file+0x0/0x71 [] vfs_write+0xa2/0x15a [] sys_write+0x41/0x6a [] syscall_call+0x7/0xb The patch also fixes a missing check for NULL return from acpi_os_acquire_object(). Signed-off-by: Davi Arnaut Cc: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 9224a867c497053842dc595e594ca6d32112221f Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 HPET: fix ACPI memory range length handling ACPI address space descriptors contain _MIN, _MAX, and _LEN. _MIN and _MAX are the bounds within which the region can be moved (this is clarified in Table 6-38 of the ACPI 3.0 spec). We should use _LEN to determine the size of the region, not _MAX - _MIN + 1. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 459c7266d7a5c1730169258217e25fdd1b7ca854 Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: fix memory hotplug range length handling Address space descriptors contain _MIN, _MAX, and _LEN. _MIN and _MAX are the bounds within which the region can be moved (this is clarified in Table 6-38 of the ACPI 3.0 spec). We should use _LEN to determine the size of the region, not _MAX - _MIN + 1. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 1a36561607abf1405b56a41aac2fd163429cd1f8 Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: simplify scan.c coding No functional changes; just remove leftover, unused "buffer" and simplify control flow (no need to remember error values and goto the end, when we can simply return the value directly). Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit e4513a57ef719d3d6d1cee0ca4d9f4016aa452bb Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: fix sonypi ACPI driver registration to unregister on failure Remove the assumption that acpi_bus_register_driver() returns the number of devices claimed. Returning the count is unreliable because devices may be hot-plugged in the future (admittedly not applicable for this driver). This also fixes a bug: if sonypi_acpi_driver was registered but found no devices, sonypi_exit() did not unregister it. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 578b333bfe8eb1360207a08a53c321822a8f40f3 Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: update asus_acpi driver registration to unload on failure Remove the assumption that acpi_bus_register_driver() returns the number of devices claimed. Returning the count is unreliable because devices may be hot-plugged in the future (admittedly not applicable for this driver). Since the hardware for this driver is not hot-pluggable, determine whether the hardware is present by noticing calls to the .add() method. It would be better to probe the ACPI namespace for the ASUS HIDs, and load the driver only when we find one, but ACPI doesn't support that yet. I don't have an ASUS laptop to test on, but on my HP dl360, it does report the appropriate error when attempting to load the module: $ sudo insmod drivers/acpi/asus_acpi.ko insmod: error inserting 'drivers/acpi/asus_acpi.ko': -1 No such device Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 9d9f749b316ac21cb59ad3e595cbce469b409e1a Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: make acpi_bus_register_driver() return success/failure, not device count acpi_bus_register_driver() should not return the number of devices claimed. We're not asking to find devices, we're making a driver available to devices, including hot-pluggable devices that may appear in the future. I audited all callers of acpi_bus_register_driver(), and except asus_acpi.c and sonypi.c (fixed in previous patches), all either ignore the return value or test only for failure (<0). Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit cd090eedd85256829f762677d0752a846c1b88b9 Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: Display "ACPI" to motherboard resources in /proc/io{mem,port} Add "ACPI" to motherboard resource allocation names, so people have a clue about where to look. And remove some trailing spaces. Changes these /proc/iomem entries from this: ff5c1004-ff5c1007 : PM_TMR ff5c1008-ff5c100b : PM1a_EVT_BLK ff5c100c-ff5c100d : PM1a_CNT_BLK ff5c1010-ff5c1013 : GPE0_BLK ff5c1014-ff5c1017 : GPE1_BLK to this: ff5c1004-ff5c1007 : ACPI PM_TMR ff5c1008-ff5c100b : ACPI PM1a_EVT_BLK ff5c100c-ff5c100d : ACPI PM1a_CNT_BLK ff5c1010-ff5c1013 : ACPI GPE0_BLK ff5c1014-ff5c1017 : ACPI GPE1_BLK Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 81507ea9cfa64e9851b53e0fefebfa776eda9ecb Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: request correct fixed hardware resource type (MMIO vs I/O port) ACPI supports fixed hardware (PM_TMR, GPE blocks, etc) in either I/O port or MMIO space, but used to always request the regions from I/O space because it didn't check the address_space_id. Sample ACPI fixed hardware in MMIO space (HP rx2600), was incorrectly reported in /proc/ioports, now reported in /proc/iomem: ff5c1004-ff5c1007 : PM_TMR ff5c1008-ff5c100b : PM1a_EVT_BLK ff5c100c-ff5c100d : PM1a_CNT_BLK ff5c1010-ff5c1013 : GPE0_BLK ff5c1014-ff5c1017 : GPE1_BLK Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 1c6e7d0aeecac38e66b1bb63e3eff07b2a1c2f2c Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 PNPACPI: whitespace cleanup Tidy up whitespace. No functional change. Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit b5f2490b6e3317059e87ba40d4f659d1c30afc1f Author: Bjorn Helgaas Date: Tue Mar 28 17:04:00 2006 -0500 PNPACPI: remove some code duplication Factor out the duplicated switch from pnpacpi_count_resources() and pnpacpi_type_resources(). Remove the unnecessary re-initialization of resource->type and length from all the encode functions (id and length are originally set in the pnpacpi_build_resource_template() -> pnpacpi_type_resources() path). Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 1acfb7f2b0d460ee86bdb25ad0679070ec8a5f0d Author: Bjorn Helgaas Date: Tue Mar 28 17:03:00 2006 -0500 PNPACPI: fix non-memory address space descriptor handling Fix resource_type handling for QWORD, DWORD, and WORD Address Space Descriptors. Previously we ignored the resource_type, so I/O ports and bus number ranges were incorrectly parsed as memory ranges. Sample PCI root bridge resources from HP rx2600 before this patch: # cat /sys/bus/pnp/devices/00:02/resources state = active mem 0x0-0x1f mem 0x0-0x3af mem 0x3e0-0x1fff mem 0x80000000-0x8fffffff With this patch: # cat /sys/bus/pnp/devices/00:02/resources state = active io 0x0-0x3af io 0x3e0-0x1fff mem 0x80000000-0x8fffffff mem 0x80004000000-0x80103fffffe Changes: 0x0-0x1f PCI bus number range was incorrectly reported as memory, now not reported at all 0x0-0x3af I/O port range was incorrectly reported as memory 0x3e0-0x1fff I/O port range was incorrectly reported as memory 0x80004000000-0x80103fffffe memory range wasn't reported at all because we only support PNP_MAX_MEM (4) memory resources Signed-off-by: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 7e1f19e50371e1d148226b64c8edc77fec47fa5b Author: Andrew Morton Date: Tue Mar 28 17:03:00 2006 -0500 ACPI: UP build fix for bugzilla-5737 cpu_online_map doesn't exist if !CONFIG_SMP. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit 1300124f69cafc54331bc06e968a8dd67863f989 Author: Adrian Bunk Date: Tue Mar 28 17:04:00 2006 -0500 ACPI: Kconfig: ACPI should depend on, not select PCI Otherwise, illegal configurations like X86_VOYAGER=y, PCI=y are possible. This patch also fixes the options select'ing ACPI to also select PCI. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Len Brown commit ec7381d6bfd3e7b8d2880dd5e9d03b131b0603f6 Author: Len Brown Date: Sat Apr 1 05:12:23 2006 -0500 ACPI: inline trivial acpi_os_get_thread_id() acpi_os_get_thread_id() is used only for debugging code that is not enabled on Linux, so stub it out. Signed-off-by: Len Brown commit 8313524a0d466f451a62709aaedf988d8257b21c Author: Bob Moore Date: Tue Oct 3 00:00:00 2006 -0400 ACPI: ACPICA 20060310 Tagged all external interfaces to the subsystem with the new ACPI_EXPORT_SYMBOL macro. This macro can be defined as necessary to assist kernel integration. For Linux, the macro resolves to the EXPORT_SYMBOL macro. The default definition is NULL. Added the ACPI_THREAD_ID type for the return value from acpi_os_get_thread_id(). This allows the host to define this as necessary to simplify kernel integration. The default definition is ACPI_NATIVE_UINT. Valery Podrezov fixed two interpreter problems related to error processing, the deletion of objects, and placing invalid pointers onto the internal operator result stack. http://bugzilla.kernel.org/show_bug.cgi?id=6028 http://bugzilla.kernel.org/show_bug.cgi?id=6151 Increased the reference count threshold where a warning is emitted for large reference counts in order to eliminate unnecessary warnings on systems with large namespaces (especially 64-bit.) Increased the value from 0x400 to 0x800. Due to universal disagreement as to the meaning of the 'c' in the calloc() function, the ACPI_MEM_CALLOCATE macro has been renamed to ACPI_ALLOCATE_ZEROED so that the purpose of the interface is 'clear'. ACPI_MEM_ALLOCATE and ACPI_MEM_FREE are renamed to ACPI_ALLOCATE and ACPI_FREE. Signed-off-by: Bob Moore Signed-off-by: Len Brown commit ea936b78f46cbe089a4ac363e1682dee7d427096 Author: Bob Moore Date: Fri Feb 17 00:00:00 2006 -0500 ACPI: ACPICA 20060217 Implemented a change to the IndexField support to match the behavior of the Microsoft AML interpreter. The value written to the Index register is now a byte offset, no longer an index based upon the width of the Data register. This should fix IndexField problems seen on some machines where the Data register is not exactly one byte wide. The ACPI specification will be clarified on this point. Fixed a problem where several resource descriptor types could overrun the internal descriptor buffer due to size miscalculation: VendorShort, VendorLong, and Interrupt. This was noticed on IA64 machines, but could affect all platforms. Fixed a problem where individual resource descriptors were misaligned within the internal buffer, causing alignment faults on IA64 platforms. Signed-off-by: Bob Moore Signed-off-by: Len Brown commit 52fc0b026e99b5d5d585095148d997d5634bbc25 Author: Bob Moore Date: Mon Oct 2 00:00:00 2006 -0400 [ACPI] ACPICA 20060210 Removed a couple of extraneous ACPI_ERROR messages that appeared during normal execution. These became apparent after the conversion from ACPI_DEBUG_PRINT. Fixed a problem where the CreateField operator could hang if the BitIndex or NumBits parameter referred to a named object. From Valery Podrezov. http://bugzilla.kernel.org/show_bug.cgi?id=5359 Fixed a problem where a DeRefOf operation on a buffer object incorrectly failed with an exception. This also fixes a couple of related RefOf and DeRefOf issues. From Valery Podrezov. http://bugzilla.kernel.org/show_bug.cgi?id=5360 http://bugzilla.kernel.org/show_bug.cgi?id=5387 http://bugzilla.kernel.org/show_bug.cgi?id=5392 Fixed a problem where the AE_BUFFER_LIMIT exception was returned instead of AE_STRING_LIMIT on an out-of-bounds Index() operation. From Valery Podrezov. http://bugzilla.kernel.org/show_bug.cgi?id=5480 Implemented a memory cleanup at the end of the execution of each iteration of an AML While() loop, preventing the accumulation of outstanding objects. From Valery Podrezov. http://bugzilla.kernel.org/show_bug.cgi?id=5427 Eliminated a chunk of duplicate code in the object resolution code. From Valery Podrezov. http://bugzilla.kernel.org/show_bug.cgi?id=5336 Fixed several warnings during the 64-bit code generation. Signed-off-by: Bob Moore Signed-off-by: Len Brown commit 46358614ed5b031797522f1020e989c959a8d8a6 Author: Len Brown Date: Fri Mar 31 02:16:19 2006 -0500 Revert "[PATCH] ACPI: fix vendor resource length computation" fixed in a different way by a subsequent ACPICA patch This reverts 35b73ceb9a7d10c81bd9e79e8485f7079ef2b40e commit. commit 6665bda76461308868bd1e52caf627f4cb29ed32 Author: Adrian Bunk Date: Sat Mar 11 10:12:00 2006 -0500 [ACPI] drivers/acpi/video.c: fix error path NULL pointer dereference The Coverity checker spotted this bug in acpi_video_device_lcd_query_levels(). Signed-off-by: Adrian Bunk Signed-off-by: Len Brown commit fdc136ccd3332938e989439c025c363f8479f3e6 Author: Dave Jones Date: Wed Mar 8 22:12:00 2006 -0500 [ACPI] fix possible acpi thermal leak in failure path Coverity: #601 Signed-off-by: Dave Jones Signed-off-by: Len Brown commit a1f9e65e2085e0a87f28a4d5a8ae43b32c087f24 Author: Len Brown Date: Wed Jan 25 23:47:36 2006 -0500 [ACPI] document cmdline acpi_os_name= This can sometimes be used to work around broken BIOS. Use "Microsoft Windows" to take the same path through the BIOS as Windows98 would. The default is "Microsoft Windows NT", which is what NT and later versions of Windows use, and is the most tested path through most BIOS. Set it to anything else, including "Linux", at your own risk, as it seems that virtually no BIOS has been tested with anything but the two options above. Note that this uses the legacy _OS interface, so we don't expect this to ever change. Signed-off-by: Len Brown commit 1fee94034917aa711fcbd4ebf4c36f7ebd9fa7d6 Author: Irwan Djajadi Date: Fri Jan 20 15:28:00 2006 -0500 [ACPI] drivers/acpi/hotkey.c: check kmalloc return value Signed-off-by: Irwan Djajadi Signed-off-by: Alexey Dobriyan Signed-off-by: Len Brown commit 0eacee585a89ce5827b572a73a024931506bef48 Author: Len Brown Date: Fri Mar 31 00:37:23 2006 -0500 ACPI: enable BIOS warning http://bugzilla.kernel.org/show_bug.cgi?id=5452 Signed-off-by: Len Brown commit 9cfda2c94df61c9f859b474abe774c65a4464d0a Author: Andi Kleen Date: Mon Mar 27 02:24:32 2006 -0500 [ACPI] fix "nolapic" flag in ACPI mode Signed-off-by: Len Brown commit d52bb94d56676acd9bdac8e097257a87b4b1b2e1 Author: Venkatesh Pallipadi Date: Wed Dec 14 15:05:00 2005 -0500 Enable P-state software coordination via _PDC http://bugzilla.kernel.org/show_bug.cgi?id=5737 Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown commit c52851b60cc0aaaf974ff0e49989fb698220447d Author: Venkatesh Pallipadi Date: Wed Dec 14 15:05:00 2005 -0500 P-state software coordination for speedstep-centrino http://bugzilla.kernel.org/show_bug.cgi?id=5737 Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown commit 09b4d1ee881c8593bfad2a42f838d85070365c3e Author: Venkatesh Pallipadi Date: Wed Dec 14 15:05:00 2005 -0500 P-state software coordination for acpi-cpufreq http://bugzilla.kernel.org/show_bug.cgi?id=5737 Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown commit 3b2d99429e3386b6e2ac949fc72486509c8bbe36 Author: Venkatesh Pallipadi Date: Wed Dec 14 15:05:00 2005 -0500 P-state software coordination for ACPI core http://bugzilla.kernel.org/show_bug.cgi?id=5737 Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown commit ffd642e748c867a7339b57225b8bf8b9a0dcd9c5 Author: David Shaohua Li Date: Wed Feb 8 17:35:00 2006 -0500 [ACPI] enable SMP C-states on x86_64 http://bugzilla.kernel.org/show_bug.cgi?id=5653 Signed-off-by: David Shaohua Li Signed-off-by: Len Brown commit f9ea7fd8be9827791f407ca1191ff70ec25eb2d9 Author: Thomas Renninger Date: Fri Jun 2 15:58:00 2006 -0400 [ACPI] Print error message if remove/install notify handler fails Signed-off-by: Thomas Renniger Signed-off-by: Len Brown commit b60e49b2383db0334bef1f0d9cdad9bec2336050 Author: Thomas Renninger Date: Fri Jun 2 15:58:00 2006 -0400 [ACPI] Export symbols for ACPI_ERROR/EXCEPTION/WARNING macros Signed-off-by: Thomas Renninger Signed-off-by: Len Brown commit 1ca218d3bd6acca0922a349cb76e3244d27ebfba Author: Thomas Renniger Date: Fri Jun 2 15:58:00 2006 -0400 [ACPI] Enable ACPI error messages w/o CONFIG_ACPI_DEBUG Signed-off-by: Thomas Renniger Signed-off-by: Len Brown --- diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index b3a6187..a853e86 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -147,6 +147,9 @@ running once the system is up. acpi_irq_isa= [HW,ACPI] If irq_balance, mark listed IRQs used by ISA Format: ,... + acpi_os_name= [HW,ACPI] Tell ACPI BIOS the name of the OS + Format: To spoof as Windows 98: ="Microsoft Windows" + acpi_osi= [HW,ACPI] empty param disables _OSI acpi_serialize [HW,ACPI] force serialization of AML methods diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index daee695..6fe92b3 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -215,7 +215,7 @@ static int __init acpi_parse_madt(unsign { struct acpi_table_madt *madt = NULL; - if (!phys_addr || !size) + if (!phys_addr || !size || !cpu_has_apic) return -EINVAL; madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size); diff --git a/arch/i386/kernel/acpi/processor.c b/arch/i386/kernel/acpi/processor.c index 9f4cc02..b54fded 100644 --- a/arch/i386/kernel/acpi/processor.c +++ b/arch/i386/kernel/acpi/processor.c @@ -47,7 +47,7 @@ static void init_intel_pdc(struct acpi_p buf[2] = ACPI_PDC_C_CAPABILITY_SMP; if (cpu_has(c, X86_FEATURE_EST)) - buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP; + buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP; obj->type = ACPI_TYPE_BUFFER; obj->buffer.length = 12; diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c index 3852d0a..11da3ca 100644 --- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c @@ -48,12 +48,13 @@ MODULE_LICENSE("GPL"); struct cpufreq_acpi_io { - struct acpi_processor_performance acpi_data; + struct acpi_processor_performance *acpi_data; struct cpufreq_frequency_table *freq_table; unsigned int resume; }; static struct cpufreq_acpi_io *acpi_io_data[NR_CPUS]; +static struct acpi_processor_performance *acpi_perf_data[NR_CPUS]; static struct cpufreq_driver acpi_cpufreq_driver; @@ -104,64 +105,43 @@ acpi_processor_set_performance ( { u16 port = 0; u8 bit_width = 0; + int i = 0; int ret = 0; u32 value = 0; - int i = 0; - struct cpufreq_freqs cpufreq_freqs; - cpumask_t saved_mask; int retval; + struct acpi_processor_performance *perf; dprintk("acpi_processor_set_performance\n"); - /* - * TBD: Use something other than set_cpus_allowed. - * As set_cpus_allowed is a bit racy, - * with any other set_cpus_allowed for this process. - */ - saved_mask = current->cpus_allowed; - set_cpus_allowed(current, cpumask_of_cpu(cpu)); - if (smp_processor_id() != cpu) { - return (-EAGAIN); - } - - if (state == data->acpi_data.state) { + retval = 0; + perf = data->acpi_data; + if (state == perf->state) { if (unlikely(data->resume)) { dprintk("Called after resume, resetting to P%d\n", state); data->resume = 0; } else { dprintk("Already at target state (P%d)\n", state); - retval = 0; - goto migrate_end; + return (retval); } } - dprintk("Transitioning from P%d to P%d\n", - data->acpi_data.state, state); - - /* cpufreq frequency struct */ - cpufreq_freqs.cpu = cpu; - cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency; - cpufreq_freqs.new = data->freq_table[state].frequency; - - /* notify cpufreq */ - cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE); + dprintk("Transitioning from P%d to P%d\n", perf->state, state); /* * First we write the target state's 'control' value to the * control_register. */ - port = data->acpi_data.control_register.address; - bit_width = data->acpi_data.control_register.bit_width; - value = (u32) data->acpi_data.states[state].control; + port = perf->control_register.address; + bit_width = perf->control_register.bit_width; + value = (u32) perf->states[state].control; dprintk("Writing 0x%08x to port 0x%04x\n", value, port); ret = acpi_processor_write_port(port, bit_width, value); if (ret) { dprintk("Invalid port width 0x%04x\n", bit_width); - retval = ret; - goto migrate_end; + return (ret); } /* @@ -177,49 +157,36 @@ acpi_processor_set_performance ( * before giving up. */ - port = data->acpi_data.status_register.address; - bit_width = data->acpi_data.status_register.bit_width; + port = perf->status_register.address; + bit_width = perf->status_register.bit_width; dprintk("Looking for 0x%08x from port 0x%04x\n", - (u32) data->acpi_data.states[state].status, port); + (u32) perf->states[state].status, port); - for (i=0; i<100; i++) { + for (i = 0; i < 100; i++) { ret = acpi_processor_read_port(port, bit_width, &value); if (ret) { dprintk("Invalid port width 0x%04x\n", bit_width); - retval = ret; - goto migrate_end; + return (ret); } - if (value == (u32) data->acpi_data.states[state].status) + if (value == (u32) perf->states[state].status) break; udelay(10); } } else { i = 0; - value = (u32) data->acpi_data.states[state].status; + value = (u32) perf->states[state].status; } - /* notify cpufreq */ - cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); - - if (unlikely(value != (u32) data->acpi_data.states[state].status)) { - unsigned int tmp = cpufreq_freqs.new; - cpufreq_freqs.new = cpufreq_freqs.old; - cpufreq_freqs.old = tmp; - cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE); - cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); + if (unlikely(value != (u32) perf->states[state].status)) { printk(KERN_WARNING "acpi-cpufreq: Transition failed\n"); retval = -ENODEV; - goto migrate_end; + return (retval); } dprintk("Transition successful after %d microseconds\n", i * 10); - data->acpi_data.state = state; - - retval = 0; -migrate_end: - set_cpus_allowed(current, saved_mask); + perf->state = state; return (retval); } @@ -231,8 +198,17 @@ acpi_cpufreq_target ( unsigned int relation) { struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu]; + struct acpi_processor_performance *perf; + struct cpufreq_freqs freqs; + cpumask_t online_policy_cpus; + cpumask_t saved_mask; + cpumask_t set_mask; + cpumask_t covered_cpus; + unsigned int cur_state = 0; unsigned int next_state = 0; unsigned int result = 0; + unsigned int j; + unsigned int tmp; dprintk("acpi_cpufreq_setpolicy\n"); @@ -241,11 +217,95 @@ acpi_cpufreq_target ( target_freq, relation, &next_state); - if (result) + if (unlikely(result)) return (result); - result = acpi_processor_set_performance (data, policy->cpu, next_state); + perf = data->acpi_data; + cur_state = perf->state; + freqs.old = data->freq_table[cur_state].frequency; + freqs.new = data->freq_table[next_state].frequency; + +#ifdef CONFIG_HOTPLUG_CPU + /* cpufreq holds the hotplug lock, so we are safe from here on */ + cpus_and(online_policy_cpus, cpu_online_map, policy->cpus); +#else + online_policy_cpus = policy->cpus; +#endif + + for_each_cpu_mask(j, online_policy_cpus) { + freqs.cpu = j; + cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); + } + + /* + * We need to call driver->target() on all or any CPU in + * policy->cpus, depending on policy->shared_type. + */ + saved_mask = current->cpus_allowed; + cpus_clear(covered_cpus); + for_each_cpu_mask(j, online_policy_cpus) { + /* + * Support for SMP systems. + * Make sure we are running on CPU that wants to change freq + */ + cpus_clear(set_mask); + if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) + cpus_or(set_mask, set_mask, online_policy_cpus); + else + cpu_set(j, set_mask); + + set_cpus_allowed(current, set_mask); + if (unlikely(!cpu_isset(smp_processor_id(), set_mask))) { + dprintk("couldn't limit to CPUs in this domain\n"); + result = -EAGAIN; + break; + } + + result = acpi_processor_set_performance (data, j, next_state); + if (result) { + result = -EAGAIN; + break; + } + + if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) + break; + + cpu_set(j, covered_cpus); + } + + for_each_cpu_mask(j, online_policy_cpus) { + freqs.cpu = j; + cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + } + if (unlikely(result)) { + /* + * We have failed halfway through the frequency change. + * We have sent callbacks to online_policy_cpus and + * acpi_processor_set_performance() has been called on + * coverd_cpus. Best effort undo.. + */ + + if (!cpus_empty(covered_cpus)) { + for_each_cpu_mask(j, covered_cpus) { + policy->cpu = j; + acpi_processor_set_performance (data, + j, + cur_state); + } + } + + tmp = freqs.new; + freqs.new = freqs.old; + freqs.old = tmp; + for_each_cpu_mask(j, online_policy_cpus) { + freqs.cpu = j; + cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); + cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + } + } + + set_cpus_allowed(current, saved_mask); return (result); } @@ -271,30 +331,65 @@ acpi_cpufreq_guess_freq ( struct cpufreq_acpi_io *data, unsigned int cpu) { + struct acpi_processor_performance *perf = data->acpi_data; + if (cpu_khz) { /* search the closest match to cpu_khz */ unsigned int i; unsigned long freq; - unsigned long freqn = data->acpi_data.states[0].core_frequency * 1000; + unsigned long freqn = perf->states[0].core_frequency * 1000; - for (i=0; i < (data->acpi_data.state_count - 1); i++) { + for (i = 0; i < (perf->state_count - 1); i++) { freq = freqn; - freqn = data->acpi_data.states[i+1].core_frequency * 1000; + freqn = perf->states[i+1].core_frequency * 1000; if ((2 * cpu_khz) > (freqn + freq)) { - data->acpi_data.state = i; + perf->state = i; return (freq); } } - data->acpi_data.state = data->acpi_data.state_count - 1; + perf->state = perf->state_count - 1; return (freqn); - } else + } else { /* assume CPU is at P0... */ - data->acpi_data.state = 0; - return data->acpi_data.states[0].core_frequency * 1000; - + perf->state = 0; + return perf->states[0].core_frequency * 1000; + } } +/* + * acpi_cpufreq_early_init - initialize ACPI P-States library + * + * Initialize the ACPI P-States library (drivers/acpi/processor_perflib.c) + * in order to determine correct frequency and voltage pairings. We can + * do _PDC and _PSD and find out the processor dependency for the + * actual init that will happen later... + */ +static int acpi_cpufreq_early_init_acpi(void) +{ + struct acpi_processor_performance *data; + unsigned int i, j; + + dprintk("acpi_cpufreq_early_init\n"); + + for_each_cpu(i) { + data = kzalloc(sizeof(struct acpi_processor_performance), + GFP_KERNEL); + if (!data) { + for_each_cpu(j) { + kfree(acpi_perf_data[j]); + acpi_perf_data[j] = NULL; + } + return (-ENOMEM); + } + acpi_perf_data[i] = data; + } + + /* Do initialization in ACPI core */ + acpi_processor_preregister_performance(acpi_perf_data); + return 0; +} + static int acpi_cpufreq_cpu_init ( struct cpufreq_policy *policy) @@ -304,41 +399,51 @@ acpi_cpufreq_cpu_init ( struct cpufreq_acpi_io *data; unsigned int result = 0; struct cpuinfo_x86 *c = &cpu_data[policy->cpu]; + struct acpi_processor_performance *perf; dprintk("acpi_cpufreq_cpu_init\n"); + if (!acpi_perf_data[cpu]) + return (-ENODEV); + data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); if (!data) return (-ENOMEM); + data->acpi_data = acpi_perf_data[cpu]; acpi_io_data[cpu] = data; - result = acpi_processor_register_performance(&data->acpi_data, cpu); + result = acpi_processor_register_performance(data->acpi_data, cpu); if (result) goto err_free; + perf = data->acpi_data; + policy->cpus = perf->shared_cpu_map; + policy->shared_type = perf->shared_type; + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS; } /* capability check */ - if (data->acpi_data.state_count <= 1) { + if (perf->state_count <= 1) { dprintk("No P-States\n"); result = -ENODEV; goto err_unreg; } - if ((data->acpi_data.control_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO) || - (data->acpi_data.status_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { + + if ((perf->control_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO) || + (perf->status_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { dprintk("Unsupported address space [%d, %d]\n", - (u32) (data->acpi_data.control_register.space_id), - (u32) (data->acpi_data.status_register.space_id)); + (u32) (perf->control_register.space_id), + (u32) (perf->status_register.space_id)); result = -ENODEV; goto err_unreg; } /* alloc freq_table */ - data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * (data->acpi_data.state_count + 1), GFP_KERNEL); + data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * (perf->state_count + 1), GFP_KERNEL); if (!data->freq_table) { result = -ENOMEM; goto err_unreg; @@ -346,9 +451,9 @@ acpi_cpufreq_cpu_init ( /* detect transition latency */ policy->cpuinfo.transition_latency = 0; - for (i=0; iacpi_data.state_count; i++) { - if ((data->acpi_data.states[i].transition_latency * 1000) > policy->cpuinfo.transition_latency) - policy->cpuinfo.transition_latency = data->acpi_data.states[i].transition_latency * 1000; + for (i=0; istate_count; i++) { + if ((perf->states[i].transition_latency * 1000) > policy->cpuinfo.transition_latency) + policy->cpuinfo.transition_latency = perf->states[i].transition_latency * 1000; } policy->governor = CPUFREQ_DEFAULT_GOVERNOR; @@ -356,11 +461,11 @@ acpi_cpufreq_cpu_init ( policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu); /* table init */ - for (i=0; i<=data->acpi_data.state_count; i++) + for (i=0; i<=perf->state_count; i++) { data->freq_table[i].index = i; - if (iacpi_data.state_count) - data->freq_table[i].frequency = data->acpi_data.states[i].core_frequency * 1000; + if (istate_count) + data->freq_table[i].frequency = perf->states[i].core_frequency * 1000; else data->freq_table[i].frequency = CPUFREQ_TABLE_END; } @@ -375,12 +480,12 @@ acpi_cpufreq_cpu_init ( printk(KERN_INFO "acpi-cpufreq: CPU%u - ACPI performance management activated.\n", cpu); - for (i = 0; i < data->acpi_data.state_count; i++) + for (i = 0; i < perf->state_count; i++) dprintk(" %cP%d: %d MHz, %d mW, %d uS\n", - (i == data->acpi_data.state?'*':' '), i, - (u32) data->acpi_data.states[i].core_frequency, - (u32) data->acpi_data.states[i].power, - (u32) data->acpi_data.states[i].transition_latency); + (i == perf->state?'*':' '), i, + (u32) perf->states[i].core_frequency, + (u32) perf->states[i].power, + (u32) perf->states[i].transition_latency); cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu); @@ -395,7 +500,7 @@ acpi_cpufreq_cpu_init ( err_freqfree: kfree(data->freq_table); err_unreg: - acpi_processor_unregister_performance(&data->acpi_data, cpu); + acpi_processor_unregister_performance(perf, cpu); err_free: kfree(data); acpi_io_data[cpu] = NULL; @@ -416,7 +521,7 @@ acpi_cpufreq_cpu_exit ( if (data) { cpufreq_frequency_table_put_attr(policy->cpu); acpi_io_data[policy->cpu] = NULL; - acpi_processor_unregister_performance(&data->acpi_data, policy->cpu); + acpi_processor_unregister_performance(data->acpi_data, policy->cpu); kfree(data); } @@ -462,7 +567,10 @@ acpi_cpufreq_init (void) dprintk("acpi_cpufreq_init\n"); - result = cpufreq_register_driver(&acpi_cpufreq_driver); + result = acpi_cpufreq_early_init_acpi(); + + if (!result) + result = cpufreq_register_driver(&acpi_cpufreq_driver); return (result); } @@ -471,10 +579,15 @@ acpi_cpufreq_init (void) static void __exit acpi_cpufreq_exit (void) { + unsigned int i; dprintk("acpi_cpufreq_exit\n"); cpufreq_unregister_driver(&acpi_cpufreq_driver); + for_each_cpu(i) { + kfree(acpi_perf_data[i]); + acpi_perf_data[i] = NULL; + } return; } diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c index b0ff907..4535ca0 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c @@ -351,7 +351,36 @@ static unsigned int get_cur_freq(unsigne #ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI -static struct acpi_processor_performance p; +static struct acpi_processor_performance *acpi_perf_data[NR_CPUS]; + +/* + * centrino_cpu_early_init_acpi - Do the preregistering with ACPI P-States + * library + * + * Before doing the actual init, we need to do _PSD related setup whenever + * supported by the BIOS. These are handled by this early_init routine. + */ +static int centrino_cpu_early_init_acpi(void) +{ + unsigned int i, j; + struct acpi_processor_performance *data; + + for_each_cpu(i) { + data = kzalloc(sizeof(struct acpi_processor_performance), + GFP_KERNEL); + if (!data) { + for_each_cpu(j) { + kfree(acpi_perf_data[j]); + acpi_perf_data[j] = NULL; + } + return (-ENOMEM); + } + acpi_perf_data[i] = data; + } + + acpi_processor_preregister_performance(acpi_perf_data); + return 0; +} /* * centrino_cpu_init_acpi - register with ACPI P-States library @@ -365,46 +394,51 @@ static int centrino_cpu_init_acpi(struct unsigned long cur_freq; int result = 0, i; unsigned int cpu = policy->cpu; + struct acpi_processor_performance *p; + + p = acpi_perf_data[cpu]; /* register with ACPI core */ - if (acpi_processor_register_performance(&p, cpu)) { + if (acpi_processor_register_performance(p, cpu)) { dprintk(KERN_INFO PFX "obtaining ACPI data failed\n"); return -EIO; } + policy->cpus = p->shared_cpu_map; + policy->shared_type = p->shared_type; /* verify the acpi_data */ - if (p.state_count <= 1) { + if (p->state_count <= 1) { dprintk("No P-States\n"); result = -ENODEV; goto err_unreg; } - if ((p.control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) || - (p.status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) { + if ((p->control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) || + (p->status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) { dprintk("Invalid control/status registers (%x - %x)\n", - p.control_register.space_id, p.status_register.space_id); + p->control_register.space_id, p->status_register.space_id); result = -EIO; goto err_unreg; } - for (i=0; istate_count; i++) { + if (p->states[i].control != p->states[i].status) { dprintk("Different control (%llu) and status values (%llu)\n", - p.states[i].control, p.states[i].status); + p->states[i].control, p->states[i].status); result = -EINVAL; goto err_unreg; } - if (!p.states[i].core_frequency) { + if (!p->states[i].core_frequency) { dprintk("Zero core frequency for state %u\n", i); result = -EINVAL; goto err_unreg; } - if (p.states[i].core_frequency > p.states[0].core_frequency) { + if (p->states[i].core_frequency > p->states[0].core_frequency) { dprintk("P%u has larger frequency (%llu) than P0 (%llu), skipping\n", i, - p.states[i].core_frequency, p.states[0].core_frequency); - p.states[i].core_frequency = 0; + p->states[i].core_frequency, p->states[0].core_frequency); + p->states[i].core_frequency = 0; continue; } } @@ -416,26 +450,26 @@ static int centrino_cpu_init_acpi(struct } centrino_model[cpu]->model_name=NULL; - centrino_model[cpu]->max_freq = p.states[0].core_frequency * 1000; + centrino_model[cpu]->max_freq = p->states[0].core_frequency * 1000; centrino_model[cpu]->op_points = kmalloc(sizeof(struct cpufreq_frequency_table) * - (p.state_count + 1), GFP_KERNEL); + (p->state_count + 1), GFP_KERNEL); if (!centrino_model[cpu]->op_points) { result = -ENOMEM; goto err_kfree; } - for (i=0; iop_points[i].index = p.states[i].control; - centrino_model[cpu]->op_points[i].frequency = p.states[i].core_frequency * 1000; + for (i=0; istate_count; i++) { + centrino_model[cpu]->op_points[i].index = p->states[i].control; + centrino_model[cpu]->op_points[i].frequency = p->states[i].core_frequency * 1000; dprintk("adding state %i with frequency %u and control value %04x\n", i, centrino_model[cpu]->op_points[i].frequency, centrino_model[cpu]->op_points[i].index); } - centrino_model[cpu]->op_points[p.state_count].frequency = CPUFREQ_TABLE_END; + centrino_model[cpu]->op_points[p->state_count].frequency = CPUFREQ_TABLE_END; cur_freq = get_cur_freq(cpu); - for (i=0; istate_count; i++) { + if (!p->states[i].core_frequency) { dprintk("skipping state %u\n", i); centrino_model[cpu]->op_points[i].frequency = CPUFREQ_ENTRY_INVALID; continue; @@ -451,7 +485,7 @@ static int centrino_cpu_init_acpi(struct } if (cur_freq == centrino_model[cpu]->op_points[i].frequency) - p.state = i; + p->state = i; } /* notify BIOS that we exist */ @@ -464,12 +498,13 @@ static int centrino_cpu_init_acpi(struct err_kfree: kfree(centrino_model[cpu]); err_unreg: - acpi_processor_unregister_performance(&p, cpu); + acpi_processor_unregister_performance(p, cpu); dprintk(KERN_INFO PFX "invalid ACPI data\n"); return (result); } #else static inline int centrino_cpu_init_acpi(struct cpufreq_policy *policy) { return -ENODEV; } +static inline int centrino_cpu_early_init_acpi(void) { return 0; } #endif static int centrino_cpu_init(struct cpufreq_policy *policy) @@ -555,10 +590,15 @@ static int centrino_cpu_exit(struct cpuf #ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI if (!centrino_model[cpu]->model_name) { - dprintk("unregistering and freeing ACPI data\n"); - acpi_processor_unregister_performance(&p, cpu); - kfree(centrino_model[cpu]->op_points); - kfree(centrino_model[cpu]); + static struct acpi_processor_performance *p; + + if (acpi_perf_data[cpu]) { + p = acpi_perf_data[cpu]; + dprintk("unregistering and freeing ACPI data\n"); + acpi_processor_unregister_performance(p, cpu); + kfree(centrino_model[cpu]->op_points); + kfree(centrino_model[cpu]); + } } #endif @@ -592,63 +632,128 @@ static int centrino_target (struct cpufr unsigned int relation) { unsigned int newstate = 0; - unsigned int msr, oldmsr, h, cpu = policy->cpu; + unsigned int msr, oldmsr = 0, h = 0, cpu = policy->cpu; struct cpufreq_freqs freqs; + cpumask_t online_policy_cpus; cpumask_t saved_mask; - int retval; + cpumask_t set_mask; + cpumask_t covered_cpus; + int retval = 0; + unsigned int j, k, first_cpu, tmp; - if (centrino_model[cpu] == NULL) + if (unlikely(centrino_model[cpu] == NULL)) return -ENODEV; - /* - * Support for SMP systems. - * Make sure we are running on the CPU that wants to change frequency - */ - saved_mask = current->cpus_allowed; - set_cpus_allowed(current, policy->cpus); - if (!cpu_isset(smp_processor_id(), policy->cpus)) { - dprintk("couldn't limit to CPUs in this domain\n"); - return(-EAGAIN); + if (unlikely(cpufreq_frequency_table_target(policy, + centrino_model[cpu]->op_points, + target_freq, + relation, + &newstate))) { + return -EINVAL; } - if (cpufreq_frequency_table_target(policy, centrino_model[cpu]->op_points, target_freq, - relation, &newstate)) { - retval = -EINVAL; - goto migrate_end; - } +#ifdef CONFIG_HOTPLUG_CPU + /* cpufreq holds the hotplug lock, so we are safe from here on */ + cpus_and(online_policy_cpus, cpu_online_map, policy->cpus); +#else + online_policy_cpus = policy->cpus; +#endif - msr = centrino_model[cpu]->op_points[newstate].index; - rdmsr(MSR_IA32_PERF_CTL, oldmsr, h); + saved_mask = current->cpus_allowed; + first_cpu = 1; + cpus_clear(covered_cpus); + for_each_cpu_mask(j, online_policy_cpus) { + /* + * Support for SMP systems. + * Make sure we are running on CPU that wants to change freq + */ + cpus_clear(set_mask); + if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) + cpus_or(set_mask, set_mask, online_policy_cpus); + else + cpu_set(j, set_mask); + + set_cpus_allowed(current, set_mask); + if (unlikely(!cpu_isset(smp_processor_id(), set_mask))) { + dprintk("couldn't limit to CPUs in this domain\n"); + retval = -EAGAIN; + if (first_cpu) { + /* We haven't started the transition yet. */ + goto migrate_end; + } + break; + } - if (msr == (oldmsr & 0xffff)) { - retval = 0; - dprintk("no change needed - msr was and needs to be %x\n", oldmsr); - goto migrate_end; - } + msr = centrino_model[cpu]->op_points[newstate].index; + + if (first_cpu) { + rdmsr(MSR_IA32_PERF_CTL, oldmsr, h); + if (msr == (oldmsr & 0xffff)) { + dprintk("no change needed - msr was and needs " + "to be %x\n", oldmsr); + retval = 0; + goto migrate_end; + } + + freqs.old = extract_clock(oldmsr, cpu, 0); + freqs.new = extract_clock(msr, cpu, 0); + + dprintk("target=%dkHz old=%d new=%d msr=%04x\n", + target_freq, freqs.old, freqs.new, msr); + + for_each_cpu_mask(k, online_policy_cpus) { + freqs.cpu = k; + cpufreq_notify_transition(&freqs, + CPUFREQ_PRECHANGE); + } + + first_cpu = 0; + /* all but 16 LSB are reserved, treat them with care */ + oldmsr &= ~0xffff; + msr &= 0xffff; + oldmsr |= msr; + } - freqs.cpu = cpu; - freqs.old = extract_clock(oldmsr, cpu, 0); - freqs.new = extract_clock(msr, cpu, 0); + wrmsr(MSR_IA32_PERF_CTL, oldmsr, h); + if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) + break; - dprintk("target=%dkHz old=%d new=%d msr=%04x\n", - target_freq, freqs.old, freqs.new, msr); + cpu_set(j, covered_cpus); + } - cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); + for_each_cpu_mask(k, online_policy_cpus) { + freqs.cpu = k; + cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + } - /* all but 16 LSB are "reserved", so treat them with - care */ - oldmsr &= ~0xffff; - msr &= 0xffff; - oldmsr |= msr; + if (unlikely(retval)) { + /* + * We have failed halfway through the frequency change. + * We have sent callbacks to policy->cpus and + * MSRs have already been written on coverd_cpus. + * Best effort undo.. + */ - wrmsr(MSR_IA32_PERF_CTL, oldmsr, h); + if (!cpus_empty(covered_cpus)) { + for_each_cpu_mask(j, covered_cpus) { + set_cpus_allowed(current, cpumask_of_cpu(j)); + wrmsr(MSR_IA32_PERF_CTL, oldmsr, h); + } + } - cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + tmp = freqs.new; + freqs.new = freqs.old; + freqs.old = tmp; + for_each_cpu_mask(j, online_policy_cpus) { + freqs.cpu = j; + cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); + cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + } + } - retval = 0; migrate_end: set_cpus_allowed(current, saved_mask); - return (retval); + return 0; } static struct freq_attr* centrino_attr[] = { @@ -690,12 +795,25 @@ static int __init centrino_init(void) if (!cpu_has(cpu, X86_FEATURE_EST)) return -ENODEV; + centrino_cpu_early_init_acpi(); + return cpufreq_register_driver(¢rino_driver); } static void __exit centrino_exit(void) { +#ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI + unsigned int j; +#endif + cpufreq_unregister_driver(¢rino_driver); + +#ifdef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI + for_each_cpu(j) { + kfree(acpi_perf_data[j]); + acpi_perf_data[j] = NULL; + } +#endif } MODULE_AUTHOR ("Jeremy Fitzhardinge "); diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 0f3076a..f0252ed 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -77,6 +77,7 @@ choice config IA64_GENERIC bool "generic" select ACPI + select PCI select NUMA select ACPI_NUMA help diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index bdccd0b..dd4a2f7 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c @@ -1999,7 +1999,7 @@ acpi_sba_ioc_add(struct acpi_device *dev if (!iovp_shift) iovp_shift = min(PAGE_SHIFT, 16); } - ACPI_MEM_FREE(dev_info); + kfree(dev_info); /* * default anything not caught above or specified on cmdline to 4k diff --git a/arch/ia64/kernel/acpi-ext.c b/arch/ia64/kernel/acpi-ext.c index fff8292..ccd0165 100644 --- a/arch/ia64/kernel/acpi-ext.c +++ b/arch/ia64/kernel/acpi-ext.c @@ -51,7 +51,7 @@ static acpi_status hp_ccsr_locate(acpi_h memcpy(length, vendor->byte_data + 8, sizeof(*length)); exit: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return status; } diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 58c93a3..bda3311 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -68,8 +68,6 @@ EXPORT_SYMBOL(pm_power_off); unsigned char acpi_kbd_controller_present = 1; unsigned char acpi_legacy_devices; -static unsigned int __initdata acpi_madt_rev; - unsigned int acpi_cpei_override; unsigned int acpi_cpei_phys_cpuid; @@ -243,6 +241,8 @@ acpi_parse_iosapic(acpi_table_entry_head return iosapic_init(iosapic->address, iosapic->global_irq_base); } +static unsigned int __initdata acpi_madt_rev; + static int __init acpi_parse_plat_int_src(acpi_table_entry_header * header, const unsigned long end) @@ -865,7 +865,7 @@ int acpi_map_lsapic(acpi_handle handle, obj = buffer.pointer; if (obj->type != ACPI_TYPE_BUFFER || obj->buffer.length < sizeof(*lsapic)) { - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return -EINVAL; } @@ -873,13 +873,13 @@ int acpi_map_lsapic(acpi_handle handle, if ((lsapic->header.type != ACPI_MADT_LSAPIC) || (!lsapic->flags.enabled)) { - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return -EINVAL; } physid = ((lsapic->id << 8) | (lsapic->eid)); - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); buffer.length = ACPI_ALLOCATE_BUFFER; buffer.pointer = NULL; @@ -943,20 +943,20 @@ acpi_map_iosapic(acpi_handle handle, u32 obj = buffer.pointer; if (obj->type != ACPI_TYPE_BUFFER || obj->buffer.length < sizeof(*iosapic)) { - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return AE_OK; } iosapic = (struct acpi_table_iosapic *)obj->buffer.pointer; if (iosapic->header.type != ACPI_MADT_IOSAPIC) { - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return AE_OK; } gsi_base = iosapic->global_irq_base; - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); /* * OK, it's an IOSAPIC MADT entry, look for a _PXM value to tell diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index cafa877..11f0800 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -671,9 +671,11 @@ int add_memory(u64 start, u64 size) return ret; } +EXPORT_SYMBOL_GPL(add_memory); int remove_memory(u64 start, u64 size) { return -EINVAL; } +EXPORT_SYMBOL_GPL(remove_memory); #endif diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig index 408d44a..6527a36 100644 --- a/arch/x86_64/Kconfig +++ b/arch/x86_64/Kconfig @@ -299,6 +299,7 @@ config X86_64_ACPI_NUMA bool "ACPI NUMA detection" depends on NUMA select ACPI + select PCI select ACPI_NUMA default y help diff --git a/arch/x86_64/kernel/acpi/Makefile b/arch/x86_64/kernel/acpi/Makefile index 4fe9707..080b996 100644 --- a/arch/x86_64/kernel/acpi/Makefile +++ b/arch/x86_64/kernel/acpi/Makefile @@ -4,5 +4,6 @@ obj-$(CONFIG_ACPI_SLEEP) += sleep.o wake ifneq ($(CONFIG_ACPI_PROCESSOR),) obj-y += processor.o +processor-y := ../../../i386/kernel/acpi/processor.o ../../../i386/kernel/acpi/cstate.o endif diff --git a/arch/x86_64/kernel/acpi/processor.c b/arch/x86_64/kernel/acpi/processor.c deleted file mode 100644 index 3bdc2ba..0000000 --- a/arch/x86_64/kernel/acpi/processor.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * arch/x86_64/kernel/acpi/processor.c - * - * Copyright (C) 2005 Intel Corporation - * Venkatesh Pallipadi - * - Added _PDC for platforms with Intel CPUs - */ - -#include -#include -#include -#include - -#include -#include - -static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c) -{ - struct acpi_object_list *obj_list; - union acpi_object *obj; - u32 *buf; - - /* allocate and initialize pdc. It will be used later. */ - obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); - if (!obj_list) { - printk(KERN_ERR "Memory allocation error\n"); - return; - } - - obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); - if (!obj) { - printk(KERN_ERR "Memory allocation error\n"); - kfree(obj_list); - return; - } - - buf = kmalloc(12, GFP_KERNEL); - if (!buf) { - printk(KERN_ERR "Memory allocation error\n"); - kfree(obj); - kfree(obj_list); - return; - } - - buf[0] = ACPI_PDC_REVISION_ID; - buf[1] = 1; - buf[2] = ACPI_PDC_EST_CAPABILITY_SMP; - - obj->type = ACPI_TYPE_BUFFER; - obj->buffer.length = 12; - obj->buffer.pointer = (u8 *) buf; - obj_list->count = 1; - obj_list->pointer = obj; - pr->pdc = obj_list; - - return; -} - -/* Initialize _PDC data based on the CPU vendor */ -void arch_acpi_processor_init_pdc(struct acpi_processor *pr) -{ - unsigned int cpu = pr->id; - struct cpuinfo_x86 *c = cpu_data + cpu; - - pr->pdc = NULL; - if (c->x86_vendor == X86_VENDOR_INTEL && cpu_has(c, X86_FEATURE_EST)) - init_intel_pdc(pr, c); - - return; -} - -EXPORT_SYMBOL(arch_acpi_processor_init_pdc); diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index c24652d..2b2fbec 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -10,9 +10,8 @@ menu "ACPI (Advanced Configuration and P config ACPI bool "ACPI Support" depends on IA64 || X86 + depends on PCI select PM - select PCI - default y ---help--- Advanced Configuration and Power Interface (ACPI) support for diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 7839b83..1d2cf05 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -84,20 +84,17 @@ static int acpi_ac_get_state(struct acpi { acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE("acpi_ac_get_state"); - if (!ac) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error reading AC Adapter state\n")); + ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state")); ac->state = ACPI_AC_STATUS_UNKNOWN; - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -110,14 +107,12 @@ static int acpi_ac_seq_show(struct seq_f { struct acpi_ac *ac = (struct acpi_ac *)seq->private; - ACPI_FUNCTION_TRACE("acpi_ac_seq_show"); - if (!ac) - return_VALUE(0); + return 0; if (acpi_ac_get_state(ac)) { seq_puts(seq, "ERROR: Unable to read AC Adapter state\n"); - return_VALUE(0); + return 0; } seq_puts(seq, "state: "); @@ -133,7 +128,7 @@ static int acpi_ac_seq_show(struct seq_f break; } - return_VALUE(0); + return 0; } static int acpi_ac_open_fs(struct inode *inode, struct file *file) @@ -145,13 +140,11 @@ static int acpi_ac_add_fs(struct acpi_de { struct proc_dir_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_ac_add_fs"); - if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_ac_dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; acpi_device_dir(device)->owner = THIS_MODULE; } @@ -159,22 +152,18 @@ static int acpi_ac_add_fs(struct acpi_de entry = create_proc_entry(ACPI_AC_FILE_STATE, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_AC_FILE_STATE)); + return -ENODEV; else { entry->proc_fops = &acpi_ac_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return_VALUE(0); + return 0; } static int acpi_ac_remove_fs(struct acpi_device *device) { - ACPI_FUNCTION_TRACE("acpi_ac_remove_fs"); - if (acpi_device_dir(device)) { remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device)); @@ -182,7 +171,7 @@ static int acpi_ac_remove_fs(struct acpi acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -194,13 +183,11 @@ static void acpi_ac_notify(acpi_handle h struct acpi_ac *ac = (struct acpi_ac *)data; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_ac_notify"); - if (!ac) - return_VOID; + return; if (acpi_bus_get_device(ac->handle, &device)) - return_VOID; + return; switch (event) { case ACPI_AC_NOTIFY_STATUS: @@ -213,7 +200,6 @@ static void acpi_ac_notify(acpi_handle h break; } - return_VOID; } static int acpi_ac_add(struct acpi_device *device) @@ -222,14 +208,12 @@ static int acpi_ac_add(struct acpi_devic acpi_status status = AE_OK; struct acpi_ac *ac = NULL; - ACPI_FUNCTION_TRACE("acpi_ac_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL); if (!ac) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(ac, 0, sizeof(struct acpi_ac)); ac->handle = device->handle; @@ -249,8 +233,6 @@ static int acpi_ac_add(struct acpi_devic ACPI_DEVICE_NOTIFY, acpi_ac_notify, ac); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -265,7 +247,7 @@ static int acpi_ac_add(struct acpi_devic kfree(ac); } - return_VALUE(result); + return result; } static int acpi_ac_remove(struct acpi_device *device, int type) @@ -273,55 +255,45 @@ static int acpi_ac_remove(struct acpi_de acpi_status status = AE_OK; struct acpi_ac *ac = NULL; - ACPI_FUNCTION_TRACE("acpi_ac_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; ac = (struct acpi_ac *)acpi_driver_data(device); status = acpi_remove_notify_handler(ac->handle, ACPI_DEVICE_NOTIFY, acpi_ac_notify); - if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); acpi_ac_remove_fs(device); kfree(ac); - return_VALUE(0); + return 0; } static int __init acpi_ac_init(void) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_ac_init"); - acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); if (!acpi_ac_dir) - return_VALUE(-ENODEV); + return -ENODEV; acpi_ac_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_ac_driver); if (result < 0) { remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } static void __exit acpi_ac_exit(void) { - ACPI_FUNCTION_TRACE("acpi_ac_exit"); - acpi_bus_unregister_driver(&acpi_ac_driver); remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); - return_VOID; } module_init(acpi_ac_init); diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index d882bf8..aa08372 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -74,7 +74,7 @@ struct acpi_memory_device { unsigned short caching; /* memory cache attribute */ unsigned short write_protect; /* memory read/write attribute */ u64 start_addr; /* Memory Range start physical addr */ - u64 end_addr; /* Memory Range end physical addr */ + u64 length; /* Memory Range length */ }; static int @@ -85,29 +85,26 @@ acpi_memory_get_device_resources(struct struct acpi_resource *resource = NULL; struct acpi_resource_address64 address64; - ACPI_FUNCTION_TRACE("acpi_memory_get_device_resources"); - /* Get the range from the _CRS */ status = acpi_get_current_resources(mem_device->handle, &buffer); if (ACPI_FAILURE(status)) - return_VALUE(-EINVAL); + return -EINVAL; resource = (struct acpi_resource *)buffer.pointer; status = acpi_resource_to_address64(resource, &address64); if (ACPI_SUCCESS(status)) { if (address64.resource_type == ACPI_MEMORY_RANGE) { /* Populate the structure */ - mem_device->caching = - address64.info.mem.caching; + mem_device->caching = address64.info.mem.caching; mem_device->write_protect = address64.info.mem.write_protect; mem_device->start_addr = address64.minimum; - mem_device->end_addr = address64.maximum; + mem_device->length = address64.address_length; } } - acpi_os_free(buffer.pointer); - return_VALUE(0); + kfree(buffer.pointer); + return 0; } static int @@ -119,23 +116,20 @@ acpi_memory_get_device(acpi_handle handl struct acpi_device *device = NULL; struct acpi_device *pdevice = NULL; - ACPI_FUNCTION_TRACE("acpi_memory_get_device"); - if (!acpi_bus_get_device(handle, &device) && device) goto end; status = acpi_get_parent(handle, &phandle); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n")); - return_VALUE(-EINVAL); + ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent")); + return -EINVAL; } /* Get the parent device */ status = acpi_bus_get_device(phandle, &pdevice); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in acpi_bus_get_device\n")); - return_VALUE(-EINVAL); + ACPI_EXCEPTION((AE_INFO, status, "Cannot get acpi bus device")); + return -EINVAL; } /* @@ -144,30 +138,28 @@ acpi_memory_get_device(acpi_handle handl */ status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n")); - return_VALUE(-EINVAL); + ACPI_EXCEPTION((AE_INFO, status, "Cannot add acpi bus")); + return -EINVAL; } end: *mem_device = acpi_driver_data(device); if (!(*mem_device)) { printk(KERN_ERR "\n driver data not found"); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } static int acpi_memory_check_device(struct acpi_memory_device *mem_device) { unsigned long current_status; - ACPI_FUNCTION_TRACE("acpi_memory_check_device"); - /* Get device present/absent information from the _STA */ if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA", NULL, ¤t_status))) - return_VALUE(-ENODEV); + return -ENODEV; /* * Check for device status. Device should be * present/enabled/functioning. @@ -175,22 +167,19 @@ static int acpi_memory_check_device(stru if (!((current_status & ACPI_MEMORY_STA_PRESENT) && (current_status & ACPI_MEMORY_STA_ENABLED) && (current_status & ACPI_MEMORY_STA_FUNCTIONAL))) - return_VALUE(-ENODEV); + return -ENODEV; - return_VALUE(0); + return 0; } static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) { int result; - ACPI_FUNCTION_TRACE("acpi_memory_enable_device"); - /* Get the range from the _CRS */ result = acpi_memory_get_device_resources(mem_device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "\nget_device_resources failed\n")); + ACPI_ERROR((AE_INFO, "get_device_resources failed")); mem_device->state = MEMORY_INVALID_STATE; return result; } @@ -199,10 +188,9 @@ static int acpi_memory_enable_device(str * Tell the VM there is more memory here... * Note: Assume that this function returns zero on success */ - result = add_memory(mem_device->start_addr, - (mem_device->end_addr - mem_device->start_addr) + 1); + result = add_memory(mem_device->start_addr, mem_device->length); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n")); + ACPI_ERROR((AE_INFO, "add_memory failed")); mem_device->state = MEMORY_INVALID_STATE; return result; } @@ -217,8 +205,6 @@ static int acpi_memory_powerdown_device( union acpi_object arg; unsigned long current_status; - ACPI_FUNCTION_TRACE("acpi_memory_powerdown_device"); - /* Issue the _EJ0 command */ arg_list.count = 1; arg_list.pointer = &arg; @@ -228,46 +214,40 @@ static int acpi_memory_powerdown_device( "_EJ0", &arg_list, NULL); /* Return on _EJ0 failure */ if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_EJ0 failed.\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "_EJ0 failed")); + return -ENODEV; } /* Evalute _STA to check if the device is disabled */ status = acpi_evaluate_integer(mem_device->handle, "_STA", NULL, ¤t_status); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; /* Check for device status. Device should be disabled */ if (current_status & ACPI_MEMORY_STA_ENABLED) - return_VALUE(-EINVAL); + return -EINVAL; - return_VALUE(0); + return 0; } static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) { int result; u64 start = mem_device->start_addr; - u64 len = mem_device->end_addr - start + 1; - - ACPI_FUNCTION_TRACE("acpi_memory_disable_device"); + u64 len = mem_device->length; /* * Ask the VM to offline this memory range. * Note: Assume that this function returns zero on success */ result = remove_memory(start, len); - if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Hot-Remove failed.\n")); - return_VALUE(result); - } + if (result) + return result; /* Power-off and eject the device */ result = acpi_memory_powerdown_device(mem_device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device Power Down failed.\n")); /* Set the status of the device to invalid */ mem_device->state = MEMORY_INVALID_STATE; return result; @@ -282,8 +262,6 @@ static void acpi_memory_device_notify(ac struct acpi_memory_device *mem_device; struct acpi_device *device; - ACPI_FUNCTION_TRACE("acpi_memory_device_notify"); - switch (event) { case ACPI_NOTIFY_BUS_CHECK: ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -294,15 +272,14 @@ static void acpi_memory_device_notify(ac ACPI_DEBUG_PRINT((ACPI_DB_INFO, "\nReceived DEVICE CHECK notification for device\n")); if (acpi_memory_get_device(handle, &mem_device)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in finding driver data\n")); - return_VOID; + ACPI_ERROR((AE_INFO, "Cannot find driver data")); + return; } if (!acpi_memory_check_device(mem_device)) { if (acpi_memory_enable_device(mem_device)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in acpi_memory_enable_device\n")); + ACPI_ERROR((AE_INFO, + "Cannot enable memory device")); } break; case ACPI_NOTIFY_EJECT_REQUEST: @@ -310,14 +287,12 @@ static void acpi_memory_device_notify(ac "\nReceived EJECT REQUEST notification for device\n")); if (acpi_bus_get_device(handle, &device)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device doesn't exist\n")); + ACPI_ERROR((AE_INFO, "Device doesn't exist")); break; } mem_device = acpi_driver_data(device); if (!mem_device) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Driver Data is NULL\n")); + ACPI_ERROR((AE_INFO, "Driver Data is NULL")); break; } @@ -328,8 +303,8 @@ static void acpi_memory_device_notify(ac * with generic sysfs driver */ if (acpi_memory_disable_device(mem_device)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error in acpi_memory_disable_device\n")); + ACPI_ERROR((AE_INFO, + "Disable memory device\n")); /* * TBD: Invoke acpi_bus_remove to cleanup data structures */ @@ -340,7 +315,6 @@ static void acpi_memory_device_notify(ac break; } - return_VOID; } static int acpi_memory_device_add(struct acpi_device *device) @@ -348,14 +322,12 @@ static int acpi_memory_device_add(struct int result; struct acpi_memory_device *mem_device = NULL; - ACPI_FUNCTION_TRACE("acpi_memory_device_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL); if (!mem_device) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(mem_device, 0, sizeof(struct acpi_memory_device)); mem_device->handle = device->handle; @@ -367,7 +339,7 @@ static int acpi_memory_device_add(struct result = acpi_memory_get_device_resources(mem_device); if (result) { kfree(mem_device); - return_VALUE(result); + return result; } /* Set the device state */ @@ -375,22 +347,20 @@ static int acpi_memory_device_add(struct printk(KERN_INFO "%s \n", acpi_device_name(device)); - return_VALUE(result); + return result; } static int acpi_memory_device_remove(struct acpi_device *device, int type) { struct acpi_memory_device *mem_device = NULL; - ACPI_FUNCTION_TRACE("acpi_memory_device_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; mem_device = (struct acpi_memory_device *)acpi_driver_data(device); kfree(mem_device); - return_VALUE(0); + return 0; } /* @@ -403,16 +373,14 @@ static acpi_status is_memory_device(acpi struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_device_info *info; - ACPI_FUNCTION_TRACE("is_memory_device"); - status = acpi_get_object_info(handle, &buffer); if (ACPI_FAILURE(status)) - return_ACPI_STATUS(AE_ERROR); + return status; info = buffer.pointer; if (!(info->valid & ACPI_VALID_HID)) { - acpi_os_free(buffer.pointer); - return_ACPI_STATUS(AE_ERROR); + kfree(buffer.pointer); + return AE_ERROR; } hardware_id = info->hardware_id.value; @@ -420,8 +388,8 @@ static acpi_status is_memory_device(acpi (strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID))) status = AE_ERROR; - acpi_os_free(buffer.pointer); - return_ACPI_STATUS(status); + kfree(buffer.pointer); + return status; } static acpi_status @@ -430,21 +398,16 @@ acpi_memory_register_notify_handler(acpi { acpi_status status; - ACPI_FUNCTION_TRACE("acpi_memory_register_notify_handler"); - status = is_memory_device(handle); - if (ACPI_FAILURE(status)) - return_ACPI_STATUS(AE_OK); /* continue */ + if (ACPI_FAILURE(status)){ + ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device")); + return AE_OK; /* continue */ + } status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_memory_device_notify, NULL); - if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); - return_ACPI_STATUS(AE_OK); /* continue */ - } - - return_ACPI_STATUS(status); + /* continue */ + return AE_OK; } static acpi_status @@ -453,22 +416,17 @@ acpi_memory_deregister_notify_handler(ac { acpi_status status; - ACPI_FUNCTION_TRACE("acpi_memory_deregister_notify_handler"); - status = is_memory_device(handle); - if (ACPI_FAILURE(status)) - return_ACPI_STATUS(AE_OK); /* continue */ + if (ACPI_FAILURE(status)){ + ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device")); + return AE_OK; /* continue */ + } status = acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_memory_device_notify); - if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); - return_ACPI_STATUS(AE_OK); /* continue */ - } - return_ACPI_STATUS(status); + return AE_OK; /* continue */ } static int __init acpi_memory_device_init(void) @@ -476,12 +434,10 @@ static int __init acpi_memory_device_ini int result; acpi_status status; - ACPI_FUNCTION_TRACE("acpi_memory_device_init"); - result = acpi_bus_register_driver(&acpi_memory_device_driver); if (result < 0) - return_VALUE(-ENODEV); + return -ENODEV; status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, @@ -489,20 +445,18 @@ static int __init acpi_memory_device_ini NULL, NULL); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); + ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed")); acpi_bus_unregister_driver(&acpi_memory_device_driver); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } static void __exit acpi_memory_device_exit(void) { acpi_status status; - ACPI_FUNCTION_TRACE("acpi_memory_device_exit"); - /* * Adding this to un-install notification handlers for all the device * handles. @@ -513,11 +467,10 @@ static void __exit acpi_memory_device_ex NULL, NULL); if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); + ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed")); acpi_bus_unregister_driver(&acpi_memory_device_driver); - return_VOID; } module_init(acpi_memory_device_init); diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index f4c8775..1f76d11 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c @@ -817,7 +817,7 @@ typedef int (proc_writefunc) (struct fil unsigned long count, void *data); static int -__init asus_proc_add(char *name, proc_writefunc * writefunc, +asus_proc_add(char *name, proc_writefunc * writefunc, proc_readfunc * readfunc, mode_t mode, struct acpi_device *device) { @@ -836,7 +836,7 @@ __init asus_proc_add(char *name, proc_wr return 0; } -static int __init asus_hotk_add_fs(struct acpi_device *device) +static int asus_hotk_add_fs(struct acpi_device *device) { struct proc_dir_entry *proc; mode_t mode; @@ -954,7 +954,7 @@ static void asus_hotk_notify(acpi_handle * This function is used to initialize the hotk with right values. In this * method, we can make all the detection we want, and modify the hotk struct */ -static int __init asus_hotk_get_info(void) +static int asus_hotk_get_info(void) { struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL }; @@ -1017,7 +1017,7 @@ static int __init asus_hotk_get_info(voi } hotk->methods = &model_conf[hotk->model]; - acpi_os_free(model); + kfree(model); return AE_OK; } @@ -1096,12 +1096,12 @@ static int __init asus_hotk_get_info(voi /* S1300A reports L84F, but L1400B too, account for that */ } - acpi_os_free(model); + kfree(model); return AE_OK; } -static int __init asus_hotk_check(void) +static int asus_hotk_check(void) { int result = 0; @@ -1119,7 +1119,9 @@ static int __init asus_hotk_check(void) return result; } -static int __init asus_hotk_add(struct acpi_device *device) +static int asus_hotk_found; + +static int asus_hotk_add(struct acpi_device *device) { acpi_status status = AE_OK; int result; @@ -1180,6 +1182,8 @@ static int __init asus_hotk_add(struct a } } + asus_hotk_found = 1; + end: if (result) { kfree(hotk); @@ -1226,12 +1230,24 @@ static int __init asus_acpi_init(void) asus_proc_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&asus_hotk_driver); - if (result < 1) { - acpi_bus_unregister_driver(&asus_hotk_driver); + if (result < 0) { remove_proc_entry(PROC_ASUS, acpi_root_dir); return -ENODEV; } + /* + * This is a bit of a kludge. We only want this module loaded + * for ASUS systems, but there's currently no way to probe the + * ACPI namespace for ASUS HIDs. So we just return failure if + * we didn't find one, which will cause the module to be + * unloaded. + */ + if (!asus_hotk_found) { + acpi_bus_unregister_driver(&asus_hotk_driver); + remove_proc_entry(PROC_ASUS, acpi_root_dir); + return result; + } + return 0; } @@ -1240,7 +1256,7 @@ static void __exit asus_acpi_exit(void) acpi_bus_unregister_driver(&asus_hotk_driver); remove_proc_entry(PROC_ASUS, acpi_root_dir); - acpi_os_free(asus_info); + kfree(asus_info); return; } diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 702e857..f3ef144 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -132,17 +132,15 @@ acpi_battery_get_info(struct acpi_batter struct acpi_buffer data = { 0, NULL }; union acpi_object *package = NULL; - ACPI_FUNCTION_TRACE("acpi_battery_get_info"); - if (!battery || !bif) - return_VALUE(-EINVAL); + return -EINVAL; /* Evalute _BIF */ status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BIF\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); + return -ENODEV; } package = (union acpi_object *)buffer.pointer; @@ -151,7 +149,7 @@ acpi_battery_get_info(struct acpi_batter status = acpi_extract_package(package, &format, &data); if (status != AE_BUFFER_OVERFLOW) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); + ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF")); result = -ENODEV; goto end; } @@ -165,19 +163,19 @@ acpi_battery_get_info(struct acpi_batter status = acpi_extract_package(package, &format, &data); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); + ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF")); kfree(data.pointer); result = -ENODEV; goto end; } end: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); if (!result) (*bif) = (struct acpi_battery_info *)data.pointer; - return_VALUE(result); + return result; } static int @@ -193,17 +191,15 @@ acpi_battery_get_status(struct acpi_batt struct acpi_buffer data = { 0, NULL }; union acpi_object *package = NULL; - ACPI_FUNCTION_TRACE("acpi_battery_get_status"); - if (!battery || !bst) - return_VALUE(-EINVAL); + return -EINVAL; /* Evalute _BST */ status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BST\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); + return -ENODEV; } package = (union acpi_object *)buffer.pointer; @@ -212,7 +208,7 @@ acpi_battery_get_status(struct acpi_batt status = acpi_extract_package(package, &format, &data); if (status != AE_BUFFER_OVERFLOW) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); + ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST")); result = -ENODEV; goto end; } @@ -226,19 +222,19 @@ acpi_battery_get_status(struct acpi_batt status = acpi_extract_package(package, &format, &data); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); + ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST")); kfree(data.pointer); result = -ENODEV; goto end; } end: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); if (!result) (*bst) = (struct acpi_battery_status *)data.pointer; - return_VALUE(result); + return result; } static int @@ -248,25 +244,23 @@ acpi_battery_set_alarm(struct acpi_batte union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list arg_list = { 1, &arg0 }; - ACPI_FUNCTION_TRACE("acpi_battery_set_alarm"); - if (!battery) - return_VALUE(-EINVAL); + return -EINVAL; if (!battery->flags.alarm) - return_VALUE(-ENODEV); + return -ENODEV; arg0.integer.value = alarm; status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm)); battery->alarm = alarm; - return_VALUE(0); + return 0; } static int acpi_battery_check(struct acpi_battery *battery) @@ -277,18 +271,16 @@ static int acpi_battery_check(struct acp struct acpi_device *device = NULL; struct acpi_battery_info *bif = NULL; - ACPI_FUNCTION_TRACE("acpi_battery_check"); - if (!battery) - return_VALUE(-EINVAL); + return -EINVAL; result = acpi_bus_get_device(battery->handle, &device); if (result) - return_VALUE(result); + return result; result = acpi_bus_get_status(device); if (result) - return_VALUE(result); + return result; /* Insertion? */ @@ -300,7 +292,7 @@ static int acpi_battery_check(struct acp result = acpi_battery_get_info(battery, &bif); if (result) - return_VALUE(result); + return result; battery->flags.power_unit = bif->power_unit; battery->trips.warning = bif->design_capacity_warning; @@ -324,7 +316,7 @@ static int acpi_battery_check(struct acp battery->flags.present = device->status.battery_present; - return_VALUE(result); + return result; } /* -------------------------------------------------------------------------- @@ -339,8 +331,6 @@ static int acpi_battery_read_info(struct struct acpi_battery_info *bif = NULL; char *units = "?"; - ACPI_FUNCTION_TRACE("acpi_battery_read_info"); - if (!battery) goto end; @@ -409,7 +399,7 @@ static int acpi_battery_read_info(struct end: kfree(bif); - return_VALUE(0); + return 0; } static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) @@ -424,8 +414,6 @@ static int acpi_battery_read_state(struc struct acpi_battery_status *bst = NULL; char *units = "?"; - ACPI_FUNCTION_TRACE("acpi_battery_read_state"); - if (!battery) goto end; @@ -458,8 +446,6 @@ static int acpi_battery_read_state(struc if ((bst->state & 0x01) && (bst->state & 0x02)) { seq_printf(seq, "charging state: charging/discharging\n"); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Battery Charging and Discharging?\n")); } else if (bst->state & 0x01) seq_printf(seq, "charging state: discharging\n"); else if (bst->state & 0x02) @@ -489,7 +475,7 @@ static int acpi_battery_read_state(struc end: kfree(bst); - return_VALUE(0); + return 0; } static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) @@ -502,8 +488,6 @@ static int acpi_battery_read_alarm(struc struct acpi_battery *battery = (struct acpi_battery *)seq->private; char *units = "?"; - ACPI_FUNCTION_TRACE("acpi_battery_read_alarm"); - if (!battery) goto end; @@ -527,7 +511,7 @@ static int acpi_battery_read_alarm(struc seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); end: - return_VALUE(0); + return 0; } static ssize_t @@ -540,25 +524,23 @@ acpi_battery_write_alarm(struct file *fi struct seq_file *m = (struct seq_file *)file->private_data; struct acpi_battery *battery = (struct acpi_battery *)m->private; - ACPI_FUNCTION_TRACE("acpi_battery_write_alarm"); - if (!battery || (count > sizeof(alarm_string) - 1)) - return_VALUE(-EINVAL); + return -EINVAL; if (!battery->flags.present) - return_VALUE(-ENODEV); + return -ENODEV; if (copy_from_user(alarm_string, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; alarm_string[count] = '\0'; result = acpi_battery_set_alarm(battery, simple_strtoul(alarm_string, NULL, 0)); if (result) - return_VALUE(result); + return result; - return_VALUE(count); + return count; } static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) @@ -595,13 +577,11 @@ static int acpi_battery_add_fs(struct ac { struct proc_dir_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_battery_add_fs"); - if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_battery_dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; acpi_device_dir(device)->owner = THIS_MODULE; } @@ -609,9 +589,7 @@ static int acpi_battery_add_fs(struct ac entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BATTERY_FILE_INFO)); + return -ENODEV; else { entry->proc_fops = &acpi_battery_info_ops; entry->data = acpi_driver_data(device); @@ -622,9 +600,7 @@ static int acpi_battery_add_fs(struct ac entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BATTERY_FILE_STATUS)); + return -ENODEV; else { entry->proc_fops = &acpi_battery_state_ops; entry->data = acpi_driver_data(device); @@ -636,22 +612,18 @@ static int acpi_battery_add_fs(struct ac S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BATTERY_FILE_ALARM)); + return -ENODEV; else { entry->proc_fops = &acpi_battery_alarm_ops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return_VALUE(0); + return 0; } static int acpi_battery_remove_fs(struct acpi_device *device) { - ACPI_FUNCTION_TRACE("acpi_battery_remove_fs"); - if (acpi_device_dir(device)) { remove_proc_entry(ACPI_BATTERY_FILE_ALARM, acpi_device_dir(device)); @@ -664,7 +636,7 @@ static int acpi_battery_remove_fs(struct acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -676,13 +648,11 @@ static void acpi_battery_notify(acpi_han struct acpi_battery *battery = (struct acpi_battery *)data; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_battery_notify"); - if (!battery) - return_VOID; + return; if (acpi_bus_get_device(handle, &device)) - return_VOID; + return; switch (event) { case ACPI_BATTERY_NOTIFY_STATUS: @@ -696,7 +666,6 @@ static void acpi_battery_notify(acpi_han break; } - return_VOID; } static int acpi_battery_add(struct acpi_device *device) @@ -705,14 +674,12 @@ static int acpi_battery_add(struct acpi_ acpi_status status = 0; struct acpi_battery *battery = NULL; - ACPI_FUNCTION_TRACE("acpi_battery_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); if (!battery) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(battery, 0, sizeof(struct acpi_battery)); battery->handle = device->handle; @@ -732,8 +699,6 @@ static int acpi_battery_add(struct acpi_ ACPI_DEVICE_NOTIFY, acpi_battery_notify, battery); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -748,7 +713,7 @@ static int acpi_battery_add(struct acpi_ kfree(battery); } - return_VALUE(result); + return result; } static int acpi_battery_remove(struct acpi_device *device, int type) @@ -756,56 +721,46 @@ static int acpi_battery_remove(struct ac acpi_status status = 0; struct acpi_battery *battery = NULL; - ACPI_FUNCTION_TRACE("acpi_battery_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; battery = (struct acpi_battery *)acpi_driver_data(device); status = acpi_remove_notify_handler(battery->handle, ACPI_DEVICE_NOTIFY, acpi_battery_notify); - if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); acpi_battery_remove_fs(device); kfree(battery); - return_VALUE(0); + return 0; } static int __init acpi_battery_init(void) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_battery_init"); - acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); if (!acpi_battery_dir) - return_VALUE(-ENODEV); + return -ENODEV; acpi_battery_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_battery_driver); if (result < 0) { remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } static void __exit acpi_battery_exit(void) { - ACPI_FUNCTION_TRACE("acpi_battery_exit"); - acpi_bus_unregister_driver(&acpi_battery_driver); remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); - return_VOID; } module_init(acpi_battery_init); diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 606f873..86a7531 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -60,21 +60,18 @@ int acpi_bus_get_device(acpi_handle hand { acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE("acpi_bus_get_device"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; /* TBD: Support fixed-feature devices */ status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); if (ACPI_FAILURE(status) || !*device) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n", - handle)); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "No context for object [%p]", handle)); + return -ENODEV; } - return_VALUE(0); + return 0; } EXPORT_SYMBOL(acpi_bus_get_device); @@ -84,10 +81,8 @@ int acpi_bus_get_status(struct acpi_devi acpi_status status = AE_OK; unsigned long sta = 0; - ACPI_FUNCTION_TRACE("acpi_bus_get_status"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; /* * Evaluate _STA if present. @@ -96,7 +91,7 @@ int acpi_bus_get_status(struct acpi_devi status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; STRUCT_TO_INT(device->status) = (int)sta; } @@ -120,7 +115,7 @@ int acpi_bus_get_status(struct acpi_devi device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status))); - return_VALUE(0); + return 0; } EXPORT_SYMBOL(acpi_bus_get_status); @@ -136,11 +131,9 @@ int acpi_bus_get_power(acpi_handle handl struct acpi_device *device = NULL; unsigned long psc = 0; - ACPI_FUNCTION_TRACE("acpi_bus_get_power"); - result = acpi_bus_get_device(handle, &device); if (result) - return_VALUE(result); + return result; *state = ACPI_STATE_UNKNOWN; @@ -159,12 +152,12 @@ int acpi_bus_get_power(acpi_handle handl status = acpi_evaluate_integer(device->handle, "_PSC", NULL, &psc); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; device->power.state = (int)psc; } else if (device->power.flags.power_resources) { result = acpi_power_get_inferred_state(device); if (result) - return_VALUE(result); + return result; } *state = device->power.state; @@ -173,7 +166,7 @@ int acpi_bus_get_power(acpi_handle handl ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n", device->pnp.bus_id, device->power.state)); - return_VALUE(0); + return 0; } EXPORT_SYMBOL(acpi_bus_get_power); @@ -185,42 +178,41 @@ int acpi_bus_set_power(acpi_handle handl struct acpi_device *device = NULL; char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' }; - ACPI_FUNCTION_TRACE("acpi_bus_set_power"); - result = acpi_bus_get_device(handle, &device); if (result) - return_VALUE(result); + return result; if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) - return_VALUE(-EINVAL); + return -EINVAL; /* Make sure this is a valid target state */ if (!device->flags.power_manageable) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Device is not power manageable\n")); - return_VALUE(-ENODEV); + ACPI_INFO((AE_INFO, "Device is not power manageable")); + return -ENODEV; } /* * Get device's current power state if it's unknown * This means device power state isn't initialized or previous setting failed */ - if (device->power.state == ACPI_STATE_UNKNOWN) - acpi_bus_get_power(device->handle, &device->power.state); - if (state == device->power.state) { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", - state)); - return_VALUE(0); + if (!device->flags.force_power_state) { + if (device->power.state == ACPI_STATE_UNKNOWN) + acpi_bus_get_power(device->handle, &device->power.state); + if (state == device->power.state) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", + state)); + return 0; + } } if (!device->power.states[state].flags.valid) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", - state)); - return_VALUE(-ENODEV); + ACPI_WARNING((AE_INFO, "Device does not support D%d", state)); + return -ENODEV; } if (device->parent && (state < device->parent->power.state)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Cannot set device to a higher-powered state than parent\n")); - return_VALUE(-ENODEV); + ACPI_WARNING((AE_INFO, + "Cannot set device to a higher-powered" + " state than parent")); + return -ENODEV; } /* @@ -262,15 +254,15 @@ int acpi_bus_set_power(acpi_handle handl end: if (result) - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Error transitioning device [%s] to D%d\n", - device->pnp.bus_id, state)); + ACPI_WARNING((AE_INFO, + "Transitioning device [%s] to D%d", + device->pnp.bus_id, state)); else ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] transitioned to D%d\n", device->pnp.bus_id, state)); - return_VALUE(result); + return result; } EXPORT_SYMBOL(acpi_bus_set_power); @@ -291,18 +283,16 @@ int acpi_bus_generate_event(struct acpi_ struct acpi_bus_event *event = NULL; unsigned long flags = 0; - ACPI_FUNCTION_TRACE("acpi_bus_generate_event"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; /* drop event on the floor if no one's listening */ if (!event_is_open) - return_VALUE(0); + return 0; event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC); if (!event) - return_VALUE(-ENOMEM); + return -ENOMEM; strcpy(event->device_class, device->pnp.device_class); strcpy(event->bus_id, device->pnp.bus_id); @@ -315,7 +305,7 @@ int acpi_bus_generate_event(struct acpi_ wake_up_interruptible(&acpi_bus_event_queue); - return_VALUE(0); + return 0; } EXPORT_SYMBOL(acpi_bus_generate_event); @@ -327,10 +317,8 @@ int acpi_bus_receive_event(struct acpi_b DECLARE_WAITQUEUE(wait, current); - ACPI_FUNCTION_TRACE("acpi_bus_receive_event"); - if (!event) - return_VALUE(-EINVAL); + return -EINVAL; if (list_empty(&acpi_bus_event_list)) { @@ -344,7 +332,7 @@ int acpi_bus_receive_event(struct acpi_b set_current_state(TASK_RUNNING); if (signal_pending(current)) - return_VALUE(-ERESTARTSYS); + return -ERESTARTSYS; } spin_lock_irqsave(&acpi_bus_event_lock, flags); @@ -355,13 +343,13 @@ int acpi_bus_receive_event(struct acpi_b spin_unlock_irqrestore(&acpi_bus_event_lock, flags); if (!entry) - return_VALUE(-ENODEV); + return -ENODEV; memcpy(event, entry, sizeof(struct acpi_bus_event)); kfree(entry); - return_VALUE(0); + return 0; } EXPORT_SYMBOL(acpi_bus_receive_event); @@ -376,10 +364,8 @@ acpi_bus_check_device(struct acpi_device acpi_status status = 0; struct acpi_device_status old_status; - ACPI_FUNCTION_TRACE("acpi_bus_check_device"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; if (status_changed) *status_changed = 0; @@ -396,15 +382,15 @@ acpi_bus_check_device(struct acpi_device if (status_changed) *status_changed = 1; } - return_VALUE(0); + return 0; } status = acpi_bus_get_status(device); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) - return_VALUE(0); + return 0; if (status_changed) *status_changed = 1; @@ -420,7 +406,7 @@ acpi_bus_check_device(struct acpi_device /* TBD: Handle device removal */ } - return_VALUE(0); + return 0; } static int acpi_bus_check_scope(struct acpi_device *device) @@ -428,25 +414,23 @@ static int acpi_bus_check_scope(struct a int result = 0; int status_changed = 0; - ACPI_FUNCTION_TRACE("acpi_bus_check_scope"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; /* Status Change? */ result = acpi_bus_check_device(device, &status_changed); if (result) - return_VALUE(result); + return result; if (!status_changed) - return_VALUE(0); + return 0; /* * TBD: Enumerate child devices within this device's scope and * run acpi_bus_check_device()'s on them. */ - return_VALUE(0); + return 0; } /** @@ -459,10 +443,8 @@ static void acpi_bus_notify(acpi_handle int result = 0; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_bus_notify"); - if (acpi_bus_get_device(handle, &device)) - return_VOID; + return; switch (type) { @@ -537,7 +519,6 @@ static void acpi_bus_notify(acpi_handle break; } - return_VOID; } /* -------------------------------------------------------------------------- @@ -551,8 +532,6 @@ static int __init acpi_bus_init_irq(void struct acpi_object_list arg_list = { 1, &arg }; char *message = NULL; - ACPI_FUNCTION_TRACE("acpi_bus_init_irq"); - /* * Let the system know what interrupt model we are using by * evaluating the \_PIC object, if exists. @@ -570,7 +549,7 @@ static int __init acpi_bus_init_irq(void break; default: printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n"); - return_VALUE(-ENODEV); + return -ENODEV; } printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message); @@ -579,11 +558,11 @@ static int __init acpi_bus_init_irq(void status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL); if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC")); + return -ENODEV; } - return_VALUE(0); + return 0; } void __init acpi_early_init(void) @@ -591,10 +570,8 @@ void __init acpi_early_init(void) acpi_status status = AE_OK; struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt }; - ACPI_FUNCTION_TRACE("acpi_early_init"); - if (acpi_disabled) - return_VOID; + return; /* enable workarounds, unless strict ACPI spec. compliance */ if (!acpi_strict) @@ -651,12 +628,11 @@ #endif printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); goto error0; } - - return_VOID; + return; error0: disable_acpi(); - return_VOID; + return; } static int __init acpi_bus_init(void) @@ -665,8 +641,6 @@ static int __init acpi_bus_init(void) acpi_status status = AE_OK; extern acpi_status acpi_os_initialize1(void); - ACPI_FUNCTION_TRACE("acpi_bus_init"); - status = acpi_os_initialize1(); status = @@ -727,12 +701,12 @@ #endif */ acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL); - return_VALUE(0); + return 0; /* Mimic structured exception handling */ error1: acpi_terminate(); - return_VALUE(-ENODEV); + return -ENODEV; } decl_subsys(acpi, NULL, NULL); @@ -741,13 +715,11 @@ static int __init acpi_init(void) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_init"); - printk(KERN_INFO PREFIX "Subsystem revision %08x\n", ACPI_CA_VERSION); if (acpi_disabled) { printk(KERN_INFO PREFIX "Interpreter disabled.\n"); - return_VALUE(-ENODEV); + return -ENODEV; } firmware_register(&acpi_subsys); @@ -768,7 +740,7 @@ #endif } else disable_acpi(); - return_VALUE(result); + return result; } subsys_initcall(acpi_init); diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 4b6d9f0..edccc8b 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -112,15 +112,13 @@ static int acpi_button_info_seq_show(str { struct acpi_button *button = (struct acpi_button *)seq->private; - ACPI_FUNCTION_TRACE("acpi_button_info_seq_show"); - if (!button || !button->device) - return_VALUE(0); + return 0; seq_printf(seq, "type: %s\n", acpi_device_name(button->device)); - return_VALUE(0); + return 0; } static int acpi_button_info_open_fs(struct inode *inode, struct file *file) @@ -134,10 +132,8 @@ static int acpi_button_state_seq_show(st acpi_status status; unsigned long state; - ACPI_FUNCTION_TRACE("acpi_button_state_seq_show"); - if (!button || !button->device) - return_VALUE(0); + return 0; status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state); if (ACPI_FAILURE(status)) { @@ -147,7 +143,7 @@ static int acpi_button_state_seq_show(st (state ? "open" : "closed")); } - return_VALUE(0); + return 0; } static int acpi_button_state_open_fs(struct inode *inode, struct file *file) @@ -164,10 +160,8 @@ static int acpi_button_add_fs(struct acp struct proc_dir_entry *entry = NULL; struct acpi_button *button = NULL; - ACPI_FUNCTION_TRACE("acpi_button_add_fs"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; button = acpi_driver_data(device); @@ -195,21 +189,19 @@ static int acpi_button_add_fs(struct acp } if (!entry) - return_VALUE(-ENODEV); + return -ENODEV; entry->owner = THIS_MODULE; acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; acpi_device_dir(device)->owner = THIS_MODULE; /* 'info' [R] */ entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BUTTON_FILE_INFO)); + return -ENODEV; else { entry->proc_fops = &acpi_button_info_fops; entry->data = acpi_driver_data(device); @@ -221,9 +213,7 @@ static int acpi_button_add_fs(struct acp entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_BUTTON_FILE_INFO)); + return -ENODEV; else { entry->proc_fops = &acpi_button_state_fops; entry->data = acpi_driver_data(device); @@ -231,15 +221,13 @@ static int acpi_button_add_fs(struct acp } } - return_VALUE(0); + return 0; } static int acpi_button_remove_fs(struct acpi_device *device) { struct acpi_button *button = NULL; - ACPI_FUNCTION_TRACE("acpi_button_remove_fs"); - button = acpi_driver_data(device); if (acpi_device_dir(device)) { if (button->type == ACPI_BUTTON_TYPE_LID) @@ -253,7 +241,7 @@ static int acpi_button_remove_fs(struct acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -264,10 +252,8 @@ static void acpi_button_notify(acpi_hand { struct acpi_button *button = (struct acpi_button *)data; - ACPI_FUNCTION_TRACE("acpi_button_notify"); - if (!button || !button->device) - return_VOID; + return; switch (event) { case ACPI_BUTTON_NOTIFY_STATUS: @@ -280,21 +266,18 @@ static void acpi_button_notify(acpi_hand break; } - return_VOID; } static acpi_status acpi_button_notify_fixed(void *data) { struct acpi_button *button = (struct acpi_button *)data; - ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); - if (!button) - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); - return_ACPI_STATUS(AE_OK); + return AE_OK; } static int acpi_button_add(struct acpi_device *device) @@ -303,14 +286,12 @@ static int acpi_button_add(struct acpi_d acpi_status status = AE_OK; struct acpi_button *button = NULL; - ACPI_FUNCTION_TRACE("acpi_button_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); if (!button) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(button, 0, sizeof(struct acpi_button)); button->device = device; @@ -349,8 +330,8 @@ static int acpi_button_add(struct acpi_d sprintf(acpi_device_class(device), "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", - acpi_device_hid(device))); + ACPI_ERROR((AE_INFO, "Unsupported hid [%s]", + acpi_device_hid(device))); result = -ENODEV; goto end; } @@ -381,8 +362,6 @@ static int acpi_button_add(struct acpi_d } if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -406,7 +385,7 @@ static int acpi_button_add(struct acpi_d kfree(button); } - return_VALUE(result); + return result; } static int acpi_button_remove(struct acpi_device *device, int type) @@ -414,10 +393,8 @@ static int acpi_button_remove(struct acp acpi_status status = 0; struct acpi_button *button = NULL; - ACPI_FUNCTION_TRACE("acpi_button_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; button = acpi_driver_data(device); @@ -440,40 +417,32 @@ static int acpi_button_remove(struct acp break; } - if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); - acpi_button_remove_fs(device); kfree(button); - return_VALUE(0); + return 0; } static int __init acpi_button_init(void) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_button_init"); - acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); if (!acpi_button_dir) - return_VALUE(-ENODEV); + return -ENODEV; acpi_button_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_button_driver); if (result < 0) { remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } static void __exit acpi_button_exit(void) { - ACPI_FUNCTION_TRACE("acpi_button_exit"); - acpi_bus_unregister_driver(&acpi_button_driver); if (acpi_power_dir) @@ -484,7 +453,6 @@ static void __exit acpi_button_exit(void remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); - return_VOID; } module_init(acpi_button_init); diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index b69a8ca..b5058bd 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c @@ -73,17 +73,15 @@ static int is_device_present(acpi_handle acpi_status status; unsigned long sta; - ACPI_FUNCTION_TRACE("is_device_present"); - status = acpi_get_handle(handle, "_STA", &temp); if (ACPI_FAILURE(status)) - return_VALUE(1); /* _STA not found, assmue device present */ + return 1; /* _STA not found, assmue device present */ status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) - return_VALUE(0); /* Firmware error */ + return 0; /* Firmware error */ - return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT); + return (sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT; } /*******************************************************************/ @@ -91,16 +89,14 @@ static int acpi_container_add(struct acp { struct acpi_container *container; - ACPI_FUNCTION_TRACE("acpi_container_add"); - if (!device) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "device is NULL\n")); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "device is NULL")); + return -EINVAL; } container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); if (!container) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(container, 0, sizeof(struct acpi_container)); container->handle = device->handle; @@ -111,7 +107,7 @@ static int acpi_container_add(struct acp ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", acpi_device_name(device), acpi_device_bid(device))); - return_VALUE(0); + return 0; } static int acpi_container_remove(struct acpi_device *device, int type) @@ -130,23 +126,21 @@ static int container_device_add(struct a struct acpi_device *pdev; int result; - ACPI_FUNCTION_TRACE("container_device_add"); - if (acpi_get_parent(handle, &phandle)) { - return_VALUE(-ENODEV); + return -ENODEV; } if (acpi_bus_get_device(phandle, &pdev)) { - return_VALUE(-ENODEV); + return -ENODEV; } if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) { - return_VALUE(-ENODEV); + return -ENODEV; } result = acpi_bus_start(*device); - return_VALUE(result); + return result; } static void container_notify_cb(acpi_handle handle, u32 type, void *context) @@ -156,8 +150,6 @@ static void container_notify_cb(acpi_han int present; acpi_status status; - ACPI_FUNCTION_TRACE("container_notify_cb"); - present = is_device_present(handle); switch (type) { @@ -192,7 +184,6 @@ static void container_notify_cb(acpi_han default: break; } - return_VOID; } static acpi_status @@ -205,11 +196,9 @@ container_walk_namespace_cb(acpi_handle acpi_status status; int *action = context; - ACPI_FUNCTION_TRACE("container_walk_namespace_cb"); - status = acpi_get_object_info(handle, &buffer); if (ACPI_FAILURE(status) || !buffer.pointer) { - return_ACPI_STATUS(AE_OK); + return AE_OK; } info = buffer.pointer; @@ -241,9 +230,9 @@ container_walk_namespace_cb(acpi_handle } end: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); - return_ACPI_STATUS(AE_OK); + return AE_OK; } static int __init acpi_container_init(void) @@ -269,8 +258,6 @@ static void __exit acpi_container_exit(v { int action = UNINSTALL_NOTIFY_HANDLER; - ACPI_FUNCTION_TRACE("acpi_container_exit"); - acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, @@ -278,7 +265,6 @@ static void __exit acpi_container_exit(v acpi_bus_unregister_driver(&acpi_container_driver); - return_VOID; } module_init(acpi_container_init); diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index 263322b..2cd66c8 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c @@ -155,13 +155,11 @@ acpi_system_write_debug(struct file *fil { char debug_string[12] = { '\0' }; - ACPI_FUNCTION_TRACE("acpi_system_write_debug"); - if (count > sizeof(debug_string) - 1) - return_VALUE(-EINVAL); + return -EINVAL; if (copy_from_user(debug_string, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; debug_string[count] = '\0'; @@ -173,10 +171,10 @@ acpi_system_write_debug(struct file *fil acpi_dbg_level = simple_strtoul(debug_string, NULL, 0); break; default: - return_VALUE(-EINVAL); + return -EINVAL; } - return_VALUE(count); + return count; } static int __init acpi_debug_init(void) @@ -185,10 +183,8 @@ static int __init acpi_debug_init(void) int error = 0; char *name; - ACPI_FUNCTION_TRACE("acpi_debug_init"); - if (acpi_disabled) - return_VALUE(0); + return 0; /* 'debug_layer' [R/W] */ name = ACPI_SYSTEM_FILE_DEBUG_LAYER; @@ -213,15 +209,12 @@ static int __init acpi_debug_init(void) goto Error; Done: - return_VALUE(error); + return error; Error: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' proc fs entry\n", name)); - remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir); remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir); - error = -EFAULT; + error = -ENODEV; goto Done; } diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c index 76bc046..3d33bcc 100644 --- a/drivers/acpi/dispatcher/dsfield.c +++ b/drivers/acpi/dispatcher/dsfield.c @@ -425,6 +425,7 @@ acpi_ds_init_field_objects(union acpi_pa * Walk the list of entries in the field_list */ while (arg) { + /* Ignore OFFSET and ACCESSAS terms here */ if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) { diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index c475546..238916c 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -81,6 +81,7 @@ acpi_ds_method_error(acpi_status status, /* Invoke the global exception handler */ if (acpi_gbl_exception_handler) { + /* Exit the interpreter, allow handler to execute methods */ acpi_ex_exit_interpreter(); @@ -100,6 +101,7 @@ acpi_ds_method_error(acpi_status status, } #ifdef ACPI_DISASSEMBLER if (ACPI_FAILURE(status)) { + /* Display method locals/args if disassembler is present */ acpi_dm_dump_method_info(status, walk_state, walk_state->op); @@ -249,6 +251,7 @@ acpi_ds_call_control_method(struct acpi_ } if (!(obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY)) { + /* 1) Parse: Create a new walk state for the preempting walk */ next_walk_state = @@ -378,9 +381,11 @@ acpi_ds_restart_control_method(struct ac /* Did the called method return a value? */ if (return_desc) { + /* Are we actually going to use the return value? */ if (walk_state->return_used) { + /* Save the return value from the previous method */ status = acpi_ds_result_push(return_desc, walk_state); diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index c025674..2ed4843 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c @@ -81,7 +81,7 @@ #endif * special data types. * * NOTES: walk_state fields are initialized to zero by the - * ACPI_MEM_CALLOCATE(). + * ACPI_ALLOCATE_ZEROED(). * * A pseudo-Namespace Node is assigned to each argument and local * so that ref_of() can return a pointer to the Node. @@ -701,6 +701,7 @@ acpi_ds_method_data_get_type(u16 opcode, object = acpi_ns_get_attached_object(node); if (!object) { + /* Uninitialized local/arg, return TYPE_ANY */ return_VALUE(ACPI_TYPE_ANY); diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index 8b21f0f..ce54715 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c @@ -103,6 +103,7 @@ acpi_ds_build_internal_object(struct acp common. node))); if (ACPI_FAILURE(status)) { + /* Check if we are resolving a named reference within a package */ if ((status == AE_NOT_FOUND) @@ -195,6 +196,7 @@ acpi_ds_build_internal_buffer_obj(struct */ obj_desc = *obj_desc_ptr; if (!obj_desc) { + /* Create a new buffer object */ obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); @@ -243,7 +245,7 @@ acpi_ds_build_internal_buffer_obj(struct "Buffer defined with zero length in AML, creating\n")); } else { obj_desc->buffer.pointer = - ACPI_MEM_CALLOCATE(obj_desc->buffer.length); + ACPI_ALLOCATE_ZEROED(obj_desc->buffer.length); if (!obj_desc->buffer.pointer) { acpi_ut_delete_object_desc(obj_desc); return_ACPI_STATUS(AE_NO_MEMORY); @@ -339,9 +341,10 @@ acpi_ds_build_internal_package_obj(struc * individual objects). Add an extra pointer slot so * that the list is always null terminated. */ - obj_desc->package.elements = ACPI_MEM_CALLOCATE(((acpi_size) obj_desc-> - package.count + - 1) * sizeof(void *)); + obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) + obj_desc->package. + count + + 1) * sizeof(void *)); if (!obj_desc->package.elements) { acpi_ut_delete_object_desc(obj_desc); @@ -355,6 +358,7 @@ acpi_ds_build_internal_package_obj(struc arg = arg->common.next; for (i = 0; arg; i++) { if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { + /* Object (package or buffer) is already built */ obj_desc->package.elements[i] = @@ -408,6 +412,7 @@ acpi_ds_create_node(struct acpi_walk_sta } if (!op->common.value.arg) { + /* No arguments, there is nothing to do */ return_ACPI_STATUS(AE_OK); @@ -469,6 +474,7 @@ acpi_ds_init_object_from_op(struct acpi_ obj_desc = *ret_obj_desc; op_info = acpi_ps_get_opcode_info(opcode); if (op_info->class == AML_CLASS_UNKNOWN) { + /* Unknown opcode */ return_ACPI_STATUS(AE_TYPE); @@ -626,6 +632,7 @@ #endif default: /* Other literals, etc.. */ if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { + /* Node was saved in Op */ obj_desc->reference.node = op->common.node; diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index 6229c10..8a690a9 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c @@ -640,6 +640,7 @@ acpi_ds_eval_buffer_field_operands(struc /* Initialize the Buffer Field */ if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { + /* NOTE: Slightly different operands for this opcode */ status = @@ -984,6 +985,7 @@ acpi_ds_exec_end_control_op(struct acpi_ ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); if (walk_state->control_state->common.value) { + /* Predicate was true, go back and evaluate it again! */ status = AE_CTRL_PENDING; @@ -1014,6 +1016,7 @@ acpi_ds_exec_end_control_op(struct acpi_ * has been bubbled up the tree */ if (op->common.value.arg) { + /* Since we have a real Return(), delete any implicit return */ acpi_ds_clear_implicit_return(walk_state); @@ -1047,6 +1050,7 @@ acpi_ds_exec_end_control_op(struct acpi_ walk_state->return_desc = walk_state->operands[0]; } else if ((walk_state->results) && (walk_state->results->results.num_results > 0)) { + /* Since we have a real Return(), delete any implicit return */ acpi_ds_clear_implicit_return(walk_state); diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c index 53356a5..ab24aa8 100644 --- a/drivers/acpi/dispatcher/dsutils.c +++ b/drivers/acpi/dispatcher/dsutils.c @@ -202,6 +202,7 @@ acpi_ds_is_result_used(union acpi_parse_ */ if ((!op->common.parent) || (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) { + /* No parent, the return value cannot possibly be used */ ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, @@ -352,6 +353,7 @@ acpi_ds_delete_result_if_not_used(union } if (!acpi_ds_is_result_used(op, walk_state)) { + /* Must pop the result stack (obj_desc should be equal to result_obj) */ status = acpi_ds_result_pop(&obj_desc, walk_state); @@ -498,7 +500,9 @@ acpi_ds_create_operand(struct acpi_walk_ */ if ((walk_state->deferred_node) && (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) - && (arg_index != 0)) { + && (arg_index == + (u32) ((walk_state->opcode == + AML_CREATE_FIELD_OP) ? 3 : 2))) { obj_desc = ACPI_CAST_PTR(union acpi_operand_object, walk_state->deferred_node); @@ -521,6 +525,7 @@ acpi_ds_create_operand(struct acpi_walk_ && (parent_op->common.aml_opcode != AML_REGION_OP) && (parent_op->common.aml_opcode != AML_INT_NAMEPATH_OP)) { + /* Enter name into namespace if not found */ interpreter_mode = ACPI_IMODE_LOAD_PASS2; @@ -572,7 +577,7 @@ acpi_ds_create_operand(struct acpi_walk_ /* Free the namestring created above */ - ACPI_MEM_FREE(name_string); + ACPI_FREE(name_string); /* Check status from the lookup */ diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c index f1af655..198949f 100644 --- a/drivers/acpi/dispatcher/dswexec.c +++ b/drivers/acpi/dispatcher/dswexec.c @@ -409,6 +409,7 @@ acpi_status acpi_ds_exec_end_op(struct a * being the object_type and size_of operators. */ if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) { + /* Resolve all operands */ status = acpi_ex_resolve_operands(walk_state->opcode, @@ -548,6 +549,7 @@ acpi_status acpi_ds_exec_end_op(struct a */ status = acpi_ds_resolve_operands(walk_state); if (ACPI_FAILURE(status)) { + /* On error, clear all resolved operands */ acpi_ds_clear_operands(walk_state); @@ -722,6 +724,7 @@ acpi_status acpi_ds_exec_end_op(struct a cleanup: if (walk_state->result_obj) { + /* Break to debugger to display result */ ACPI_DEBUGGER_EXEC(acpi_db_display_result_object diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index d3d24da..1ad7870 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -261,6 +261,7 @@ #endif */ if (walk_state->deferred_node) { + /* This name is already in the namespace, get the node */ node = walk_state->deferred_node; @@ -311,6 +312,7 @@ #endif /* Common exit */ if (!op) { + /* Create a new op */ op = acpi_ps_alloc_op(walk_state->opcode); @@ -413,6 +415,7 @@ #ifndef ACPI_NO_METHOD_EXECUTION #endif if (op->common.aml_opcode == AML_NAME_OP) { + /* For Name opcode, get the object type from the argument */ if (op->common.value.arg) { @@ -521,6 +524,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_ if ((walk_state->control_state) && (walk_state->control_state->common.state == ACPI_CONTROL_CONDITIONAL_EXECUTING)) { + /* We are executing a while loop outside of a method */ status = acpi_ds_exec_begin_op(walk_state, out_op); @@ -554,10 +558,12 @@ #endif /* Get the name we are going to enter or lookup in the namespace */ if (walk_state->opcode == AML_INT_NAMEPATH_OP) { + /* For Namepath op, get the path string */ buffer_ptr = op->common.value.string; if (!buffer_ptr) { + /* No name, just exit */ return_ACPI_STATUS(AE_OK); @@ -680,6 +686,7 @@ #endif /* All other opcodes */ if (op && op->common.node) { + /* This op/node was previously entered into the namespace */ node = op->common.node; @@ -705,6 +712,7 @@ #endif * Note: Name may already exist if we are executing a deferred opcode. */ if (walk_state->deferred_node) { + /* This name is already in the namespace, get the node */ node = walk_state->deferred_node; @@ -727,6 +735,7 @@ #endif } if (!op) { + /* Create a new op */ op = acpi_ps_alloc_op(walk_state->opcode); @@ -1104,7 +1113,6 @@ #endif /* ACPI_NO_METHOD_EXECUTION */ ACPI_NS_DONT_OPEN_SCOPE, walk_state, &(new_node)); if (ACPI_SUCCESS(status)) { - /* * Make sure that what we found is indeed a method * We didn't search for a method on purpose, to see if the name diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c index ada21ef..e2954ff 100644 --- a/drivers/acpi/dispatcher/dswscope.c +++ b/drivers/acpi/dispatcher/dswscope.c @@ -66,6 +66,7 @@ void acpi_ds_scope_stack_clear(struct ac ACPI_FUNCTION_NAME("ds_scope_stack_clear"); while (walk_state->scope_info) { + /* Pop a scope off the stack */ scope_info = walk_state->scope_info; @@ -105,6 +106,7 @@ acpi_ds_scope_stack_push(struct acpi_nam ACPI_FUNCTION_TRACE("ds_scope_stack_push"); if (!node) { + /* Invalid scope */ ACPI_ERROR((AE_INFO, "Null scope parameter")); diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index fa78cb7..d2846ff 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c @@ -66,7 +66,6 @@ void *acpi_ds_obj_stack_get_value(u32 in #endif #ifdef ACPI_FUTURE_USAGE - /******************************************************************************* * * FUNCTION: acpi_ds_result_remove @@ -128,7 +127,6 @@ acpi_ds_result_remove(union acpi_operand return (AE_OK); } - #endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* @@ -170,6 +168,7 @@ acpi_ds_result_pop(union acpi_operand_ob state->results.num_results--; for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) { + /* Check for a valid result object */ if (state->results.obj_desc[index - 1]) { @@ -448,6 +447,7 @@ acpi_ds_obj_stack_pop(u32 pop_count, str ACPI_FUNCTION_NAME("ds_obj_stack_pop"); for (i = 0; i < pop_count; i++) { + /* Check for stack underflow */ if (walk_state->num_operands == 0) { @@ -494,6 +494,7 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop ACPI_FUNCTION_NAME("ds_obj_stack_pop_and_delete"); for (i = 0; i < pop_count; i++) { + /* Check for stack underflow */ if (walk_state->num_operands == 0) { @@ -598,6 +599,7 @@ struct acpi_walk_state *acpi_ds_pop_walk walk_state = thread->walk_state_list; if (walk_state) { + /* Next walk state becomes the current walk state */ thread->walk_state_list = walk_state->next; @@ -641,7 +643,7 @@ struct acpi_walk_state *acpi_ds_create_w ACPI_FUNCTION_TRACE("ds_create_walk_state"); - walk_state = ACPI_MEM_CALLOCATE(sizeof(struct acpi_walk_state)); + walk_state = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_walk_state)); if (!walk_state) { return_PTR(NULL); } @@ -664,7 +666,7 @@ #endif status = acpi_ds_result_stack_push(walk_state); if (ACPI_FAILURE(status)) { - ACPI_MEM_FREE(walk_state); + ACPI_FREE(walk_state); return_PTR(NULL); } @@ -778,6 +780,7 @@ acpi_ds_init_aml_walk(struct acpi_walk_s } if (parser_state->start_node) { + /* Push start scope on scope stack and make it current */ status = @@ -854,7 +857,7 @@ void acpi_ds_delete_walk_state(struct ac acpi_ut_delete_generic_state(state); } - ACPI_MEM_FREE(walk_state); + ACPI_FREE(walk_state); return_VOID; } diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index eee0864..b9222b3 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -116,7 +116,7 @@ union acpi_ec { struct acpi_generic_address command_addr; struct acpi_generic_address data_addr; unsigned long global_lock; - spinlock_t lock; + struct semaphore sem; } poll; }; @@ -207,8 +207,6 @@ static int acpi_ec_intr_wait(union acpi_ { int result = 0; - ACPI_FUNCTION_TRACE("acpi_ec_wait"); - ec->intr.expect_event = event; smp_mb(); @@ -216,7 +214,7 @@ static int acpi_ec_intr_wait(union acpi_ case ACPI_EC_EVENT_IBE: if (~acpi_ec_read_status(ec) & event) { ec->intr.expect_event = 0; - return_VALUE(0); + return 0; } break; default: @@ -238,16 +236,16 @@ static int acpi_ec_intr_wait(union acpi_ switch (event) { case ACPI_EC_EVENT_OBF: if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF) - return_VALUE(0); + return 0; break; case ACPI_EC_EVENT_IBE: if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) - return_VALUE(0); + return 0; break; } - return_VALUE(-ETIME); + return -ETIME; } #ifdef ACPI_FUTURE_USAGE @@ -260,8 +258,6 @@ int acpi_ec_enter_burst_mode(union acpi_ u32 tmp = 0; int status = 0; - ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode"); - status = acpi_ec_read_status(ec); if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); @@ -272,23 +268,21 @@ int acpi_ec_enter_burst_mode(union acpi_ status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); if (tmp != 0x90) { /* Burst ACK byte */ - return_VALUE(-EINVAL); + return -EINVAL; } } atomic_set(&ec->intr.leaving_burst, 0); - return_VALUE(0); + return 0; end: - printk(KERN_WARNING PREFIX "Error in acpi_ec_wait\n"); - return_VALUE(-1); + ACPI_EXCEPTION ((AE_INFO, status, "EC wait, burst mode"); + return -1; } int acpi_ec_leave_burst_mode(union acpi_ec *ec) { int status = 0; - ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); - status = acpi_ec_read_status(ec); if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); @@ -298,10 +292,10 @@ int acpi_ec_leave_burst_mode(union acpi_ acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); } atomic_set(&ec->intr.leaving_burst, 1); - return_VALUE(0); + return 0; end: - printk(KERN_WARNING PREFIX "leave burst_mode:error\n"); - return_VALUE(-1); + ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"); + return -1; } #endif /* ACPI_FUTURE_USAGE */ @@ -323,24 +317,24 @@ static int acpi_ec_poll_read(union acpi_ { acpi_status status = AE_OK; int result = 0; - unsigned long flags = 0; u32 glk = 0; - ACPI_FUNCTION_TRACE("acpi_ec_read"); - if (!ec || !data) - return_VALUE(-EINVAL); + return -EINVAL; *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; } - spin_lock_irqsave(&ec->poll.lock, flags); - + if (down_interruptible(&ec->poll.sem)) { + result = -ERESTARTSYS; + goto end_nosem; + } + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); @@ -358,34 +352,34 @@ static int acpi_ec_poll_read(union acpi_ *data, address)); end: - spin_unlock_irqrestore(&ec->poll.lock, flags); - + up(&ec->poll.sem); +end_nosem: if (ec->common.global_lock) acpi_release_global_lock(glk); - return_VALUE(result); + return result; } static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data) { int result = 0; acpi_status status = AE_OK; - unsigned long flags = 0; u32 glk = 0; - ACPI_FUNCTION_TRACE("acpi_ec_write"); - if (!ec) - return_VALUE(-EINVAL); + return -EINVAL; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; } - spin_lock_irqsave(&ec->poll.lock, flags); - + if (down_interruptible(&ec->poll.sem)) { + result = -ERESTARTSYS; + goto end_nosem; + } + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); @@ -406,12 +400,12 @@ static int acpi_ec_poll_write(union acpi data, address)); end: - spin_unlock_irqrestore(&ec->poll.lock, flags); - + up(&ec->poll.sem); +end_nosem: if (ec->common.global_lock) acpi_release_global_lock(glk); - return_VALUE(result); + return result; } static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) @@ -419,17 +413,15 @@ static int acpi_ec_intr_read(union acpi_ int status = 0; u32 glk; - ACPI_FUNCTION_TRACE("acpi_ec_read"); - if (!ec || !data) - return_VALUE(-EINVAL); + return -EINVAL; *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; } WARN_ON(in_interrupt()); @@ -463,7 +455,7 @@ static int acpi_ec_intr_read(union acpi_ if (ec->common.global_lock) acpi_release_global_lock(glk); - return_VALUE(status); + return status; } static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) @@ -471,15 +463,13 @@ static int acpi_ec_intr_write(union acpi int status = 0; u32 glk; - ACPI_FUNCTION_TRACE("acpi_ec_write"); - if (!ec) - return_VALUE(-EINVAL); + return -EINVAL; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; } WARN_ON(in_interrupt()); @@ -512,7 +502,7 @@ static int acpi_ec_intr_write(union acpi if (ec->common.global_lock) acpi_release_global_lock(glk); - return_VALUE(status); + return status; } /* @@ -568,20 +558,17 @@ static int acpi_ec_poll_query(union acpi { int result = 0; acpi_status status = AE_OK; - unsigned long flags = 0; u32 glk = 0; - ACPI_FUNCTION_TRACE("acpi_ec_query"); - if (!ec || !data) - return_VALUE(-EINVAL); + return -EINVAL; *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; } /* @@ -589,8 +576,11 @@ static int acpi_ec_poll_query(union acpi * Note that successful completion of the query causes the ACPI_EC_SCI * bit to be cleared (and thus clearing the interrupt source). */ - spin_lock_irqsave(&ec->poll.lock, flags); - + if (down_interruptible(&ec->poll.sem)) { + result = -ERESTARTSYS; + goto end_nosem; + } + acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr); result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); @@ -602,28 +592,26 @@ static int acpi_ec_poll_query(union acpi result = -ENODATA; end: - spin_unlock_irqrestore(&ec->poll.lock, flags); - + up(&ec->poll.sem); +end_nosem: if (ec->common.global_lock) acpi_release_global_lock(glk); - return_VALUE(result); + return result; } static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data) { int status = 0; u32 glk; - ACPI_FUNCTION_TRACE("acpi_ec_query"); - if (!ec || !data) - return_VALUE(-EINVAL); + return -EINVAL; *data = 0; if (ec->common.global_lock) { status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; } down(&ec->intr.sem); @@ -656,7 +644,7 @@ static int acpi_ec_intr_query(union acpi if (ec->common.global_lock) acpi_release_global_lock(glk); - return_VALUE(status); + return status; } /* -------------------------------------------------------------------------- @@ -680,20 +668,19 @@ static void acpi_ec_gpe_poll_query(void { union acpi_ec *ec = (union acpi_ec *)ec_cxt; u32 value = 0; - unsigned long flags = 0; static char object_name[5] = { '_', 'Q', '0', '0', '\0' }; const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); - if (!ec_cxt) goto end; - spin_lock_irqsave(&ec->poll.lock, flags); + if (down_interruptible (&ec->poll.sem)) { + return_VOID; + } acpi_hw_low_level_read(8, &value, &ec->common.command_addr); - spin_unlock_irqrestore(&ec->poll.lock, flags); + up(&ec->poll.sem); /* TBD: Implement asynch events! * NOTE: All we care about are EC-SCI's. Other EC events are @@ -727,8 +714,6 @@ static void acpi_ec_gpe_intr_query(void '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - ACPI_FUNCTION_TRACE("acpi_ec_gpe_query"); - if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) result = acpi_ec_query(ec, &value); @@ -763,8 +748,7 @@ static u32 acpi_ec_gpe_poll_handler(void acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); - status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, - acpi_ec_gpe_query, ec); + status = acpi_os_execute(OSL_EC_POLL_HANDLER, acpi_ec_gpe_query, ec); if (status == AE_OK) return ACPI_INTERRUPT_HANDLED; @@ -799,7 +783,7 @@ static u32 acpi_ec_gpe_intr_handler(void if (value & ACPI_EC_FLAG_SCI) { atomic_add(1, &ec->intr.pending_gpe); - status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, + status = acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec); return status == AE_OK ? ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; @@ -840,15 +824,13 @@ acpi_ec_space_handler(u32 function, acpi_integer f_v = 0; int i = 0; - ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); - if ((address > 0xFF) || !value || !handler_context) - return_VALUE(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; if (bit_width != 8 && acpi_strict) { printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n"); - return_VALUE(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; } ec = (union acpi_ec *)handler_context; @@ -887,16 +869,16 @@ acpi_ec_space_handler(u32 function, out: switch (result) { case -EINVAL: - return_VALUE(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; break; case -ENODEV: - return_VALUE(AE_NOT_FOUND); + return AE_NOT_FOUND; break; case -ETIME: - return_VALUE(AE_TIME); + return AE_TIME; break; default: - return_VALUE(AE_OK); + return AE_OK; } } @@ -910,8 +892,6 @@ static int acpi_ec_read_info(struct seq_ { union acpi_ec *ec = (union acpi_ec *)seq->private; - ACPI_FUNCTION_TRACE("acpi_ec_read_info"); - if (!ec) goto end; @@ -925,7 +905,7 @@ static int acpi_ec_read_info(struct seq_ acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); end: - return_VALUE(0); + return 0; } static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) @@ -945,41 +925,35 @@ static int acpi_ec_add_fs(struct acpi_de { struct proc_dir_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); - if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_ec_dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; } entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Unable to create '%s' fs entry\n", - ACPI_EC_FILE_INFO)); + return -ENODEV; else { entry->proc_fops = &acpi_ec_info_ops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return_VALUE(0); + return 0; } static int acpi_ec_remove_fs(struct acpi_device *device) { - ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); - if (acpi_device_dir(device)) { remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device)); remove_proc_entry(acpi_device_bid(device), acpi_ec_dir); acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -991,21 +965,18 @@ static int acpi_ec_poll_add(struct acpi_ int result = 0; acpi_status status = AE_OK; union acpi_ec *ec = NULL; - unsigned long uid; - - ACPI_FUNCTION_TRACE("acpi_ec_add"); if (!device) - return_VALUE(-EINVAL); + return -EINVAL; ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); if (!ec) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(ec, 0, sizeof(union acpi_ec)); ec->common.handle = device->handle; ec->common.uid = -1; - spin_lock_init(&ec->poll.lock); + init_MUTEX(&ec->poll.sem); strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_EC_CLASS); acpi_driver_data(device) = ec; @@ -1014,10 +985,9 @@ static int acpi_ec_poll_add(struct acpi_ acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); - /* If our UID matches the UID for the ECDT-enumerated EC, - we now have the *real* EC info, so kill the makeshift one. */ - acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); - if (ec_ecdt && ec_ecdt->common.uid == uid) { + /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: + http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ + if (ec_ecdt) { acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); @@ -1034,8 +1004,7 @@ static int acpi_ec_poll_add(struct acpi_ acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error obtaining GPE bit assignment\n")); + ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit")); result = -ENODEV; goto end; } @@ -1055,23 +1024,20 @@ static int acpi_ec_poll_add(struct acpi_ if (result) kfree(ec); - return_VALUE(result); + return result; } static int acpi_ec_intr_add(struct acpi_device *device) { int result = 0; acpi_status status = AE_OK; union acpi_ec *ec = NULL; - unsigned long uid; - - ACPI_FUNCTION_TRACE("acpi_ec_add"); if (!device) - return_VALUE(-EINVAL); + return -EINVAL; ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); if (!ec) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(ec, 0, sizeof(union acpi_ec)); ec->common.handle = device->handle; @@ -1088,10 +1054,9 @@ static int acpi_ec_intr_add(struct acpi_ acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock); - /* If our UID matches the UID for the ECDT-enumerated EC, - we now have the *real* EC info, so kill the makeshift one. */ - acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid); - if (ec_ecdt && ec_ecdt->common.uid == uid) { + /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: + http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ + if (ec_ecdt) { acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); @@ -1108,8 +1073,7 @@ static int acpi_ec_intr_add(struct acpi_ acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error obtaining GPE bit assignment\n")); + ACPI_ERROR((AE_INFO, "Obtaining GPE bit assignment")); result = -ENODEV; goto end; } @@ -1129,17 +1093,15 @@ static int acpi_ec_intr_add(struct acpi_ if (result) kfree(ec); - return_VALUE(result); + return result; } static int acpi_ec_remove(struct acpi_device *device, int type) { union acpi_ec *ec = NULL; - ACPI_FUNCTION_TRACE("acpi_ec_remove"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; ec = acpi_driver_data(device); @@ -1147,7 +1109,7 @@ static int acpi_ec_remove(struct acpi_de kfree(ec); - return_VALUE(0); + return 0; } static acpi_status @@ -1186,15 +1148,13 @@ static int acpi_ec_start(struct acpi_dev acpi_status status = AE_OK; union acpi_ec *ec = NULL; - ACPI_FUNCTION_TRACE("acpi_ec_start"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; ec = acpi_driver_data(device); if (!ec) - return_VALUE(-EINVAL); + return -EINVAL; /* * Get I/O port addresses. Convert to GAS format. @@ -1203,9 +1163,8 @@ static int acpi_ec_start(struct acpi_dev acpi_ec_io_ports, ec); if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error getting I/O port addresses")); - return_VALUE(-ENODEV); + ACPI_ERROR((AE_INFO, "Error getting I/O port addresses")); + return -ENODEV; } ec->common.status_addr = ec->common.command_addr; @@ -1222,7 +1181,7 @@ static int acpi_ec_start(struct acpi_dev ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); if (ACPI_FAILURE(status)) { - return_VALUE(-ENODEV); + return -ENODEV; } acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); @@ -1234,10 +1193,10 @@ static int acpi_ec_start(struct acpi_dev if (ACPI_FAILURE(status)) { acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(AE_OK); + return AE_OK; } static int acpi_ec_stop(struct acpi_device *device, int type) @@ -1245,10 +1204,8 @@ static int acpi_ec_stop(struct acpi_devi acpi_status status = AE_OK; union acpi_ec *ec = NULL; - ACPI_FUNCTION_TRACE("acpi_ec_stop"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; ec = acpi_driver_data(device); @@ -1256,15 +1213,15 @@ static int acpi_ec_stop(struct acpi_devi ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; - return_VALUE(0); + return 0; } static acpi_status __init @@ -1300,7 +1257,7 @@ acpi_fake_ecdt_poll_callback(acpi_handle &ec_ecdt->common.gpe_bit); if (ACPI_FAILURE(status)) return status; - spin_lock_init(&ec_ecdt->poll.lock); + init_MUTEX(&ec_ecdt->poll.sem); ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.handle = handle; @@ -1416,7 +1373,7 @@ static int __init acpi_ec_poll_get_real_ ec_ecdt->common.status_addr = ecdt_ptr->ec_control; ec_ecdt->common.data_addr = ecdt_ptr->ec_data; ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit; - spin_lock_init(&ec_ecdt->poll.lock); + init_MUTEX(&ec_ecdt->poll.sem); /* use the GL just to be safe */ ec_ecdt->common.global_lock = TRUE; ec_ecdt->common.uid = ecdt_ptr->uid; @@ -1534,23 +1491,21 @@ static int __init acpi_ec_init(void) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_ec_init"); - if (acpi_disabled) - return_VALUE(0); + return 0; acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); if (!acpi_ec_dir) - return_VALUE(-ENODEV); + return -ENODEV; /* Now register the driver for the EC */ result = acpi_bus_register_driver(&acpi_ec_driver); if (result < 0) { remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(result); + return result; } subsys_initcall(acpi_ec_init); @@ -1559,13 +1514,10 @@ subsys_initcall(acpi_ec_init); #if 0 static void __exit acpi_ec_exit(void) { - ACPI_FUNCTION_TRACE("acpi_ec_exit"); - acpi_bus_unregister_driver(&acpi_ec_driver); remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); - return_VOID; } #endif /* 0 */ diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index 2dbb1b0..ed27d8e 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c @@ -48,18 +48,16 @@ acpi_system_read_event(struct file *file static int chars_remaining = 0; static char *ptr; - ACPI_FUNCTION_TRACE("acpi_system_read_event"); - if (!chars_remaining) { memset(&event, 0, sizeof(struct acpi_bus_event)); if ((file->f_flags & O_NONBLOCK) && (list_empty(&acpi_bus_event_list))) - return_VALUE(-EAGAIN); + return -EAGAIN; result = acpi_bus_receive_event(&event); if (result) - return_VALUE(result); + return result; chars_remaining = sprintf(str, "%s %s %08x %08x\n", event.device_class ? event. @@ -75,13 +73,13 @@ acpi_system_read_event(struct file *file } if (copy_to_user(buffer, ptr, count)) - return_VALUE(-EFAULT); + return -EFAULT; *ppos += count; chars_remaining -= count; ptr += count; - return_VALUE(count); + return count; } static int acpi_system_close_event(struct inode *inode, struct file *file) @@ -112,22 +110,17 @@ static int __init acpi_event_init(void) struct proc_dir_entry *entry; int error = 0; - ACPI_FUNCTION_TRACE("acpi_event_init"); - if (acpi_disabled) - return_VALUE(0); + return 0; /* 'event' [R] */ entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); if (entry) entry->proc_fops = &acpi_system_event_ops; else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' proc fs entry\n", - "event")); - error = -EFAULT; + error = -ENODEV; } - return_VALUE(error); + return error; } subsys_initcall(acpi_event_init); diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c index c9ac05c..c8d9752 100644 --- a/drivers/acpi/events/evevent.c +++ b/drivers/acpi/events/evevent.c @@ -260,12 +260,14 @@ u32 acpi_ev_fixed_event_detect(void) * Check for all possible Fixed Events and dispatch those that are active */ for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { + /* Both the status and enable bits must be on for this event */ if ((fixed_status & acpi_gbl_fixed_event_info[i]. status_bit_mask) && (fixed_enable & acpi_gbl_fixed_event_info[i]. enable_bit_mask)) { + /* Found an active (signalled) event */ int_status |= acpi_ev_fixed_event_dispatch((u32) i); diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index f64f977..32ef12b 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -207,6 +207,7 @@ acpi_ev_enable_gpe(struct acpi_gpe_event ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); if (write_to_hardware) { + /* Clear the GPE (of stale events), then enable it */ status = acpi_hw_clear_gpe(gpe_event_info); @@ -313,6 +314,7 @@ struct acpi_gpe_event_info *acpi_ev_get_ /* A NULL gpe_block means use the FADT-defined GPE block(s) */ if (!gpe_device) { + /* Examine GPE Block 0 and 1 (These blocks are permanent) */ for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { @@ -402,6 +404,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_x * Find all currently active GP events. */ for (i = 0; i < gpe_block->register_count; i++) { + /* Get the next status/enable pair */ gpe_register_info = &gpe_block->register_info[i]; @@ -437,6 +440,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_x enabled_status_byte = (u8) (status_reg & enable_reg); if (!enabled_status_byte) { + /* No active GPEs in this register, move on */ continue; @@ -445,6 +449,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_x /* Now look at the individual GPEs in this byte register */ for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { + /* Examine one GPE bit */ if (enabled_status_byte & @@ -669,9 +674,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_eve * Execute the method associated with the GPE * NOTE: Level-triggered GPEs are cleared after the method completes. */ - status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, - acpi_ev_asynch_execute_gpe_method, - gpe_event_info); + status = acpi_os_execute(OSL_GPE_HANDLER, acpi_ev_asynch_execute_gpe_method, gpe_event_info); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Unable to queue handler for GPE[%2X] - event disabled", diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index 0fd00b5..e8e7298 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c @@ -146,10 +146,12 @@ acpi_status acpi_ev_walk_gpe_list(ACPI_G gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; while (gpe_xrupt_info) { + /* Walk all Gpe Blocks attached to this interrupt level */ gpe_block = gpe_xrupt_info->gpe_block_list_head; while (gpe_block) { + /* One callback per GPE block */ status = gpe_walk_callback(gpe_xrupt_info, gpe_block); @@ -195,6 +197,7 @@ acpi_ev_delete_gpe_handlers(struct acpi_ /* Examine each GPE Register within the block */ for (i = 0; i < gpe_block->register_count; i++) { + /* Now look at the individual GPEs in this byte register */ for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { @@ -204,7 +207,7 @@ acpi_ev_delete_gpe_handlers(struct acpi_ if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { - ACPI_MEM_FREE(gpe_event_info->dispatch.handler); + ACPI_FREE(gpe_event_info->dispatch.handler); gpe_event_info->dispatch.handler = NULL; gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK; @@ -289,6 +292,7 @@ acpi_ev_save_method_info(acpi_handle obj gpe_number = ACPI_STRTOUL(&name[2], NULL, 16); if (gpe_number == ACPI_UINT32_MAX) { + /* Conversion failed; invalid method, just ignore it */ ACPI_ERROR((AE_INFO, @@ -371,6 +375,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle ob status = acpi_ut_evaluate_object(obj_handle, METHOD_NAME__PRW, ACPI_BTYPE_PACKAGE, &pkg_desc); if (ACPI_FAILURE(status)) { + /* Ignore all errors from _PRW, we don't want to abort the subsystem */ return_ACPI_STATUS(AE_OK); @@ -394,6 +399,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle ob obj_desc = pkg_desc->package.elements[0]; if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + /* Use FADT-defined GPE device (from definition of _PRW) */ target_gpe_device = acpi_gbl_fadt_gpe_device; @@ -402,6 +408,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle ob gpe_number = (u32) obj_desc->integer.value; } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { + /* Package contains a GPE reference and GPE number within a GPE block */ if ((obj_desc->package.count < 2) || @@ -497,7 +504,7 @@ static struct acpi_gpe_xrupt_info *acpi_ /* Not found, must allocate a new xrupt descriptor */ - gpe_xrupt = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_xrupt_info)); + gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); if (!gpe_xrupt) { return_PTR(NULL); } @@ -588,7 +595,7 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe /* Free the block */ - ACPI_MEM_FREE(gpe_xrupt); + ACPI_FREE(gpe_xrupt); return_ACPI_STATUS(AE_OK); } @@ -679,6 +686,7 @@ acpi_status acpi_ev_delete_gpe_block(str status = acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block); if (!gpe_block->previous && !gpe_block->next) { + /* This is the last gpe_block on this interrupt */ status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block); @@ -704,9 +712,9 @@ acpi_status acpi_ev_delete_gpe_block(str /* Free the gpe_block */ - ACPI_MEM_FREE(gpe_block->register_info); - ACPI_MEM_FREE(gpe_block->event_info); - ACPI_MEM_FREE(gpe_block); + ACPI_FREE(gpe_block->register_info); + ACPI_FREE(gpe_block->event_info); + ACPI_FREE(gpe_block); unlock_and_exit: status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); @@ -740,10 +748,10 @@ acpi_ev_create_gpe_info_blocks(struct ac /* Allocate the GPE register information block */ - gpe_register_info = ACPI_MEM_CALLOCATE((acpi_size) gpe_block-> - register_count * - sizeof(struct - acpi_gpe_register_info)); + gpe_register_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block-> + register_count * + sizeof(struct + acpi_gpe_register_info)); if (!gpe_register_info) { ACPI_ERROR((AE_INFO, "Could not allocate the gpe_register_info table")); @@ -754,10 +762,11 @@ acpi_ev_create_gpe_info_blocks(struct ac * Allocate the GPE event_info block. There are eight distinct GPEs * per register. Initialization to zeros is sufficient. */ - gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block-> - register_count * - ACPI_GPE_REGISTER_WIDTH) * - sizeof(struct acpi_gpe_event_info)); + gpe_event_info = ACPI_ALLOCATE_ZEROED(((acpi_size) gpe_block-> + register_count * + ACPI_GPE_REGISTER_WIDTH) * + sizeof(struct + acpi_gpe_event_info)); if (!gpe_event_info) { ACPI_ERROR((AE_INFO, "Could not allocate the gpe_event_info table")); @@ -780,6 +789,7 @@ acpi_ev_create_gpe_info_blocks(struct ac this_event = gpe_event_info; for (i = 0; i < gpe_block->register_count; i++) { + /* Init the register_info for this GPE register (8 GPEs) */ this_register->base_gpe_number = @@ -839,10 +849,10 @@ acpi_ev_create_gpe_info_blocks(struct ac error_exit: if (gpe_register_info) { - ACPI_MEM_FREE(gpe_register_info); + ACPI_FREE(gpe_register_info); } if (gpe_event_info) { - ACPI_MEM_FREE(gpe_event_info); + ACPI_FREE(gpe_event_info); } return_ACPI_STATUS(status); @@ -886,7 +896,7 @@ acpi_ev_create_gpe_block(struct acpi_nam /* Allocate a new GPE block */ - gpe_block = ACPI_MEM_CALLOCATE(sizeof(struct acpi_gpe_block_info)); + gpe_block = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_block_info)); if (!gpe_block) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -906,7 +916,7 @@ acpi_ev_create_gpe_block(struct acpi_nam */ status = acpi_ev_create_gpe_info_blocks(gpe_block); if (ACPI_FAILURE(status)) { - ACPI_MEM_FREE(gpe_block); + ACPI_FREE(gpe_block); return_ACPI_STATUS(status); } @@ -914,7 +924,7 @@ acpi_ev_create_gpe_block(struct acpi_nam status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); if (ACPI_FAILURE(status)) { - ACPI_MEM_FREE(gpe_block); + ACPI_FREE(gpe_block); return_ACPI_STATUS(status); } @@ -1013,6 +1023,7 @@ acpi_ev_initialize_gpe_block(struct acpi for (i = 0; i < gpe_block->register_count; i++) { for (j = 0; j < 8; j++) { + /* Get the info block for this particular GPE */ gpe_event_info = @@ -1099,6 +1110,7 @@ acpi_status acpi_ev_gpe_initialize(void) * particular block is not supported. */ if (acpi_gbl_FADT->gpe0_blk_len && acpi_gbl_FADT->xgpe0_blk.address) { + /* GPE block 0 exists (has both length and address > 0) */ register_count0 = (u16) (acpi_gbl_FADT->gpe0_blk_len / 2); @@ -1121,6 +1133,7 @@ acpi_status acpi_ev_gpe_initialize(void) } if (acpi_gbl_FADT->gpe1_blk_len && acpi_gbl_FADT->xgpe1_blk.address) { + /* GPE block 1 exists (has both length and address > 0) */ register_count1 = (u16) (acpi_gbl_FADT->gpe1_blk_len / 2); @@ -1168,6 +1181,7 @@ acpi_status acpi_ev_gpe_initialize(void) /* Exit if there are no GPE registers */ if ((register_count0 + register_count1) == 0) { + /* GPEs are not required by ACPI, this is OK */ ACPI_DEBUG_PRINT((ACPI_DB_INIT, diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 0909ba6..8d820f1 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c @@ -150,6 +150,7 @@ acpi_ev_queue_notify_request(struct acpi obj_desc = acpi_ns_get_attached_object(node); if (obj_desc) { + /* We have the notify object, Get the right handler */ switch (node->type) { @@ -189,9 +190,8 @@ acpi_ev_queue_notify_request(struct acpi notify_info->notify.value = (u16) notify_value; notify_info->notify.handler_obj = handler_obj; - status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH, - acpi_ev_notify_dispatch, - notify_info); + status = acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_notify_dispatch, notify_info); + if (ACPI_FAILURE(status)) { acpi_ut_delete_generic_state(notify_info); } @@ -240,6 +240,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_no * to the device. */ if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) { + /* Global system notification handler */ if (acpi_gbl_system_notify.handler) { @@ -297,6 +298,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_gl /* Signal threads that are waiting for the lock */ if (acpi_gbl_global_lock_thread_count) { + /* Send sufficient units to the semaphore */ status = @@ -335,15 +337,16 @@ static u32 acpi_ev_global_lock_handler(v */ ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired); if (acquired) { + /* Got the lock, now wake all threads waiting for it */ acpi_gbl_global_lock_acquired = TRUE; /* Run the Global Lock thread which will signal all waiting threads */ - status = acpi_os_queue_for_execution(OSD_PRIORITY_HIGH, - acpi_ev_global_lock_thread, - context); + status = acpi_os_execute(OSL_NOTIFY_HANDLER, + acpi_ev_global_lock_thread, + context); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Could not queue Global Lock thread")); @@ -439,6 +442,7 @@ #endif ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_common_fACS.global_lock, acquired); if (acquired) { + /* We got the lock */ ACPI_DEBUG_PRINT((ACPI_DB_EXEC, @@ -492,6 +496,7 @@ acpi_status acpi_ev_release_global_lock( acpi_gbl_global_lock_thread_count--; if (acpi_gbl_global_lock_thread_count) { + /* There are still some threads holding the lock, cannot release */ return_ACPI_STATUS(AE_OK); diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c index 6da58e7..2b900ef 100644 --- a/drivers/acpi/events/evregion.c +++ b/drivers/acpi/events/evregion.c @@ -164,6 +164,7 @@ acpi_status acpi_ev_initialize_op_region * Run the _REG methods for op_regions in each default address space */ for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { + /* TBD: Make sure handler is the DEFAULT handler, otherwise * _REG will have already been run. */ @@ -315,6 +316,7 @@ acpi_ev_address_space_dispatch(union acp */ region_setup = handler_desc->address_space.setup; if (!region_setup) { + /* No initialization routine, exit with error */ ACPI_ERROR((AE_INFO, @@ -361,9 +363,10 @@ acpi_ev_address_space_dispatch(union acp region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE; if (region_obj2->extra.region_context) { + /* The handler for this region was already installed */ - ACPI_MEM_FREE(region_context); + ACPI_FREE(region_context); } else { /* * Save the returned context for use in all accesses to @@ -463,6 +466,7 @@ acpi_ev_detach_region(union acpi_operand handler_obj = region_obj->region.handler; if (!handler_obj) { + /* This region has no handler, all done */ return_VOID; @@ -474,6 +478,7 @@ acpi_ev_detach_region(union acpi_operand last_obj_ptr = &handler_obj->address_space.region_list; while (obj_desc) { + /* Is this the correct Region? */ if (obj_desc == region_obj) { @@ -666,6 +671,7 @@ acpi_ev_install_handler(acpi_handle obj_ obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { + /* No object, just exit */ return (AE_OK); @@ -674,10 +680,12 @@ acpi_ev_install_handler(acpi_handle obj_ /* Devices are handled different than regions */ if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) { + /* Check if this Device already has a handler for this address space */ next_handler_obj = obj_desc->device.handler; while (next_handler_obj) { + /* Found a handler, is it for the same address space? */ if (next_handler_obj->address_space.space_id == @@ -839,6 +847,7 @@ acpi_ev_install_space_handler(struct acp /* Walk the handler list for this device */ while (handler_obj) { + /* Same space_id indicates a handler already installed */ if (handler_obj->address_space.space_id == space_id) { @@ -1035,6 +1044,7 @@ acpi_ev_reg_run(acpi_handle obj_handle, obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { + /* No object, just exit */ return (AE_OK); diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c index baed8c1..db98747 100644 --- a/drivers/acpi/events/evrgnini.c +++ b/drivers/acpi/events/evrgnini.c @@ -75,7 +75,7 @@ acpi_ev_system_memory_region_setup(acpi_ if (function == ACPI_REGION_DEACTIVATE) { if (*region_context) { - ACPI_MEM_FREE(*region_context); + ACPI_FREE(*region_context); *region_context = NULL; } return_ACPI_STATUS(AE_OK); @@ -84,7 +84,7 @@ acpi_ev_system_memory_region_setup(acpi_ /* Create a new context */ local_region_context = - ACPI_MEM_CALLOCATE(sizeof(struct acpi_mem_space_context)); + ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_mem_space_context)); if (!(local_region_context)) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -178,7 +178,7 @@ acpi_ev_pci_config_region_setup(acpi_han *region_context = NULL; if (function == ACPI_REGION_DEACTIVATE) { if (pci_id) { - ACPI_MEM_FREE(pci_id); + ACPI_FREE(pci_id); } return_ACPI_STATUS(status); } @@ -199,6 +199,7 @@ acpi_ev_pci_config_region_setup(acpi_han * handlers with that device. */ if (handler_obj->address_space.node == acpi_gbl_root_node) { + /* Start search from the parent object */ pci_root_node = parent_node; @@ -220,6 +221,7 @@ acpi_ev_pci_config_region_setup(acpi_han PCI_EXPRESS_ROOT_HID_STRING, sizeof(PCI_EXPRESS_ROOT_HID_STRING))))) { + /* Install a handler for this PCI root bridge */ status = @@ -262,7 +264,7 @@ acpi_ev_pci_config_region_setup(acpi_han /* Region is still not initialized. Create a new context */ - pci_id = ACPI_MEM_CALLOCATE(sizeof(struct acpi_pci_id)); + pci_id = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pci_id)); if (!pci_id) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -478,11 +480,13 @@ acpi_ev_initialize_region(union acpi_ope * ie: acpi_gbl_root_node->parent_entry being set to NULL */ while (node) { + /* Check to see if a handler exists */ handler_obj = NULL; obj_desc = acpi_ns_get_attached_object(node); if (obj_desc) { + /* Can only be a handler if the object exists */ switch (node->type) { @@ -507,10 +511,12 @@ acpi_ev_initialize_region(union acpi_ope } while (handler_obj) { + /* Is this handler of the correct type? */ if (handler_obj->address_space.space_id == space_id) { + /* Found correct handler */ ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index b38b39d..da9cf36 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include #include @@ -90,6 +88,8 @@ acpi_status acpi_install_exception_handl (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); return_ACPI_STATUS(status); } + +ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) #endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* @@ -107,7 +107,6 @@ #endif /* ACPI_FUTURE_USAGE */ * event. * ******************************************************************************/ - acpi_status acpi_install_fixed_event_handler(u32 event, acpi_event_handler handler, void *context) @@ -161,7 +160,7 @@ acpi_install_fixed_event_handler(u32 eve return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_fixed_event_handler); +ACPI_EXPORT_SYMBOL(acpi_install_fixed_event_handler) /******************************************************************************* * @@ -175,7 +174,6 @@ EXPORT_SYMBOL(acpi_install_fixed_event_h * DESCRIPTION: Disables the event and unregisters the event handler. * ******************************************************************************/ - acpi_status acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) { @@ -216,7 +214,7 @@ acpi_remove_fixed_event_handler(u32 even return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_fixed_event_handler); +ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler) /******************************************************************************* * @@ -235,7 +233,6 @@ EXPORT_SYMBOL(acpi_remove_fixed_event_ha * DESCRIPTION: Install a handler for notifies on an ACPI device * ******************************************************************************/ - acpi_status acpi_install_notify_handler(acpi_handle device, u32 handler_type, @@ -275,6 +272,7 @@ acpi_install_notify_handler(acpi_handle * only one global handler can be regsitered (per notify type). */ if (device == ACPI_ROOT_OBJECT) { + /* Make sure the handler is not already installed */ if (((handler_type & ACPI_SYSTEM_NOTIFY) && @@ -317,6 +315,7 @@ acpi_install_notify_handler(acpi_handle obj_desc = acpi_ns_get_attached_object(node); if (obj_desc) { + /* Object exists - make sure there's no handler */ if (((handler_type & ACPI_SYSTEM_NOTIFY) && @@ -370,6 +369,7 @@ acpi_install_notify_handler(acpi_handle } if (handler_type == ACPI_ALL_NOTIFY) { + /* Extra ref if installed in both */ acpi_ut_add_reference(notify_obj); @@ -381,7 +381,7 @@ acpi_install_notify_handler(acpi_handle return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_notify_handler); +ACPI_EXPORT_SYMBOL(acpi_install_notify_handler) /******************************************************************************* * @@ -399,7 +399,6 @@ EXPORT_SYMBOL(acpi_install_notify_handle * DESCRIPTION: Remove a handler for notifies on an ACPI device * ******************************************************************************/ - acpi_status acpi_remove_notify_handler(acpi_handle device, u32 handler_type, acpi_notify_handler handler) @@ -415,12 +414,13 @@ acpi_remove_notify_handler(acpi_handle d if ((!device) || (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { - return_ACPI_STATUS(AE_BAD_PARAMETER); + status = AE_BAD_PARAMETER; + goto exit; } status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto exit; } /* Convert and validate the device handle */ @@ -428,7 +428,7 @@ acpi_remove_notify_handler(acpi_handle d node = acpi_ns_map_handle_to_node(device); if (!node) { status = AE_BAD_PARAMETER; - goto unlock_and_exit; + goto unlock; } /* Root Object */ @@ -442,7 +442,7 @@ acpi_remove_notify_handler(acpi_handle d ((handler_type & ACPI_DEVICE_NOTIFY) && !acpi_gbl_device_notify.handler)) { status = AE_NOT_EXIST; - goto unlock_and_exit; + goto unlock; } /* Make sure all deferred tasks are completed */ @@ -451,7 +451,7 @@ acpi_remove_notify_handler(acpi_handle d acpi_os_wait_events_complete(NULL); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto exit; } if (handler_type & ACPI_SYSTEM_NOTIFY) { @@ -474,7 +474,7 @@ acpi_remove_notify_handler(acpi_handle d if (!acpi_ev_is_notify_object(node)) { status = AE_TYPE; - goto unlock_and_exit; + goto unlock; } /* Check for an existing internal object */ @@ -482,7 +482,7 @@ acpi_remove_notify_handler(acpi_handle d obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { status = AE_NOT_EXIST; - goto unlock_and_exit; + goto unlock; } /* Object exists - make sure there's an existing handler */ @@ -492,7 +492,7 @@ acpi_remove_notify_handler(acpi_handle d if ((!notify_obj) || (notify_obj->notify.handler != handler)) { status = AE_BAD_PARAMETER; - goto unlock_and_exit; + goto unlock; } /* Make sure all deferred tasks are completed */ @@ -500,7 +500,7 @@ acpi_remove_notify_handler(acpi_handle d acpi_os_wait_events_complete(NULL); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto exit; } /* Remove the handler */ @@ -513,7 +513,7 @@ acpi_remove_notify_handler(acpi_handle d if ((!notify_obj) || (notify_obj->notify.handler != handler)) { status = AE_BAD_PARAMETER; - goto unlock_and_exit; + goto unlock; } /* Make sure all deferred tasks are completed */ @@ -521,7 +521,7 @@ acpi_remove_notify_handler(acpi_handle d acpi_os_wait_events_complete(NULL); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto exit; } /* Remove the handler */ @@ -530,12 +530,15 @@ acpi_remove_notify_handler(acpi_handle d } } - unlock_and_exit: +unlock: (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); +exit: + if (ACPI_FAILURE(status)) + ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler")); return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_notify_handler); +ACPI_EXPORT_SYMBOL(acpi_remove_notify_handler) /******************************************************************************* * @@ -554,7 +557,6 @@ EXPORT_SYMBOL(acpi_remove_notify_handler * DESCRIPTION: Install a handler for a General Purpose Event. * ******************************************************************************/ - acpi_status acpi_install_gpe_handler(acpi_handle gpe_device, u32 gpe_number, @@ -570,12 +572,13 @@ acpi_install_gpe_handler(acpi_handle gpe /* Parameter validation */ if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { - return_ACPI_STATUS(AE_BAD_PARAMETER); + status = AE_BAD_PARAMETER; + goto exit; } status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + goto exit; } /* Ensure that we have a valid GPE number */ @@ -583,7 +586,7 @@ acpi_install_gpe_handler(acpi_handle gpe gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); if (!gpe_event_info) { status = AE_BAD_PARAMETER; - goto unlock_and_exit; + goto unlock; } /* Make sure that there isn't a handler there already */ @@ -591,15 +594,15 @@ acpi_install_gpe_handler(acpi_handle gpe if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { status = AE_ALREADY_EXISTS; - goto unlock_and_exit; + goto unlock; } /* Allocate and init handler object */ - handler = ACPI_MEM_CALLOCATE(sizeof(struct acpi_handler_info)); + handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); if (!handler) { status = AE_NO_MEMORY; - goto unlock_and_exit; + goto unlock; } handler->address = address; @@ -610,7 +613,7 @@ acpi_install_gpe_handler(acpi_handle gpe status = acpi_ev_disable_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - goto unlock_and_exit; + goto unlock; } /* Install the handler */ @@ -625,12 +628,16 @@ acpi_install_gpe_handler(acpi_handle gpe acpi_os_release_lock(acpi_gbl_gpe_lock, flags); - unlock_and_exit: +unlock: (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); +exit: + if (ACPI_FAILURE(status)) + ACPI_EXCEPTION((AE_INFO, status, + "Installing notify handler failed")); return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_gpe_handler); +ACPI_EXPORT_SYMBOL(acpi_install_gpe_handler) /******************************************************************************* * @@ -646,7 +653,6 @@ EXPORT_SYMBOL(acpi_install_gpe_handler); * DESCRIPTION: Remove a handler for a General Purpose acpi_event. * ******************************************************************************/ - acpi_status acpi_remove_gpe_handler(acpi_handle gpe_device, u32 gpe_number, acpi_event_handler address) @@ -724,14 +730,14 @@ acpi_remove_gpe_handler(acpi_handle gpe_ /* Now we can free the handler object */ - ACPI_MEM_FREE(handler); + ACPI_FREE(handler); unlock_and_exit: (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_gpe_handler); +ACPI_EXPORT_SYMBOL(acpi_remove_gpe_handler) /******************************************************************************* * @@ -746,7 +752,6 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler); * DESCRIPTION: Acquire the ACPI Global Lock * ******************************************************************************/ - acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle) { acpi_status status; @@ -771,7 +776,7 @@ acpi_status acpi_acquire_global_lock(u16 return (status); } -EXPORT_SYMBOL(acpi_acquire_global_lock); +ACPI_EXPORT_SYMBOL(acpi_acquire_global_lock) /******************************************************************************* * @@ -784,7 +789,6 @@ EXPORT_SYMBOL(acpi_acquire_global_lock); * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid. * ******************************************************************************/ - acpi_status acpi_release_global_lock(u32 handle) { acpi_status status; @@ -797,4 +801,4 @@ acpi_status acpi_release_global_lock(u32 return (status); } -EXPORT_SYMBOL(acpi_release_global_lock); +ACPI_EXPORT_SYMBOL(acpi_release_global_lock) diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index ec9ce84..4a36559 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include #include @@ -94,6 +92,8 @@ acpi_status acpi_enable(void) return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_enable) + /******************************************************************************* * * FUNCTION: acpi_disable @@ -105,7 +105,6 @@ acpi_status acpi_enable(void) * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. * ******************************************************************************/ - acpi_status acpi_disable(void) { acpi_status status = AE_OK; @@ -137,6 +136,8 @@ acpi_status acpi_disable(void) return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_disable) + /******************************************************************************* * * FUNCTION: acpi_enable_event @@ -149,7 +150,6 @@ acpi_status acpi_disable(void) * DESCRIPTION: Enable an ACPI event (fixed) * ******************************************************************************/ - acpi_status acpi_enable_event(u32 event, u32 flags) { acpi_status status = AE_OK; @@ -193,7 +193,7 @@ acpi_status acpi_enable_event(u32 event, return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_enable_event); +ACPI_EXPORT_SYMBOL(acpi_enable_event) /******************************************************************************* * @@ -208,7 +208,6 @@ EXPORT_SYMBOL(acpi_enable_event); * DESCRIPTION: Set the type of an individual GPE * ******************************************************************************/ - acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type) { acpi_status status = AE_OK; @@ -236,7 +235,7 @@ acpi_status acpi_set_gpe_type(acpi_handl return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_set_gpe_type); +ACPI_EXPORT_SYMBOL(acpi_set_gpe_type) /******************************************************************************* * @@ -252,7 +251,6 @@ EXPORT_SYMBOL(acpi_set_gpe_type); * DESCRIPTION: Enable an ACPI event (general purpose) * ******************************************************************************/ - acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) { acpi_status status = AE_OK; @@ -288,7 +286,7 @@ acpi_status acpi_enable_gpe(acpi_handle return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_enable_gpe); +ACPI_EXPORT_SYMBOL(acpi_enable_gpe) /******************************************************************************* * @@ -304,7 +302,6 @@ EXPORT_SYMBOL(acpi_enable_gpe); * DESCRIPTION: Disable an ACPI event (general purpose) * ******************************************************************************/ - acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) { acpi_status status = AE_OK; @@ -338,6 +335,8 @@ acpi_status acpi_disable_gpe(acpi_handle return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_disable_gpe) + /******************************************************************************* * * FUNCTION: acpi_disable_event @@ -350,7 +349,6 @@ acpi_status acpi_disable_gpe(acpi_handle * DESCRIPTION: Disable an ACPI event (fixed) * ******************************************************************************/ - acpi_status acpi_disable_event(u32 event, u32 flags) { acpi_status status = AE_OK; @@ -392,7 +390,7 @@ acpi_status acpi_disable_event(u32 event return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_disable_event); +ACPI_EXPORT_SYMBOL(acpi_disable_event) /******************************************************************************* * @@ -405,7 +403,6 @@ EXPORT_SYMBOL(acpi_disable_event); * DESCRIPTION: Clear an ACPI event (fixed) * ******************************************************************************/ - acpi_status acpi_clear_event(u32 event) { acpi_status status = AE_OK; @@ -429,7 +426,7 @@ acpi_status acpi_clear_event(u32 event) return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_clear_event); +ACPI_EXPORT_SYMBOL(acpi_clear_event) /******************************************************************************* * @@ -444,7 +441,6 @@ EXPORT_SYMBOL(acpi_clear_event); * DESCRIPTION: Clear an ACPI event (general purpose) * ******************************************************************************/ - acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags) { acpi_status status = AE_OK; @@ -478,6 +474,8 @@ acpi_status acpi_clear_gpe(acpi_handle g return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_clear_gpe) + #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -492,7 +490,6 @@ #ifdef ACPI_FUTURE_USAGE * DESCRIPTION: Obtains and returns the current status of the event * ******************************************************************************/ - acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) { acpi_status status = AE_OK; @@ -518,6 +515,8 @@ acpi_status acpi_get_event_status(u32 ev return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_get_event_status) + /******************************************************************************* * * FUNCTION: acpi_get_gpe_status @@ -533,7 +532,6 @@ acpi_status acpi_get_event_status(u32 ev * DESCRIPTION: Get status of an event (general purpose) * ******************************************************************************/ - acpi_status acpi_get_gpe_status(acpi_handle gpe_device, u32 gpe_number, u32 flags, acpi_event_status * event_status) @@ -570,6 +568,8 @@ acpi_get_gpe_status(acpi_handle gpe_devi } return_ACPI_STATUS(status); } + +ACPI_EXPORT_SYMBOL(acpi_get_gpe_status) #endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* @@ -586,7 +586,6 @@ #endif /* ACPI_FUTURE_USAGE */ * DESCRIPTION: Create and Install a block of GPE registers * ******************************************************************************/ - acpi_status acpi_install_gpe_block(acpi_handle gpe_device, struct acpi_generic_address *gpe_block_address, @@ -636,6 +635,7 @@ acpi_install_gpe_block(acpi_handle gpe_d obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { + /* No object, create a new one */ obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE); @@ -665,7 +665,7 @@ acpi_install_gpe_block(acpi_handle gpe_d return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_gpe_block); +ACPI_EXPORT_SYMBOL(acpi_install_gpe_block) /******************************************************************************* * @@ -678,7 +678,6 @@ EXPORT_SYMBOL(acpi_install_gpe_block); * DESCRIPTION: Remove a previously installed block of GPE registers * ******************************************************************************/ - acpi_status acpi_remove_gpe_block(acpi_handle gpe_device) { union acpi_operand_object *obj_desc; @@ -721,4 +720,4 @@ acpi_status acpi_remove_gpe_block(acpi_h return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_gpe_block); +ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block) diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c index abf5cac..63a070b 100644 --- a/drivers/acpi/events/evxfregn.c +++ b/drivers/acpi/events/evxfregn.c @@ -42,8 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include #include @@ -114,7 +112,7 @@ acpi_install_address_space_handler(acpi_ return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_install_address_space_handler); +ACPI_EXPORT_SYMBOL(acpi_install_address_space_handler) /******************************************************************************* * @@ -129,7 +127,6 @@ EXPORT_SYMBOL(acpi_install_address_space * DESCRIPTION: Remove a previously installed handler. * ******************************************************************************/ - acpi_status acpi_remove_address_space_handler(acpi_handle device, acpi_adr_space_type space_id, @@ -176,9 +173,11 @@ acpi_remove_address_space_handler(acpi_h handler_obj = obj_desc->device.handler; last_obj_ptr = &obj_desc->device.handler; while (handler_obj) { + /* We have a handler, see if user requested this one */ if (handler_obj->address_space.space_id == space_id) { + /* Matched space_id, first dereference this in the Regions */ ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, @@ -240,4 +239,4 @@ acpi_remove_address_space_handler(acpi_h return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_remove_address_space_handler); +ACPI_EXPORT_SYMBOL(acpi_remove_address_space_handler) diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index a29782f..e0deffb 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c @@ -110,6 +110,7 @@ acpi_ex_add_table(struct acpi_table_head if (ACPI_FAILURE(status)) { if (status == AE_ALREADY_EXISTS) { + /* Table already exists, just return the handle */ return_ACPI_STATUS(AE_OK); @@ -121,6 +122,7 @@ acpi_ex_add_table(struct acpi_table_head status = acpi_ns_load_table(table_info.installed_desc, parent_node); if (ACPI_FAILURE(status)) { + /* Uninstall table on error */ (void)acpi_tb_uninstall_table(table_info.installed_desc); @@ -169,6 +171,7 @@ #if 0 */ status = acpi_tb_match_signature(operand[0]->string.pointer, NULL); if (status == AE_OK) { + /* Signature matched -- don't allow override */ return_ACPI_STATUS(AE_ALREADY_EXISTS); @@ -252,6 +255,7 @@ #endif /* Parameter Data (optional) */ if (parameter_node) { + /* Store the parameter data into the optional parameter object */ status = acpi_ex_store(operand[5], @@ -345,7 +349,7 @@ acpi_ex_load_op(union acpi_operand_objec /* Allocate a buffer for the entire table */ - table_ptr = ACPI_MEM_ALLOCATE(table_header.length); + table_ptr = ACPI_ALLOCATE(table_header.length); if (!table_ptr) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -424,6 +428,7 @@ acpi_ex_load_op(union acpi_operand_objec status = acpi_ex_add_table(table_ptr, acpi_gbl_root_node, &ddb_handle); if (ACPI_FAILURE(status)) { + /* On error, table_ptr was deallocated above */ return_ACPI_STATUS(status); @@ -442,7 +447,7 @@ acpi_ex_load_op(union acpi_operand_objec cleanup: if (ACPI_FAILURE(status)) { - ACPI_MEM_FREE(table_ptr); + ACPI_FREE(table_ptr); } return_ACPI_STATUS(status); } diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index e6d52e1..a2c93c9 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c @@ -319,6 +319,7 @@ acpi_ex_convert_to_ascii(acpi_integer in remainder = 0; for (i = decimal_length; i > 0; i--) { + /* Divide by nth factor of 10 */ digit = integer; @@ -346,6 +347,7 @@ acpi_ex_convert_to_ascii(acpi_integer in hex_length = (acpi_native_uint) ACPI_MUL_2(data_width); for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) { + /* Get one hex digit, most significant digits first */ string[k] = diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index a7cca8d..502293c 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -463,6 +463,7 @@ void acpi_ex_dump_operand(union acpi_ope } if (!obj_desc) { + /* This could be a null element of a package */ ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n")); @@ -532,6 +533,7 @@ void acpi_ex_dump_operand(union acpi_ope obj_desc->reference.offset); if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + /* Value is an Integer */ acpi_os_printf(" value is [%8.8X%8.8x]", @@ -901,7 +903,7 @@ static void acpi_ex_dump_reference_obj(u acpi_os_printf("Could not convert name to pathname\n"); } else { acpi_os_printf("%s\n", (char *)ret_buf.pointer); - ACPI_MEM_FREE(ret_buf.pointer); + ACPI_FREE(ret_buf.pointer); } } else if (obj_desc->reference.object) { acpi_os_printf("\nReferenced Object: %p\n", diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c index e259201..36c265a 100644 --- a/drivers/acpi/executer/exfield.c +++ b/drivers/acpi/executer/exfield.c @@ -142,6 +142,7 @@ acpi_ex_read_data_from_field(struct acpi length = (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length); if (length > acpi_gbl_integer_byte_width) { + /* Field is too large for an Integer, create a Buffer instead */ buffer_desc = acpi_ut_create_buffer_object(length); @@ -329,9 +330,10 @@ acpi_ex_write_data_to_field(union acpi_o ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length); if (length < required_length) { + /* We need to create a new buffer */ - new_buffer = ACPI_MEM_CALLOCATE(required_length); + new_buffer = ACPI_ALLOCATE_ZEROED(required_length); if (!new_buffer) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -375,7 +377,7 @@ acpi_ex_write_data_to_field(union acpi_o /* Free temporary buffer if we used one */ if (new_buffer) { - ACPI_MEM_FREE(new_buffer); + ACPI_FREE(new_buffer); } return_ACPI_STATUS(status); diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c index bd1af35..d5a4b26 100644 --- a/drivers/acpi/executer/exfldio.c +++ b/drivers/acpi/executer/exfldio.c @@ -113,6 +113,7 @@ acpi_ex_setup_region(union acpi_operand_ } if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS) { + /* SMBus has a non-linear address space */ return_ACPI_STATUS(AE_OK); @@ -491,6 +492,7 @@ acpi_ex_field_datum_io(union acpi_operan value)); if (read_write == ACPI_READ) { + /* Read the datum from the data_register */ status = @@ -568,6 +570,7 @@ acpi_ex_write_with_update_rule(union acp /* If the mask is all ones, we don't need to worry about the update rule */ if (mask != ACPI_INTEGER_MAX) { + /* Decode the update rule */ switch (obj_desc->common_field. @@ -704,6 +707,7 @@ acpi_ex_extract_from_field(union acpi_op /* Read the rest of the field */ for (i = 1; i < field_datum_count; i++) { + /* Get next input datum from the field */ field_offset += obj_desc->common_field.access_byte_width; @@ -817,6 +821,7 @@ acpi_ex_insert_into_field(union acpi_ope /* Write the entire field */ for (i = 1; i < field_datum_count; i++) { + /* Write merged datum to the target field */ merged_datum &= mask; diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 48c18d2..74f2c1a 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c @@ -649,6 +649,7 @@ acpi_ex_do_logical_op(u16 opcode, /* Length and all bytes must be equal */ if ((length0 == length1) && (compare == 0)) { + /* Length and all bytes match ==> TRUE */ local_result = TRUE; diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c index f843b22..eaee1de 100644 --- a/drivers/acpi/executer/exmutex.c +++ b/drivers/acpi/executer/exmutex.c @@ -173,6 +173,7 @@ acpi_ex_acquire_mutex(union acpi_operand /* Support for multiple acquires by the owning thread */ if (obj_desc->mutex.owner_thread) { + /* Special case for Global Lock, allow all threads */ if ((obj_desc->mutex.owner_thread->thread_id == @@ -192,6 +193,7 @@ acpi_ex_acquire_mutex(union acpi_operand status = acpi_ex_system_acquire_mutex(time_desc, obj_desc); if (ACPI_FAILURE(status)) { + /* Includes failure from a timeout on time_desc */ return_ACPI_STATUS(status); @@ -286,6 +288,7 @@ acpi_ex_release_mutex(union acpi_operand obj_desc->mutex.acquisition_depth--; if (obj_desc->mutex.acquisition_depth != 0) { + /* Just decrement the depth and return */ return_ACPI_STATUS(AE_OK); diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index 054fe5e..80bbc20 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c @@ -85,6 +85,7 @@ static char *acpi_ex_allocate_name_strin * This may actually be somewhat longer than needed. */ if (prefix_count == ACPI_UINT32_MAX) { + /* Special case for root */ size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; @@ -97,7 +98,7 @@ static char *acpi_ex_allocate_name_strin * Allocate a buffer for the name. * This buffer must be deleted by the caller! */ - name_string = ACPI_MEM_ALLOCATE(size_needed); + name_string = ACPI_ALLOCATE(size_needed); if (!name_string) { ACPI_ERROR((AE_INFO, "Could not allocate size %d", size_needed)); @@ -119,11 +120,13 @@ static char *acpi_ex_allocate_name_strin /* Set up Dual or Multi prefixes if needed */ if (num_name_segs > 2) { + /* Set up multi prefixes */ *temp_ptr++ = AML_MULTI_NAME_PREFIX_OP; *temp_ptr++ = (char)num_name_segs; } else if (2 == num_name_segs) { + /* Set up dual prefixes */ *temp_ptr++ = AML_DUAL_NAME_PREFIX; @@ -184,6 +187,7 @@ static acpi_status acpi_ex_name_segment( /* Valid name segment */ if (index == 4) { + /* Found 4 valid characters */ char_buf[4] = '\0'; @@ -254,6 +258,7 @@ acpi_ex_get_name_string(acpi_object_type if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type || ACPI_TYPE_LOCAL_BANK_FIELD == data_type || ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) { + /* Disallow prefixes for types associated with field_unit names */ name_string = acpi_ex_allocate_name_string(0, 1); @@ -410,6 +415,7 @@ acpi_ex_get_name_string(acpi_object_type } if (AE_CTRL_PENDING == status && has_prefix) { + /* Ran out of segments after processing a prefix */ ACPI_ERROR((AE_INFO, "Malformed Name at %p", name_string)); @@ -418,7 +424,7 @@ acpi_ex_get_name_string(acpi_object_type if (ACPI_FAILURE(status)) { if (name_string) { - ACPI_MEM_FREE(name_string); + ACPI_FREE(name_string); } return_ACPI_STATUS(status); } diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index 23d0823..d00f766 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c @@ -342,6 +342,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(stru for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) { + /* Get the least significant 4-bit BCD digit */ temp32 = ((u32) digit) & 0xF; @@ -487,6 +488,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(stru status = acpi_ex_convert_to_string(operand[0], &return_desc, ACPI_EXPLICIT_CONVERT_DECIMAL); if (return_desc == operand[0]) { + /* No conversion performed, add ref to handle return value */ acpi_ut_add_reference(return_desc); } @@ -497,6 +499,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(stru status = acpi_ex_convert_to_string(operand[0], &return_desc, ACPI_EXPLICIT_CONVERT_HEX); if (return_desc == operand[0]) { + /* No conversion performed, add ref to handle return value */ acpi_ut_add_reference(return_desc); } @@ -506,6 +509,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(stru status = acpi_ex_convert_to_buffer(operand[0], &return_desc); if (return_desc == operand[0]) { + /* No conversion performed, add ref to handle return value */ acpi_ut_add_reference(return_desc); } @@ -516,6 +520,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(stru status = acpi_ex_convert_to_integer(operand[0], &return_desc, ACPI_ANY_BASE); if (return_desc == operand[0]) { + /* No conversion performed, add ref to handle return value */ acpi_ut_add_reference(return_desc); } @@ -541,6 +546,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(stru } if (ACPI_SUCCESS(status)) { + /* Store the return value computed above into the target object */ status = acpi_ex_store(return_desc, operand[1], walk_state); @@ -548,16 +554,18 @@ acpi_status acpi_ex_opcode_1A_1T_1R(stru cleanup: - if (!walk_state->result_obj) { - walk_state->result_obj = return_desc; - } - /* Delete return object on error */ if (ACPI_FAILURE(status)) { acpi_ut_remove_reference(return_desc); } + /* Save return object on success */ + + else if (!walk_state->result_obj) { + walk_state->result_obj = return_desc; + } + return_ACPI_STATUS(status); } @@ -625,6 +633,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(stru temp_desc = operand[0]; if (ACPI_GET_DESCRIPTOR_TYPE(temp_desc) == ACPI_DESC_TYPE_OPERAND) { + /* Internal reference object - prevent deletion */ acpi_ut_add_reference(temp_desc); @@ -777,8 +786,25 @@ acpi_status acpi_ex_opcode_1A_0T_1R(stru /* Check for a method local or argument, or standalone String */ - if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) != + if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) == ACPI_DESC_TYPE_NAMED) { + temp_desc = + acpi_ns_get_attached_object((struct + acpi_namespace_node *) + operand[0]); + if (temp_desc + && + ((ACPI_GET_OBJECT_TYPE(temp_desc) == + ACPI_TYPE_STRING) + || (ACPI_GET_OBJECT_TYPE(temp_desc) == + ACPI_TYPE_LOCAL_REFERENCE))) { + operand[0] = temp_desc; + acpi_ut_add_reference(temp_desc); + } else { + status = AE_AML_OPERAND_TYPE; + goto cleanup; + } + } else { switch (ACPI_GET_OBJECT_TYPE(operand[0])) { case ACPI_TYPE_LOCAL_REFERENCE: /* @@ -827,13 +853,24 @@ acpi_status acpi_ex_opcode_1A_0T_1R(stru break; case ACPI_TYPE_STRING: + break; + + default: + status = AE_AML_OPERAND_TYPE; + goto cleanup; + } + } + if (ACPI_GET_DESCRIPTOR_TYPE(operand[0]) != + ACPI_DESC_TYPE_NAMED) { + if (ACPI_GET_OBJECT_TYPE(operand[0]) == + ACPI_TYPE_STRING) { /* * This is a deref_of (String). The string is a reference * to a named ACPI object. * * 1) Find the owning Node - * 2) Dereference the node to an actual object. Could be a + * 2) Dereference the node to an actual object. Could be a * Field, so we need to resolve the node to a value. */ status = @@ -857,11 +894,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(stru (struct acpi_namespace_node, &return_desc), walk_state); goto cleanup; - - default: - - status = AE_AML_OPERAND_TYPE; - goto cleanup; } } @@ -998,6 +1030,11 @@ acpi_status acpi_ex_opcode_1A_0T_1R(stru acpi_ut_remove_reference(return_desc); } - walk_state->result_obj = return_desc; + /* Save return object on success */ + + else { + walk_state->result_obj = return_desc; + } + return_ACPI_STATUS(status); } diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c index e263a5d..690e43d 100644 --- a/drivers/acpi/executer/exoparg2.c +++ b/drivers/acpi/executer/exoparg2.c @@ -138,6 +138,7 @@ #ifdef ACPI_GPE_NOTIFY_CHECK acpi_ev_check_for_wake_only_gpe(walk_state-> gpe_event_info); if (ACPI_FAILURE(status)) { + /* AE_WAKE_ONLY_GPE only error, means ignore this notify */ return_ACPI_STATUS(AE_OK) @@ -252,6 +253,7 @@ acpi_status acpi_ex_opcode_2A_2T_1R(stru acpi_ut_remove_reference(return_desc2); if (ACPI_FAILURE(status)) { + /* Delete the return object */ acpi_ut_remove_reference(return_desc1); @@ -287,6 +289,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(stru /* Execute the opcode */ if (walk_state->op_info->flags & AML_MATH) { + /* All simple math opcodes (add, etc.) */ return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); @@ -383,54 +386,70 @@ acpi_status acpi_ex_opcode_2A_1T_1R(stru goto cleanup; } + /* Initialize the Index reference object */ + index = operand[1]->integer.value; + return_desc->reference.offset = (u32) index; + return_desc->reference.opcode = AML_INDEX_OP; - /* At this point, the Source operand is a Package, Buffer, or String */ + /* + * At this point, the Source operand is a String, Buffer, or Package. + * Verify that the index is within range. + */ + switch (ACPI_GET_OBJECT_TYPE(operand[0])) { + case ACPI_TYPE_STRING: - if (ACPI_GET_OBJECT_TYPE(operand[0]) == ACPI_TYPE_PACKAGE) { - /* Object to be indexed is a Package */ + if (index >= operand[0]->string.length) { + status = AE_AML_STRING_LIMIT; + } + + return_desc->reference.target_type = + ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_BUFFER: + + if (index >= operand[0]->buffer.length) { + status = AE_AML_BUFFER_LIMIT; + } + + return_desc->reference.target_type = + ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_PACKAGE: if (index >= operand[0]->package.count) { - ACPI_ERROR((AE_INFO, - "Index value (%X%8.8X) beyond package end (%X)", - ACPI_FORMAT_UINT64(index), - operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; - goto cleanup; } return_desc->reference.target_type = ACPI_TYPE_PACKAGE; - return_desc->reference.object = operand[0]; return_desc->reference.where = &operand[0]->package.elements[index]; - } else { - /* Object to be indexed is a Buffer/String */ + break; - if (index >= operand[0]->buffer.length) { - ACPI_ERROR((AE_INFO, - "Index value (%X%8.8X) beyond end of buffer (%X)", - ACPI_FORMAT_UINT64(index), - operand[0]->buffer.length)); - status = AE_AML_BUFFER_LIMIT; - goto cleanup; - } + default: - return_desc->reference.target_type = - ACPI_TYPE_BUFFER_FIELD; - return_desc->reference.object = operand[0]; + status = AE_AML_INTERNAL; + goto cleanup; + } + + /* Failure means that the Index was beyond the end of the object */ + + if (ACPI_FAILURE(status)) { + ACPI_EXCEPTION((AE_INFO, status, + "Index (%X%8.8X) is beyond end of object", + ACPI_FORMAT_UINT64(index))); + goto cleanup; } /* - * Add a reference to the target package/buffer/string for the life - * of the index. + * Save the target object and add a reference to it for the life + * of the index */ + return_desc->reference.object = operand[0]; acpi_ut_add_reference(operand[0]); - /* Complete the Index reference object */ - - return_desc->reference.opcode = AML_INDEX_OP; - return_desc->reference.offset = (u32) index; - /* Store the reference to the Target */ status = acpi_ex_store(return_desc, operand[2], walk_state); @@ -509,6 +528,7 @@ acpi_status acpi_ex_opcode_2A_0T_1R(stru /* Execute the Opcode */ if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) { + /* logical_op (Operand0, Operand1) */ status = acpi_ex_do_logical_numeric_op(walk_state->opcode, @@ -518,6 +538,7 @@ acpi_status acpi_ex_opcode_2A_0T_1R(stru value, &logical_result); goto store_logical_result; } else if (walk_state->op_info->flags & AML_LOGICAL) { + /* logical_op (Operand0, Operand1) */ status = acpi_ex_do_logical_op(walk_state->opcode, operand[0], diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c index 6a3a883..4897e6c 100644 --- a/drivers/acpi/executer/exoparg3.c +++ b/drivers/acpi/executer/exoparg3.c @@ -100,8 +100,7 @@ acpi_status acpi_ex_opcode_3A_0T_0R(stru (u32) operand[1]->integer.value, (u32) operand[2]->integer.value)); - fatal = - ACPI_MEM_ALLOCATE(sizeof(struct acpi_signal_fatal_info)); + fatal = ACPI_ALLOCATE(sizeof(struct acpi_signal_fatal_info)); if (fatal) { fatal->type = (u32) operand[0]->integer.value; fatal->code = (u32) operand[1]->integer.value; @@ -114,7 +113,7 @@ acpi_status acpi_ex_opcode_3A_0T_0R(stru /* Might return while OS is shutting down, just continue */ - ACPI_MEM_FREE(fatal); + ACPI_FREE(fatal); break; default: @@ -196,7 +195,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(stru /* Always allocate a new buffer for the String */ - buffer = ACPI_MEM_CALLOCATE((acpi_size) length + 1); + buffer = ACPI_ALLOCATE_ZEROED((acpi_size) length + 1); if (!buffer) { status = AE_NO_MEMORY; goto cleanup; @@ -208,9 +207,10 @@ acpi_status acpi_ex_opcode_3A_1T_1R(stru /* If the requested length is zero, don't allocate a buffer */ if (length > 0) { + /* Allocate a new buffer for the Buffer */ - buffer = ACPI_MEM_CALLOCATE(length); + buffer = ACPI_ALLOCATE_ZEROED(length); if (!buffer) { status = AE_NO_MEMORY; goto cleanup; @@ -225,6 +225,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(stru } if (buffer) { + /* We have a buffer, copy the portion requested */ ACPI_MEMCPY(buffer, operand[0]->string.pointer + index, diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c index e043d92..33e4fb1 100644 --- a/drivers/acpi/executer/exoparg6.c +++ b/drivers/acpi/executer/exoparg6.c @@ -276,6 +276,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(stru * match was found. */ for (; index < operand[0]->package.count; index++) { + /* Get the current package element */ this_element = operand[0]->package.elements[index]; diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c index 7719ae5..916234b 100644 --- a/drivers/acpi/executer/exprep.c +++ b/drivers/acpi/executer/exprep.c @@ -519,13 +519,20 @@ acpi_status acpi_ex_prep_field_value(str acpi_ut_add_reference(obj_desc->index_field.index_obj); /* + * February 2006: Changed to match MS behavior + * * The value written to the Index register is the byte offset of the - * target field - * Note: may change code to: ACPI_DIV_8 (Info->field_bit_position) + * target field. + * + * Previously, the value was calculated as an index in terms of the + * width of the Data register, as below: + * + * obj_desc->index_field.Value = (u32) + * (Info->field_bit_position / ACPI_MUL_8 ( + * obj_desc->Field.access_byte_width)); */ - obj_desc->index_field.value = (u32) - (info->field_bit_position / - ACPI_MUL_8(obj_desc->field.access_byte_width)); + obj_desc->index_field.value = + (u32) ACPI_DIV_8(info->field_bit_position); ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c index 6a4cfdf..fdeda7b 100644 --- a/drivers/acpi/executer/exregion.c +++ b/drivers/acpi/executer/exregion.c @@ -135,6 +135,7 @@ #endif * Delete the existing mapping and create a new one. */ if (mem_info->mapped_length) { + /* Valid mapping, delete it */ acpi_os_unmap_memory(mem_info->mapped_logical_address, @@ -181,8 +182,8 @@ #endif (acpi_integer) mem_info->mapped_physical_address); ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "system_memory %d (%d width) Address=%8.8X%8.8X\n", - function, bit_width, ACPI_FORMAT_UINT64(address))); + "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", + bit_width, function, ACPI_FORMAT_UINT64(address))); /* * Perform the memory read or write @@ -286,8 +287,8 @@ acpi_ex_system_io_space_handler(u32 func ACPI_FUNCTION_TRACE("ex_system_io_space_handler"); ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "system_iO %d (%d width) Address=%8.8X%8.8X\n", - function, bit_width, ACPI_FORMAT_UINT64(address))); + "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n", + bit_width, function, ACPI_FORMAT_UINT64(address))); /* Decode the function parameter */ @@ -360,7 +361,7 @@ acpi_ex_pci_config_space_handler(u32 fun pci_register = (u16) (u32) address; ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", + "Pci-Config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", function, bit_width, pci_id->segment, pci_id->bus, pci_id->device, pci_id->function, pci_register)); diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c index 01b26c8..417d914 100644 --- a/drivers/acpi/executer/exresnte.c +++ b/drivers/acpi/executer/exresnte.c @@ -103,6 +103,7 @@ acpi_ex_resolve_node_to_value(struct acp if ((entry_type == ACPI_TYPE_LOCAL_ALIAS) || (entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { + /* There is always exactly one level of indirection */ node = ACPI_CAST_PTR(struct acpi_namespace_node, node->object); @@ -141,6 +142,7 @@ acpi_ex_resolve_node_to_value(struct acp status = acpi_ds_get_package_arguments(source_desc); if (ACPI_SUCCESS(status)) { + /* Return an additional reference to the object */ obj_desc = source_desc; @@ -158,6 +160,7 @@ acpi_ex_resolve_node_to_value(struct acp status = acpi_ds_get_buffer_arguments(source_desc); if (ACPI_SUCCESS(status)) { + /* Return an additional reference to the object */ obj_desc = source_desc; @@ -240,6 +243,8 @@ acpi_ex_resolve_node_to_value(struct acp /* This is a ddb_handle */ /* Return an additional reference to the object */ + case AML_REF_OF_OP: + obj_desc = source_desc; acpi_ut_add_reference(obj_desc); break; diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c index 1deed49..22dabdd 100644 --- a/drivers/acpi/executer/exresolv.c +++ b/drivers/acpi/executer/exresolv.c @@ -382,10 +382,16 @@ acpi_ex_resolve_multiple(struct acpi_wal while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { switch (obj_desc->reference.opcode) { case AML_REF_OF_OP: + case AML_INT_NAMEPATH_OP: /* Dereference the reference pointer */ - node = obj_desc->reference.object; + if (obj_desc->reference.opcode == AML_REF_OF_OP) { + node = obj_desc->reference.object; + } else { /* AML_INT_NAMEPATH_OP */ + + node = obj_desc->reference.node; + } /* All "References" point to a NS node */ @@ -401,6 +407,7 @@ acpi_ex_resolve_multiple(struct acpi_wal obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { + /* No object, use the NS node type */ type = acpi_ns_get_type(node); @@ -432,6 +439,7 @@ acpi_ex_resolve_multiple(struct acpi_wal */ obj_desc = *(obj_desc->reference.where); if (!obj_desc) { + /* NULL package elements are allowed */ type = 0; /* Uninitialized */ @@ -439,39 +447,6 @@ acpi_ex_resolve_multiple(struct acpi_wal } break; - case AML_INT_NAMEPATH_OP: - - /* Dereference the reference pointer */ - - node = obj_desc->reference.node; - - /* All "References" point to a NS node */ - - if (ACPI_GET_DESCRIPTOR_TYPE(node) != - ACPI_DESC_TYPE_NAMED) { - ACPI_ERROR((AE_INFO, "Not a NS node %p [%s]", - node, - acpi_ut_get_descriptor_name(node))); - return_ACPI_STATUS(AE_AML_INTERNAL); - } - - /* Get the attached object */ - - obj_desc = acpi_ns_get_attached_object(node); - if (!obj_desc) { - /* No object, use the NS node type */ - - type = acpi_ns_get_type(node); - goto exit; - } - - /* Check for circular references */ - - if (obj_desc == operand) { - return_ACPI_STATUS(AE_AML_CIRCULAR_REFERENCE); - } - break; - case AML_LOCAL_OP: case AML_ARG_OP: diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index a1c000f..42b9089 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c @@ -77,6 +77,7 @@ acpi_ex_check_object_type(acpi_object_ty ACPI_FUNCTION_ENTRY(); if (type_needed == ACPI_TYPE_ANY) { + /* All types OK, so we don't perform any typechecks */ return (AE_OK); @@ -224,6 +225,7 @@ acpi_ex_resolve_operands(u16 opcode, } if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { + /* Decode the Reference */ op_info = acpi_ps_get_opcode_info(opcode); @@ -332,6 +334,7 @@ acpi_ex_resolve_operands(u16 opcode, } if (obj_desc->reference.opcode == AML_NAME_OP) { + /* Convert a named reference to the actual named object */ temp_node = obj_desc->reference.object; @@ -662,6 +665,7 @@ acpi_ex_resolve_operands(u16 opcode, } if (target_op == AML_DEBUG_OP) { + /* Allow store of any object to the Debug object */ break; diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c index 3f020c0..287476f 100644 --- a/drivers/acpi/executer/exstore.c +++ b/drivers/acpi/executer/exstore.c @@ -423,6 +423,7 @@ acpi_ex_store_object_to_index(union acpi } if (obj_desc) { + /* Decrement reference count by the ref count of the parent package */ for (i = 0; i < ((union acpi_operand_object *) @@ -572,6 +573,7 @@ acpi_ex_store_object_to_node(union acpi_ /* If no implicit conversion, drop into the default case below */ if ((!implicit_conversion) || (walk_state->opcode == AML_COPY_OP)) { + /* Force execution of default (no implicit conversion) */ target_type = ACPI_TYPE_ANY; diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c index 42967ba..969f9cb 100644 --- a/drivers/acpi/executer/exstoren.c +++ b/drivers/acpi/executer/exstoren.c @@ -97,6 +97,7 @@ acpi_ex_resolve_object(union acpi_operan */ if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_LOCAL_REFERENCE) { + /* Resolve a reference object first */ status = @@ -121,6 +122,7 @@ acpi_ex_resolve_object(union acpi_operan !((ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_LOCAL_REFERENCE) && (source_desc->reference.opcode == AML_LOAD_OP))) { + /* Conversion successful but still not a valid type */ ACPI_ERROR((AE_INFO, @@ -289,6 +291,7 @@ acpi_ex_store_object_to_object(union acp } if (actual_src_desc != source_desc) { + /* Delete the intermediate (temporary) source object */ acpi_ut_remove_reference(actual_src_desc); diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c index 6ab7070..db42461 100644 --- a/drivers/acpi/executer/exstorob.c +++ b/drivers/acpi/executer/exstorob.c @@ -80,7 +80,7 @@ acpi_ex_store_buffer_to_buffer(union acp */ if ((target_desc->buffer.length == 0) || (target_desc->common.flags & AOPOBJ_STATIC_POINTER)) { - target_desc->buffer.pointer = ACPI_MEM_ALLOCATE(length); + target_desc->buffer.pointer = ACPI_ALLOCATE(length); if (!target_desc->buffer.pointer) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -91,6 +91,7 @@ acpi_ex_store_buffer_to_buffer(union acp /* Copy source buffer to target buffer */ if (length <= target_desc->buffer.length) { + /* Clear existing buffer and copy in the new one */ ACPI_MEMSET(target_desc->buffer.pointer, 0, @@ -113,6 +114,7 @@ #ifdef ACPI_OBSOLETE_BEHAVIOR * copy must not truncate the original buffer. */ if (original_src_type == ACPI_TYPE_STRING) { + /* Set the new length of the target */ target_desc->buffer.length = length; @@ -183,13 +185,14 @@ acpi_ex_store_string_to_string(union acp */ if (target_desc->string.pointer && (!(target_desc->common.flags & AOPOBJ_STATIC_POINTER))) { + /* Only free if not a pointer into the DSDT */ - ACPI_MEM_FREE(target_desc->string.pointer); + ACPI_FREE(target_desc->string.pointer); } - target_desc->string.pointer = ACPI_MEM_CALLOCATE((acpi_size) - length + 1); + target_desc->string.pointer = ACPI_ALLOCATE_ZEROED((acpi_size) + length + 1); if (!target_desc->string.pointer) { return_ACPI_STATUS(AE_NO_MEMORY); } diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c index ea9144f..6a2e47a 100644 --- a/drivers/acpi/executer/exsystem.c +++ b/drivers/acpi/executer/exsystem.c @@ -76,6 +76,7 @@ acpi_status acpi_ex_system_wait_semaphor } if (status == AE_TIME) { + /* We must wait, so unlock the interpreter */ acpi_ex_exit_interpreter(); @@ -90,6 +91,7 @@ acpi_status acpi_ex_system_wait_semaphor status2 = acpi_ex_enter_interpreter(); if (ACPI_FAILURE(status2)) { + /* Report fatal error, could not acquire interpreter */ return_ACPI_STATUS(status2); diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index f73a61a..8543d1a 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c @@ -194,6 +194,7 @@ u8 acpi_ex_acquire_global_lock(u32 field /* Only attempt lock if the always_lock bit is set */ if (field_flags & AML_FIELD_LOCK_RULE_MASK) { + /* We should attempt to get the lock, wait forever */ status = acpi_ev_acquire_global_lock(ACPI_WAIT_FOREVER); @@ -230,10 +231,12 @@ void acpi_ex_release_global_lock(u8 lock /* Only attempt unlock if the caller locked it */ if (locked_by_me) { + /* OK, now release the lock */ status = acpi_ev_release_global_lock(); if (ACPI_FAILURE(status)) { + /* Report the error, but there isn't much else we can do */ ACPI_EXCEPTION((AE_INFO, status, diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index e8165c4..dbcce9b 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -48,6 +48,8 @@ MODULE_LICENSE("GPL"); static int acpi_fan_add(struct acpi_device *device); static int acpi_fan_remove(struct acpi_device *device, int type); +static int acpi_fan_suspend(struct acpi_device *device, int state); +static int acpi_fan_resume(struct acpi_device *device, int state); static struct acpi_driver acpi_fan_driver = { .name = ACPI_FAN_DRIVER_NAME, @@ -56,6 +58,8 @@ static struct acpi_driver acpi_fan_drive .ops = { .add = acpi_fan_add, .remove = acpi_fan_remove, + .suspend = acpi_fan_suspend, + .resume = acpi_fan_resume, }, }; @@ -74,8 +78,6 @@ static int acpi_fan_read_state(struct se struct acpi_fan *fan = seq->private; int state = 0; - ACPI_FUNCTION_TRACE("acpi_fan_read_state"); - if (fan) { if (acpi_bus_get_power(fan->handle, &state)) seq_printf(seq, "status: ERROR\n"); @@ -83,7 +85,7 @@ static int acpi_fan_read_state(struct se seq_printf(seq, "status: %s\n", !state ? "on" : "off"); } - return_VALUE(0); + return 0; } static int acpi_fan_state_open_fs(struct inode *inode, struct file *file) @@ -100,22 +102,20 @@ acpi_fan_write_state(struct file *file, struct acpi_fan *fan = (struct acpi_fan *)m->private; char state_string[12] = { '\0' }; - ACPI_FUNCTION_TRACE("acpi_fan_write_state"); - if (!fan || (count > sizeof(state_string) - 1)) - return_VALUE(-EINVAL); + return -EINVAL; if (copy_from_user(state_string, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; state_string[count] = '\0'; result = acpi_bus_set_power(fan->handle, simple_strtoul(state_string, NULL, 0)); if (result) - return_VALUE(result); + return result; - return_VALUE(count); + return count; } static struct file_operations acpi_fan_state_ops = { @@ -131,16 +131,14 @@ static int acpi_fan_add_fs(struct acpi_d { struct proc_dir_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_fan_add_fs"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_fan_dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; acpi_device_dir(device)->owner = THIS_MODULE; } @@ -149,29 +147,25 @@ static int acpi_fan_add_fs(struct acpi_d S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_FAN_FILE_STATE)); + return -ENODEV; else { entry->proc_fops = &acpi_fan_state_ops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return_VALUE(0); + return 0; } static int acpi_fan_remove_fs(struct acpi_device *device) { - ACPI_FUNCTION_TRACE("acpi_fan_remove_fs"); - if (acpi_device_dir(device)) { remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device)); remove_proc_entry(acpi_device_bid(device), acpi_fan_dir); acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -184,14 +178,12 @@ static int acpi_fan_add(struct acpi_devi struct acpi_fan *fan = NULL; int state = 0; - ACPI_FUNCTION_TRACE("acpi_fan_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL); if (!fan) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(fan, 0, sizeof(struct acpi_fan)); fan->handle = device->handle; @@ -201,11 +193,14 @@ static int acpi_fan_add(struct acpi_devi result = acpi_bus_get_power(fan->handle, &state); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error reading power state\n")); + ACPI_ERROR((AE_INFO, "Reading power state")); goto end; } + device->flags.force_power_state = 1; + acpi_bus_set_power(device->handle, state); + device->flags.force_power_state = 0; + result = acpi_fan_add_fs(device); if (result) goto end; @@ -218,17 +213,15 @@ static int acpi_fan_add(struct acpi_devi if (result) kfree(fan); - return_VALUE(result); + return result; } static int acpi_fan_remove(struct acpi_device *device, int type) { struct acpi_fan *fan = NULL; - ACPI_FUNCTION_TRACE("acpi_fan_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; fan = (struct acpi_fan *)acpi_driver_data(device); @@ -236,38 +229,65 @@ static int acpi_fan_remove(struct acpi_d kfree(fan); - return_VALUE(0); + return 0; } -static int __init acpi_fan_init(void) +static int acpi_fan_suspend(struct acpi_device *device, int state) +{ + if (!device) + return -EINVAL; + + acpi_bus_set_power(device->handle, ACPI_STATE_D0); + + return AE_OK; +} + +static int acpi_fan_resume(struct acpi_device *device, int state) { int result = 0; + int power_state = 0; + + if (!device) + return -EINVAL; + + result = acpi_bus_get_power(device->handle, &power_state); + if (result) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error reading fan power state\n")); + return result; + } - ACPI_FUNCTION_TRACE("acpi_fan_init"); + device->flags.force_power_state = 1; + acpi_bus_set_power(device->handle, power_state); + device->flags.force_power_state = 0; + + return result; +} + +static int __init acpi_fan_init(void) +{ + int result = 0; acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); if (!acpi_fan_dir) - return_VALUE(-ENODEV); + return -ENODEV; acpi_fan_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_fan_driver); if (result < 0) { remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } static void __exit acpi_fan_exit(void) { - ACPI_FUNCTION_TRACE("acpi_fan_exit"); - acpi_bus_unregister_driver(&acpi_fan_driver); remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); - return_VOID; } module_init(acpi_fan_init); diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 8daef57..10f160d 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -152,7 +152,7 @@ static int get_root_bridge_busnr(acpi_ha bbn = bus; } exit: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return (int)bbn; } @@ -192,7 +192,7 @@ find_pci_rootbridge(acpi_handle handle, find->handle = handle; status = AE_OK; exit: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return status; } @@ -224,7 +224,7 @@ do_acpi_find_child(acpi_handle handle, u info = buffer.pointer; if (info->address == find->address) find->handle = handle; - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); } return AE_OK; } @@ -330,7 +330,7 @@ #if ACPI_GLUE_DEBUG acpi_get_name(dev->firmware_data, ACPI_FULL_PATHNAME, &buffer); DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer); - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); } else DBG("Device %s -> No ACPI support\n", dev->bus_id); #endif diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c index d84942d..729b68e 100644 --- a/drivers/acpi/hardware/hwgpe.c +++ b/drivers/acpi/hardware/hwgpe.c @@ -214,6 +214,7 @@ acpi_hw_disable_gpe_block(struct acpi_gp /* Examine each GPE Register within the block */ for (i = 0; i < gpe_block->register_count; i++) { + /* Disable all GPEs in this register */ status = acpi_hw_low_level_write(8, 0x00, @@ -250,6 +251,7 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_ /* Examine each GPE Register within the block */ for (i = 0; i < gpe_block->register_count; i++) { + /* Clear status on all GPEs in this register */ status = acpi_hw_low_level_write(8, 0xFF, diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index e1fe754..3d1f41c 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c @@ -43,8 +43,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include #include @@ -220,7 +218,7 @@ acpi_get_sleep_type_data(u8 sleep_state, return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_sleep_type_data); +ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data) /******************************************************************************* * @@ -233,7 +231,6 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data); * DESCRIPTION: Map register_id into a register bitmask. * ******************************************************************************/ - struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) { ACPI_FUNCTION_ENTRY(); @@ -295,6 +292,7 @@ acpi_status acpi_get_register(u32 regist } if (ACPI_SUCCESS(status)) { + /* Normalize the value that was read */ register_value = @@ -311,7 +309,7 @@ acpi_status acpi_get_register(u32 regist return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_register); +ACPI_EXPORT_SYMBOL(acpi_get_register) /******************************************************************************* * @@ -327,7 +325,6 @@ EXPORT_SYMBOL(acpi_get_register); * DESCRIPTION: ACPI Bit Register write function. * ******************************************************************************/ - acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags) { u32 register_value = 0; @@ -474,7 +471,7 @@ acpi_status acpi_set_register(u32 regist return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_set_register); +ACPI_EXPORT_SYMBOL(acpi_set_register) /****************************************************************************** * @@ -490,7 +487,6 @@ EXPORT_SYMBOL(acpi_set_register); * given offset. * ******************************************************************************/ - acpi_status acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) { diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index 8926927..685deba 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include #include #define _COMPONENT ACPI_HARDWARE @@ -79,6 +78,8 @@ acpi_set_firmware_waking_vector(acpi_phy return_ACPI_STATUS(AE_OK); } +ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) + /******************************************************************************* * * FUNCTION: acpi_get_firmware_waking_vector @@ -92,7 +93,6 @@ acpi_set_firmware_waking_vector(acpi_phy * DESCRIPTION: Access function for the firmware_waking_vector field in FACS * ******************************************************************************/ - #ifdef ACPI_FUTURE_USAGE acpi_status acpi_get_firmware_waking_vector(acpi_physical_address * physical_address) @@ -118,6 +118,8 @@ acpi_get_firmware_waking_vector(acpi_phy return_ACPI_STATUS(AE_OK); } + +ACPI_EXPORT_SYMBOL(acpi_get_firmware_waking_vector) #endif /******************************************************************************* @@ -134,7 +136,6 @@ #endif * various OS-specific tasks between the two steps. * ******************************************************************************/ - acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) { acpi_status status; @@ -206,6 +207,8 @@ acpi_status acpi_enter_sleep_state_prep( return_ACPI_STATUS(AE_OK); } +ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) + /******************************************************************************* * * FUNCTION: acpi_enter_sleep_state @@ -218,7 +221,6 @@ acpi_status acpi_enter_sleep_state_prep( * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ - acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) { u32 PM1Acontrol; @@ -378,7 +380,7 @@ acpi_status asmlinkage acpi_enter_sleep_ return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_enter_sleep_state); +ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state) /******************************************************************************* * @@ -392,7 +394,6 @@ EXPORT_SYMBOL(acpi_enter_sleep_state); * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ - acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) { u32 in_value; @@ -443,7 +444,7 @@ acpi_status asmlinkage acpi_enter_sleep_ return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios); +ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios) /******************************************************************************* * @@ -457,7 +458,6 @@ EXPORT_SYMBOL(acpi_enter_sleep_state_s4b * Called with interrupts ENABLED. * ******************************************************************************/ - acpi_status acpi_leave_sleep_state(u8 sleep_state) { struct acpi_object_list arg_list; @@ -490,6 +490,7 @@ acpi_status acpi_leave_sleep_state(u8 sl ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); if (ACPI_SUCCESS(status)) { + /* Clear SLP_EN and SLP_TYP fields */ PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | @@ -583,3 +584,5 @@ acpi_status acpi_leave_sleep_state(u8 sl return_ACPI_STATUS(status); } + +ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state) diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c index fc10b7c..9d53e46 100644 --- a/drivers/acpi/hardware/hwtimer.c +++ b/drivers/acpi/hardware/hwtimer.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include #include #define _COMPONENT ACPI_HARDWARE @@ -76,6 +75,8 @@ acpi_status acpi_get_timer_resolution(u3 return_ACPI_STATUS(AE_OK); } +ACPI_EXPORT_SYMBOL(acpi_get_timer_resolution) + /****************************************************************************** * * FUNCTION: acpi_get_timer @@ -87,7 +88,6 @@ acpi_status acpi_get_timer_resolution(u3 * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). * ******************************************************************************/ - acpi_status acpi_get_timer(u32 * ticks) { acpi_status status; @@ -103,7 +103,7 @@ acpi_status acpi_get_timer(u32 * ticks) return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_timer); +ACPI_EXPORT_SYMBOL(acpi_get_timer) /****************************************************************************** * @@ -133,7 +133,6 @@ EXPORT_SYMBOL(acpi_get_timer); * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes * ******************************************************************************/ - acpi_status acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed) { @@ -155,6 +154,7 @@ acpi_get_timer_duration(u32 start_ticks, delta_ticks = end_ticks - start_ticks; } else if (start_ticks > end_ticks) { if (0 == acpi_gbl_FADT->tmr_val_ext) { + /* 24-bit Timer */ delta_ticks = @@ -183,4 +183,4 @@ acpi_get_timer_duration(u32 start_ticks, return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_timer_duration); +ACPI_EXPORT_SYMBOL(acpi_get_timer_duration) diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c index 2e2e405..202f3ae 100644 --- a/drivers/acpi/hotkey.c +++ b/drivers/acpi/hotkey.c @@ -231,11 +231,9 @@ struct list_head hotkey_entries; /* head static int hotkey_info_seq_show(struct seq_file *seq, void *offset) { - ACPI_FUNCTION_TRACE("hotkey_info_seq_show"); - seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION); - return_VALUE(0); + return 0; } static int hotkey_info_open_fs(struct inode *inode, struct file *file) @@ -266,15 +264,13 @@ static int hotkey_polling_seq_show(struc (struct acpi_polling_hotkey *)seq->private; char *buf; - ACPI_FUNCTION_TRACE("hotkey_polling_seq_show"); - if (poll_hotkey->poll_result) { buf = format_result(poll_hotkey->poll_result); if (buf) seq_printf(seq, "%s", buf); kfree(buf); } - return_VALUE(0); + return 0; } static int hotkey_polling_open_fs(struct inode *inode, struct file *file) @@ -293,8 +289,6 @@ static int hotkey_get_internal_event(int struct list_head *entries; int val = -1; - ACPI_FUNCTION_TRACE("hotkey_get_internal_event"); - list_for_each(entries, list->entries) { union acpi_hotkey *key = container_of(entries, union acpi_hotkey, entries); @@ -305,7 +299,7 @@ static int hotkey_get_internal_event(int } } - return_VALUE(val); + return val; } static void @@ -314,15 +308,12 @@ acpi_hotkey_notify_handler(acpi_handle h struct acpi_device *device = NULL; u32 internal_event; - ACPI_FUNCTION_TRACE("acpi_hotkey_notify_handler"); - if (acpi_bus_get_device(handle, &device)) - return_VOID; + return; internal_event = hotkey_get_internal_event(event, &global_hotkey_list); acpi_bus_generate_event(device, internal_event, 0); - return_VOID; } /* Need to invent automatically hotkey add method */ @@ -344,10 +335,7 @@ static int create_polling_proc(union acp { struct proc_dir_entry *proc; char proc_name[80]; - mode_t mode; - - ACPI_FUNCTION_TRACE("create_polling_proc"); - mode = S_IFREG | S_IRUGO | S_IWUGO; + mode_t mode = S_IFREG | S_IRUGO | S_IWUGO; sprintf(proc_name, "%d", device->link.hotkey_standard_num); /* @@ -356,10 +344,7 @@ static int create_polling_proc(union acp proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); if (!proc) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Hotkey: Unable to create %s entry\n", - device->poll_hotkey.poll_method)); - return_VALUE(-ENODEV); + return -ENODEV; } else { proc->proc_fops = &hotkey_polling_fops; proc->owner = THIS_MODULE; @@ -368,7 +353,7 @@ static int create_polling_proc(union acp proc->gid = 0; device->poll_hotkey.proc = proc; } - return_VALUE(0); + return 0; } static int hotkey_add(union acpi_hotkey *device) @@ -376,8 +361,6 @@ static int hotkey_add(union acpi_hotkey int status = 0; struct acpi_device *dev = NULL; - ACPI_FUNCTION_TRACE("hotkey_add"); - if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) { acpi_bus_get_device(device->event_hotkey.bus_handle, &dev); status = acpi_install_notify_handler(dev->handle, @@ -391,15 +374,13 @@ static int hotkey_add(union acpi_hotkey list_add_tail(&device->link.entries, global_hotkey_list.entries); - return_VALUE(status); + return status; } static int hotkey_remove(union acpi_hotkey *device) { struct list_head *entries, *next; - ACPI_FUNCTION_TRACE("hotkey_remove"); - list_for_each_safe(entries, next, global_hotkey_list.entries) { union acpi_hotkey *key = container_of(entries, union acpi_hotkey, entries); @@ -412,15 +393,13 @@ static int hotkey_remove(union acpi_hotk } } kfree(device); - return_VALUE(0); + return 0; } static int hotkey_update(union acpi_hotkey *key) { struct list_head *entries; - ACPI_FUNCTION_TRACE("hotkey_update"); - list_for_each(entries, global_hotkey_list.entries) { union acpi_hotkey *tmp = container_of(entries, union acpi_hotkey, entries); @@ -461,20 +440,18 @@ static int hotkey_update(union acpi_hotk */ kfree(key); } - return_VALUE(0); + return 0; break; } } - return_VALUE(-ENODEV); + return -ENODEV; } static void free_hotkey_device(union acpi_hotkey *key) { struct acpi_device *dev; - ACPI_FUNCTION_TRACE("free_hotkey_device"); - if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { acpi_bus_get_device(key->event_hotkey.bus_handle, &dev); if (dev->handle) @@ -493,7 +470,6 @@ static void free_hotkey_device(union acp free_poll_hotkey_buffer(key); } kfree(key); - return_VOID; } static void free_hotkey_buffer(union acpi_hotkey *key) @@ -514,8 +490,6 @@ init_hotkey_device(union acpi_hotkey *ke acpi_handle tmp_handle; acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE("init_hotkey_device"); - if (std_num < 0 || IS_POLL(std_num) || !key) goto do_fail; @@ -541,9 +515,9 @@ init_hotkey_device(union acpi_hotkey *ke method, &tmp_handle); if (ACPI_FAILURE(status)) goto do_fail; - return_VALUE(AE_OK); + return AE_OK; do_fail: - return_VALUE(-ENODEV); + return -ENODEV; } static int @@ -555,8 +529,6 @@ init_poll_hotkey_device(union acpi_hotke acpi_status status = AE_OK; acpi_handle tmp_handle; - ACPI_FUNCTION_TRACE("init_poll_hotkey_device"); - if (std_num < 0 || IS_EVENT(std_num) || !key) goto do_fail; @@ -590,23 +562,19 @@ init_poll_hotkey_device(union acpi_hotke (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); if (!key->poll_hotkey.poll_result) goto do_fail; - return_VALUE(AE_OK); + return AE_OK; do_fail: - return_VALUE(-ENODEV); + return -ENODEV; } static int hotkey_open_config(struct inode *inode, struct file *file) { - ACPI_FUNCTION_TRACE("hotkey_open_config"); - return_VALUE(single_open - (file, hotkey_config_seq_show, PDE(inode)->data)); + return single_open(file, hotkey_config_seq_show, PDE(inode)->data); } static int hotkey_poll_open_config(struct inode *inode, struct file *file) { - ACPI_FUNCTION_TRACE("hotkey_poll_open_config"); - return_VALUE(single_open - (file, hotkey_poll_config_seq_show, PDE(inode)->data)); + return single_open(file, hotkey_poll_config_seq_show, PDE(inode)->data); } static int hotkey_config_seq_show(struct seq_file *seq, void *offset) @@ -618,8 +586,6 @@ static int hotkey_config_seq_show(struct struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; - ACPI_FUNCTION_TRACE(("hotkey_config_seq_show")); - list_for_each(entries, hotkey_list->entries) { union acpi_hotkey *key = container_of(entries, union acpi_hotkey, entries); @@ -636,7 +602,7 @@ static int hotkey_config_seq_show(struct } } seq_puts(seq, "\n"); - return_VALUE(0); + return 0; } static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) @@ -648,8 +614,6 @@ static int hotkey_poll_config_seq_show(s struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; - ACPI_FUNCTION_TRACE(("hotkey_config_seq_show")); - list_for_each(entries, hotkey_list->entries) { union acpi_hotkey *key = container_of(entries, union acpi_hotkey, entries); @@ -666,7 +630,7 @@ static int hotkey_poll_config_seq_show(s } } seq_puts(seq, "\n"); - return_VALUE(0); + return 0; } static int @@ -678,8 +642,6 @@ get_parms(char *config_record, char **method, int *internal_event_num, int *external_event_num) { char *tmp, *tmp1, count; - ACPI_FUNCTION_TRACE(("get_parms")); - sscanf(config_record, "%d", cmd); if (*cmd == 1) { @@ -723,6 +685,8 @@ get_parms(char *config_record, goto do_fail; count = tmp1 - tmp; *action_handle = (char *)kmalloc(count + 1, GFP_KERNEL); + if (!*action_handle) + goto do_fail; strncpy(*action_handle, tmp, count); *(*action_handle + count) = 0; @@ -742,9 +706,9 @@ get_parms(char *config_record, 0) goto do_fail; - return_VALUE(6); + return 6; do_fail: - return_VALUE(-1); + return -1; } /* count is length for one input record */ @@ -761,16 +725,14 @@ static ssize_t hotkey_write_config(struc int ret = 0; union acpi_hotkey *key = NULL; - ACPI_FUNCTION_TRACE(("hotkey_write_config")); - config_record = (char *)kmalloc(count + 1, GFP_KERNEL); if (!config_record) - return_VALUE(-ENOMEM); + return -ENOMEM; if (copy_from_user(config_record, buffer, count)) { kfree(config_record); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n")); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "Invalid data")); + return -EINVAL; } config_record[count] = 0; @@ -790,9 +752,8 @@ static ssize_t hotkey_write_config(struc kfree(bus_method); kfree(action_handle); kfree(method); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid data format ret=%d\n", ret)); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "Invalid data format ret=%d", ret)); + return -EINVAL; } key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); @@ -804,7 +765,7 @@ static ssize_t hotkey_write_config(struc tmp = get_hotkey_by_event(&global_hotkey_list, internal_event_num); if (!tmp) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key")); + ACPI_ERROR((AE_INFO, "Invalid key")); else memcpy(key, tmp, sizeof(union acpi_hotkey)); goto cont_cmd; @@ -826,8 +787,8 @@ static ssize_t hotkey_write_config(struc else free_poll_hotkey_buffer(key); kfree(key); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n")); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "Invalid hotkey")); + return -EINVAL; } cont_cmd: @@ -853,15 +814,15 @@ static ssize_t hotkey_write_config(struc goto fail_out; break; } - return_VALUE(count); + return count; fail_out: if (IS_EVENT(internal_event_num)) free_hotkey_buffer(key); else free_poll_hotkey_buffer(key); kfree(key); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "invalid key\n")); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "invalid key")); + return -EINVAL; } /* @@ -878,15 +839,13 @@ static int write_acpi_int(acpi_handle ha union acpi_object in_obj; /* the only param we use */ acpi_status status; - ACPI_FUNCTION_TRACE("write_acpi_int"); - params.count = 1; params.pointer = &in_obj; in_obj.type = ACPI_TYPE_INTEGER; in_obj.integer.value = val; status = acpi_evaluate_object(handle, (char *)method, ¶ms, output); - return_VALUE(status == AE_OK); + return status == AE_OK; } static int read_acpi_int(acpi_handle handle, const char *method, @@ -896,8 +855,6 @@ static int read_acpi_int(acpi_handle han union acpi_object out_obj; acpi_status status; - ACPI_FUNCTION_TRACE("read_acpi_int"); - output.length = sizeof(out_obj); output.pointer = &out_obj; status = acpi_evaluate_object(handle, (char *)method, NULL, &output); @@ -905,8 +862,8 @@ static int read_acpi_int(acpi_handle han val->integer.value = out_obj.integer.value; val->type = out_obj.type; } else - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "null val pointer")); - return_VALUE((status == AE_OK) + ACPI_ERROR((AE_INFO, "null val pointer")); + return ((status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER)); } @@ -943,24 +900,22 @@ static ssize_t hotkey_execute_aml_method int event, method_type, type, value; union acpi_hotkey *key; - ACPI_FUNCTION_TRACE("hotkey_execte_aml_method"); - arg = (char *)kmalloc(count + 1, GFP_KERNEL); if (!arg) - return_VALUE(-ENOMEM); + return -ENOMEM; arg[count] = 0; if (copy_from_user(arg, buffer, count)) { kfree(arg); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2")); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "Invalid argument 2")); + return -EINVAL; } if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 4) { kfree(arg); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3")); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "Invalid argument 3")); + return -EINVAL; } kfree(arg); if (type == ACPI_TYPE_INTEGER) { @@ -985,12 +940,12 @@ static ssize_t hotkey_execute_aml_method } } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported")); - return_VALUE(-EINVAL); + ACPI_WARNING((AE_INFO, "Not supported")); + return -EINVAL; } - return_VALUE(count); + return count; do_fail: - return_VALUE(-EINVAL); + return -EINVAL; } @@ -999,8 +954,6 @@ static int __init hotkey_init(void) int result; mode_t mode = S_IFREG | S_IRUGO | S_IWUGO; - ACPI_FUNCTION_TRACE("hotkey_init"); - if (acpi_disabled) return -ENODEV; @@ -1011,9 +964,6 @@ static int __init hotkey_init(void) hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir); if (!hotkey_proc_dir) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Hotkey: Unable to create %s entry\n", - HOTKEY_PROC)); return (-ENODEV); } hotkey_proc_dir->owner = THIS_MODULE; @@ -1021,9 +971,6 @@ static int __init hotkey_init(void) hotkey_config = create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir); if (!hotkey_config) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Hotkey: Unable to create %s entry\n", - HOTKEY_EV_CONFIG)); goto do_fail1; } else { hotkey_config->proc_fops = &hotkey_config_fops; @@ -1036,10 +983,6 @@ static int __init hotkey_init(void) hotkey_poll_config = create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir); if (!hotkey_poll_config) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Hotkey: Unable to create %s entry\n", - HOTKEY_EV_CONFIG)); - goto do_fail2; } else { hotkey_poll_config->proc_fops = &hotkey_poll_config_fops; @@ -1051,9 +994,6 @@ static int __init hotkey_init(void) hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir); if (!hotkey_action) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Hotkey: Unable to create %s entry\n", - HOTKEY_ACTION)); goto do_fail3; } else { hotkey_action->proc_fops = &hotkey_action_fops; @@ -1064,9 +1004,6 @@ static int __init hotkey_init(void) hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir); if (!hotkey_info) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Hotkey: Unable to create %s entry\n", - HOTKEY_INFO)); goto do_fail4; } else { hotkey_info->proc_fops = &hotkey_info_fops; @@ -1102,8 +1039,6 @@ static void __exit hotkey_exit(void) { struct list_head *entries, *next; - ACPI_FUNCTION_TRACE("hotkey_exit"); - list_for_each_safe(entries, next, global_hotkey_list.entries) { union acpi_hotkey *key = container_of(entries, union acpi_hotkey, entries); diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c index 4682441..ac74e6c 100644 --- a/drivers/acpi/motherboard.c +++ b/drivers/acpi/motherboard.c @@ -37,7 +37,7 @@ #define ACPI_MB_HID1 "PNP0C01" #define ACPI_MB_HID2 "PNP0C02" /** * Doesn't care about legacy IO ports, only IO ports beyond 0x1000 are reserved - * Doesn't care about the failure of 'request_region', since other may reserve + * Doesn't care about the failure of 'request_region', since other may reserve * the io ports as well */ #define IS_RESERVED_ADDR(base, len) \ @@ -46,19 +46,17 @@ #define IS_RESERVED_ADDR(base, len) \ /* * Clearing the flag (IORESOURCE_BUSY) allows drivers to use * the io ports if they really know they can use it, while - * still preventing hotplug PCI devices from using it. + * still preventing hotplug PCI devices from using it. */ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data) { struct resource *requested_res = NULL; - ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges"); - if (res->type == ACPI_RESOURCE_TYPE_IO) { struct acpi_resource_io *io_res = &res->data.io; if (io_res->minimum != io_res->maximum) - return_VALUE(AE_OK); + return AE_OK; if (IS_RESERVED_ADDR (io_res->minimum, io_res->address_length)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -92,7 +90,7 @@ static acpi_status acpi_reserve_io_range if (requested_res) requested_res->flags &= ~IORESOURCE_BUSY; - return_VALUE(AE_OK); + return AE_OK; } static int acpi_motherboard_add(struct acpi_device *device) @@ -123,49 +121,54 @@ static struct acpi_driver acpi_motherboa }, }; +static void __init acpi_request_region (struct acpi_generic_address *addr, + unsigned int length, char *desc) +{ + if (!addr->address || !length) + return; + + if (addr->address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) + request_region(addr->address, length, desc); + else if (addr->address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) + request_mem_region(addr->address, length, desc); +} + static void __init acpi_reserve_resources(void) { - if (acpi_gbl_FADT->xpm1a_evt_blk.address && acpi_gbl_FADT->pm1_evt_len) - request_region(acpi_gbl_FADT->xpm1a_evt_blk.address, - acpi_gbl_FADT->pm1_evt_len, "PM1a_EVT_BLK"); + acpi_request_region(&acpi_gbl_FADT->xpm1a_evt_blk, + acpi_gbl_FADT->pm1_evt_len, "ACPI PM1a_EVT_BLK"); - if (acpi_gbl_FADT->xpm1b_evt_blk.address && acpi_gbl_FADT->pm1_evt_len) - request_region(acpi_gbl_FADT->xpm1b_evt_blk.address, - acpi_gbl_FADT->pm1_evt_len, "PM1b_EVT_BLK"); + acpi_request_region(&acpi_gbl_FADT->xpm1b_evt_blk, + acpi_gbl_FADT->pm1_evt_len, "ACPI PM1b_EVT_BLK"); - if (acpi_gbl_FADT->xpm1a_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len) - request_region(acpi_gbl_FADT->xpm1a_cnt_blk.address, - acpi_gbl_FADT->pm1_cnt_len, "PM1a_CNT_BLK"); + acpi_request_region(&acpi_gbl_FADT->xpm1a_cnt_blk, + acpi_gbl_FADT->pm1_cnt_len, "ACPI PM1a_CNT_BLK"); - if (acpi_gbl_FADT->xpm1b_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len) - request_region(acpi_gbl_FADT->xpm1b_cnt_blk.address, - acpi_gbl_FADT->pm1_cnt_len, "PM1b_CNT_BLK"); + acpi_request_region(&acpi_gbl_FADT->xpm1b_cnt_blk, + acpi_gbl_FADT->pm1_cnt_len, "ACPI PM1b_CNT_BLK"); - if (acpi_gbl_FADT->xpm_tmr_blk.address && acpi_gbl_FADT->pm_tm_len == 4) - request_region(acpi_gbl_FADT->xpm_tmr_blk.address, 4, "PM_TMR"); + if (acpi_gbl_FADT->pm_tm_len == 4) + acpi_request_region(&acpi_gbl_FADT->xpm_tmr_blk, 4, "ACPI PM_TMR"); - if (acpi_gbl_FADT->xpm2_cnt_blk.address && acpi_gbl_FADT->pm2_cnt_len) - request_region(acpi_gbl_FADT->xpm2_cnt_blk.address, - acpi_gbl_FADT->pm2_cnt_len, "PM2_CNT_BLK"); + acpi_request_region(&acpi_gbl_FADT->xpm2_cnt_blk, + acpi_gbl_FADT->pm2_cnt_len, "ACPI PM2_CNT_BLK"); /* Length of GPE blocks must be a non-negative multiple of 2 */ - if (acpi_gbl_FADT->xgpe0_blk.address && acpi_gbl_FADT->gpe0_blk_len && - !(acpi_gbl_FADT->gpe0_blk_len & 0x1)) - request_region(acpi_gbl_FADT->xgpe0_blk.address, - acpi_gbl_FADT->gpe0_blk_len, "GPE0_BLK"); + if (!(acpi_gbl_FADT->gpe0_blk_len & 0x1)) + acpi_request_region(&acpi_gbl_FADT->xgpe0_blk, + acpi_gbl_FADT->gpe0_blk_len, "ACPI GPE0_BLK"); - if (acpi_gbl_FADT->xgpe1_blk.address && acpi_gbl_FADT->gpe1_blk_len && - !(acpi_gbl_FADT->gpe1_blk_len & 0x1)) - request_region(acpi_gbl_FADT->xgpe1_blk.address, - acpi_gbl_FADT->gpe1_blk_len, "GPE1_BLK"); + if (!(acpi_gbl_FADT->gpe1_blk_len & 0x1)) + acpi_request_region(&acpi_gbl_FADT->xgpe1_blk, + acpi_gbl_FADT->gpe1_blk_len, "ACPI GPE1_BLK"); } static int __init acpi_motherboard_init(void) { acpi_bus_register_driver(&acpi_motherboard_driver1); acpi_bus_register_driver(&acpi_motherboard_driver2); - /* + /* * Guarantee motherboard IO reservation first * This module must run after scan.c */ diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index 1149bc1..d4914fd 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -98,6 +98,7 @@ acpi_status acpi_ns_root_initialize(void "Entering predefined entries into namespace\n")); for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) { + /* _OSI is optional for now, will be permanent later */ if (!ACPI_STRCMP(init_val->name, "_OSI") @@ -346,14 +347,17 @@ acpi_ns_lookup(union acpi_generic_state return_ACPI_STATUS(AE_AML_INTERNAL); } - /* - * This node might not be a actual "scope" node (such as a - * Device/Method, etc.) It could be a Package or other object node. - * Backup up the tree to find the containing scope node. - */ - while (!acpi_ns_opens_scope(prefix_node->type) && - prefix_node->type != ACPI_TYPE_ANY) { - prefix_node = acpi_ns_get_parent_node(prefix_node); + if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) { + /* + * This node might not be a actual "scope" node (such as a + * Device/Method, etc.) It could be a Package or other object node. + * Backup up the tree to find the containing scope node. + */ + while (!acpi_ns_opens_scope(prefix_node->type) && + prefix_node->type != ACPI_TYPE_ANY) { + prefix_node = + acpi_ns_get_parent_node(prefix_node); + } } } @@ -365,6 +369,7 @@ acpi_ns_lookup(union acpi_generic_state * Begin examination of the actual pathname */ if (!pathname) { + /* A Null name_path is allowed and refers to the root */ num_segments = 0; @@ -389,6 +394,7 @@ acpi_ns_lookup(union acpi_generic_state * to the current scope). */ if (*path == (u8) AML_ROOT_PREFIX) { + /* Pathname is fully qualified, start from the root */ this_node = acpi_gbl_root_node; @@ -416,6 +422,7 @@ acpi_ns_lookup(union acpi_generic_state this_node = prefix_node; num_carats = 0; while (*path == (u8) AML_PARENT_PREFIX) { + /* Name is fully qualified, no search rules apply */ search_parent_flag = ACPI_NS_NO_UPSEARCH; @@ -430,6 +437,7 @@ acpi_ns_lookup(union acpi_generic_state num_carats++; this_node = acpi_ns_get_parent_node(this_node); if (!this_node) { + /* Current scope has no parent scope */ ACPI_ERROR((AE_INFO, @@ -569,6 +577,7 @@ acpi_ns_lookup(union acpi_generic_state &this_node); if (ACPI_FAILURE(status)) { if (status == AE_NOT_FOUND) { + /* Name not found in ACPI namespace */ ACPI_DEBUG_PRINT((ACPI_DB_NAMES, @@ -602,6 +611,7 @@ acpi_ns_lookup(union acpi_generic_state (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) && (this_node->type != ACPI_TYPE_ANY) && (this_node->type != type_to_check_for)) { + /* Complain about a type mismatch */ ACPI_WARNING((AE_INFO, diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index 9b871f3..acd4b67 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c @@ -68,7 +68,7 @@ struct acpi_namespace_node *acpi_ns_crea ACPI_FUNCTION_TRACE("ns_create_node"); - node = ACPI_MEM_CALLOCATE(sizeof(struct acpi_namespace_node)); + node = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_namespace_node)); if (!node) { return_PTR(NULL); } @@ -115,6 +115,7 @@ void acpi_ns_delete_node(struct acpi_nam } if (prev_node) { + /* Node is not first child, unlink it */ prev_node->peer = next_node->peer; @@ -125,6 +126,7 @@ void acpi_ns_delete_node(struct acpi_nam /* Node is first child (has no previous peer) */ if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { + /* No peers at all */ parent_node->child = NULL; @@ -140,7 +142,7 @@ void acpi_ns_delete_node(struct acpi_nam * Detach an object if there is one then delete the node */ acpi_ns_detach_object(node); - ACPI_MEM_FREE(node); + ACPI_FREE(node); return_VOID; } @@ -264,6 +266,7 @@ void acpi_ns_delete_children(struct acpi * Deallocate all children at this level */ do { + /* Get the things we need */ next_node = child_node->peer; @@ -308,7 +311,7 @@ void acpi_ns_delete_children(struct acpi /* Now we can delete the node */ - ACPI_MEM_FREE(child_node); + ACPI_FREE(child_node); /* And move on to the next child in the list */ @@ -352,11 +355,13 @@ void acpi_ns_delete_namespace_subtree(st * to where we started. */ while (level > 0) { + /* Get the next node in this scope (NULL if none) */ child_node = acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node, child_node); if (child_node) { + /* Found a child node - detach any attached object */ acpi_ns_detach_object(child_node); @@ -427,6 +432,7 @@ static void acpi_ns_remove_reference(str */ this_node = node; while (this_node) { + /* Prepare to move up to parent */ parent_node = acpi_ns_get_parent_node(this_node); @@ -438,6 +444,7 @@ static void acpi_ns_remove_reference(str /* Delete the node if no more references */ if (!this_node->reference_count) { + /* Delete all children and delete the node */ acpi_ns_delete_children(this_node); @@ -500,6 +507,7 @@ void acpi_ns_delete_namespace_by_owner(a if (child_node) { if (child_node->owner_id == owner_id) { + /* Found a matching child node - detach any attached object */ acpi_ns_detach_object(child_node); diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index a280731..e275373 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -191,6 +191,7 @@ acpi_ns_dump_one_object(acpi_handle obj_ } if (!(info->display_type & ACPI_DISPLAY_SHORT)) { + /* Indent the object according to the level */ acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " "); @@ -226,6 +227,7 @@ acpi_ns_dump_one_object(acpi_handle obj_ case ACPI_DISPLAY_SUMMARY: if (!obj_desc) { + /* No attached object, we are done */ acpi_os_printf("\n"); @@ -419,6 +421,7 @@ acpi_ns_dump_one_object(acpi_handle obj_ acpi_os_printf("O:%p", obj_desc); if (!obj_desc) { + /* No attached object, we are done */ acpi_os_printf("\n"); @@ -682,6 +685,7 @@ void acpi_ns_dump_tables(acpi_handle sea } if (ACPI_NS_ALL == search_base) { + /* Entire namespace */ search_handle = acpi_gbl_root_node; diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c index aff899a..2b311da 100644 --- a/drivers/acpi/namespace/nsdumpdv.c +++ b/drivers/acpi/namespace/nsdumpdv.c @@ -92,7 +92,7 @@ acpi_ns_dump_one_device(acpi_handle obj_ info->hardware_id.value, ACPI_FORMAT_UINT64(info->address), info->current_status)); - ACPI_MEM_FREE(info); + ACPI_FREE(info); } return (status); diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c index 19d7b94..f5d8e71 100644 --- a/drivers/acpi/namespace/nseval.c +++ b/drivers/acpi/namespace/nseval.c @@ -151,7 +151,7 @@ acpi_ns_evaluate_relative(char *pathname acpi_ut_delete_generic_state(scope_info); cleanup1: - ACPI_MEM_FREE(internal_path); + ACPI_FREE(internal_path); return_ACPI_STATUS(status); } @@ -228,7 +228,7 @@ acpi_ns_evaluate_by_name(char *pathname, /* Cleanup */ if (internal_path) { - ACPI_MEM_FREE(internal_path); + ACPI_FREE(internal_path); } return_ACPI_STATUS(status); @@ -326,6 +326,7 @@ acpi_status acpi_ns_evaluate_by_handle(s * Check if there is a return value on the stack that must be dealt with */ if (status == AE_CTRL_RETURN_VALUE) { + /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ status = AE_OK; diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index 9f929e4..57b2537 100644 --- a/drivers/acpi/namespace/nsinit.c +++ b/drivers/acpi/namespace/nsinit.c @@ -366,6 +366,7 @@ acpi_ns_init_one_device(acpi_handle obj_ status = acpi_ns_search_node(*ACPI_CAST_PTR(u32, METHOD_NAME__INI), device_node, ACPI_TYPE_METHOD, &ini_node); if (ACPI_FAILURE(status)) { + /* No _INI method found - move on to next device */ return_ACPI_STATUS(AE_OK); @@ -386,6 +387,7 @@ acpi_ns_init_one_device(acpi_handle obj_ status = acpi_ut_execute_STA(pinfo.node, &flags); if (ACPI_FAILURE(status)) { + /* Ignore error and move on to next device */ return_ACPI_STATUS(AE_OK); @@ -396,6 +398,7 @@ acpi_ns_init_one_device(acpi_handle obj_ } if (!(flags & ACPI_STA_DEVICE_PRESENT)) { + /* Don't look at children of a not present device */ return_ACPI_STATUS(AE_CTRL_DEPTH); @@ -412,6 +415,7 @@ acpi_ns_init_one_device(acpi_handle obj_ pinfo.node = ini_node; status = acpi_ns_evaluate_by_handle(&pinfo); if (ACPI_FAILURE(status)) { + /* Ignore error and move on to next device */ #ifdef ACPI_DEBUG_OUTPUT @@ -420,7 +424,7 @@ #ifdef ACPI_DEBUG_OUTPUT ACPI_WARNING((AE_INFO, "%s._INI failed: %s", scope_name, acpi_format_exception(status))); - ACPI_MEM_FREE(scope_name); + ACPI_FREE(scope_name); #endif } else { /* Delete any return object (especially if implicit_return is enabled) */ @@ -435,6 +439,7 @@ #endif } if (acpi_gbl_init_handler) { + /* External initialization handler is present, call it */ status = diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c index 4e0b052..80acfd3 100644 --- a/drivers/acpi/namespace/nsload.c +++ b/drivers/acpi/namespace/nsload.c @@ -84,6 +84,7 @@ acpi_ns_load_table(struct acpi_table_des if (! (acpi_gbl_table_data[table_desc->type]. flags & ACPI_TABLE_EXECUTABLE)) { + /* Just ignore this table */ return_ACPI_STATUS(AE_OK); @@ -325,6 +326,7 @@ static acpi_status acpi_ns_delete_subtre * to where we started. */ while (level > 0) { + /* Attempt to get the next object in this scope */ status = acpi_get_next_object(ACPI_TYPE_ANY, parent_handle, @@ -335,6 +337,7 @@ static acpi_status acpi_ns_delete_subtre /* Did we get a new object? */ if (ACPI_SUCCESS(status)) { + /* Check if this object has any children */ if (ACPI_SUCCESS diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c index 639f653..ba812f4 100644 --- a/drivers/acpi/namespace/nsnames.c +++ b/drivers/acpi/namespace/nsnames.c @@ -48,11 +48,6 @@ #include #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME("nsnames") -/* Local prototypes */ -static void -acpi_ns_build_external_path(struct acpi_namespace_node *node, - acpi_size size, char *name_buffer); - /******************************************************************************* * * FUNCTION: acpi_ns_build_external_path @@ -67,8 +62,7 @@ acpi_ns_build_external_path(struct acpi_ * DESCRIPTION: Generate a full pathaname * ******************************************************************************/ - -static void +void acpi_ns_build_external_path(struct acpi_namespace_node *node, acpi_size size, char *name_buffer) { @@ -146,7 +140,7 @@ char *acpi_ns_get_external_pathname(stru /* Allocate a buffer to be returned to caller */ - name_buffer = ACPI_MEM_CALLOCATE(size); + name_buffer = ACPI_ALLOCATE_ZEROED(size); if (!name_buffer) { ACPI_ERROR((AE_INFO, "Allocation failure")); return_PTR(NULL); diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c index 10ae629..39dc87b 100644 --- a/drivers/acpi/namespace/nsobject.c +++ b/drivers/acpi/namespace/nsobject.c @@ -82,6 +82,7 @@ acpi_ns_attach_object(struct acpi_namesp * Parameter validation */ if (!node) { + /* Invalid handle */ ACPI_ERROR((AE_INFO, "Null named_obj handle")); @@ -89,6 +90,7 @@ acpi_ns_attach_object(struct acpi_namesp } if (!object && (ACPI_TYPE_ANY != type)) { + /* Null object */ ACPI_ERROR((AE_INFO, @@ -97,6 +99,7 @@ acpi_ns_attach_object(struct acpi_namesp } if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { + /* Not a name handle */ ACPI_ERROR((AE_INFO, "Invalid handle %p [%s]", diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c index 232be43..64daf30 100644 --- a/drivers/acpi/namespace/nsparse.c +++ b/drivers/acpi/namespace/nsparse.c @@ -62,7 +62,7 @@ ACPI_MODULE_NAME("nsparse") * ******************************************************************************/ acpi_status -acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc * table_desc) +acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc *table_desc) { union acpi_parse_object *parse_root; acpi_status status; diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c index d64b789..c929f45 100644 --- a/drivers/acpi/namespace/nssearch.c +++ b/drivers/acpi/namespace/nssearch.c @@ -103,7 +103,7 @@ #ifdef ACPI_DEBUG_OUTPUT &target_name), acpi_ut_get_type_name(type))); - ACPI_MEM_FREE(scope_name); + ACPI_FREE(scope_name); } } #endif @@ -114,9 +114,11 @@ #endif */ next_node = node->child; while (next_node) { + /* Check for match against the name */ if (next_node->name.integer == target_name) { + /* Resolve a control method alias if any */ if (acpi_ns_get_type(next_node) == @@ -146,6 +148,7 @@ #endif * so a flag is used to indicate the end-of-list */ if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { + /* Searched entire list, we are done */ break; diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c index 3e7cad5..586014e 100644 --- a/drivers/acpi/namespace/nsutils.c +++ b/drivers/acpi/namespace/nsutils.c @@ -78,15 +78,17 @@ acpi_ns_report_error(char *module_name, char *internal_name, acpi_status lookup_status) { acpi_status status; + u32 bad_name; char *name = NULL; acpi_ut_report_error(module_name, line_number); if (lookup_status == AE_BAD_CHARACTER) { + /* There is a non-ascii character in the name */ - acpi_os_printf("[0x%4.4X] (NON-ASCII)", - *(ACPI_CAST_PTR(u32, internal_name))); + ACPI_MOVE_32_TO_32(&bad_name, internal_name); + acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name); } else { /* Convert path to external format */ @@ -102,7 +104,7 @@ acpi_ns_report_error(char *module_name, } if (name) { - ACPI_MEM_FREE(name); + ACPI_FREE(name); } } @@ -185,7 +187,7 @@ acpi_ns_print_node_pathname(struct acpi_ } acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node); - ACPI_MEM_FREE(buffer.pointer); + ACPI_FREE(buffer.pointer); } } @@ -267,6 +269,7 @@ u32 acpi_ns_local(acpi_object_type type) ACPI_FUNCTION_TRACE("ns_local"); if (!acpi_ut_valid_object_type(type)) { + /* Type code out of range */ ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type)); @@ -411,6 +414,7 @@ acpi_status acpi_ns_build_internal_name( for (i = 0; i < ACPI_NAME_SIZE; i++) { if (acpi_ns_valid_path_separator(*external_name) || (*external_name == 0)) { + /* Pad the segment with underscore(s) if segment is short */ result[i] = '_'; @@ -486,7 +490,7 @@ acpi_status acpi_ns_internalize_name(cha /* We need a segment to store the internal name */ - internal_name = ACPI_MEM_CALLOCATE(info.length); + internal_name = ACPI_ALLOCATE_ZEROED(info.length); if (!internal_name) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -496,7 +500,7 @@ acpi_status acpi_ns_internalize_name(cha info.internal_name = internal_name; status = acpi_ns_build_internal_name(&info); if (ACPI_FAILURE(status)) { - ACPI_MEM_FREE(internal_name); + ACPI_FREE(internal_name); return_ACPI_STATUS(status); } @@ -628,7 +632,7 @@ acpi_ns_externalize_name(u32 internal_na /* * Build converted_name */ - *converted_name = ACPI_MEM_CALLOCATE(required_length); + *converted_name = ACPI_ALLOCATE_ZEROED(required_length); if (!(*converted_name)) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -795,6 +799,7 @@ u32 acpi_ns_opens_scope(acpi_object_type ACPI_FUNCTION_TRACE_STR("ns_opens_scope", acpi_ut_get_type_name(type)); if (!acpi_ut_valid_object_type(type)) { + /* type code out of range */ ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type)); @@ -838,6 +843,7 @@ acpi_ns_get_node_by_path(char *pathname, ACPI_FUNCTION_TRACE_PTR("ns_get_node_by_path", pathname); if (pathname) { + /* Convert path to internal representation */ status = acpi_ns_internalize_name(pathname, &internal_path); @@ -873,7 +879,7 @@ acpi_ns_get_node_by_path(char *pathname, cleanup: if (internal_path) { - ACPI_MEM_FREE(internal_path); + ACPI_FREE(internal_path); } return_ACPI_STATUS(status); } @@ -963,6 +969,7 @@ acpi_name acpi_ns_find_parent_name(struc ACPI_FUNCTION_TRACE("ns_find_parent_name"); if (child_node) { + /* Valid entry. Get the parent Node */ parent_node = acpi_ns_get_parent_node(child_node); diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c index fcab1e7..6bbc734 100644 --- a/drivers/acpi/namespace/nswalk.c +++ b/drivers/acpi/namespace/nswalk.c @@ -76,6 +76,7 @@ struct acpi_namespace_node *acpi_ns_get_ ACPI_FUNCTION_ENTRY(); if (!child_node) { + /* It's really the parent's _scope_ that we want */ if (parent_node->child) { @@ -92,6 +93,7 @@ struct acpi_namespace_node *acpi_ns_get_ /* If any type is OK, we are done */ if (type == ACPI_TYPE_ANY) { + /* next_node is NULL if we are at the end-of-list */ return (next_node); @@ -100,6 +102,7 @@ struct acpi_namespace_node *acpi_ns_get_ /* Must search for the node -- but within this scope only */ while (next_node) { + /* If type matches, we are done */ if (next_node->type == type) { @@ -182,6 +185,7 @@ acpi_ns_walk_namespace(acpi_object_type * bubbled up to (and passed) the original parent handle (start_entry) */ while (level > 0) { + /* Get the next node in this scope. Null if not found */ status = AE_OK; diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index a95f636..08394d6 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c @@ -42,8 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include #include @@ -51,6 +49,7 @@ #include #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME("nsxfeval") +#ifdef ACPI_FUTURE_USAGE /******************************************************************************* * * FUNCTION: acpi_evaluate_object_typed @@ -71,12 +70,11 @@ ACPI_MODULE_NAME("nsxfeval") * be valid (non-null) * ******************************************************************************/ -#ifdef ACPI_FUTURE_USAGE acpi_status acpi_evaluate_object_typed(acpi_handle handle, acpi_string pathname, - struct acpi_object_list *external_params, - struct acpi_buffer *return_buffer, + struct acpi_object_list * external_params, + struct acpi_buffer * return_buffer, acpi_object_type return_type) { acpi_status status; @@ -110,6 +108,7 @@ acpi_evaluate_object_typed(acpi_handle h } if (return_buffer->length == 0) { + /* Error because caller specifically asked for a return value */ ACPI_ERROR((AE_INFO, "No return value")); @@ -131,15 +130,18 @@ acpi_evaluate_object_typed(acpi_handle h acpi_ut_get_type_name(return_type))); if (must_free) { + /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ - acpi_os_free(return_buffer->pointer); + kfree(return_buffer->pointer); return_buffer->pointer = NULL; } return_buffer->length = 0; return_ACPI_STATUS(AE_TYPE); } + +ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed) #endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* @@ -161,7 +163,6 @@ #endif /* ACPI_FUTURE_USAGE */ * be valid (non-null) * ******************************************************************************/ - acpi_status acpi_evaluate_object(acpi_handle handle, acpi_string pathname, @@ -191,9 +192,9 @@ acpi_evaluate_object(acpi_handle handle, * Allocate a new parameter block for the internal objects * Add 1 to count to allow for null terminated internal list */ - info.parameters = ACPI_MEM_CALLOCATE(((acpi_size) - external_params->count + - 1) * sizeof(void *)); + info.parameters = ACPI_ALLOCATE_ZEROED(((acpi_size) + external_params->count + + 1) * sizeof(void *)); if (!info.parameters) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -224,9 +225,9 @@ acpi_evaluate_object(acpi_handle handle, * 3) Valid handle */ if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) { - /* - * The path is fully qualified, just evaluate by name - */ + + /* The path is fully qualified, just evaluate by name */ + status = acpi_ns_evaluate_by_name(pathname, &info); } else if (!handle) { /* @@ -235,11 +236,12 @@ acpi_evaluate_object(acpi_handle handle, * qualified names above, this is an error */ if (!pathname) { - ACPI_ERROR((AE_INFO, - "Both Handle and Pathname are NULL")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Both Handle and Pathname are NULL")); } else { - ACPI_ERROR((AE_INFO, - "Handle is NULL and Pathname is relative")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Null Handle with relative pathname [%s]", + pathname)); } status = AE_BAD_PARAMETER; @@ -256,9 +258,8 @@ acpi_evaluate_object(acpi_handle handle, */ status = acpi_ns_evaluate_by_handle(&info); } else { - /* - * Both a Handle and a relative Pathname - */ + /* Both a Handle and a relative Pathname */ + status = acpi_ns_evaluate_relative(pathname, &info); } } @@ -295,6 +296,7 @@ acpi_evaluate_object(acpi_handle handle, acpi_ut_get_object_size(info.return_object, &buffer_space_needed); if (ACPI_SUCCESS(status)) { + /* Validate/Allocate/Clear caller buffer */ status = @@ -303,7 +305,8 @@ acpi_evaluate_object(acpi_handle handle, buffer_space_needed); if (ACPI_FAILURE(status)) { /* - * Caller's buffer is too small or a new one can't be allocated + * Caller's buffer is too small or a new one can't + * be allocated */ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Needed buffer size %X, %s\n", @@ -312,9 +315,8 @@ acpi_evaluate_object(acpi_handle handle, acpi_format_exception (status))); } else { - /* - * We have enough space for the object, build it - */ + /* We have enough space for the object, build it */ + status = acpi_ut_copy_iobject_to_eobject (info.return_object, @@ -341,10 +343,10 @@ acpi_evaluate_object(acpi_handle handle, } } - /* - * Free the input parameter list (if we created one), - */ + /* Free the input parameter list (if we created one) */ + if (info.parameters) { + /* Free the allocated parameter block */ acpi_ut_delete_internal_object_list(info.parameters); @@ -353,7 +355,7 @@ acpi_evaluate_object(acpi_handle handle, return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_evaluate_object); +ACPI_EXPORT_SYMBOL(acpi_evaluate_object) /******************************************************************************* * @@ -384,7 +386,6 @@ EXPORT_SYMBOL(acpi_evaluate_object); * function, etc. * ******************************************************************************/ - acpi_status acpi_walk_namespace(acpi_object_type type, acpi_handle start_object, @@ -421,7 +422,7 @@ acpi_walk_namespace(acpi_object_type typ return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_walk_namespace); +ACPI_EXPORT_SYMBOL(acpi_walk_namespace) /******************************************************************************* * @@ -436,7 +437,6 @@ EXPORT_SYMBOL(acpi_walk_namespace); * on that. * ******************************************************************************/ - static acpi_status acpi_ns_get_device_callback(acpi_handle obj_handle, u32 nesting_level, @@ -473,6 +473,7 @@ acpi_ns_get_device_callback(acpi_handle } if (!(flags & ACPI_STA_DEVICE_PRESENT)) { + /* Don't examine children of the device if not present */ return (AE_CTRL_DEPTH); @@ -489,6 +490,7 @@ acpi_ns_get_device_callback(acpi_handle } if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) { + /* Get the list of Compatible IDs */ status = acpi_ut_execute_CID(node, &cid); @@ -505,11 +507,11 @@ acpi_ns_get_device_callback(acpi_handle sizeof(struct acpi_compatible_id)) != 0) { - ACPI_MEM_FREE(cid); + ACPI_FREE(cid); return (AE_OK); } } - ACPI_MEM_FREE(cid); + ACPI_FREE(cid); } } @@ -563,9 +565,9 @@ acpi_get_devices(char *HID, * We're going to call their callback from OUR callback, so we need * to know what it is, and their context parameter. */ + info.hid = HID; info.context = context; info.user_function = user_function; - info.hid = HID; /* * Lock the namespace around the walk. @@ -578,9 +580,8 @@ acpi_get_devices(char *HID, return_ACPI_STATUS(status); } - status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, - ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, + status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, acpi_ns_get_device_callback, &info, return_value); @@ -588,7 +589,7 @@ acpi_get_devices(char *HID, return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_devices); +ACPI_EXPORT_SYMBOL(acpi_get_devices) /******************************************************************************* * @@ -603,7 +604,6 @@ EXPORT_SYMBOL(acpi_get_devices); * DESCRIPTION: Attach arbitrary data and handler to a namespace node. * ******************************************************************************/ - acpi_status acpi_attach_data(acpi_handle obj_handle, acpi_object_handler handler, void *data) @@ -637,6 +637,8 @@ acpi_attach_data(acpi_handle obj_handle, return (status); } +ACPI_EXPORT_SYMBOL(acpi_attach_data) + /******************************************************************************* * * FUNCTION: acpi_detach_data @@ -649,7 +651,6 @@ acpi_attach_data(acpi_handle obj_handle, * DESCRIPTION: Remove data that was previously attached to a node. * ******************************************************************************/ - acpi_status acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler) { @@ -682,6 +683,8 @@ acpi_detach_data(acpi_handle obj_handle, return (status); } +ACPI_EXPORT_SYMBOL(acpi_detach_data) + /******************************************************************************* * * FUNCTION: acpi_get_data @@ -695,7 +698,6 @@ acpi_detach_data(acpi_handle obj_handle, * DESCRIPTION: Retrieve data that was previously attached to a namespace node. * ******************************************************************************/ - acpi_status acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) { @@ -727,3 +729,5 @@ acpi_get_data(acpi_handle obj_handle, ac (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return (status); } + +ACPI_EXPORT_SYMBOL(acpi_get_data) diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c index 8cd8675..1303e2b 100644 --- a/drivers/acpi/namespace/nsxfname.c +++ b/drivers/acpi/namespace/nsxfname.c @@ -42,8 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include @@ -126,7 +124,7 @@ acpi_get_handle(acpi_handle parent, return (status); } -EXPORT_SYMBOL(acpi_get_handle); +ACPI_EXPORT_SYMBOL(acpi_get_handle) /****************************************************************************** * @@ -143,7 +141,6 @@ EXPORT_SYMBOL(acpi_get_handle); * complementary functions. * ******************************************************************************/ - acpi_status acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer) { @@ -162,6 +159,7 @@ acpi_get_name(acpi_handle handle, u32 na } if (name_type == ACPI_FULL_PATHNAME) { + /* Get the full pathname (From the namespace root) */ status = acpi_ns_handle_to_pathname(handle, buffer); @@ -203,7 +201,7 @@ acpi_get_name(acpi_handle handle, u32 na return (status); } -EXPORT_SYMBOL(acpi_get_name); +ACPI_EXPORT_SYMBOL(acpi_get_name) /****************************************************************************** * @@ -219,7 +217,6 @@ EXPORT_SYMBOL(acpi_get_name); * control methods (Such as in the case of a device.) * ******************************************************************************/ - acpi_status acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer) { @@ -241,7 +238,7 @@ acpi_get_object_info(acpi_handle handle, return (status); } - info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_device_info)); + info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_device_info)); if (!info) { return (AE_NO_MEMORY); } @@ -345,11 +342,11 @@ acpi_get_object_info(acpi_handle handle, } cleanup: - ACPI_MEM_FREE(info); + ACPI_FREE(info); if (cid_list) { - ACPI_MEM_FREE(cid_list); + ACPI_FREE(cid_list); } return (status); } -EXPORT_SYMBOL(acpi_get_object_info); +ACPI_EXPORT_SYMBOL(acpi_get_object_info) diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c index a033259..a163e1d 100644 --- a/drivers/acpi/namespace/nsxfobj.c +++ b/drivers/acpi/namespace/nsxfobj.c @@ -42,8 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include @@ -101,7 +99,7 @@ acpi_status acpi_get_type(acpi_handle ha return (status); } -EXPORT_SYMBOL(acpi_get_type); +ACPI_EXPORT_SYMBOL(acpi_get_type) /******************************************************************************* * @@ -116,7 +114,6 @@ EXPORT_SYMBOL(acpi_get_type); * Handle. * ******************************************************************************/ - acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle) { struct acpi_namespace_node *node; @@ -162,7 +159,7 @@ acpi_status acpi_get_parent(acpi_handle return (status); } -EXPORT_SYMBOL(acpi_get_parent); +ACPI_EXPORT_SYMBOL(acpi_get_parent) /******************************************************************************* * @@ -181,7 +178,6 @@ EXPORT_SYMBOL(acpi_get_parent); * Scope is returned. * ******************************************************************************/ - acpi_status acpi_get_next_object(acpi_object_type type, acpi_handle parent, @@ -206,6 +202,7 @@ acpi_get_next_object(acpi_object_type ty /* If null handle, use the parent */ if (!child) { + /* Start search at the beginning of the specified scope */ parent_node = acpi_ns_map_handle_to_node(parent); @@ -242,4 +239,4 @@ acpi_get_next_object(acpi_object_type ty return (status); } -EXPORT_SYMBOL(acpi_get_next_object); +ACPI_EXPORT_SYMBOL(acpi_get_next_object) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 13b5fd5..8113c8d 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -37,6 +37,7 @@ #include #include #include #include +#include #include #include #include @@ -136,22 +137,6 @@ #else #endif } -extern int acpi_in_resume; -void *acpi_os_allocate(acpi_size size) -{ - if (acpi_in_resume) - return kmalloc(size, GFP_ATOMIC); - else - return kmalloc(size, GFP_KERNEL); -} - -void acpi_os_free(void *ptr) -{ - kfree(ptr); -} - -EXPORT_SYMBOL(acpi_os_free); - acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr) { if (efi_enabled) { @@ -585,38 +570,54 @@ static void acpi_os_execute_deferred(voi { struct acpi_os_dpc *dpc = NULL; - ACPI_FUNCTION_TRACE("os_execute_deferred"); - dpc = (struct acpi_os_dpc *)context; if (!dpc) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); - return_VOID; + ACPI_ERROR((AE_INFO, "Invalid (NULL) context")); + return; } dpc->function(dpc->context); kfree(dpc); - return_VOID; + return; } -acpi_status -acpi_os_queue_for_execution(u32 priority, +static int acpi_os_execute_thread(void *context) +{ + struct acpi_os_dpc *dpc = (struct acpi_os_dpc *)context; + if (dpc) { + dpc->function(dpc->context); + kfree(dpc); + } + do_exit(0); +} + +/******************************************************************************* + * + * FUNCTION: acpi_os_execute + * + * PARAMETERS: Type - Type of the callback + * Function - Function to be executed + * Context - Function parameters + * + * RETURN: Status + * + * DESCRIPTION: Depending on type, either queues function for deferred execution or + * immediately executes function on a separate thread. + * + ******************************************************************************/ + +acpi_status acpi_os_execute(enum acpi_callback_type type, acpi_osd_exec_callback function, void *context) { acpi_status status = AE_OK; struct acpi_os_dpc *dpc; struct work_struct *task; - - ACPI_FUNCTION_TRACE("os_queue_for_execution"); - - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, - "Scheduling function [%p(%p)] for deferred execution.\n", - function, context)); + struct task_struct *p; if (!function) - return_ACPI_STATUS(AE_BAD_PARAMETER); - + return AE_BAD_PARAMETER; /* * Allocate/initialize DPC structure. Note that this memory will be * freed by the callee. The kernel handles the tq_struct list in a @@ -627,30 +628,38 @@ acpi_os_queue_for_execution(u32 priority * We can save time and code by allocating the DPC and tq_structs * from the same memory. */ - - dpc = - kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct), - GFP_ATOMIC); + if (type == OSL_NOTIFY_HANDLER) { + dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_KERNEL); + } else { + dpc = kmalloc(sizeof(struct acpi_os_dpc) + + sizeof(struct work_struct), GFP_ATOMIC); + } if (!dpc) - return_ACPI_STATUS(AE_NO_MEMORY); + return AE_NO_MEMORY; dpc->function = function; dpc->context = context; - task = (void *)(dpc + 1); - INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); - - if (!queue_work(kacpid_wq, task)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Call to queue_work() failed.\n")); - kfree(dpc); - status = AE_ERROR; + if (type == OSL_NOTIFY_HANDLER) { + p = kthread_create(acpi_os_execute_thread, dpc, "kacpid_notify"); + if (!IS_ERR(p)) { + wake_up_process(p); + } else { + status = AE_NO_MEMORY; + kfree(dpc); + } + } else { + task = (void *)(dpc + 1); + INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); + if (!queue_work(kacpid_wq, task)) { + status = AE_ERROR; + kfree(dpc); + } } - - return_ACPI_STATUS(status); + return status; } -EXPORT_SYMBOL(acpi_os_queue_for_execution); +EXPORT_SYMBOL(acpi_os_execute); void acpi_os_wait_events_complete(void *context) { @@ -666,9 +675,7 @@ acpi_status acpi_os_create_lock(acpi_han { spinlock_t *lock_ptr; - ACPI_FUNCTION_TRACE("os_create_lock"); - - lock_ptr = acpi_os_allocate(sizeof(spinlock_t)); + lock_ptr = kmalloc(sizeof(spinlock_t), GFP_KERNEL); spin_lock_init(lock_ptr); @@ -676,7 +683,7 @@ acpi_status acpi_os_create_lock(acpi_han *out_handle = lock_ptr; - return_ACPI_STATUS(AE_OK); + return AE_OK; } /* @@ -684,13 +691,11 @@ acpi_status acpi_os_create_lock(acpi_han */ void acpi_os_delete_lock(acpi_handle handle) { - ACPI_FUNCTION_TRACE("os_create_lock"); - ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle)); - acpi_os_free(handle); + kfree(handle); - return_VOID; + return; } acpi_status @@ -698,11 +703,9 @@ acpi_os_create_semaphore(u32 max_units, { struct semaphore *sem = NULL; - ACPI_FUNCTION_TRACE("os_create_semaphore"); - - sem = acpi_os_allocate(sizeof(struct semaphore)); + sem = kmalloc(sizeof(struct semaphore), GFP_KERNEL); if (!sem) - return_ACPI_STATUS(AE_NO_MEMORY); + return AE_NO_MEMORY; memset(sem, 0, sizeof(struct semaphore)); sema_init(sem, initial_units); @@ -712,7 +715,7 @@ acpi_os_create_semaphore(u32 max_units, ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", *handle, initial_units)); - return_ACPI_STATUS(AE_OK); + return AE_OK ; } EXPORT_SYMBOL(acpi_os_create_semaphore); @@ -728,17 +731,15 @@ acpi_status acpi_os_delete_semaphore(acp { struct semaphore *sem = (struct semaphore *)handle; - ACPI_FUNCTION_TRACE("os_delete_semaphore"); - if (!sem) - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); - acpi_os_free(sem); + kfree(sem); sem = NULL; - return_ACPI_STATUS(AE_OK); + return AE_OK; } EXPORT_SYMBOL(acpi_os_delete_semaphore); @@ -758,13 +759,11 @@ acpi_status acpi_os_wait_semaphore(acpi_ struct semaphore *sem = (struct semaphore *)handle; int ret = 0; - ACPI_FUNCTION_TRACE("os_wait_semaphore"); - if (!sem || (units < 1)) - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; if (units > 1) - return_ACPI_STATUS(AE_SUPPORT); + return AE_SUPPORT; ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout)); @@ -816,17 +815,17 @@ acpi_status acpi_os_wait_semaphore(acpi_ } if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Failed to acquire semaphore[%p|%d|%d], %s\n", + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, + "Failed to acquire semaphore[%p|%d|%d], %s", handle, units, timeout, acpi_format_exception(status))); } else { ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, - "Acquired semaphore[%p|%d|%d]\n", handle, + "Acquired semaphore[%p|%d|%d]", handle, units, timeout)); } - return_ACPI_STATUS(status); + return status; } EXPORT_SYMBOL(acpi_os_wait_semaphore); @@ -838,20 +837,18 @@ acpi_status acpi_os_signal_semaphore(acp { struct semaphore *sem = (struct semaphore *)handle; - ACPI_FUNCTION_TRACE("os_signal_semaphore"); - if (!sem || (units < 1)) - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; if (units > 1) - return_ACPI_STATUS(AE_SUPPORT); + return AE_SUPPORT; ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, units)); up(sem); - return_ACPI_STATUS(AE_OK); + return AE_OK; } EXPORT_SYMBOL(acpi_os_signal_semaphore); @@ -896,14 +893,6 @@ u8 acpi_os_writable(void *ptr, acpi_size } #endif -u32 acpi_os_get_thread_id(void) -{ - if (!in_atomic()) - return current->pid; - - return 0; -} - acpi_status acpi_os_signal(u32 function, void *info) { switch (function) { @@ -1141,7 +1130,9 @@ acpi_status acpi_os_release_object(acpi_ void *acpi_os_acquire_object(acpi_cache_t * cache) { - void *object = kmem_cache_alloc(cache, GFP_KERNEL); + void *object; + + object = kmem_cache_alloc(cache, GFP_KERNEL); WARN_ON(!object); return object; } diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c index de573be..1c5934f 100644 --- a/drivers/acpi/parser/psargs.c +++ b/drivers/acpi/parser/psargs.c @@ -275,6 +275,7 @@ acpi_ps_get_next_namepath(struct acpi_wa */ if (ACPI_SUCCESS(status) && possible_method_call && (node->type == ACPI_TYPE_METHOD)) { + /* This name is actually a control method invocation */ method_desc = acpi_ns_get_attached_object(node); @@ -319,6 +320,7 @@ acpi_ps_get_next_namepath(struct acpi_wa * some not_found cases are allowed */ if (status == AE_NOT_FOUND) { + /* 1) not_found is ok during load pass 1/2 (allow forward references) */ if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) != @@ -354,6 +356,7 @@ acpi_ps_get_next_namepath(struct acpi_wa if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { + /* Report a control method execution error */ status = acpi_ds_method_error(status, walk_state); @@ -620,6 +623,7 @@ acpi_ps_get_next_arg(struct acpi_walk_st case ARGP_FIELDLIST: if (parser_state->aml < parser_state->pkg_end) { + /* Non-empty list */ while (parser_state->aml < parser_state->pkg_end) { @@ -645,6 +649,7 @@ acpi_ps_get_next_arg(struct acpi_walk_st case ARGP_BYTELIST: if (parser_state->aml < parser_state->pkg_end) { + /* Non-empty list */ arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP); @@ -673,6 +678,7 @@ acpi_ps_get_next_arg(struct acpi_walk_st if (subop == 0 || acpi_ps_is_leading_char(subop) || acpi_ps_is_prefix_char(subop)) { + /* null_name or name_string */ arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); @@ -703,6 +709,7 @@ acpi_ps_get_next_arg(struct acpi_walk_st case ARGP_OBJLIST: if (parser_state->aml < parser_state->pkg_end) { + /* Non-empty list of variable arguments, nothing returned */ walk_state->arg_count = ACPI_VAR_ARGS; diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index 00b072e..14052cb 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c @@ -95,6 +95,7 @@ acpi_status acpi_ps_parse_loop(struct ac #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) { + /* We are restarting a preempted control method */ if (acpi_ps_has_completed_scope(parser_state)) { @@ -143,6 +144,7 @@ #if (!defined (ACPI_NO_METHOD_EXECUTION) ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", op)); } else if (walk_state->prev_op) { + /* We were in the middle of an op */ op = walk_state->prev_op; @@ -156,6 +158,7 @@ #endif while ((parser_state->aml < parser_state->aml_end) || (op)) { aml_op_start = parser_state->aml; if (!op) { + /* Get the next opcode from the AML stream */ walk_state->aml_offset = @@ -213,6 +216,7 @@ #endif /* Create Op structure and append to parent's argument list */ if (walk_state->op_info->flags & AML_NAMED) { + /* Allocate a new pre_op if necessary */ if (!pre_op) { @@ -388,6 +392,7 @@ #endif /* Are there any arguments that must be processed? */ if (walk_state->arg_types) { + /* Get arguments */ switch (op->common.aml_opcode) { @@ -762,6 +767,7 @@ #endif return_ACPI_STATUS(status2); } } + acpi_ps_pop_scope(parser_state, &op, &walk_state->arg_types, &walk_state->arg_count); @@ -853,6 +859,7 @@ #endif } else if (ACPI_FAILURE(status)) { + /* First error is most important */ (void) diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c index 11d6351..9eb8d06 100644 --- a/drivers/acpi/parser/psopcode.c +++ b/drivers/acpi/parser/psopcode.c @@ -731,6 +731,7 @@ const struct acpi_opcode_info *acpi_ps_g * Detect normal 8-bit opcode or extended 16-bit opcode */ if (!(opcode & 0xFF00)) { + /* Simple (8-bit) opcode: 0-255, can't index beyond table */ return (&acpi_gbl_aml_op_info @@ -739,6 +740,7 @@ const struct acpi_opcode_info *acpi_ps_g if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) && (((u8) opcode) <= MAX_EXTENDED_OPCODE)) { + /* Valid extended (16-bit) opcode */ return (&acpi_gbl_aml_op_info diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index a9f3229..83d8916 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -106,6 +106,7 @@ u16 acpi_ps_peek_opcode(struct acpi_pars opcode = (u16) ACPI_GET8(aml); if (opcode == AML_EXTENDED_OP_PREFIX) { + /* Extended opcode, get the second opcode byte */ aml++; @@ -158,6 +159,7 @@ acpi_ps_complete_this_op(struct acpi_wal if (op->common.parent) { prev = op->common.parent->common.value.arg; if (!prev) { + /* Nothing more to do */ goto cleanup; @@ -245,6 +247,7 @@ acpi_ps_complete_this_op(struct acpi_wal /* We must unlink this op from the parent tree */ if (prev == op) { + /* This op is the first in the list */ if (replacement_op) { @@ -265,6 +268,7 @@ acpi_ps_complete_this_op(struct acpi_wal else while (prev) { + /* Traverse all siblings in the parent's argument list */ next = prev->common.next; @@ -510,6 +514,7 @@ acpi_status acpi_ps_parse_aml(struct acp } else if (status == AE_CTRL_TERMINATE) { status = AE_OK; } else if ((status != AE_OK) && (walk_state->method_desc)) { + /* Either the method parse or actual execution failed */ ACPI_ERROR_METHOD("Method parse/execution failed", @@ -551,6 +556,7 @@ acpi_status acpi_ps_parse_aml(struct acp if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) { if (walk_state->method_desc) { + /* Decrement the thread count on the method parse tree */ if (walk_state->method_desc->method. @@ -633,12 +639,14 @@ acpi_status acpi_ps_parse_aml(struct acp } } else { if (previous_walk_state->return_desc) { + /* Caller doesn't want it, must delete it */ acpi_ut_remove_reference(previous_walk_state-> return_desc); } if (previous_walk_state->implicit_return_obj) { + /* Caller doesn't want it, must delete it */ acpi_ut_remove_reference(previous_walk_state-> diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c index bc6047c..edb7c9b 100644 --- a/drivers/acpi/parser/psscope.c +++ b/drivers/acpi/parser/psscope.c @@ -165,6 +165,7 @@ acpi_ps_push_scope(struct acpi_parse_sta acpi_ut_push_generic_state(&parser_state->scope, scope); if (arg_count == ACPI_VAR_ARGS) { + /* Multiple arguments */ scope->parse_scope.arg_end = parser_state->pkg_end; diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c index dd6f167..0015717 100644 --- a/drivers/acpi/parser/pstree.c +++ b/drivers/acpi/parser/pstree.c @@ -77,6 +77,7 @@ union acpi_parse_object *acpi_ps_get_arg op_info = acpi_ps_get_opcode_info(op->common.aml_opcode); if (op_info->class == AML_CLASS_UNKNOWN) { + /* Invalid opcode or ASCII character */ return (NULL); @@ -85,6 +86,7 @@ union acpi_parse_object *acpi_ps_get_arg /* Check if this opcode requires argument sub-objects */ if (!(op_info->flags & AML_HAS_ARGS)) { + /* Has no linked argument objects */ return (NULL); @@ -130,6 +132,7 @@ acpi_ps_append_arg(union acpi_parse_obje op_info = acpi_ps_get_opcode_info(op->common.aml_opcode); if (op_info->class == AML_CLASS_UNKNOWN) { + /* Invalid opcode */ ACPI_ERROR((AE_INFO, "Invalid AML Opcode: 0x%2.2X", @@ -140,6 +143,7 @@ acpi_ps_append_arg(union acpi_parse_obje /* Check if this opcode requires argument sub-objects */ if (!(op_info->flags & AML_HAS_ARGS)) { + /* Has no linked argument objects */ return; @@ -148,6 +152,7 @@ acpi_ps_append_arg(union acpi_parse_obje /* Append the argument to the linked argument list */ if (op->common.value.arg) { + /* Append to existing argument list */ prev_arg = op->common.value.arg; @@ -222,12 +227,14 @@ union acpi_parse_object *acpi_ps_get_dep } if (arg == origin) { + /* Reached parent of origin, end search */ return (NULL); } if (parent->common.next) { + /* Found sibling of parent */ return (parent->common.next); @@ -299,5 +306,4 @@ union acpi_parse_object *acpi_ps_get_chi return (child); } #endif - #endif /* ACPI_FUTURE_USAGE */ diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c index 3e07cb9..a283207 100644 --- a/drivers/acpi/parser/psutils.c +++ b/drivers/acpi/parser/psutils.c @@ -135,15 +135,20 @@ union acpi_parse_object *acpi_ps_alloc_o /* Allocate the minimum required size object */ if (flags == ACPI_PARSEOP_GENERIC) { + /* The generic op (default) is by far the most common (16 to 1) */ op = acpi_os_acquire_object(acpi_gbl_ps_node_cache); - memset(op, 0, sizeof(struct acpi_parse_obj_common)); + + if (op) + memset(op, 0, sizeof(struct acpi_parse_obj_common)); } else { /* Extended parseop */ op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache); - memset(op, 0, sizeof(struct acpi_parse_obj_named)); + + if (op) + memset(op, 0, sizeof(struct acpi_parse_obj_named)); } /* Initialize the Op */ diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c index 06f05bf..3d08b8c 100644 --- a/drivers/acpi/parser/pswalk.c +++ b/drivers/acpi/parser/pswalk.c @@ -69,13 +69,16 @@ void acpi_ps_delete_parse_tree(union acp /* Visit all nodes in the subtree */ while (op) { + /* Check if we are not ascending */ if (op != parent) { + /* Look for an argument or child of the current op */ next = acpi_ps_get_arg(op, 0); if (next) { + /* Still going downward in tree (Op is not completed yet) */ op = next; diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index 2dd48cb..e09a820 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -317,9 +317,11 @@ acpi_ps_update_parameter_list(struct acp acpi_native_uint i; if ((info->parameter_type == ACPI_PARAM_ARGS) && (info->parameters)) { + /* Update reference count for each parameter */ for (i = 0; info->parameters[i]; i++) { + /* Ignore errors, just do them all */ (void)acpi_ut_update_object_reference(info-> diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index 2a718df..e4b6990 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c @@ -47,11 +47,8 @@ struct acpi_pci_data { static void acpi_pci_data_handler(acpi_handle handle, u32 function, void *context) { - ACPI_FUNCTION_TRACE("acpi_pci_data_handler"); - /* TBD: Anything we need to do here? */ - return_VOID; } /** @@ -68,25 +65,23 @@ acpi_status acpi_get_pci_id(acpi_handle struct acpi_device *device = NULL; struct acpi_pci_data *data = NULL; - ACPI_FUNCTION_TRACE("acpi_get_pci_id"); - if (!id) - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; result = acpi_bus_get_device(handle, &device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid ACPI Bus context for device %s\n", - acpi_device_bid(device))); - return_ACPI_STATUS(AE_NOT_EXIST); + ACPI_ERROR((AE_INFO, + "Invalid ACPI Bus context for device %s", + acpi_device_bid(device))); + return AE_NOT_EXIST; } status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data); if (ACPI_FAILURE(status) || !data) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid ACPI-PCI context for device %s\n", - acpi_device_bid(device))); - return_ACPI_STATUS(status); + ACPI_EXCEPTION((AE_INFO, status, + "Invalid ACPI-PCI context for device %s", + acpi_device_bid(device))); + return status; } *id = data->id; @@ -103,7 +98,7 @@ acpi_status acpi_get_pci_id(acpi_handle acpi_device_bid(device), id->segment, id->bus, id->device, id->function)); - return_ACPI_STATUS(AE_OK); + return AE_OK; } EXPORT_SYMBOL(acpi_get_pci_id); @@ -120,14 +115,12 @@ int acpi_pci_bind(struct acpi_device *de struct pci_dev *dev; struct pci_bus *bus; - ACPI_FUNCTION_TRACE("acpi_pci_bind"); - if (!device || !device->parent) - return_VALUE(-EINVAL); + return -EINVAL; pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); if (!pathname) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(pathname, 0, ACPI_PATHNAME_MAX); buffer.length = ACPI_PATHNAME_MAX; buffer.pointer = pathname; @@ -135,7 +128,7 @@ int acpi_pci_bind(struct acpi_device *de data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); if (!data) { kfree(pathname); - return_VALUE(-ENOMEM); + return -ENOMEM; } memset(data, 0, sizeof(struct acpi_pci_data)); @@ -151,9 +144,9 @@ int acpi_pci_bind(struct acpi_device *de status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, (void **)&pdata); if (ACPI_FAILURE(status) || !pdata || !pdata->bus) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid ACPI-PCI context for parent device %s\n", - acpi_device_bid(device->parent))); + ACPI_EXCEPTION((AE_INFO, status, + "Invalid ACPI-PCI context for parent device %s", + acpi_device_bid(device->parent))); result = -ENODEV; goto end; } @@ -206,10 +199,10 @@ int acpi_pci_bind(struct acpi_device *de goto end; } if (!data->dev->bus) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", - data->id.segment, data->id.bus, - data->id.device, data->id.function)); + ACPI_ERROR((AE_INFO, + "Device %02x:%02x:%02x.%02x has invalid 'bus' field", + data->id.segment, data->id.bus, + data->id.device, data->id.function)); result = -ENODEV; goto end; } @@ -237,9 +230,9 @@ int acpi_pci_bind(struct acpi_device *de */ status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to attach ACPI-PCI context to device %s\n", - acpi_device_bid(device))); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to attach ACPI-PCI context to device %s", + acpi_device_bid(device))); result = -ENODEV; goto end; } @@ -269,7 +262,7 @@ int acpi_pci_bind(struct acpi_device *de if (result) kfree(data); - return_VALUE(result); + return result; } int acpi_pci_unbind(struct acpi_device *device) @@ -280,14 +273,12 @@ int acpi_pci_unbind(struct acpi_device * char *pathname = NULL; struct acpi_buffer buffer = { 0, NULL }; - ACPI_FUNCTION_TRACE("acpi_pci_unbind"); - if (!device || !device->parent) - return_VALUE(-EINVAL); + return -EINVAL; pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); if (!pathname) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(pathname, 0, ACPI_PATHNAME_MAX); buffer.length = ACPI_PATHNAME_MAX; @@ -301,18 +292,18 @@ int acpi_pci_unbind(struct acpi_device * acpi_get_data(device->handle, acpi_pci_data_handler, (void **)&data); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to get data from device %s\n", - acpi_device_bid(device))); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to get data from device %s", + acpi_device_bid(device))); result = -ENODEV; goto end; } status = acpi_detach_data(device->handle, acpi_pci_data_handler); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to detach data from device %s\n", - acpi_device_bid(device))); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to detach data from device %s", + acpi_device_bid(device))); result = -ENODEV; goto end; } @@ -322,7 +313,7 @@ int acpi_pci_unbind(struct acpi_device * kfree(data); end: - return_VALUE(result); + return result; } int @@ -335,11 +326,9 @@ acpi_pci_bind_root(struct acpi_device *d char *pathname = NULL; struct acpi_buffer buffer = { 0, NULL }; - ACPI_FUNCTION_TRACE("acpi_pci_bind_root"); - pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); if (!pathname) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(pathname, 0, ACPI_PATHNAME_MAX); buffer.length = ACPI_PATHNAME_MAX; @@ -347,13 +336,13 @@ acpi_pci_bind_root(struct acpi_device *d if (!device || !id || !bus) { kfree(pathname); - return_VALUE(-EINVAL); + return -EINVAL; } data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); if (!data) { kfree(pathname); - return_VALUE(-ENOMEM); + return -ENOMEM; } memset(data, 0, sizeof(struct acpi_pci_data)); @@ -369,9 +358,9 @@ acpi_pci_bind_root(struct acpi_device *d status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to attach ACPI-PCI context to device %s\n", - pathname)); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to attach ACPI-PCI context to device %s", + pathname)); result = -ENODEV; goto end; } @@ -381,5 +370,5 @@ acpi_pci_bind_root(struct acpi_device *d if (result != 0) kfree(data); - return_VALUE(result); + return result; } diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 65aee79..7e2c353 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -55,10 +55,8 @@ static struct acpi_prt_entry *acpi_pci_i struct list_head *node = NULL; struct acpi_prt_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry"); - if (!acpi_prt.count) - return_PTR(NULL); + return NULL; /* * Parse through all PRT entries looking for a match on the specified @@ -73,12 +71,12 @@ static struct acpi_prt_entry *acpi_pci_i && (device == entry->id.device) && (pin == entry->pin)) { spin_unlock(&acpi_prt_lock); - return_PTR(entry); + return entry; } } spin_unlock(&acpi_prt_lock); - return_PTR(NULL); + return NULL; } static int @@ -87,14 +85,12 @@ acpi_pci_irq_add_entry(acpi_handle handl { struct acpi_prt_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry"); - if (!prt) - return_VALUE(-EINVAL); + return -EINVAL; entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); if (!entry) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(entry, 0, sizeof(struct acpi_prt_entry)); entry->id.segment = segment; @@ -141,7 +137,7 @@ acpi_pci_irq_add_entry(acpi_handle handl acpi_prt.count++; spin_unlock(&acpi_prt_lock); - return_VALUE(0); + return 0; } static void @@ -163,11 +159,9 @@ int acpi_pci_irq_add_prt(acpi_handle han struct acpi_pci_routing_table *entry = NULL; static int first_time = 1; - ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt"); - pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); if (!pathname) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(pathname, 0, ACPI_PATHNAME_MAX); if (first_time) { @@ -197,24 +191,24 @@ int acpi_pci_irq_add_prt(acpi_handle han kfree(pathname); status = acpi_get_irq_routing_table(handle, &buffer); if (status != AE_BUFFER_OVERFLOW) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", - acpi_format_exception(status))); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]", + acpi_format_exception(status))); + return -ENODEV; } prt = kmalloc(buffer.length, GFP_KERNEL); if (!prt) { - return_VALUE(-ENOMEM); + return -ENOMEM; } memset(prt, 0, buffer.length); buffer.pointer = prt; status = acpi_get_irq_routing_table(handle, &buffer); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]", + acpi_format_exception(status))); kfree(buffer.pointer); - return_VALUE(-ENODEV); + return -ENODEV; } entry = prt; @@ -227,7 +221,7 @@ int acpi_pci_irq_add_prt(acpi_handle han kfree(prt); - return_VALUE(0); + return 0; } void acpi_pci_irq_del_prt(int segment, int bus) @@ -262,16 +256,14 @@ acpi_pci_allocate_irq(struct acpi_prt_en { int irq; - ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq"); - if (entry->link.handle) { irq = acpi_pci_link_allocate_irq(entry->link.handle, entry->link.index, triggering, polarity, link); if (irq < 0) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Invalid IRQ link routing entry\n")); - return_VALUE(-1); + ACPI_WARNING((AE_INFO, + "Invalid IRQ link routing entry")); + return -1; } } else { irq = entry->link.index; @@ -280,7 +272,7 @@ acpi_pci_allocate_irq(struct acpi_prt_en } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); - return_VALUE(irq); + return irq; } static int @@ -289,13 +281,12 @@ acpi_pci_free_irq(struct acpi_prt_entry { int irq; - ACPI_FUNCTION_TRACE("acpi_pci_free_irq"); if (entry->link.handle) { irq = acpi_pci_link_free_irq(entry->link.handle); } else { irq = entry->link.index; } - return_VALUE(irq); + return irq; } /* @@ -315,8 +306,6 @@ acpi_pci_irq_lookup(struct pci_bus *bus, int bus_nr = bus->number; int ret; - ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup"); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Searching for PRT entry for %02x:%02x:%02x[%c]\n", segment, bus_nr, device, ('A' + pin))); @@ -324,11 +313,11 @@ acpi_pci_irq_lookup(struct pci_bus *bus, entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); if (!entry) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n")); - return_VALUE(-1); + return -1; } ret = func(entry, triggering, polarity, link); - return_VALUE(ret); + return ret; } /* @@ -346,10 +335,8 @@ acpi_pci_irq_derive(struct pci_dev *dev, int irq = -1; u8 bridge_pin = 0; - ACPI_FUNCTION_TRACE("acpi_pci_irq_derive"); - if (!dev) - return_VALUE(-EINVAL); + return -EINVAL; /* * Attempt to derive an IRQ for this device from a parent bridge's @@ -366,7 +353,7 @@ acpi_pci_irq_derive(struct pci_dev *dev, ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", pci_name(bridge))); - return_VALUE(-1); + return -1; } /* Pin is from 0 to 3 */ bridge_pin--; @@ -379,16 +366,15 @@ acpi_pci_irq_derive(struct pci_dev *dev, } if (irq < 0) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Unable to derive IRQ for device %s\n", - pci_name(dev))); - return_VALUE(-1); + ACPI_WARNING((AE_INFO, "Unable to derive IRQ for device %s", + pci_name(dev))); + return -1; } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", irq, pci_name(dev), pci_name(bridge))); - return_VALUE(irq); + return irq; } /* @@ -406,24 +392,21 @@ int acpi_pci_irq_enable(struct pci_dev * char *link = NULL; int rc; - ACPI_FUNCTION_TRACE("acpi_pci_irq_enable"); - if (!dev) - return_VALUE(-EINVAL); + return -EINVAL; pin = dev->pin; if (!pin) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", pci_name(dev))); - return_VALUE(0); + return 0; } pin--; if (!dev->bus) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid (NULL) 'bus' field\n")); - return_VALUE(-ENODEV); + ACPI_ERROR((AE_INFO, "Invalid (NULL) 'bus' field")); + return -ENODEV; } /* @@ -455,10 +438,10 @@ int acpi_pci_irq_enable(struct pci_dev * printk(" - using IRQ %d\n", dev->irq); acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW); - return_VALUE(0); + return 0; } else { printk("\n"); - return_VALUE(0); + return 0; } } @@ -466,7 +449,7 @@ int acpi_pci_irq_enable(struct pci_dev * if (rc < 0) { printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " "to register GSI\n", pci_name(dev), ('A' + pin)); - return_VALUE(rc); + return rc; } dev->irq = rc; @@ -480,7 +463,7 @@ int acpi_pci_irq_enable(struct pci_dev * (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); - return_VALUE(0); + return 0; } EXPORT_SYMBOL(acpi_pci_irq_enable); @@ -497,14 +480,12 @@ void acpi_pci_irq_disable(struct pci_dev int triggering = ACPI_LEVEL_SENSITIVE; int polarity = ACPI_ACTIVE_LOW; - ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); - if (!dev || !dev->bus) - return_VOID; + return; pin = dev->pin; if (!pin) - return_VOID; + return; pin--; /* @@ -522,7 +503,7 @@ void acpi_pci_irq_disable(struct pci_dev &triggering, &polarity, NULL, acpi_pci_free_irq); if (gsi < 0) - return_VOID; + return; /* * TBD: It might be worth clearing dev->irq by magic constant @@ -534,5 +515,4 @@ void acpi_pci_irq_disable(struct pci_dev acpi_unregister_gsi(gsi); - return_VOID; } diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 07bc6df..e4136a0 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -38,6 +38,7 @@ #include #include #include #include +#include #include #include @@ -91,7 +92,7 @@ static struct { int count; struct list_head entries; } acpi_link; -DECLARE_MUTEX(acpi_link_lock); +DEFINE_MUTEX(acpi_link_lock); /* -------------------------------------------------------------------------- PCI Link Device Management @@ -106,26 +107,22 @@ acpi_pci_link_check_possible(struct acpi struct acpi_pci_link *link = (struct acpi_pci_link *)context; u32 i = 0; - ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); - switch (resource->type) { case ACPI_RESOURCE_TYPE_START_DEPENDENT: - return_ACPI_STATUS(AE_OK); + return AE_OK; case ACPI_RESOURCE_TYPE_IRQ: { struct acpi_resource_irq *p = &resource->data.irq; if (!p || !p->interrupt_count) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Blank IRQ resource\n")); - return_ACPI_STATUS(AE_OK); + ACPI_WARNING((AE_INFO, "Blank IRQ resource")); + return AE_OK; } for (i = 0; (i < p->interrupt_count && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { if (!p->interrupts[i]) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Invalid IRQ %d\n", - p->interrupts[i])); + ACPI_WARNING((AE_INFO, "Invalid IRQ %d", + p->interrupts[i])); continue; } link->irq.possible[i] = p->interrupts[i]; @@ -141,17 +138,16 @@ acpi_pci_link_check_possible(struct acpi struct acpi_resource_extended_irq *p = &resource->data.extended_irq; if (!p || !p->interrupt_count) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Blank EXT IRQ resource\n")); - return_ACPI_STATUS(AE_OK); + ACPI_WARNING((AE_INFO, + "Blank EXT IRQ resource")); + return AE_OK; } for (i = 0; (i < p->interrupt_count && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { if (!p->interrupts[i]) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Invalid IRQ %d\n", - p->interrupts[i])); + ACPI_WARNING((AE_INFO, "Invalid IRQ %d", + p->interrupts[i])); continue; } link->irq.possible[i] = p->interrupts[i]; @@ -163,35 +159,32 @@ acpi_pci_link_check_possible(struct acpi break; } default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Resource is not an IRQ entry\n")); - return_ACPI_STATUS(AE_OK); + ACPI_ERROR((AE_INFO, "Resource is not an IRQ entry\n")); + return AE_OK; } - return_ACPI_STATUS(AE_CTRL_TERMINATE); + return AE_CTRL_TERMINATE; } static int acpi_pci_link_get_possible(struct acpi_pci_link *link) { acpi_status status; - ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible"); - if (!link) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_walk_resources(link->handle, METHOD_NAME__PRS, acpi_pci_link_check_possible, link); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRS")); + return -ENODEV; } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d possible IRQs\n", link->irq.possible_count)); - return_VALUE(0); + return 0; } static acpi_status @@ -199,8 +192,6 @@ acpi_pci_link_check_current(struct acpi_ { int *irq = (int *)context; - ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); - switch (resource->type) { case ACPI_RESOURCE_TYPE_IRQ: { @@ -212,7 +203,7 @@ acpi_pci_link_check_current(struct acpi_ */ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Blank IRQ resource\n")); - return_ACPI_STATUS(AE_OK); + return AE_OK; } *irq = p->interrupts[0]; break; @@ -226,20 +217,20 @@ acpi_pci_link_check_current(struct acpi_ * extended IRQ descriptors must * return at least 1 IRQ */ - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Blank EXT IRQ resource\n")); - return_ACPI_STATUS(AE_OK); + ACPI_WARNING((AE_INFO, + "Blank EXT IRQ resource")); + return AE_OK; } *irq = p->interrupts[0]; break; } break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource %d isn't an IRQ\n", resource->type)); + ACPI_ERROR((AE_INFO, "Resource %d isn't an IRQ", resource->type)); case ACPI_RESOURCE_TYPE_END_TAG: - return_ACPI_STATUS(AE_OK); + return AE_OK; } - return_ACPI_STATUS(AE_CTRL_TERMINATE); + return AE_CTRL_TERMINATE; } /* @@ -255,10 +246,8 @@ static int acpi_pci_link_get_current(str acpi_status status = AE_OK; int irq = 0; - ACPI_FUNCTION_TRACE("acpi_pci_link_get_current"); - if (!link || !link->handle) - return_VALUE(-EINVAL); + return -EINVAL; link->irq.active = 0; @@ -267,14 +256,13 @@ static int acpi_pci_link_get_current(str /* Query _STA, set link->device->status */ result = acpi_bus_get_status(link->device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to read status\n")); + ACPI_ERROR((AE_INFO, "Unable to read status")); goto end; } if (!link->device->status.enabled) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n")); - return_VALUE(0); + return 0; } } @@ -285,13 +273,13 @@ static int acpi_pci_link_get_current(str status = acpi_walk_resources(link->handle, METHOD_NAME__CRS, acpi_pci_link_check_current, &irq); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n")); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _CRS")); result = -ENODEV; goto end; } if (acpi_strict && !irq) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_CRS returned 0\n")); + ACPI_ERROR((AE_INFO, "_CRS returned 0")); result = -ENODEV; } @@ -300,7 +288,7 @@ static int acpi_pci_link_get_current(str ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active)); end: - return_VALUE(result); + return result; } static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) @@ -313,14 +301,12 @@ static int acpi_pci_link_set(struct acpi } *resource; struct acpi_buffer buffer = { 0, NULL }; - ACPI_FUNCTION_TRACE("acpi_pci_link_set"); - if (!link || !irq) - return_VALUE(-EINVAL); + return -EINVAL; resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC); if (!resource) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(resource, 0, sizeof(*resource) + 1); buffer.length = sizeof(*resource) + 1; @@ -361,7 +347,7 @@ static int acpi_pci_link_set(struct acpi /* ignore resource_source, it's optional */ break; default: - printk("ACPI BUG: resource_type %d\n", link->irq.resource_type); + ACPI_ERROR((AE_INFO, "Invalid Resource_type %d\n", link->irq.resource_type)); result = -EINVAL; goto end; @@ -373,7 +359,7 @@ static int acpi_pci_link_set(struct acpi /* check for total failure */ if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n")); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SRS")); result = -ENODEV; goto end; } @@ -381,14 +367,14 @@ static int acpi_pci_link_set(struct acpi /* Query _STA, set device->status */ result = acpi_bus_get_status(link->device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n")); + ACPI_ERROR((AE_INFO, "Unable to read status")); goto end; } if (!link->device->status.enabled) { - printk(KERN_WARNING PREFIX - "%s [%s] disabled and referenced, BIOS bug.\n", - acpi_device_name(link->device), - acpi_device_bid(link->device)); + ACPI_WARNING((AE_INFO, + "%s [%s] disabled and referenced, BIOS bug", + acpi_device_name(link->device), + acpi_device_bid(link->device))); } /* Query _CRS, set link->irq.active */ @@ -406,10 +392,10 @@ static int acpi_pci_link_set(struct acpi * policy: when _CRS doesn't return what we just _SRS * assume _SRS worked and override _CRS value. */ - printk(KERN_WARNING PREFIX - "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", - acpi_device_name(link->device), - acpi_device_bid(link->device), link->irq.active, irq); + ACPI_WARNING((AE_INFO, + "%s [%s] BIOS reported IRQ %d, using IRQ %d", + acpi_device_name(link->device), + acpi_device_bid(link->device), link->irq.active, irq)); link->irq.active = irq; } @@ -417,7 +403,7 @@ static int acpi_pci_link_set(struct acpi end: kfree(resource); - return_VALUE(result); + return result; } /* -------------------------------------------------------------------------- @@ -491,8 +477,6 @@ int __init acpi_irq_penalty_init(void) struct acpi_pci_link *link = NULL; int i = 0; - ACPI_FUNCTION_TRACE("acpi_irq_penalty_init"); - /* * Update penalties to facilitate IRQ balancing. */ @@ -500,8 +484,7 @@ int __init acpi_irq_penalty_init(void) link = list_entry(node, struct acpi_pci_link, node); if (!link) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid link context\n")); + ACPI_ERROR((AE_INFO, "Invalid link context")); continue; } @@ -529,7 +512,7 @@ int __init acpi_irq_penalty_init(void) /* Add a penalty for the SCI */ acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING; - return_VALUE(0); + return 0; } static int acpi_irq_balance; /* 0: static, 1: balance */ @@ -539,13 +522,11 @@ static int acpi_pci_link_allocate(struct int irq; int i; - ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); - if (link->irq.initialized) { if (link->refcnt == 0) /* This means the link is disabled but initialized */ acpi_pci_link_set(link, link->irq.active); - return_VALUE(0); + return 0; } /* @@ -560,8 +541,8 @@ static int acpi_pci_link_allocate(struct */ if (i == link->irq.possible_count) { if (acpi_strict) - printk(KERN_WARNING PREFIX "_CRS %d not found" - " in _PRS\n", link->irq.active); + ACPI_WARNING((AE_INFO, "_CRS %d not found" + " in _PRS", link->irq.active)); link->irq.active = 0; } @@ -588,12 +569,11 @@ static int acpi_pci_link_allocate(struct /* Attempt to enable the link device at this IRQ. */ if (acpi_pci_link_set(link, irq)) { - printk(PREFIX - "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" - "Try pci=noacpi or acpi=off\n", - acpi_device_name(link->device), - acpi_device_bid(link->device)); - return_VALUE(-ENODEV); + ACPI_ERROR((AE_INFO, "Unable to set IRQ for %s [%s]. " + "Try pci=noacpi or acpi=off", + acpi_device_name(link->device), + acpi_device_bid(link->device))); + return -ENODEV; } else { acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; printk(PREFIX "%s [%s] enabled at IRQ %d\n", @@ -603,7 +583,7 @@ static int acpi_pci_link_allocate(struct link->irq.initialized = 1; - return_VALUE(0); + return 0; } /* @@ -621,39 +601,37 @@ acpi_pci_link_allocate_irq(acpi_handle h struct acpi_device *device = NULL; struct acpi_pci_link *link = NULL; - ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq"); - result = acpi_bus_get_device(handle, &device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); - return_VALUE(-1); + ACPI_ERROR((AE_INFO, "Invalid link device")); + return -1; } link = (struct acpi_pci_link *)acpi_driver_data(device); if (!link) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); - return_VALUE(-1); + ACPI_ERROR((AE_INFO, "Invalid link context")); + return -1; } /* TBD: Support multiple index (IRQ) entries per Link Device */ if (index) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index)); - return_VALUE(-1); + ACPI_ERROR((AE_INFO, "Invalid index %d", index)); + return -1; } - down(&acpi_link_lock); + mutex_lock(&acpi_link_lock); if (acpi_pci_link_allocate(link)) { - up(&acpi_link_lock); - return_VALUE(-1); + mutex_unlock(&acpi_link_lock); + return -1; } if (!link->irq.active) { - up(&acpi_link_lock); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); - return_VALUE(-1); + mutex_unlock(&acpi_link_lock); + ACPI_ERROR((AE_INFO, "Link active IRQ is 0!")); + return -1; } link->refcnt++; - up(&acpi_link_lock); + mutex_unlock(&acpi_link_lock); if (triggering) *triggering = link->irq.triggering; @@ -664,7 +642,7 @@ acpi_pci_link_allocate_irq(acpi_handle h ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link %s is referenced\n", acpi_device_bid(link->device))); - return_VALUE(link->irq.active); + return link->irq.active; } /* @@ -677,25 +655,23 @@ int acpi_pci_link_free_irq(acpi_handle h struct acpi_pci_link *link = NULL; acpi_status result; - ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq"); - result = acpi_bus_get_device(handle, &device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); - return_VALUE(-1); + ACPI_ERROR((AE_INFO, "Invalid link device")); + return -1; } link = (struct acpi_pci_link *)acpi_driver_data(device); if (!link) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); - return_VALUE(-1); + ACPI_ERROR((AE_INFO, "Invalid link context")); + return -1; } - down(&acpi_link_lock); + mutex_lock(&acpi_link_lock); if (!link->irq.initialized) { - up(&acpi_link_lock); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n")); - return_VALUE(-1); + mutex_unlock(&acpi_link_lock); + ACPI_ERROR((AE_INFO, "Link isn't initialized")); + return -1; } #ifdef FUTURE_USE /* @@ -716,8 +692,8 @@ #endif if (link->refcnt == 0) { acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); } - up(&acpi_link_lock); - return_VALUE(link->irq.active); + mutex_unlock(&acpi_link_lock); + return link->irq.active; } /* -------------------------------------------------------------------------- @@ -731,14 +707,12 @@ static int acpi_pci_link_add(struct acpi int i = 0; int found = 0; - ACPI_FUNCTION_TRACE("acpi_pci_link_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); if (!link) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(link, 0, sizeof(struct acpi_pci_link)); link->device = device; @@ -747,7 +721,7 @@ static int acpi_pci_link_add(struct acpi strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS); acpi_driver_data(device) = link; - down(&acpi_link_lock); + mutex_lock(&acpi_link_lock); result = acpi_pci_link_get_possible(link); if (result) goto end; @@ -782,68 +756,54 @@ static int acpi_pci_link_add(struct acpi end: /* disable all links -- to be activated on use */ acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); - up(&acpi_link_lock); + mutex_unlock(&acpi_link_lock); if (result) kfree(link); - return_VALUE(result); + return result; } static int acpi_pci_link_resume(struct acpi_pci_link *link) { - ACPI_FUNCTION_TRACE("acpi_pci_link_resume"); - if (link->refcnt && link->irq.active && link->irq.initialized) - return_VALUE(acpi_pci_link_set(link, link->irq.active)); + return acpi_pci_link_set(link, link->irq.active); else - return_VALUE(0); + return 0; } -/* - * FIXME: this is a workaround to avoid nasty warning. It will be removed - * after every device calls pci_disable_device in .resume. - */ -int acpi_in_resume; static int irqrouter_resume(struct sys_device *dev) { struct list_head *node = NULL; struct acpi_pci_link *link = NULL; - ACPI_FUNCTION_TRACE("irqrouter_resume"); - - acpi_in_resume = 1; list_for_each(node, &acpi_link.entries) { link = list_entry(node, struct acpi_pci_link, node); if (!link) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid link context\n")); + ACPI_ERROR((AE_INFO, "Invalid link context")); continue; } acpi_pci_link_resume(link); } - acpi_in_resume = 0; - return_VALUE(0); + return 0; } static int acpi_pci_link_remove(struct acpi_device *device, int type) { struct acpi_pci_link *link = NULL; - ACPI_FUNCTION_TRACE("acpi_pci_link_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; link = (struct acpi_pci_link *)acpi_driver_data(device); - down(&acpi_link_lock); + mutex_lock(&acpi_link_lock); list_del(&link->node); - up(&acpi_link_lock); + mutex_unlock(&acpi_link_lock); kfree(link); - return_VALUE(0); + return 0; } /* @@ -949,34 +909,30 @@ static int __init irqrouter_init_sysfs(v { int error; - ACPI_FUNCTION_TRACE("irqrouter_init_sysfs"); - if (acpi_disabled || acpi_noirq) - return_VALUE(0); + return 0; error = sysdev_class_register(&irqrouter_sysdev_class); if (!error) error = sysdev_register(&device_irqrouter); - return_VALUE(error); + return error; } device_initcall(irqrouter_init_sysfs); static int __init acpi_pci_link_init(void) { - ACPI_FUNCTION_TRACE("acpi_pci_link_init"); - if (acpi_noirq) - return_VALUE(0); + return 0; acpi_link.count = 0; INIT_LIST_HEAD(&acpi_link.entries); if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0) - return_VALUE(-ENODEV); + return -ENODEV; - return_VALUE(0); + return 0; } subsys_initcall(acpi_pci_link_init); diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 4c313ea..3dcc091 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -160,14 +160,12 @@ static int acpi_pci_root_add(struct acpi unsigned long value = 0; acpi_handle handle = NULL; - ACPI_FUNCTION_TRACE("acpi_pci_root_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); if (!root) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(root, 0, sizeof(struct acpi_pci_root)); INIT_LIST_HEAD(&root->node); @@ -198,7 +196,7 @@ static int acpi_pci_root_add(struct acpi root->id.segment = 0; break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SEG\n")); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SEG")); result = -ENODEV; goto end; } @@ -219,7 +217,7 @@ static int acpi_pci_root_add(struct acpi root->id.bus = 0; break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BBN\n")); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BBN")); result = -ENODEV; goto end; } @@ -231,8 +229,9 @@ static int acpi_pci_root_add(struct acpi int bus = 0; acpi_status status; - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n")); + ACPI_ERROR((AE_INFO, + "Wrong _BBN value, reboot" + " and use option 'pci=noacpi'")); status = try_get_root_bridge_busnr(root->handle, &bus); if (ACPI_FAILURE(status)) @@ -273,9 +272,9 @@ static int acpi_pci_root_add(struct acpi */ root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus); if (!root->bus) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Bus %04x:%02x not present in PCI namespace\n", - root->id.segment, root->id.bus)); + ACPI_ERROR((AE_INFO, + "Bus %04x:%02x not present in PCI namespace", + root->id.segment, root->id.bus)); result = -ENODEV; goto end; } @@ -306,46 +305,40 @@ static int acpi_pci_root_add(struct acpi kfree(root); } - return_VALUE(result); + return result; } static int acpi_pci_root_start(struct acpi_device *device) { struct acpi_pci_root *root; - ACPI_FUNCTION_TRACE("acpi_pci_root_start"); - list_for_each_entry(root, &acpi_pci_roots, node) { if (root->handle == device->handle) { pci_bus_add_devices(root->bus); - return_VALUE(0); + return 0; } } - return_VALUE(-ENODEV); + return -ENODEV; } static int acpi_pci_root_remove(struct acpi_device *device, int type) { struct acpi_pci_root *root = NULL; - ACPI_FUNCTION_TRACE("acpi_pci_root_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; root = (struct acpi_pci_root *)acpi_driver_data(device); kfree(root); - return_VALUE(0); + return 0; } static int __init acpi_pci_root_init(void) { - ACPI_FUNCTION_TRACE("acpi_pci_root_init"); - if (acpi_pci_disabled) - return_VALUE(0); + return 0; /* DEBUG: acpi_dbg_layer = ACPI_PCI_COMPONENT; @@ -353,9 +346,9 @@ static int __init acpi_pci_root_init(voi */ if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) - return_VALUE(-ENODEV); + return -ENODEV; - return_VALUE(0); + return 0; } subsys_initcall(acpi_pci_root_init); diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 62a5595..aaefc12 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -98,23 +98,20 @@ acpi_power_get_context(acpi_handle handl int result = 0; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_power_get_context"); - if (!resource) - return_VALUE(-ENODEV); + return -ENODEV; result = acpi_bus_get_device(handle, &device); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", - handle)); - return_VALUE(result); + ACPI_WARNING((AE_INFO, "Getting context [%p]", handle)); + return result; } *resource = (struct acpi_power_resource *)acpi_driver_data(device); if (!resource) - return_VALUE(-ENODEV); + return -ENODEV; - return_VALUE(0); + return 0; } static int acpi_power_get_state(struct acpi_power_resource *resource) @@ -122,14 +119,12 @@ static int acpi_power_get_state(struct a acpi_status status = AE_OK; unsigned long sta = 0; - ACPI_FUNCTION_TRACE("acpi_power_get_state"); - if (!resource) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; if (sta & 0x01) resource->state = ACPI_POWER_RESOURCE_STATE_ON; @@ -139,7 +134,7 @@ static int acpi_power_get_state(struct a ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", resource->name, resource->state ? "on" : "off")); - return_VALUE(0); + return 0; } static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) @@ -148,20 +143,18 @@ static int acpi_power_get_list_state(str struct acpi_power_resource *resource = NULL; u32 i = 0; - ACPI_FUNCTION_TRACE("acpi_power_get_list_state"); - if (!list || !state) - return_VALUE(-EINVAL); + return -EINVAL; /* The state of the list is 'on' IFF all resources are 'on'. */ for (i = 0; i < list->count; i++) { result = acpi_power_get_context(list->handles[i], &resource); if (result) - return_VALUE(result); + return result; result = acpi_power_get_state(resource); if (result) - return_VALUE(result); + return result; *state = resource->state; @@ -172,7 +165,7 @@ static int acpi_power_get_list_state(str ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", *state ? "on" : "off")); - return_VALUE(result); + return result; } static int acpi_power_on(acpi_handle handle) @@ -182,11 +175,9 @@ static int acpi_power_on(acpi_handle han struct acpi_device *device = NULL; struct acpi_power_resource *resource = NULL; - ACPI_FUNCTION_TRACE("acpi_power_on"); - result = acpi_power_get_context(handle, &resource); if (result) - return_VALUE(result); + return result; resource->references++; @@ -194,29 +185,29 @@ static int acpi_power_on(acpi_handle han || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", resource->name)); - return_VALUE(0); + return 0; } status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; result = acpi_power_get_state(resource); if (result) - return_VALUE(result); + return result; if (resource->state != ACPI_POWER_RESOURCE_STATE_ON) - return_VALUE(-ENOEXEC); + return -ENOEXEC; /* Update the power resource's _device_ power state */ result = acpi_bus_get_device(resource->handle, &device); if (result) - return_VALUE(result); + return result; device->power.state = ACPI_STATE_D0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", resource->name)); - return_VALUE(0); + return 0; } static int acpi_power_off_device(acpi_handle handle) @@ -226,11 +217,9 @@ static int acpi_power_off_device(acpi_ha struct acpi_device *device = NULL; struct acpi_power_resource *resource = NULL; - ACPI_FUNCTION_TRACE("acpi_power_off_device"); - result = acpi_power_get_context(handle, &resource); if (result) - return_VALUE(result); + return result; if (resource->references) resource->references--; @@ -239,35 +228,35 @@ static int acpi_power_off_device(acpi_ha ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is still in use, dereferencing\n", device->pnp.bus_id)); - return_VALUE(0); + return 0; } if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", device->pnp.bus_id)); - return_VALUE(0); + return 0; } status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; result = acpi_power_get_state(resource); if (result) - return_VALUE(result); + return result; if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF) - return_VALUE(-ENOEXEC); + return -ENOEXEC; /* Update the power resource's _device_ power state */ result = acpi_bus_get_device(resource->handle, &device); if (result) - return_VALUE(result); + return result; device->power.state = ACPI_STATE_D3; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", resource->name)); - return_VALUE(0); + return 0; } /* @@ -283,31 +272,28 @@ int acpi_enable_wakeup_device_power(stru int i; int ret = 0; - ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power"); - if (!dev || !dev->wakeup.flags.valid) - return_VALUE(-1); + return -1; arg.integer.value = 1; /* Open power resource */ for (i = 0; i < dev->wakeup.resources.count; i++) { ret = acpi_power_on(dev->wakeup.resources.handles[i]); if (ret) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error transition power state\n")); + ACPI_ERROR((AE_INFO, "Transition power state")); dev->wakeup.flags.valid = 0; - return_VALUE(-1); + return -1; } } /* Execute PSW */ status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); + ACPI_ERROR((AE_INFO, "Evaluate _PSW")); dev->wakeup.flags.valid = 0; ret = -1; } - return_VALUE(ret); + return ret; } /* @@ -323,32 +309,29 @@ int acpi_disable_wakeup_device_power(str int i; int ret = 0; - ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power"); - if (!dev || !dev->wakeup.flags.valid) - return_VALUE(-1); + return -1; arg.integer.value = 0; /* Execute PSW */ status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); + ACPI_ERROR((AE_INFO, "Evaluate _PSW")); dev->wakeup.flags.valid = 0; - return_VALUE(-1); + return -1; } /* Close power resource */ for (i = 0; i < dev->wakeup.resources.count; i++) { ret = acpi_power_off_device(dev->wakeup.resources.handles[i]); if (ret) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error transition power state\n")); + ACPI_ERROR((AE_INFO, "Transition power state")); dev->wakeup.flags.valid = 0; - return_VALUE(-1); + return -1; } } - return_VALUE(ret); + return ret; } /* -------------------------------------------------------------------------- @@ -362,10 +345,8 @@ int acpi_power_get_inferred_state(struct int list_state = 0; int i = 0; - ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; device->power.state = ACPI_STATE_UNKNOWN; @@ -380,17 +361,17 @@ int acpi_power_get_inferred_state(struct result = acpi_power_get_list_state(list, &list_state); if (result) - return_VALUE(result); + return result; if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { device->power.state = i; - return_VALUE(0); + return 0; } } device->power.state = ACPI_STATE_D3; - return_VALUE(0); + return 0; } int acpi_power_transition(struct acpi_device *device, int state) @@ -400,14 +381,12 @@ int acpi_power_transition(struct acpi_de struct acpi_handle_list *tl = NULL; /* Target Resources */ int i = 0; - ACPI_FUNCTION_TRACE("acpi_power_transition"); - if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) - return_VALUE(-EINVAL); + return -EINVAL; if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3)) - return_VALUE(-ENODEV); + return -ENODEV; cl = &device->power.states[device->power.state].resources; tl = &device->power.states[state].resources; @@ -444,11 +423,10 @@ int acpi_power_transition(struct acpi_de device->power.state = state; end: if (result) - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Error transitioning device [%s] to D%d\n", - device->pnp.bus_id, state)); + ACPI_WARNING((AE_INFO, "Transitioning device [%s] to D%d", + device->pnp.bus_id, state)); - return_VALUE(result); + return result; } /* -------------------------------------------------------------------------- @@ -461,8 +439,6 @@ static int acpi_power_seq_show(struct se { struct acpi_power_resource *resource = NULL; - ACPI_FUNCTION_TRACE("acpi_power_seq_show"); - resource = (struct acpi_power_resource *)seq->private; if (!resource) @@ -488,7 +464,7 @@ static int acpi_power_seq_show(struct se resource->order, resource->references); end: - return_VALUE(0); + return 0; } static int acpi_power_open_fs(struct inode *inode, struct file *file) @@ -500,37 +476,31 @@ static int acpi_power_add_fs(struct acpi { struct proc_dir_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_power_add_fs"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_power_dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; } /* 'status' [R] */ entry = create_proc_entry(ACPI_POWER_FILE_STATUS, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_POWER_FILE_STATUS)); + return -EIO; else { entry->proc_fops = &acpi_power_fops; entry->data = acpi_driver_data(device); } - return_VALUE(0); + return 0; } static int acpi_power_remove_fs(struct acpi_device *device) { - ACPI_FUNCTION_TRACE("acpi_power_remove_fs"); - if (acpi_device_dir(device)) { remove_proc_entry(ACPI_POWER_FILE_STATUS, acpi_device_dir(device)); @@ -538,7 +508,7 @@ static int acpi_power_remove_fs(struct a acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -553,14 +523,12 @@ static int acpi_power_add(struct acpi_de union acpi_object acpi_object; struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; - ACPI_FUNCTION_TRACE("acpi_power_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL); if (!resource) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(resource, 0, sizeof(struct acpi_power_resource)); resource->handle = device->handle; @@ -605,17 +573,15 @@ static int acpi_power_add(struct acpi_de if (result) kfree(resource); - return_VALUE(result); + return result; } static int acpi_power_remove(struct acpi_device *device, int type) { struct acpi_power_resource *resource = NULL; - ACPI_FUNCTION_TRACE("acpi_power_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; resource = (struct acpi_power_resource *)acpi_driver_data(device); @@ -623,31 +589,29 @@ static int acpi_power_remove(struct acpi kfree(resource); - return_VALUE(0); + return 0; } static int __init acpi_power_init(void) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_power_init"); - if (acpi_disabled) - return_VALUE(0); + return 0; INIT_LIST_HEAD(&acpi_power_resource_list); acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir); if (!acpi_power_dir) - return_VALUE(-ENODEV); + return -ENODEV; result = acpi_bus_register_driver(&acpi_power_driver); if (result < 0) { remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } subsys_initcall(acpi_power_init); diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 713b763..29f8120 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -122,10 +122,8 @@ static int acpi_processor_errata_piix4(s u8 value1 = 0; u8 value2 = 0; - ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4"); - if (!dev) - return_VALUE(-EINVAL); + return -EINVAL; /* * Note that 'dev' references the PIIX4 ACPI Controller. @@ -218,7 +216,7 @@ static int acpi_processor_errata_piix4(s ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Type-F DMA livelock erratum (C3 disabled)\n")); - return_VALUE(0); + return 0; } static int acpi_processor_errata(struct acpi_processor *pr) @@ -226,10 +224,8 @@ static int acpi_processor_errata(struct int result = 0; struct pci_dev *dev = NULL; - ACPI_FUNCTION_TRACE("acpi_processor_errata"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; /* * PIIX4 @@ -242,7 +238,7 @@ static int acpi_processor_errata(struct pci_dev_put(dev); } - return_VALUE(result); + return result; } /* -------------------------------------------------------------------------- @@ -258,10 +254,8 @@ static int acpi_processor_set_pdc(struct struct acpi_object_list *pdc_in = pr->pdc; acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE("acpi_processor_set_pdc"); - if (!pdc_in) - return_VALUE(status); + return status; status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL); @@ -269,7 +263,7 @@ static int acpi_processor_set_pdc(struct ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not evaluate _PDC, using legacy perf. control...\n")); - return_VALUE(status); + return status; } /* -------------------------------------------------------------------------- @@ -282,8 +276,6 @@ static int acpi_processor_info_seq_show( { struct acpi_processor *pr = (struct acpi_processor *)seq->private; - ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show"); - if (!pr) goto end; @@ -301,7 +293,7 @@ static int acpi_processor_info_seq_show( pr->flags.limit ? "yes" : "no"); end: - return_VALUE(0); + return 0; } static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) @@ -314,13 +306,11 @@ static int acpi_processor_add_fs(struct { struct proc_dir_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_processor_add_fs"); - if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_processor_dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; } acpi_device_dir(device)->owner = THIS_MODULE; @@ -328,9 +318,7 @@ static int acpi_processor_add_fs(struct entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_INFO)); + return -EIO; else { entry->proc_fops = &acpi_processor_info_fops; entry->data = acpi_driver_data(device); @@ -342,9 +330,7 @@ static int acpi_processor_add_fs(struct S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_THROTTLING)); + return -EIO; else { entry->proc_fops = &acpi_processor_throttling_fops; entry->data = acpi_driver_data(device); @@ -356,22 +342,18 @@ static int acpi_processor_add_fs(struct S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_LIMIT)); + return -EIO; else { entry->proc_fops = &acpi_processor_limit_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return_VALUE(0); + return 0; } static int acpi_processor_remove_fs(struct acpi_device *device) { - ACPI_FUNCTION_TRACE("acpi_processor_remove_fs"); - if (acpi_device_dir(device)) { remove_proc_entry(ACPI_PROCESSOR_FILE_INFO, acpi_device_dir(device)); @@ -383,12 +365,12 @@ static int acpi_processor_remove_fs(stru acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* Use the acpiid in MADT to map cpus in case of SMP */ #ifndef CONFIG_SMP -#define convert_acpiid_to_cpu(acpi_id) (0xff) +#define convert_acpiid_to_cpu(acpi_id) (-1) #else #ifdef CONFIG_IA64 @@ -401,7 +383,7 @@ #define arch_cpu_to_apicid x86_cpu_to_a #define ARCH_BAD_APICID (0xff) #endif -static u8 convert_acpiid_to_cpu(u8 acpi_id) +static int convert_acpiid_to_cpu(u8 acpi_id) { u16 apic_id; int i; @@ -427,13 +409,11 @@ static int acpi_processor_get_info(struc acpi_status status = 0; union acpi_object object = { 0 }; struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; - u8 cpu_index; + int cpu_index; static int cpu0_initialized; - ACPI_FUNCTION_TRACE("acpi_processor_get_info"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; if (num_online_cpus() > 1) errata.smp = TRUE; @@ -459,9 +439,8 @@ static int acpi_processor_get_info(struc */ status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error evaluating processor object\n")); - return_VALUE(-ENODEV); + ACPI_ERROR((AE_INFO, "Evaluating processor object")); + return -ENODEV; } /* @@ -473,7 +452,7 @@ static int acpi_processor_get_info(struc cpu_index = convert_acpiid_to_cpu(pr->acpi_id); /* Handle UP system running SMP kernel, with no LAPIC in MADT */ - if (!cpu0_initialized && (cpu_index == 0xff) && + if (!cpu0_initialized && (cpu_index == -1) && (num_online_cpus() == 1)) { cpu_index = 0; } @@ -487,13 +466,13 @@ static int acpi_processor_get_info(struc * less than the max # of CPUs. They should be ignored _iff * they are physically not present. */ - if (cpu_index >= NR_CPUS) { + if (cpu_index == -1) { if (ACPI_FAILURE (acpi_processor_hotadd_init(pr->handle, &pr->id))) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error getting cpuindex for acpiid 0x%x\n", - pr->acpi_id)); - return_VALUE(-ENODEV); + ACPI_ERROR((AE_INFO, + "Getting cpuindex for acpiid 0x%x", + pr->acpi_id)); + return -ENODEV; } } @@ -503,8 +482,8 @@ static int acpi_processor_get_info(struc if (!object.processor.pblk_address) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); else if (object.processor.pblk_length != 6) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n", - object.processor.pblk_length)); + ACPI_ERROR((AE_INFO, "Invalid PBLK length [%d]", + object.processor.pblk_length)); else { pr->throttling.address = object.processor.pblk_address; pr->throttling.duty_offset = acpi_fadt.duty_offset; @@ -528,7 +507,7 @@ #endif acpi_processor_get_throttling_info(pr); acpi_processor_get_limit_info(pr); - return_VALUE(0); + return 0; } static void *processor_device_array[NR_CPUS]; @@ -539,14 +518,12 @@ static int acpi_processor_start(struct a acpi_status status = AE_OK; struct acpi_processor *pr; - ACPI_FUNCTION_TRACE("acpi_processor_start"); - pr = acpi_driver_data(device); result = acpi_processor_get_info(pr); if (result) { /* Processor is physically not present */ - return_VALUE(0); + return 0; } BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); @@ -558,9 +535,9 @@ static int acpi_processor_start(struct a */ if (processor_device_array[pr->id] != NULL && processor_device_array[pr->id] != (void *)device) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "BIOS reporting wrong ACPI id" - "for the processor\n")); - return_VALUE(-ENODEV); + printk(KERN_WARNING "BIOS reported wrong ACPI id" + "for the processor\n"); + return -ENODEV; } processor_device_array[pr->id] = (void *)device; @@ -572,10 +549,6 @@ static int acpi_processor_start(struct a status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify, pr); - if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing device notify handler\n")); - } /* _PDC call should be done before doing anything else (if reqd.). */ arch_acpi_processor_init_pdc(pr); @@ -592,7 +565,7 @@ static int acpi_processor_start(struct a end: - return_VALUE(result); + return result; } static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) @@ -600,13 +573,11 @@ static void acpi_processor_notify(acpi_h struct acpi_processor *pr = (struct acpi_processor *)data; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_processor_notify"); - if (!pr) - return_VOID; + return; if (acpi_bus_get_device(pr->handle, &device)) - return_VOID; + return; switch (event) { case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: @@ -624,21 +595,18 @@ static void acpi_processor_notify(acpi_h break; } - return_VOID; } static int acpi_processor_add(struct acpi_device *device) { struct acpi_processor *pr = NULL; - ACPI_FUNCTION_TRACE("acpi_processor_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL); if (!pr) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(pr, 0, sizeof(struct acpi_processor)); pr->handle = device->handle; @@ -646,7 +614,7 @@ static int acpi_processor_add(struct acp strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); acpi_driver_data(device) = pr; - return_VALUE(0); + return 0; } static int acpi_processor_remove(struct acpi_device *device, int type) @@ -654,31 +622,25 @@ static int acpi_processor_remove(struct acpi_status status = AE_OK; struct acpi_processor *pr = NULL; - ACPI_FUNCTION_TRACE("acpi_processor_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; pr = (struct acpi_processor *)acpi_driver_data(device); if (pr->id >= NR_CPUS) { kfree(pr); - return_VALUE(0); + return 0; } if (type == ACPI_BUS_REMOVAL_EJECT) { if (acpi_processor_handle_eject(pr)) - return_VALUE(-EINVAL); + return -EINVAL; } acpi_processor_power_exit(pr, device); status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify); - if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); - } acpi_processor_remove_fs(device); @@ -686,7 +648,7 @@ static int acpi_processor_remove(struct kfree(pr); - return_VALUE(0); + return 0; } #ifdef CONFIG_ACPI_HOTPLUG_CPU @@ -701,15 +663,12 @@ static int is_processor_present(acpi_han acpi_status status; unsigned long sta = 0; - ACPI_FUNCTION_TRACE("is_processor_present"); - status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Processor Device is not present\n")); - return_VALUE(0); + ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present")); + return 0; } - return_VALUE(1); + return 1; } static @@ -719,30 +678,28 @@ int acpi_processor_device_add(acpi_handl struct acpi_device *pdev; struct acpi_processor *pr; - ACPI_FUNCTION_TRACE("acpi_processor_device_add"); - if (acpi_get_parent(handle, &phandle)) { - return_VALUE(-ENODEV); + return -ENODEV; } if (acpi_bus_get_device(phandle, &pdev)) { - return_VALUE(-ENODEV); + return -ENODEV; } if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { - return_VALUE(-ENODEV); + return -ENODEV; } acpi_bus_start(*device); pr = acpi_driver_data(*device); if (!pr) - return_VALUE(-ENODEV); + return -ENODEV; if ((pr->id >= 0) && (pr->id < NR_CPUS)) { kobject_uevent(&(*device)->kobj, KOBJ_ONLINE); } - return_VALUE(0); + return 0; } static void @@ -752,8 +709,6 @@ acpi_processor_hotplug_notify(acpi_handl struct acpi_device *device = NULL; int result; - ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify"); - switch (event) { case ACPI_NOTIFY_BUS_CHECK: case ACPI_NOTIFY_DEVICE_CHECK: @@ -767,15 +722,14 @@ acpi_processor_hotplug_notify(acpi_handl if (acpi_bus_get_device(handle, &device)) { result = acpi_processor_device_add(handle, &device); if (result) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to add the device\n")); + ACPI_ERROR((AE_INFO, + "Unable to add the device")); break; } pr = acpi_driver_data(device); if (!pr) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Driver data is NULL\n")); + ACPI_ERROR((AE_INFO, "Driver data is NULL")); break; } @@ -788,9 +742,8 @@ acpi_processor_hotplug_notify(acpi_handl if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { kobject_uevent(&device->kobj, KOBJ_ONLINE); } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device [%s] failed to start\n", - acpi_device_bid(device))); + ACPI_ERROR((AE_INFO, "Device [%s] failed to start", + acpi_device_bid(device))); } break; case ACPI_NOTIFY_EJECT_REQUEST: @@ -798,15 +751,15 @@ acpi_processor_hotplug_notify(acpi_handl "received ACPI_NOTIFY_EJECT_REQUEST\n")); if (acpi_bus_get_device(handle, &device)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Device don't exist, dropping EJECT\n")); + ACPI_ERROR((AE_INFO, + "Device don't exist, dropping EJECT")); break; } pr = acpi_driver_data(device); if (!pr) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Driver data is NULL, dropping EJECT\n")); - return_VOID; + ACPI_ERROR((AE_INFO, + "Driver data is NULL, dropping EJECT")); + return; } if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) @@ -818,7 +771,6 @@ acpi_processor_hotplug_notify(acpi_handl break; } - return_VOID; } static acpi_status @@ -857,21 +809,19 @@ processor_walk_namespace_cb(acpi_handle static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) { - ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init"); - if (!is_processor_present(handle)) { - return_VALUE(AE_ERROR); + return AE_ERROR; } if (acpi_map_lsapic(handle, p_cpu)) - return_VALUE(AE_ERROR); + return AE_ERROR; if (arch_register_cpu(*p_cpu)) { acpi_unmap_lsapic(*p_cpu); - return_VALUE(AE_ERROR); + return AE_ERROR; } - return_VALUE(AE_OK); + return AE_OK; } static int acpi_processor_handle_eject(struct acpi_processor *pr) @@ -928,20 +878,18 @@ static int __init acpi_processor_init(vo { int result = 0; - ACPI_FUNCTION_TRACE("acpi_processor_init"); - memset(&processors, 0, sizeof(processors)); memset(&errata, 0, sizeof(errata)); acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); if (!acpi_processor_dir) - return_VALUE(0); + return 0; acpi_processor_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_processor_driver); if (result < 0) { remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); - return_VALUE(0); + return 0; } acpi_processor_install_hotplug_notify(); @@ -950,13 +898,11 @@ static int __init acpi_processor_init(vo acpi_processor_ppc_init(); - return_VALUE(0); + return 0; } static void __exit acpi_processor_exit(void) { - ACPI_FUNCTION_TRACE("acpi_processor_exit"); - acpi_processor_ppc_exit(); acpi_thermal_cpufreq_exit(); @@ -967,7 +913,6 @@ static void __exit acpi_processor_exit(v remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); - return_VOID; } module_init(acpi_processor_init); diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 80fa434..e8c8094 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -54,10 +54,10 @@ #define ACPI_PROCESSOR_FILE_POWER "power #define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) #define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ #define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */ -static void (*pm_idle_save) (void); +static void (*pm_idle_save) (void) __read_mostly; module_param(max_cstate, uint, 0644); -static unsigned int nocst = 0; +static unsigned int nocst __read_mostly; module_param(nocst, uint, 0000); /* @@ -67,7 +67,7 @@ module_param(nocst, uint, 0000); * 100 HZ: 0x0000000F: 4 jiffies = 40ms * reduce history for more aggressive entry into C3 */ -static unsigned int bm_history = +static unsigned int bm_history __read_mostly = (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1)); module_param(bm_history, uint, 0644); /* -------------------------------------------------------------------------- @@ -508,10 +508,8 @@ static int acpi_processor_set_power_poli struct acpi_processor_cx *higher = NULL; struct acpi_processor_cx *cx; - ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; /* * This function sets the default Cx state policy (OS idle handler). @@ -535,7 +533,7 @@ static int acpi_processor_set_power_poli } if (!state_is_set) - return_VALUE(-ENODEV); + return -ENODEV; /* demotion */ for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { @@ -574,18 +572,16 @@ static int acpi_processor_set_power_poli higher = cx; } - return_VALUE(0); + return 0; } static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) { - ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; if (!pr->pblk) - return_VALUE(-ENODEV); + return -ENODEV; /* if info is obtained from pblk/fadt, type equals state */ pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2; @@ -597,7 +593,7 @@ #ifndef CONFIG_HOTPLUG_CPU * an SMP system. */ if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up) - return_VALUE(-ENODEV); + return -ENODEV; #endif /* determine C2 and C3 address from pblk */ @@ -613,13 +609,11 @@ #endif pr->power.states[ACPI_STATE_C2].address, pr->power.states[ACPI_STATE_C3].address)); - return_VALUE(0); + return 0; } static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) { - ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); - /* Zero initialize all the C-states info. */ memset(pr->power.states, 0, sizeof(pr->power.states)); @@ -631,7 +625,7 @@ static int acpi_processor_get_power_info pr->power.states[ACPI_STATE_C0].valid = 1; pr->power.states[ACPI_STATE_C1].valid = 1; - return_VALUE(0); + return 0; } static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) @@ -643,10 +637,8 @@ static int acpi_processor_get_power_info struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *cst; - ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst"); - if (nocst) - return_VALUE(-ENODEV); + return -ENODEV; current_count = 1; @@ -658,15 +650,14 @@ static int acpi_processor_get_power_info status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n")); - return_VALUE(-ENODEV); + return -ENODEV; } cst = (union acpi_object *)buffer.pointer; /* There must be at least 2 elements */ if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "not enough elements in _CST\n")); + ACPI_ERROR((AE_INFO, "not enough elements in _CST")); status = -EFAULT; goto end; } @@ -675,8 +666,7 @@ static int acpi_processor_get_power_info /* Validate number of power states. */ if (count < 1 || count != cst->package.count - 1) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "count given by _CST is not valid\n")); + ACPI_ERROR((AE_INFO, "count given by _CST is not valid")); status = -EFAULT; goto end; } @@ -764,17 +754,15 @@ static int acpi_processor_get_power_info status = -EFAULT; end: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); - return_VALUE(status); + return status; } static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) { - ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c2"); - if (!cx->address) - return_VOID; + return; /* * C2 latency must be less than or equal to 100 @@ -783,7 +771,7 @@ static void acpi_processor_power_verify_ else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "latency too large [%d]\n", cx->latency)); - return_VOID; + return; } /* @@ -793,7 +781,6 @@ static void acpi_processor_power_verify_ cx->valid = 1; cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); - return_VOID; } static void acpi_processor_power_verify_c3(struct acpi_processor *pr, @@ -801,10 +788,8 @@ static void acpi_processor_power_verify_ { static int bm_check_flag; - ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3"); - if (!cx->address) - return_VOID; + return; /* * C3 latency must be less than or equal to 1000 @@ -813,7 +798,7 @@ static void acpi_processor_power_verify_ else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "latency too large [%d]\n", cx->latency)); - return_VOID; + return; } /* @@ -826,7 +811,7 @@ static void acpi_processor_power_verify_ else if (errata.piix4.fdma) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "C3 not supported on PIIX4 with Type-F DMA\n")); - return_VOID; + return; } /* All the logic here assumes flags.bm_check is same across all CPUs */ @@ -843,7 +828,7 @@ static void acpi_processor_power_verify_ if (!pr->flags.bm_control) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "C3 support requires bus mastering control\n")); - return_VOID; + return; } } else { /* @@ -854,7 +839,7 @@ static void acpi_processor_power_verify_ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cache invalidation should work properly" " for C3 to be enabled on SMP systems\n")); - return_VOID; + return; } acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK); @@ -869,7 +854,6 @@ static void acpi_processor_power_verify_ cx->valid = 1; cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); - return_VOID; } static int acpi_processor_power_verify(struct acpi_processor *pr) @@ -928,8 +912,6 @@ static int acpi_processor_get_power_info unsigned int i; int result; - ACPI_FUNCTION_TRACE("acpi_processor_get_power_info"); - /* NOTE: the idle thread may not be running while calling * this function */ @@ -951,7 +933,7 @@ static int acpi_processor_get_power_info */ result = acpi_processor_set_power_policy(pr); if (result) - return_VALUE(result); + return result; /* * if one state of type C2 or C3 is available, mark this @@ -965,24 +947,22 @@ static int acpi_processor_get_power_info } } - return_VALUE(0); + return 0; } int acpi_processor_cst_has_changed(struct acpi_processor *pr) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_processor_cst_has_changed"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; if (nocst) { - return_VALUE(-ENODEV); + return -ENODEV; } if (!pr->flags.power_setup_done) - return_VALUE(-ENODEV); + return -ENODEV; /* Fall back to the default idle loop */ pm_idle = pm_idle_save; @@ -993,7 +973,7 @@ int acpi_processor_cst_has_changed(struc if ((pr->flags.power == 1) && (pr->flags.power_setup_done)) pm_idle = acpi_processor_idle; - return_VALUE(result); + return result; } /* proc interface */ @@ -1003,8 +983,6 @@ static int acpi_processor_power_seq_show struct acpi_processor *pr = (struct acpi_processor *)seq->private; unsigned int i; - ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show"); - if (!pr) goto end; @@ -1061,7 +1039,7 @@ static int acpi_processor_power_seq_show } end: - return_VALUE(0); + return 0; } static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) @@ -1081,12 +1059,10 @@ int acpi_processor_power_init(struct acp struct acpi_device *device) { acpi_status status = 0; - static int first_run = 0; + static int first_run; struct proc_dir_entry *entry = NULL; unsigned int i; - ACPI_FUNCTION_TRACE("acpi_processor_power_init"); - if (!first_run) { dmi_check_system(processor_power_dmi_table); if (max_cstate < ACPI_C_STATES_MAX) @@ -1097,14 +1073,14 @@ int acpi_processor_power_init(struct acp } if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; if (acpi_fadt.cst_cnt && !nocst) { status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Notifying BIOS of _CST ability failed\n")); + ACPI_EXCEPTION((AE_INFO, status, + "Notifying BIOS of _CST ability failed")); } } @@ -1133,9 +1109,7 @@ int acpi_processor_power_init(struct acp entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_POWER)); + return -EIO; else { entry->proc_fops = &acpi_processor_power_fops; entry->data = acpi_driver_data(device); @@ -1144,14 +1118,12 @@ int acpi_processor_power_init(struct acp pr->flags.power_setup_done = 1; - return_VALUE(0); + return 0; } int acpi_processor_power_exit(struct acpi_processor *pr, struct acpi_device *device) { - ACPI_FUNCTION_TRACE("acpi_processor_power_exit"); - pr->flags.power_setup_done = 0; if (acpi_device_dir(device)) @@ -1170,5 +1142,5 @@ int acpi_processor_power_exit(struct acp cpu_idle_wait(); } - return_VALUE(0); + return 0; } diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index abbdb37..844d97c 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c @@ -34,6 +34,7 @@ #include #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF #include #include +#include #include #endif @@ -48,7 +49,7 @@ #define ACPI_PROCESSOR_FILE_PERFORMANCE #define _COMPONENT ACPI_PROCESSOR_COMPONENT ACPI_MODULE_NAME("acpi_processor") -static DECLARE_MUTEX(performance_sem); +static DEFINE_MUTEX(performance_mutex); /* * _PPC support is implemented as a CPUfreq policy notifier: @@ -72,7 +73,7 @@ static int acpi_processor_ppc_notifier(s struct acpi_processor *pr; unsigned int ppc = 0; - down(&performance_sem); + mutex_lock(&performance_mutex); if (event != CPUFREQ_INCOMPATIBLE) goto out; @@ -93,7 +94,7 @@ static int acpi_processor_ppc_notifier(s core_frequency * 1000); out: - up(&performance_sem); + mutex_unlock(&performance_mutex); return 0; } @@ -107,10 +108,8 @@ static int acpi_processor_get_platform_l acpi_status status = 0; unsigned long ppc = 0; - ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; /* * _PPC indicates the maximum state currently supported by the platform @@ -122,13 +121,13 @@ static int acpi_processor_get_platform_l acpi_processor_ppc_status |= PPC_IN_USE; if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC")); + return -ENODEV; } pr->performance_platform_limit = (int)ppc; - return_VALUE(0); + return 0; } int acpi_processor_ppc_has_changed(struct acpi_processor *pr) @@ -167,18 +166,16 @@ static int acpi_processor_get_performanc union acpi_object *pct = NULL; union acpi_object obj = { 0 }; - ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control"); - status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT")); + return -ENODEV; } pct = (union acpi_object *)buffer.pointer; if (!pct || (pct->type != ACPI_TYPE_PACKAGE) || (pct->package.count != 2)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n")); + ACPI_ERROR((AE_INFO, "Invalid _PCT data")); result = -EFAULT; goto end; } @@ -192,8 +189,7 @@ static int acpi_processor_get_performanc if ((obj.type != ACPI_TYPE_BUFFER) || (obj.buffer.length < sizeof(struct acpi_pct_register)) || (obj.buffer.pointer == NULL)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid _PCT data (control_register)\n")); + ACPI_ERROR((AE_INFO, "Invalid _PCT data (control_register)")); result = -EFAULT; goto end; } @@ -209,8 +205,7 @@ static int acpi_processor_get_performanc if ((obj.type != ACPI_TYPE_BUFFER) || (obj.buffer.length < sizeof(struct acpi_pct_register)) || (obj.buffer.pointer == NULL)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid _PCT data (status_register)\n")); + ACPI_ERROR((AE_INFO, "Invalid _PCT data (status_register)")); result = -EFAULT; goto end; } @@ -219,9 +214,9 @@ static int acpi_processor_get_performanc sizeof(struct acpi_pct_register)); end: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); - return_VALUE(result); + return result; } static int acpi_processor_get_performance_states(struct acpi_processor *pr) @@ -234,17 +229,15 @@ static int acpi_processor_get_performanc union acpi_object *pss = NULL; int i; - ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states"); - status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS")); + return -ENODEV; } pss = (union acpi_object *)buffer.pointer; if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n")); + ACPI_ERROR((AE_INFO, "Invalid _PSS data")); result = -EFAULT; goto end; } @@ -273,8 +266,7 @@ static int acpi_processor_get_performanc status = acpi_extract_package(&(pss->package.elements[i]), &format, &state); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid _PSS data\n")); + ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data")); result = -EFAULT; kfree(pr->performance->states); goto end; @@ -290,8 +282,8 @@ static int acpi_processor_get_performanc (u32) px->control, (u32) px->status)); if (!px->core_frequency) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid _PSS data: freq is zero\n")); + ACPI_ERROR((AE_INFO, + "Invalid _PSS data: freq is zero")); result = -EFAULT; kfree(pr->performance->states); goto end; @@ -299,9 +291,9 @@ static int acpi_processor_get_performanc } end: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); - return_VALUE(result); + return result; } static int acpi_processor_get_performance_info(struct acpi_processor *pr) @@ -310,31 +302,29 @@ static int acpi_processor_get_performanc acpi_status status = AE_OK; acpi_handle handle = NULL; - ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info"); - if (!pr || !pr->performance || !pr->handle) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_get_handle(pr->handle, "_PCT", &handle); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI-based processor performance control unavailable\n")); - return_VALUE(-ENODEV); + return -ENODEV; } result = acpi_processor_get_performance_control(pr); if (result) - return_VALUE(result); + return result; result = acpi_processor_get_performance_states(pr); if (result) - return_VALUE(result); + return result; result = acpi_processor_get_platform_limit(pr); if (result) - return_VALUE(result); + return result; - return_VALUE(0); + return 0; } int acpi_processor_notify_smm(struct module *calling_module) @@ -342,13 +332,11 @@ int acpi_processor_notify_smm(struct mod acpi_status status; static int is_done = 0; - ACPI_FUNCTION_TRACE("acpi_processor_notify_smm"); - if (!(acpi_processor_ppc_status & PPC_REGISTERED)) - return_VALUE(-EBUSY); + return -EBUSY; if (!try_module_get(calling_module)) - return_VALUE(-EINVAL); + return -EINVAL; /* is_done is set to negative if an error occured, * and to postitive if _no_ error occured, but SMM @@ -357,10 +345,10 @@ int acpi_processor_notify_smm(struct mod */ if (is_done > 0) { module_put(calling_module); - return_VALUE(0); + return 0; } else if (is_done < 0) { module_put(calling_module); - return_VALUE(is_done); + return is_done; } is_done = -EIO; @@ -369,7 +357,7 @@ int acpi_processor_notify_smm(struct mod if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n")); module_put(calling_module); - return_VALUE(0); + return 0; } ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -386,12 +374,12 @@ int acpi_processor_notify_smm(struct mod status = acpi_os_write_port(acpi_fadt.smi_cmd, (u32) acpi_fadt.pstate_cnt, 8); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Failed to write pstate_cnt [0x%x] to " - "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, - acpi_fadt.smi_cmd)); + ACPI_EXCEPTION((AE_INFO, status, + "Failed to write pstate_cnt [0x%x] to " + "smi_cmd [0x%x]", acpi_fadt.pstate_cnt, + acpi_fadt.smi_cmd)); module_put(calling_module); - return_VALUE(status); + return status; } /* Success. If there's no _PPC, we need to fear nothing, so @@ -401,7 +389,7 @@ int acpi_processor_notify_smm(struct mod if (!(acpi_processor_ppc_status & PPC_IN_USE)) module_put(calling_module); - return_VALUE(0); + return 0; } EXPORT_SYMBOL(acpi_processor_notify_smm); @@ -422,8 +410,6 @@ static int acpi_processor_perf_seq_show( struct acpi_processor *pr = (struct acpi_processor *)seq->private; int i; - ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show"); - if (!pr) goto end; @@ -446,7 +432,7 @@ static int acpi_processor_perf_seq_show( (u32) pr->performance->states[i].transition_latency); end: - return_VALUE(0); + return 0; } static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) @@ -468,23 +454,21 @@ acpi_processor_write_performance(struct unsigned int new_state = 0; struct cpufreq_policy policy; - ACPI_FUNCTION_TRACE("acpi_processor_write_performance"); - if (!pr || (count > sizeof(state_string) - 1)) - return_VALUE(-EINVAL); + return -EINVAL; perf = pr->performance; if (!perf) - return_VALUE(-EINVAL); + return -EINVAL; if (copy_from_user(state_string, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; state_string[count] = '\0'; new_state = simple_strtoul(state_string, NULL, 0); if (new_state >= perf->state_count) - return_VALUE(-EINVAL); + return -EINVAL; cpufreq_get_policy(&policy, pr->id); @@ -494,9 +478,9 @@ acpi_processor_write_performance(struct result = cpufreq_set_policy(&policy); if (result) - return_VALUE(result); + return result; - return_VALUE(count); + return count; } static void acpi_cpufreq_add_file(struct acpi_processor *pr) @@ -504,42 +488,32 @@ static void acpi_cpufreq_add_file(struct struct proc_dir_entry *entry = NULL; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile"); - if (acpi_bus_get_device(pr->handle, &device)) - return_VOID; + return; /* add file 'performance' [R/W] */ entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); - if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_PROCESSOR_FILE_PERFORMANCE)); - else { + if (entry){ acpi_processor_perf_fops.write = acpi_processor_write_performance; entry->proc_fops = &acpi_processor_perf_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return_VOID; } static void acpi_cpufreq_remove_file(struct acpi_processor *pr) { struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile"); - if (acpi_bus_get_device(pr->handle, &device)) - return_VOID; + return; /* remove file 'performance' */ remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, acpi_device_dir(device)); - return_VOID; } #else @@ -553,42 +527,264 @@ static void acpi_cpufreq_remove_file(str } #endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */ +static int acpi_processor_get_psd(struct acpi_processor *pr) +{ + int result = 0; + acpi_status status = AE_OK; + struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"}; + struct acpi_buffer state = {0, NULL}; + union acpi_object *psd = NULL; + struct acpi_psd_package *pdomain; + + status = acpi_evaluate_object(pr->handle, "_PSD", NULL, &buffer); + if (ACPI_FAILURE(status)) { + return -ENODEV; + } + + psd = (union acpi_object *) buffer.pointer; + if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); + result = -EFAULT; + goto end; + } + + if (psd->package.count != 1) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); + result = -EFAULT; + goto end; + } + + pdomain = &(pr->performance->domain_info); + + state.length = sizeof(struct acpi_psd_package); + state.pointer = pdomain; + + status = acpi_extract_package(&(psd->package.elements[0]), + &format, &state); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); + result = -EFAULT; + goto end; + } + + if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _PSD:num_entries\n")); + result = -EFAULT; + goto end; + } + + if (pdomain->revision != ACPI_PSD_REV0_REVISION) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _PSD:revision\n")); + result = -EFAULT; + goto end; + } + +end: + kfree(buffer.pointer); + return result; +} + +int acpi_processor_preregister_performance( + struct acpi_processor_performance **performance) +{ + int count, count_target; + int retval = 0; + unsigned int i, j; + cpumask_t covered_cpus; + struct acpi_processor *pr; + struct acpi_psd_package *pdomain; + struct acpi_processor *match_pr; + struct acpi_psd_package *match_pdomain; + + mutex_lock(&performance_mutex); + + retval = 0; + + /* Call _PSD for all CPUs */ + for_each_possible_cpu(i) { + pr = processors[i]; + if (!pr) { + /* Look only at processors in ACPI namespace */ + continue; + } + + if (pr->performance) { + retval = -EBUSY; + continue; + } + + if (!performance || !performance[i]) { + retval = -EINVAL; + continue; + } + + pr->performance = performance[i]; + cpu_set(i, pr->performance->shared_cpu_map); + if (acpi_processor_get_psd(pr)) { + retval = -EINVAL; + continue; + } + } + if (retval) + goto err_ret; + + /* + * Now that we have _PSD data from all CPUs, lets setup P-state + * domain info. + */ + for_each_possible_cpu(i) { + pr = processors[i]; + if (!pr) + continue; + + /* Basic validity check for domain info */ + pdomain = &(pr->performance->domain_info); + if ((pdomain->revision != ACPI_PSD_REV0_REVISION) || + (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES)) { + retval = -EINVAL; + goto err_ret; + } + if (pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ALL && + pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ANY && + pdomain->coord_type != DOMAIN_COORD_TYPE_HW_ALL) { + retval = -EINVAL; + goto err_ret; + } + } + + cpus_clear(covered_cpus); + for_each_possible_cpu(i) { + pr = processors[i]; + if (!pr) + continue; + + if (cpu_isset(i, covered_cpus)) + continue; + + pdomain = &(pr->performance->domain_info); + cpu_set(i, pr->performance->shared_cpu_map); + cpu_set(i, covered_cpus); + if (pdomain->num_processors <= 1) + continue; + + /* Validate the Domain info */ + count_target = pdomain->num_processors; + count = 1; + if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL || + pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) { + pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; + } else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY) { + pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY; + } + + for_each_possible_cpu(j) { + if (i == j) + continue; + + match_pr = processors[j]; + if (!match_pr) + continue; + + match_pdomain = &(match_pr->performance->domain_info); + if (match_pdomain->domain != pdomain->domain) + continue; + + /* Here i and j are in the same domain */ + + if (match_pdomain->num_processors != count_target) { + retval = -EINVAL; + goto err_ret; + } + + if (pdomain->coord_type != match_pdomain->coord_type) { + retval = -EINVAL; + goto err_ret; + } + + cpu_set(j, covered_cpus); + cpu_set(j, pr->performance->shared_cpu_map); + count++; + } + + for_each_possible_cpu(j) { + if (i == j) + continue; + + match_pr = processors[j]; + if (!match_pr) + continue; + + match_pdomain = &(match_pr->performance->domain_info); + if (match_pdomain->domain != pdomain->domain) + continue; + + match_pr->performance->shared_type = + pr->performance->shared_type; + match_pr->performance->shared_cpu_map = + pr->performance->shared_cpu_map; + } + } + +err_ret: + if (retval) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error while parsing _PSD domain information. Assuming no coordination\n")); + } + + for_each_possible_cpu(i) { + pr = processors[i]; + if (!pr || !pr->performance) + continue; + + /* Assume no coordination on any error parsing domain info */ + if (retval) { + cpus_clear(pr->performance->shared_cpu_map); + cpu_set(i, pr->performance->shared_cpu_map); + pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; + } + pr->performance = NULL; /* Will be set for real in register */ + } + + mutex_unlock(&performance_mutex); + return retval; +} +EXPORT_SYMBOL(acpi_processor_preregister_performance); + + int acpi_processor_register_performance(struct acpi_processor_performance *performance, unsigned int cpu) { struct acpi_processor *pr; - ACPI_FUNCTION_TRACE("acpi_processor_register_performance"); - if (!(acpi_processor_ppc_status & PPC_REGISTERED)) - return_VALUE(-EINVAL); + return -EINVAL; - down(&performance_sem); + mutex_lock(&performance_mutex); pr = processors[cpu]; if (!pr) { - up(&performance_sem); - return_VALUE(-ENODEV); + mutex_unlock(&performance_mutex); + return -ENODEV; } if (pr->performance) { - up(&performance_sem); - return_VALUE(-EBUSY); + mutex_unlock(&performance_mutex); + return -EBUSY; } pr->performance = performance; if (acpi_processor_get_performance_info(pr)) { pr->performance = NULL; - up(&performance_sem); - return_VALUE(-EIO); + mutex_unlock(&performance_mutex); + return -EIO; } acpi_cpufreq_add_file(pr); - up(&performance_sem); - return_VALUE(0); + mutex_unlock(&performance_mutex); + return 0; } EXPORT_SYMBOL(acpi_processor_register_performance); @@ -599,14 +795,12 @@ acpi_processor_unregister_performance(st { struct acpi_processor *pr; - ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance"); - - down(&performance_sem); + mutex_lock(&performance_mutex); pr = processors[cpu]; if (!pr) { - up(&performance_sem); - return_VOID; + mutex_unlock(&performance_mutex); + return; } kfree(pr->performance->states); @@ -614,9 +808,8 @@ acpi_processor_unregister_performance(st acpi_cpufreq_remove_file(pr); - up(&performance_sem); + mutex_unlock(&performance_mutex); - return_VOID; } EXPORT_SYMBOL(acpi_processor_unregister_performance); diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index f99ad05..b2fd31d 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c @@ -54,13 +54,11 @@ static int acpi_processor_apply_limit(st u16 px = 0; u16 tx = 0; - ACPI_FUNCTION_TRACE("acpi_processor_apply_limit"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; if (!pr->flags.limit) - return_VALUE(-ENODEV); + return -ENODEV; if (pr->flags.throttling) { if (pr->limit.user.tx > tx) @@ -82,9 +80,9 @@ static int acpi_processor_apply_limit(st end: if (result) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n")); + ACPI_ERROR((AE_INFO, "Unable to set limit")); - return_VALUE(result); + return result; } #ifdef CONFIG_CPU_FREQ @@ -200,19 +198,17 @@ int acpi_processor_set_thermal_limit(acp struct acpi_device *device = NULL; int tx = 0, max_tx_px = 0; - ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit"); - if ((type < ACPI_PROCESSOR_LIMIT_NONE) || (type > ACPI_PROCESSOR_LIMIT_DECREMENT)) - return_VALUE(-EINVAL); + return -EINVAL; result = acpi_bus_get_device(handle, &device); if (result) - return_VALUE(result); + return result; pr = (struct acpi_processor *)acpi_driver_data(device); if (!pr) - return_VALUE(-ENODEV); + return -ENODEV; /* Thermal limits are always relative to the current Px/Tx state. */ if (pr->flags.throttling) @@ -289,30 +285,27 @@ int acpi_processor_set_thermal_limit(acp result = acpi_processor_apply_limit(pr); if (result) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to set thermal limit\n")); + ACPI_ERROR((AE_INFO, "Unable to set thermal limit")); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n", pr->limit.thermal.px, pr->limit.thermal.tx)); } else result = 0; if (max_tx_px) - return_VALUE(1); + return 1; else - return_VALUE(result); + return result; } int acpi_processor_get_limit_info(struct acpi_processor *pr) { - ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; if (pr->flags.throttling) pr->flags.limit = 1; - return_VALUE(0); + return 0; } /* /proc interface */ @@ -321,8 +314,6 @@ static int acpi_processor_limit_seq_show { struct acpi_processor *pr = (struct acpi_processor *)seq->private; - ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show"); - if (!pr) goto end; @@ -339,7 +330,7 @@ static int acpi_processor_limit_seq_show pr->limit.thermal.px, pr->limit.thermal.tx); end: - return_VALUE(0); + return 0; } static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) @@ -359,36 +350,32 @@ static ssize_t acpi_processor_write_limi int px = 0; int tx = 0; - ACPI_FUNCTION_TRACE("acpi_processor_write_limit"); - if (!pr || (count > sizeof(limit_string) - 1)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n")); - return_VALUE(-EINVAL); + return -EINVAL; } if (copy_from_user(limit_string, buffer, count)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); - return_VALUE(-EFAULT); + return -EFAULT; } limit_string[count] = '\0'; if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "Invalid data format")); + return -EINVAL; } if (pr->flags.throttling) { if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid tx\n")); - return_VALUE(-EINVAL); + ACPI_ERROR((AE_INFO, "Invalid tx")); + return -EINVAL; } pr->limit.user.tx = tx; } result = acpi_processor_apply_limit(pr); - return_VALUE(count); + return count; } struct file_operations acpi_processor_limit_fops = { diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index b966549..6552e22 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -55,13 +55,11 @@ static int acpi_processor_get_throttling u32 duty_mask = 0; u32 duty_value = 0; - ACPI_FUNCTION_TRACE("acpi_processor_get_throttling"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; if (!pr->flags.throttling) - return_VALUE(-ENODEV); + return -ENODEV; pr->throttling.state = 0; @@ -93,7 +91,7 @@ static int acpi_processor_get_throttling "Throttling state is T%d (%d%% throttling applied)\n", state, pr->throttling.states[state].performance)); - return_VALUE(0); + return 0; } int acpi_processor_set_throttling(struct acpi_processor *pr, int state) @@ -102,19 +100,17 @@ int acpi_processor_set_throttling(struct u32 duty_mask = 0; u32 duty_value = 0; - ACPI_FUNCTION_TRACE("acpi_processor_set_throttling"); - if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; if ((state < 0) || (state > (pr->throttling.state_count - 1))) - return_VALUE(-EINVAL); + return -EINVAL; if (!pr->flags.throttling) - return_VALUE(-ENODEV); + return -ENODEV; if (state == pr->throttling.state) - return_VALUE(0); + return 0; /* * Calculate the duty_value and duty_mask. @@ -165,7 +161,7 @@ int acpi_processor_set_throttling(struct (pr->throttling.states[state].performance ? pr-> throttling.states[state].performance / 10 : 0))); - return_VALUE(0); + return 0; } int acpi_processor_get_throttling_info(struct acpi_processor *pr) @@ -174,8 +170,6 @@ int acpi_processor_get_throttling_info(s int step = 0; int i = 0; - ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info"); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", pr->throttling.address, @@ -183,21 +177,21 @@ int acpi_processor_get_throttling_info(s pr->throttling.duty_width)); if (!pr) - return_VALUE(-EINVAL); + return -EINVAL; /* TBD: Support ACPI 2.0 objects */ if (!pr->throttling.address) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); - return_VALUE(0); + return 0; } else if (!pr->throttling.duty_width) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); - return_VALUE(0); + return 0; } /* TBD: Support duty_cycle values that span bit 4. */ else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n")); - return_VALUE(0); + ACPI_WARNING((AE_INFO, "duty_cycle spans bit 4")); + return 0; } /* @@ -208,7 +202,7 @@ int acpi_processor_get_throttling_info(s if (errata.piix4.throttle) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Throttling not supported on PIIX4 A- or B-step\n")); - return_VALUE(0); + return 0; } pr->throttling.state_count = 1 << acpi_fadt.duty_width; @@ -254,7 +248,7 @@ int acpi_processor_get_throttling_info(s if (result) pr->flags.throttling = 0; - return_VALUE(result); + return result; } /* proc interface */ @@ -266,8 +260,6 @@ static int acpi_processor_throttling_seq int i = 0; int result = 0; - ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show"); - if (!pr) goto end; @@ -296,7 +288,7 @@ static int acpi_processor_throttling_seq throttling.states[i].performance / 10 : 0)); end: - return_VALUE(0); + return 0; } static int acpi_processor_throttling_open_fs(struct inode *inode, @@ -315,13 +307,11 @@ static ssize_t acpi_processor_write_thro struct acpi_processor *pr = (struct acpi_processor *)m->private; char state_string[12] = { '\0' }; - ACPI_FUNCTION_TRACE("acpi_processor_write_throttling"); - if (!pr || (count > sizeof(state_string) - 1)) - return_VALUE(-EINVAL); + return -EINVAL; if (copy_from_user(state_string, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; state_string[count] = '\0'; @@ -329,9 +319,9 @@ static ssize_t acpi_processor_write_thro simple_strtoul(state_string, NULL, 0)); if (result) - return_VALUE(result); + return result; - return_VALUE(count); + return count; } struct file_operations acpi_processor_throttling_fops = { diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index 4038dbf..8e406d9 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -78,6 +78,7 @@ static u8 acpi_rs_count_set_bits(u16 bit ACPI_FUNCTION_ENTRY(); for (bits_set = 0; bit_field; bits_set++) { + /* Zero the least significant bit that is set */ bit_field &= (bit_field - 1); @@ -154,15 +155,18 @@ acpi_rs_stream_option_length(u32 resourc * length, minus one byte for the resource_source_index itself. */ if (resource_length > minimum_aml_resource_length) { + /* Compute the length of the optional string */ string_length = resource_length - minimum_aml_resource_length - 1; } - /* Round up length to 32 bits for internal structure alignment */ - - return (ACPI_ROUND_UP_to_32_bITS(string_length)); + /* + * Round the length up to a multiple of the native word in order to + * guarantee that the entire resource descriptor is native word aligned + */ + return ((u32) ACPI_ROUND_UP_TO_NATIVE_WORD(string_length)); } /******************************************************************************* @@ -191,6 +195,7 @@ acpi_rs_get_aml_length(struct acpi_resou /* Traverse entire list of internal resource descriptors */ while (resource) { + /* Validate the descriptor type */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { @@ -214,6 +219,7 @@ acpi_rs_get_aml_length(struct acpi_resou * is a Large Resource data type. */ if (resource->data.vendor.byte_length > 7) { + /* Base size of a Large resource descriptor */ total_size = @@ -332,7 +338,7 @@ acpi_rs_get_list_length(u8 * aml_buffer, acpi_status status; u8 *end_aml; u8 *buffer; - u32 buffer_size = 0; + u32 buffer_size; u16 temp16; u16 resource_length; u32 extra_struct_bytes; @@ -341,11 +347,13 @@ acpi_rs_get_list_length(u8 * aml_buffer, ACPI_FUNCTION_TRACE("rs_get_list_length"); + *size_needed = 0; end_aml = aml_buffer + aml_buffer_length; /* Walk the list of AML resource descriptors */ while (aml_buffer < end_aml) { + /* Validate the Resource Type and Resource Length */ status = acpi_ut_validate_resource(aml_buffer, &resource_index); @@ -386,35 +394,28 @@ acpi_rs_get_list_length(u8 * aml_buffer, break; case ACPI_RESOURCE_NAME_VENDOR_SMALL: + case ACPI_RESOURCE_NAME_VENDOR_LARGE: /* * Vendor Resource: - * Ensure a 32-bit boundary for the structure + * Get the number of vendor data bytes */ - extra_struct_bytes = - ACPI_ROUND_UP_to_32_bITS(resource_length); + extra_struct_bytes = resource_length; break; case ACPI_RESOURCE_NAME_END_TAG: /* - * End Tag: This is the normal exit, add size of end_tag + * End Tag: + * This is the normal exit, add size of end_tag */ - *size_needed = buffer_size + ACPI_RS_SIZE_MIN; + *size_needed += ACPI_RS_SIZE_MIN; return_ACPI_STATUS(AE_OK); - case ACPI_RESOURCE_NAME_VENDOR_LARGE: - /* - * Vendor Resource: - * Add vendor data and ensure a 32-bit boundary for the structure - */ - extra_struct_bytes = - ACPI_ROUND_UP_to_32_bITS(resource_length); - break; - case ACPI_RESOURCE_NAME_ADDRESS32: case ACPI_RESOURCE_NAME_ADDRESS16: + case ACPI_RESOURCE_NAME_ADDRESS64: /* - * 32-Bit or 16-bit Address Resource: - * Add the size of any optional data (resource_source) + * Address Resource: + * Add the size of the optional resource_source */ extra_struct_bytes = acpi_rs_stream_option_length(resource_length, @@ -423,50 +424,46 @@ acpi_rs_get_list_length(u8 * aml_buffer, case ACPI_RESOURCE_NAME_EXTENDED_IRQ: /* - * Extended IRQ: - * Point past the interrupt_vector_flags to get the - * interrupt_table_length. + * Extended IRQ Resource: + * Using the interrupt_table_length, add 4 bytes for each additional + * interrupt. Note: at least one interrupt is required and is + * included in the minimum descriptor size (reason for the -1) */ - buffer++; + extra_struct_bytes = (buffer[1] - 1) * sizeof(u32); - extra_struct_bytes = - /* - * Add 4 bytes for each additional interrupt. Note: at - * least one interrupt is required and is included in - * the minimum descriptor size - */ - ((*buffer - 1) * sizeof(u32)) + - /* Add the size of any optional data (resource_source) */ + /* Add the size of the optional resource_source */ + + extra_struct_bytes += acpi_rs_stream_option_length(resource_length - extra_struct_bytes, minimum_aml_resource_length); break; - case ACPI_RESOURCE_NAME_ADDRESS64: - /* - * 64-Bit Address Resource: - * Add the size of any optional data (resource_source) - * Ensure a 64-bit boundary for the structure - */ - extra_struct_bytes = - ACPI_ROUND_UP_to_64_bITS - (acpi_rs_stream_option_length - (resource_length, minimum_aml_resource_length)); - break; - default: break; } - /* Update the required buffer size for the internal descriptor structs */ + /* + * Update the required buffer size for the internal descriptor structs + * + * Important: Round the size up for the appropriate alignment. This + * is a requirement on IA64. + */ + buffer_size = acpi_gbl_resource_struct_sizes[resource_index] + + extra_struct_bytes; + buffer_size = ACPI_ROUND_UP_TO_NATIVE_WORD(buffer_size); - temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] + - extra_struct_bytes); - buffer_size += (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(temp16); + *size_needed += buffer_size; + + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, + "Type %.2X, Aml %.2X internal %.2X\n", + acpi_ut_get_resource_type(aml_buffer), + acpi_ut_get_descriptor_length(aml_buffer), + buffer_size)); /* - * Point to the next resource within the stream - * using the size of the header plus the length contained in the header + * Point to the next resource within the AML stream using the length + * contained in the resource descriptor header */ aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); } @@ -523,6 +520,7 @@ acpi_rs_get_pci_routing_table_length(uni top_object_list = package_object->package.elements; for (index = 0; index < number_of_elements; index++) { + /* Dereference the sub-package */ package_element = *top_object_list; @@ -581,7 +579,7 @@ acpi_rs_get_pci_routing_table_length(uni /* Round up the size since each element must be aligned */ - temp_size_needed = ACPI_ROUND_UP_to_64_bITS(temp_size_needed); + temp_size_needed = ACPI_ROUND_UP_to_64_bIT(temp_size_needed); /* Point to the next union acpi_operand_object */ @@ -589,7 +587,7 @@ acpi_rs_get_pci_routing_table_length(uni } /* - * Adding an extra element to the end of the list, essentially a + * Add an extra element to the end of the list, essentially a * NULL terminator */ *buffer_size_needed = diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 8c128de..67c052a 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c @@ -332,7 +332,7 @@ acpi_rs_create_pci_routing_table(union a /* Now align the current length */ user_prt->length = - (u32) ACPI_ROUND_UP_to_64_bITS(user_prt->length); + (u32) ACPI_ROUND_UP_to_64_bIT(user_prt->length); /* 4) Fourth subobject: Dereference the PRT.source_index */ diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index d9ae64b..9e7ae2f 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c @@ -141,6 +141,7 @@ struct acpi_rsdump_info *acpi_gbl_dump_r acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ }; #endif + #endif /* ACPI_FUTURE_USAGE */ /* * Base sizes for external AML resource descriptors, indexed by internal type. diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index 1434e78..6f2d8de 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -77,6 +77,16 @@ acpi_rs_convert_aml_to_resources(u8 * am /* Loop until end-of-buffer or an end_tag is found */ while (aml < end_aml) { + /* + * Check that the input buffer and all subsequent pointers into it + * are aligned on a native word boundary. Most important on IA64 + */ + if (ACPI_IS_MISALIGNED(resource)) { + ACPI_WARNING((AE_INFO, + "Misaligned resource pointer %p", + resource)); + } + /* Validate the Resource Type and Resource Length */ status = acpi_ut_validate_resource(aml, &resource_index); @@ -100,6 +110,12 @@ acpi_rs_convert_aml_to_resources(u8 * am return_ACPI_STATUS(status); } + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, + "Type %.2X, Aml %.2X internal %.2X\n", + acpi_ut_get_resource_type(aml), + acpi_ut_get_descriptor_length(aml), + resource->length)); + /* Normal exit on completion of an end_tag resource descriptor */ if (acpi_ut_get_resource_type(aml) == @@ -155,6 +171,7 @@ acpi_rs_convert_resources_to_aml(struct /* Walk the resource descriptor list, convert each descriptor */ while (aml < end_aml) { + /* Validate the (internal) Resource Type */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { @@ -191,6 +208,7 @@ acpi_rs_convert_resources_to_aml(struct /* Check for end-of-list, normal exit */ if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { + /* An End Tag indicates the end of the input Resource Template */ return_ACPI_STATUS(AE_OK); diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index ed866cf..6a731f4 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c @@ -81,9 +81,10 @@ acpi_rs_convert_aml_to_resource(struct a u16 item_count = 0; u16 temp16 = 0; - ACPI_FUNCTION_TRACE("rs_get_resource"); + ACPI_FUNCTION_TRACE("rs_convert_aml_to_resource"); if (((acpi_native_uint) resource) & 0x3) { + /* Each internal resource struct is expected to be 32-bit aligned */ ACPI_WARNING((AE_INFO, @@ -295,9 +296,11 @@ acpi_rs_convert_aml_to_resource(struct a exit: if (!flags_mode) { - /* Round the resource struct length up to the next 32-bit boundary */ - resource->length = ACPI_ROUND_UP_to_32_bITS(resource->length); + /* Round the resource struct length up to the next boundary (32 or 64) */ + + resource->length = + (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(resource->length); } return_ACPI_STATUS(AE_OK); } @@ -535,6 +538,7 @@ if (((aml->irq.flags & 0x09) == 0x00) || resource->data.extended_irq.interrupt_count = temp8; if (temp8 < 1) { + /* Must have at least one IRQ */ return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 25b5aed..db25a10 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -205,6 +205,7 @@ acpi_rs_set_resource_length(acpi_rsdesc_ /* Length is stored differently for large and small descriptors */ if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large descriptor -- bytes 1-2 contain the 16-bit length */ ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, @@ -298,7 +299,8 @@ static u16 acpi_rs_strcpy(char *destinat * string_ptr - (optional) where to store the actual * resource_source string * - * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit + * RETURN: Length of the string plus NULL terminator, rounded up to native + * word boundary * * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor * to an internal resource descriptor @@ -328,6 +330,7 @@ acpi_rs_get_resource_source(acpi_rs_leng * we add 1 to the minimum length. */ if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) { + /* Get the resource_source_index */ resource_source->index = aml_resource_source[0]; @@ -344,23 +347,25 @@ acpi_rs_get_resource_source(acpi_rs_leng } /* - * In order for the struct_size to fall on a 32-bit boundary, calculate - * the length of the string (+1 for the NULL terminator) and expand the - * struct_size to the next 32-bit boundary. + * In order for the Resource length to be a multiple of the native + * word, calculate the length of the string (+1 for NULL terminator) + * and expand to the next word multiple. * * Zero the entire area of the buffer. */ total_length = - ACPI_ROUND_UP_to_32_bITS(ACPI_STRLEN - ((char *)&aml_resource_source[1]) + - 1); + ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + + 1; + total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length); + ACPI_MEMSET(resource_source->string_ptr, 0, total_length); /* Copy the resource_source string to the destination */ resource_source->string_length = acpi_rs_strcpy(resource_source->string_ptr, - (char *)&aml_resource_source[1]); + ACPI_CAST_PTR(char, + &aml_resource_source[1])); return ((acpi_rs_length) total_length); } @@ -405,6 +410,7 @@ acpi_rs_set_resource_source(union aml_re /* Non-zero string length indicates presence of a resource_source */ if (resource_source->string_length) { + /* Point to the end of the AML descriptor */ aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length); @@ -415,7 +421,7 @@ acpi_rs_set_resource_source(union aml_re /* Copy the resource_source string */ - ACPI_STRCPY((char *)&aml_resource_source[1], + ACPI_STRCPY(ACPI_CAST_PTR(char, &aml_resource_source[1]), resource_source->string_ptr); /* @@ -435,9 +441,9 @@ acpi_rs_set_resource_source(union aml_re * * FUNCTION: acpi_rs_get_prt_method_data * - * PARAMETERS: Handle - a handle to the containing object - * ret_buffer - a pointer to a buffer structure for the - * results + * PARAMETERS: Handle - Handle to the containing object + * ret_buffer - Pointer to a buffer structure for the + * results * * RETURN: Status * @@ -483,9 +489,9 @@ acpi_rs_get_prt_method_data(acpi_handle * * FUNCTION: acpi_rs_get_crs_method_data * - * PARAMETERS: Handle - a handle to the containing object - * ret_buffer - a pointer to a buffer structure for the - * results + * PARAMETERS: Handle - Handle to the containing object + * ret_buffer - Pointer to a buffer structure for the + * results * * RETURN: Status * @@ -532,9 +538,9 @@ acpi_rs_get_crs_method_data(acpi_handle * * FUNCTION: acpi_rs_get_prs_method_data * - * PARAMETERS: Handle - a handle to the containing object - * ret_buffer - a pointer to a buffer structure for the - * results + * PARAMETERS: Handle - Handle to the containing object + * ret_buffer - Pointer to a buffer structure for the + * results * * RETURN: Status * @@ -583,10 +589,10 @@ #endif /* ACPI_FUTURE_USAGE */ * * FUNCTION: acpi_rs_get_method_data * - * PARAMETERS: Handle - a handle to the containing object + * PARAMETERS: Handle - Handle to the containing object * Path - Path to method, relative to Handle - * ret_buffer - a pointer to a buffer structure for the - * results + * ret_buffer - Pointer to a buffer structure for the + * results * * RETURN: Status * @@ -634,9 +640,9 @@ acpi_rs_get_method_data(acpi_handle hand * * FUNCTION: acpi_rs_set_srs_method_data * - * PARAMETERS: Handle - a handle to the containing object - * in_buffer - a pointer to a buffer structure of the - * parameter + * PARAMETERS: Handle - Handle to the containing object + * in_buffer - Pointer to a buffer structure of the + * parameter * * RETURN: Status * @@ -677,7 +683,7 @@ acpi_rs_set_srs_method_data(acpi_handle params[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); if (!params[0]) { - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return_ACPI_STATUS(AE_NO_MEMORY); } @@ -696,6 +702,7 @@ acpi_rs_set_srs_method_data(acpi_handle status = acpi_ns_evaluate_relative(METHOD_NAME__SRS, &info); if (ACPI_SUCCESS(status)) { + /* Delete any return object (especially if implicit_return is enabled) */ if (info.return_object) { diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 88b6707..b3feebb 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include @@ -118,6 +116,8 @@ acpi_get_irq_routing_table(acpi_handle d return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_get_irq_routing_table) + /******************************************************************************* * * FUNCTION: acpi_get_current_resources @@ -141,7 +141,6 @@ acpi_get_irq_routing_table(acpi_handle d * the object indicated by the passed device_handle. * ******************************************************************************/ - acpi_status acpi_get_current_resources(acpi_handle device_handle, struct acpi_buffer *ret_buffer) @@ -169,8 +168,9 @@ acpi_get_current_resources(acpi_handle d return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_current_resources); +ACPI_EXPORT_SYMBOL(acpi_get_current_resources) +#ifdef ACPI_FUTURE_USAGE /******************************************************************************* * * FUNCTION: acpi_get_possible_resources @@ -191,8 +191,6 @@ EXPORT_SYMBOL(acpi_get_current_resources * and the value of ret_buffer is undefined. * ******************************************************************************/ - -#ifdef ACPI_FUTURE_USAGE acpi_status acpi_get_possible_resources(acpi_handle device_handle, struct acpi_buffer *ret_buffer) @@ -220,7 +218,7 @@ acpi_get_possible_resources(acpi_handle return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_possible_resources); +ACPI_EXPORT_SYMBOL(acpi_get_possible_resources) #endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* @@ -241,7 +239,6 @@ #endif /* ACPI_FUTURE_USAGE */ * each resource in the list. * ******************************************************************************/ - acpi_status acpi_walk_resources(acpi_handle device_handle, char *name, @@ -279,6 +276,7 @@ acpi_walk_resources(acpi_handle device_h /* Walk the resource list until the end_tag is found (or buffer end) */ while (resource < resource_end) { + /* Sanity check the resource */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { @@ -291,6 +289,7 @@ acpi_walk_resources(acpi_handle device_h status = user_function(resource, context); if (ACPI_FAILURE(status)) { if (status == AE_CTRL_TERMINATE) { + /* This is an OK termination by the user function */ status = AE_OK; @@ -311,11 +310,11 @@ acpi_walk_resources(acpi_handle device_h resource->length); } - ACPI_MEM_FREE(buffer.pointer); + ACPI_FREE(buffer.pointer); return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_walk_resources); +ACPI_EXPORT_SYMBOL(acpi_walk_resources) /******************************************************************************* * @@ -334,7 +333,6 @@ EXPORT_SYMBOL(acpi_walk_resources); * the buffer pointed to by the in_buffer variable. * ******************************************************************************/ - acpi_status acpi_set_current_resources(acpi_handle device_handle, struct acpi_buffer *in_buffer) @@ -354,7 +352,7 @@ acpi_set_current_resources(acpi_handle d return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_set_current_resources); +ACPI_EXPORT_SYMBOL(acpi_set_current_resources) /****************************************************************************** * @@ -373,7 +371,6 @@ EXPORT_SYMBOL(acpi_set_current_resources * addresses. * ******************************************************************************/ - acpi_status acpi_resource_to_address64(struct acpi_resource *resource, struct acpi_resource_address64 *out) @@ -415,7 +412,7 @@ acpi_resource_to_address64(struct acpi_r return (AE_OK); } -EXPORT_SYMBOL(acpi_resource_to_address64); +ACPI_EXPORT_SYMBOL(acpi_resource_to_address64) /******************************************************************************* * @@ -435,7 +432,6 @@ EXPORT_SYMBOL(acpi_resource_to_address64 * UUID subtype. Returns a struct acpi_resource of type Vendor. * ******************************************************************************/ - acpi_status acpi_get_vendor_resource(acpi_handle device_handle, char *name, @@ -467,6 +463,8 @@ acpi_get_vendor_resource(acpi_handle dev return (info.status); } +ACPI_EXPORT_SYMBOL(acpi_get_vendor_resource) + /******************************************************************************* * * FUNCTION: acpi_rs_match_vendor_resource @@ -478,7 +476,6 @@ acpi_get_vendor_resource(acpi_handle dev * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID * ******************************************************************************/ - static acpi_status acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) { @@ -526,3 +523,5 @@ acpi_rs_match_vendor_resource(struct acp info->status = AE_OK; return (AE_CTRL_TERMINATE); } + +ACPI_EXPORT_SYMBOL(acpi_rs_match_vendor_resource) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a0ab828..63e1aa4 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -142,7 +142,7 @@ static void acpi_device_register(struct create_sysfs_device_files(device); } -static int acpi_device_unregister(struct acpi_device *device, int type) +static void acpi_device_unregister(struct acpi_device *device, int type) { spin_lock(&acpi_device_lock); if (device->parent) { @@ -158,16 +158,13 @@ static int acpi_device_unregister(struct acpi_detach_data(device->handle, acpi_bus_data_handler); remove_sysfs_device_files(device); kobject_unregister(&device->kobj); - return 0; } void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) { - ACPI_FUNCTION_TRACE("acpi_bus_data_handler"); - /* TBD */ - return_VOID; + return; } static int acpi_bus_get_power_flags(struct acpi_device *device) @@ -176,8 +173,6 @@ static int acpi_bus_get_power_flags(stru acpi_handle handle = NULL; u32 i = 0; - ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags"); - /* * Power Management Flags */ @@ -229,17 +224,14 @@ static int acpi_bus_get_power_flags(stru device->power.state = ACPI_STATE_UNKNOWN; - return_VALUE(0); + return 0; } int acpi_match_ids(struct acpi_device *device, char *ids) { - int error = 0; - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; - if (device->flags.hardware_id) if (strstr(ids, device->pnp.hardware_id)) - goto Done; + return 0; if (device->flags.compatible_ids) { struct acpi_compatible_id_list *cid_list = device->pnp.cid_list; @@ -248,15 +240,10 @@ int acpi_match_ids(struct acpi_device *d /* compare multiple _CID entries against driver ids */ for (i = 0; i < cid_list->count; i++) { if (strstr(ids, cid_list->id[i].value)) - goto Done; + return 0; } } - error = -ENOENT; - - Done: - if (buffer.pointer) - acpi_os_free(buffer.pointer); - return error; + return -ENOENT; } static acpi_status @@ -315,24 +302,21 @@ static int acpi_bus_get_wakeup_device_fl struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *package = NULL; - ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags"); - /* _PRW */ status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRW\n")); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRW")); goto end; } package = (union acpi_object *)buffer.pointer; status = acpi_bus_extract_wakeup_device_power_package(device, package); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error extracting _PRW package\n")); + ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package")); goto end; } - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); device->wakeup.flags.valid = 1; /* Power button, Lid switch always enable wakeup */ @@ -342,7 +326,7 @@ static int acpi_bus_get_wakeup_device_fl end: if (ACPI_FAILURE(status)) device->flags.wake_capable = 0; - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -441,10 +425,7 @@ #endif islockable = device->flags.lockable; handle = device->handle; - if (type == ACPI_TYPE_PROCESSOR) - result = acpi_bus_trim(device, 0); - else - result = acpi_bus_trim(device, 1); + result = acpi_bus_trim(device, 1); if (!result) result = acpi_eject_operation(handle, islockable); @@ -471,7 +452,6 @@ static int acpi_bus_get_perf_flags(struc -------------------------------------------------------------------------- */ static LIST_HEAD(acpi_bus_drivers); -static DECLARE_MUTEX(acpi_bus_drivers_lock); /** * acpi_bus_match - match device IDs to driver's supported IDs @@ -502,19 +482,17 @@ acpi_bus_driver_init(struct acpi_device { int result = 0; - ACPI_FUNCTION_TRACE("acpi_bus_driver_init"); - if (!device || !driver) - return_VALUE(-EINVAL); + return -EINVAL; if (!driver->ops.add) - return_VALUE(-ENOSYS); + return -ENOSYS; result = driver->ops.add(device); if (result) { device->driver = NULL; acpi_driver_data(device) = NULL; - return_VALUE(result); + return result; } device->driver = driver; @@ -526,7 +504,7 @@ acpi_bus_driver_init(struct acpi_device ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n")); - return_VALUE(0); + return 0; } static int acpi_start_single_object(struct acpi_device *device) @@ -534,10 +512,8 @@ static int acpi_start_single_object(stru int result = 0; struct acpi_driver *driver; - ACPI_FUNCTION_TRACE("acpi_start_single_object"); - if (!(driver = device->driver)) - return_VALUE(0); + return 0; if (driver->ops.start) { result = driver->ops.start(device); @@ -545,15 +521,12 @@ static int acpi_start_single_object(stru driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); } - return_VALUE(result); + return result; } -static int acpi_driver_attach(struct acpi_driver *drv) +static void acpi_driver_attach(struct acpi_driver *drv) { struct list_head *node, *next; - int count = 0; - - ACPI_FUNCTION_TRACE("acpi_driver_attach"); spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_device_list) { @@ -568,7 +541,6 @@ static int acpi_driver_attach(struct acp if (!acpi_bus_driver_init(dev, drv)) { acpi_start_single_object(dev); atomic_inc(&drv->references); - count++; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", drv->name, dev->pnp.bus_id)); @@ -577,15 +549,12 @@ static int acpi_driver_attach(struct acp spin_lock(&acpi_device_lock); } spin_unlock(&acpi_device_lock); - return_VALUE(count); } -static int acpi_driver_detach(struct acpi_driver *drv) +static void acpi_driver_detach(struct acpi_driver *drv) { struct list_head *node, *next; - ACPI_FUNCTION_TRACE("acpi_driver_detach"); - spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_device_list) { struct acpi_device *dev = @@ -602,7 +571,6 @@ static int acpi_driver_detach(struct acp } } spin_unlock(&acpi_device_lock); - return_VALUE(0); } /** @@ -610,28 +578,20 @@ static int acpi_driver_detach(struct acp * @driver: driver being registered * * Registers a driver with the ACPI bus. Searches the namespace for all - * devices that match the driver's criteria and binds. Returns the - * number of devices that were claimed by the driver, or a negative - * error status for failure. + * devices that match the driver's criteria and binds. Returns zero for + * success or a negative error status for failure. */ int acpi_bus_register_driver(struct acpi_driver *driver) { - int count; - - ACPI_FUNCTION_TRACE("acpi_bus_register_driver"); - if (acpi_disabled) - return_VALUE(-ENODEV); - - if (!driver) - return_VALUE(-EINVAL); + return -ENODEV; spin_lock(&acpi_device_lock); list_add_tail(&driver->node, &acpi_bus_drivers); spin_unlock(&acpi_device_lock); - count = acpi_driver_attach(driver); + acpi_driver_attach(driver); - return_VALUE(count); + return 0; } EXPORT_SYMBOL(acpi_bus_register_driver); @@ -643,23 +603,16 @@ EXPORT_SYMBOL(acpi_bus_register_driver); * Unregisters a driver with the ACPI bus. Searches the namespace for all * devices that match the driver's criteria and unbinds. */ -int acpi_bus_unregister_driver(struct acpi_driver *driver) +void acpi_bus_unregister_driver(struct acpi_driver *driver) { - int error = 0; + acpi_driver_detach(driver); - ACPI_FUNCTION_TRACE("acpi_bus_unregister_driver"); - - if (driver) { - acpi_driver_detach(driver); - - if (!atomic_read(&driver->references)) { - spin_lock(&acpi_device_lock); - list_del_init(&driver->node); - spin_unlock(&acpi_device_lock); - } - } else - error = -EINVAL; - return_VALUE(error); + if (!atomic_read(&driver->references)) { + spin_lock(&acpi_device_lock); + list_del_init(&driver->node); + spin_unlock(&acpi_device_lock); + } + return; } EXPORT_SYMBOL(acpi_bus_unregister_driver); @@ -676,8 +629,6 @@ static int acpi_bus_find_driver(struct a int result = 0; struct list_head *node, *next; - ACPI_FUNCTION_TRACE("acpi_bus_find_driver"); - spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_bus_drivers) { struct acpi_driver *driver = @@ -696,7 +647,7 @@ static int acpi_bus_find_driver(struct a spin_unlock(&acpi_device_lock); Done: - return_VALUE(result); + return result; } /* -------------------------------------------------------------------------- @@ -708,8 +659,6 @@ static int acpi_bus_get_flags(struct acp acpi_status status = AE_OK; acpi_handle temp = NULL; - ACPI_FUNCTION_TRACE("acpi_bus_get_flags"); - /* Presence of _STA indicates 'dynamic_status' */ status = acpi_get_handle(device->handle, "_STA", &temp); if (ACPI_SUCCESS(status)) @@ -754,7 +703,7 @@ static int acpi_bus_get_flags(struct acp /* TBD: Peformance management */ - return_VALUE(0); + return 0; } static void acpi_device_get_busid(struct acpi_device *device, @@ -872,7 +821,7 @@ static void acpi_device_set_id(struct ac printk(KERN_ERR "Memory allocation error\n"); } - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); } static int acpi_device_set_context(struct acpi_device *device, int type) @@ -948,10 +897,8 @@ static int acpi_bus_remove(struct acpi_d int result = 0; struct acpi_driver *driver; - ACPI_FUNCTION_TRACE("acpi_bus_remove"); - if (!dev) - return_VALUE(-EINVAL); + return -EINVAL; driver = dev->driver; @@ -960,12 +907,12 @@ static int acpi_bus_remove(struct acpi_d if (driver->ops.stop) { result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT); if (result) - return_VALUE(result); + return result; } result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT); if (result) { - return_VALUE(result); + return result; } atomic_dec(&dev->driver->references); @@ -974,7 +921,7 @@ static int acpi_bus_remove(struct acpi_d } if (!rmdevice) - return_VALUE(0); + return 0; if (dev->flags.bus_address) { if ((dev->parent) && (dev->parent->ops.unbind)) @@ -983,7 +930,7 @@ static int acpi_bus_remove(struct acpi_d acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); - return_VALUE(0); + return 0; } static int @@ -993,15 +940,13 @@ acpi_add_single_object(struct acpi_devic int result = 0; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_add_single_object"); - if (!child) - return_VALUE(-EINVAL); + return -EINVAL; device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL); if (!device) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); - return_VALUE(-ENOMEM); + ACPI_ERROR((AE_INFO, "Memory allocation error")); + return -ENOMEM; } memset(device, 0, sizeof(struct acpi_device)); @@ -1126,7 +1071,7 @@ acpi_add_single_object(struct acpi_devic kfree(device); } - return_VALUE(result); + return result; } static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) @@ -1139,10 +1084,8 @@ static int acpi_bus_scan(struct acpi_dev acpi_object_type type = 0; u32 level = 1; - ACPI_FUNCTION_TRACE("acpi_bus_scan"); - if (!start) - return_VALUE(-EINVAL); + return -EINVAL; parent = start; phandle = start->handle; @@ -1239,7 +1182,7 @@ static int acpi_bus_scan(struct acpi_dev } } - return_VALUE(0); + return 0; } int @@ -1249,15 +1192,13 @@ acpi_bus_add(struct acpi_device **child, int result; struct acpi_bus_ops ops; - ACPI_FUNCTION_TRACE("acpi_bus_add"); - result = acpi_add_single_object(child, parent, handle, type); if (!result) { memset(&ops, 0, sizeof(ops)); ops.acpi_op_add = 1; result = acpi_bus_scan(*child, &ops); } - return_VALUE(result); + return result; } EXPORT_SYMBOL(acpi_bus_add); @@ -1267,10 +1208,8 @@ int acpi_bus_start(struct acpi_device *d int result; struct acpi_bus_ops ops; - ACPI_FUNCTION_TRACE("acpi_bus_start"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; result = acpi_start_single_object(device); if (!result) { @@ -1278,7 +1217,7 @@ int acpi_bus_start(struct acpi_device *d ops.acpi_op_start = 1; result = acpi_bus_scan(device, &ops); } - return_VALUE(result); + return result; } EXPORT_SYMBOL(acpi_bus_start); @@ -1344,10 +1283,8 @@ static int acpi_bus_scan_fixed(struct ac int result = 0; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed"); - if (!root) - return_VALUE(-ENODEV); + return -ENODEV; /* * Enumerate all fixed-feature devices. @@ -1368,21 +1305,119 @@ static int acpi_bus_scan_fixed(struct ac result = acpi_start_single_object(device); } - return_VALUE(result); + return result; } + +static inline struct acpi_device * to_acpi_dev(struct device * dev) +{ + return container_of(dev, struct acpi_device, dev); +} + + +static int root_suspend(struct acpi_device * acpi_dev, pm_message_t state) +{ + struct acpi_device * dev, * next; + int result; + + spin_lock(&acpi_device_lock); + list_for_each_entry_safe_reverse(dev, next, &acpi_device_list, g_list) { + if (dev->driver && dev->driver->ops.suspend) { + spin_unlock(&acpi_device_lock); + result = dev->driver->ops.suspend(dev, 0); + if (result) { + printk(KERN_ERR PREFIX "[%s - %s] Suspend failed: %d\n", + acpi_device_name(dev), + acpi_device_bid(dev), result); + } + spin_lock(&acpi_device_lock); + } + } + spin_unlock(&acpi_device_lock); + return 0; +} + + +static int acpi_device_suspend(struct device * dev, pm_message_t state) +{ + struct acpi_device * acpi_dev = to_acpi_dev(dev); + + /* + * For now, we should only register 1 generic device - + * the ACPI root device - and from there, we walk the + * tree of ACPI devices to suspend each one using the + * ACPI driver methods. + */ + if (acpi_dev->handle == ACPI_ROOT_OBJECT) + root_suspend(acpi_dev, state); + return 0; +} + + + +static int root_resume(struct acpi_device * acpi_dev) +{ + struct acpi_device * dev, * next; + int result; + + spin_lock(&acpi_device_lock); + list_for_each_entry_safe(dev, next, &acpi_device_list, g_list) { + if (dev->driver && dev->driver->ops.resume) { + spin_unlock(&acpi_device_lock); + result = dev->driver->ops.resume(dev, 0); + if (result) { + printk(KERN_ERR PREFIX "[%s - %s] resume failed: %d\n", + acpi_device_name(dev), + acpi_device_bid(dev), result); + } + spin_lock(&acpi_device_lock); + } + } + spin_unlock(&acpi_device_lock); + return 0; +} + + +static int acpi_device_resume(struct device * dev) +{ + struct acpi_device * acpi_dev = to_acpi_dev(dev); + + /* + * For now, we should only register 1 generic device - + * the ACPI root device - and from there, we walk the + * tree of ACPI devices to resume each one using the + * ACPI driver methods. + */ + if (acpi_dev->handle == ACPI_ROOT_OBJECT) + root_resume(acpi_dev); + return 0; +} + + +struct bus_type acpi_bus_type = { + .name = "acpi", + .suspend = acpi_device_suspend, + .resume = acpi_device_resume, +}; + + + static int __init acpi_scan_init(void) { int result; struct acpi_bus_ops ops; - ACPI_FUNCTION_TRACE("acpi_scan_init"); - if (acpi_disabled) - return_VALUE(0); + return 0; kset_register(&acpi_namespace_kset); + result = bus_register(&acpi_bus_type); + if (result) { + /* We don't want to quit even if we failed to add suspend/resume */ + printk(KERN_ERR PREFIX "Could not register bus type\n"); + } + /* * Create the root device in the bus's device tree */ @@ -1392,6 +1427,16 @@ static int __init acpi_scan_init(void) goto Done; result = acpi_start_single_object(acpi_root); + if (result) + goto Done; + + acpi_root->dev.bus = &acpi_bus_type; + snprintf(acpi_root->dev.bus_id, BUS_ID_SIZE, "%s", acpi_bus_type.name); + result = device_register(&acpi_root->dev); + if (result) { + /* We don't want to quit even if we failed to add suspend/resume */ + printk(KERN_ERR PREFIX "Could not register device\n"); + } /* * Enumerate devices in the ACPI namespace. @@ -1408,7 +1453,7 @@ static int __init acpi_scan_init(void) acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); Done: - return_VALUE(result); + return result; } subsys_initcall(acpi_scan_init); diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index 930427f..62ce87d 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c @@ -105,6 +105,14 @@ static int acpi_pm_enter(suspend_state_t default: return -EINVAL; } + + /* ACPI 3.0 specs (P62) says that it's the responsabilty + * of the OSPM to clear the status bit [ implying that the + * POWER_BUTTON event should not reach userspace ] + */ + if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) + acpi_clear_event(ACPI_EVENT_POWER_BUTTON); + local_irq_restore(flags); printk(KERN_DEBUG "Back to C!\n"); diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c index 85df0ce..af1dbab 100644 --- a/drivers/acpi/sleep/wakeup.c +++ b/drivers/acpi/sleep/wakeup.c @@ -155,7 +155,6 @@ static int __init acpi_wakeup_device_ini if (acpi_disabled) return 0; - printk("ACPI wakeup devices: \n"); spin_lock(&acpi_device_lock); list_for_each_safe(node, next, &acpi_wakeup_device_list) { @@ -174,10 +173,8 @@ static int __init acpi_wakeup_device_ini dev->wakeup.state.enabled = 1; spin_lock(&acpi_device_lock); } - printk("%4s ", dev->pnp.bus_id); } spin_unlock(&acpi_device_lock); - printk("\n"); return 0; } diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index e4308c7..d623fe8 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c @@ -47,10 +47,8 @@ extern FADT_DESCRIPTOR acpi_fadt; static int acpi_system_read_info(struct seq_file *seq, void *offset) { - ACPI_FUNCTION_TRACE("acpi_system_read_info"); - seq_printf(seq, "version: %x\n", ACPI_CA_VERSION); - return_VALUE(0); + return 0; } static int acpi_system_info_open_fs(struct inode *inode, struct file *file) @@ -80,17 +78,15 @@ acpi_system_read_dsdt(struct file *file, struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL }; ssize_t res; - ACPI_FUNCTION_TRACE("acpi_system_read_dsdt"); - status = acpi_get_table(ACPI_TABLE_DSDT, 1, &dsdt); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; res = simple_read_from_buffer(buffer, count, ppos, dsdt.pointer, dsdt.length); - acpi_os_free(dsdt.pointer); + kfree(dsdt.pointer); - return_VALUE(res); + return res; } static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, @@ -108,17 +104,15 @@ acpi_system_read_fadt(struct file *file, struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL }; ssize_t res; - ACPI_FUNCTION_TRACE("acpi_system_read_fadt"); - status = acpi_get_table(ACPI_TABLE_FADT, 1, &fadt); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; res = simple_read_from_buffer(buffer, count, ppos, fadt.pointer, fadt.length); - acpi_os_free(fadt.pointer); + kfree(fadt.pointer); - return_VALUE(res); + return res; } static int __init acpi_system_init(void) @@ -127,10 +121,8 @@ static int __init acpi_system_init(void) int error = 0; char *name; - ACPI_FUNCTION_TRACE("acpi_system_init"); - if (acpi_disabled) - return_VALUE(0); + return 0; /* 'info' [R] */ name = ACPI_SYSTEM_FILE_INFO; @@ -158,12 +150,9 @@ static int __init acpi_system_init(void) goto Error; Done: - return_VALUE(error); + return error; Error: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' proc fs entry\n", name)); - remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir); diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c index 03b37d2..5155b27 100644 --- a/drivers/acpi/tables/tbconvrt.c +++ b/drivers/acpi/tables/tbconvrt.c @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include @@ -64,7 +62,7 @@ acpi_tb_convert_fadt2(struct fadt_descri struct fadt_descriptor_rev2 *original_fadt); u8 acpi_fadt_is_v1; -EXPORT_SYMBOL(acpi_fadt_is_v1); +ACPI_EXPORT_SYMBOL(acpi_fadt_is_v1) /******************************************************************************* * @@ -133,7 +131,7 @@ acpi_status acpi_tb_convert_to_xsdt(stru /* Allocate an XSDT */ - new_table = ACPI_MEM_CALLOCATE(table_size); + new_table = ACPI_ALLOCATE_ZEROED(table_size); if (!new_table) { return (AE_NO_MEMORY); } @@ -147,6 +145,7 @@ acpi_status acpi_tb_convert_to_xsdt(stru /* Copy the table pointers */ for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { + /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { @@ -508,13 +507,14 @@ acpi_status acpi_tb_convert_table_fadt(v /* Allocate buffer for the ACPI 2.0(+) FADT */ - local_fadt = ACPI_MEM_CALLOCATE(sizeof(struct fadt_descriptor_rev2)); + local_fadt = ACPI_ALLOCATE_ZEROED(sizeof(struct fadt_descriptor_rev2)); if (!local_fadt) { return_ACPI_STATUS(AE_NO_MEMORY); } if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) { if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) { + /* Length is too short to be a V2.0 table */ ACPI_WARNING((AE_INFO, @@ -603,6 +603,7 @@ acpi_status acpi_tb_build_common_facs(st if ((acpi_gbl_RSDP->revision < 2) || (acpi_gbl_FACS->length < 32) || (!(acpi_gbl_FACS->xfirmware_waking_vector))) { + /* ACPI 1.0 FACS or short table or optional X_ field is zero */ acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64, diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c index 09b4ee6..b7bd20b 100644 --- a/drivers/acpi/tables/tbget.c +++ b/drivers/acpi/tables/tbget.c @@ -148,6 +148,10 @@ acpi_tb_get_table_header(struct acpi_poi sizeof(struct acpi_table_header), (void *)&header); if (ACPI_FAILURE(status)) { + ACPI_ERROR((AE_INFO, + "Could not map memory at %8.8X%8.8X for table header", + ACPI_FORMAT_UINT64(address->pointer. + physical))); return_ACPI_STATUS(status); } @@ -208,6 +212,7 @@ acpi_tb_get_table_body(struct acpi_point status = acpi_tb_table_override(header, table_info); if (ACPI_SUCCESS(status)) { + /* Table was overridden by the host OS */ return_ACPI_STATUS(status); @@ -250,6 +255,7 @@ acpi_tb_table_override(struct acpi_table */ status = acpi_os_table_override(header, &new_table); if (ACPI_FAILURE(status)) { + /* Some severe error from the OSL, but we basically ignore it */ ACPI_EXCEPTION((AE_INFO, status, @@ -258,6 +264,7 @@ acpi_tb_table_override(struct acpi_table } if (!new_table) { + /* No table override */ return_ACPI_STATUS(AE_NO_ACPI_TABLES); @@ -323,7 +330,7 @@ acpi_tb_get_this_table(struct acpi_point /* Pointer matches processor mode, copy the table to a new buffer */ - full_table = ACPI_MEM_ALLOCATE(header->length); + full_table = ACPI_ALLOCATE(header->length); if (!full_table) { ACPI_ERROR((AE_INFO, "Could not allocate table memory for [%4.4s] length %X", @@ -381,6 +388,7 @@ acpi_tb_get_this_table(struct acpi_point #if (!ACPI_CHECKSUM_ABORT) if (ACPI_FAILURE(status)) { + /* Ignore the error if configuration says so */ status = AE_OK; @@ -440,6 +448,7 @@ acpi_tb_get_table_ptr(acpi_table_type ta * instance is always in the list head. */ if (instance == 1) { + /* Get the first */ *table_ptr_loc = NULL; diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c index 134e5dc..b4ec61d 100644 --- a/drivers/acpi/tables/tbgetall.c +++ b/drivers/acpi/tables/tbgetall.c @@ -223,6 +223,7 @@ acpi_status acpi_tb_get_required_tables( * any SSDTs. */ for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { + /* Get the table address from the common internal XSDT */ address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i]; diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index 7ffd0fd..ce57a19 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c @@ -84,6 +84,7 @@ acpi_tb_match_signature(char *signature, if (!ACPI_STRNCMP(signature, acpi_gbl_table_data[i].signature, acpi_gbl_table_data[i].sig_length)) { + /* Found a signature match, return index if requested */ if (table_info) { @@ -247,7 +248,7 @@ acpi_tb_init_table_descriptor(acpi_table /* Allocate a descriptor for this table */ - table_desc = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc)); + table_desc = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_table_desc)); if (!table_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -274,7 +275,7 @@ acpi_tb_init_table_descriptor(acpi_table * at this location, so return an error. */ if (list_head->next) { - ACPI_MEM_FREE(table_desc); + ACPI_FREE(table_desc); return_ACPI_STATUS(AE_ALREADY_EXISTS); } @@ -471,7 +472,7 @@ void acpi_tb_delete_single_table(struct case ACPI_MEM_ALLOCATED: - ACPI_MEM_FREE(table_desc->pointer); + ACPI_FREE(table_desc->pointer); break; case ACPI_MEM_MAPPED: @@ -530,7 +531,7 @@ struct acpi_table_desc *acpi_tb_uninstal /* Free the table descriptor */ next_desc = table_desc->next; - ACPI_MEM_FREE(table_desc); + ACPI_FREE(table_desc); /* Return pointer to the next descriptor */ diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c index 4d30822..946d2f2 100644 --- a/drivers/acpi/tables/tbrsdt.c +++ b/drivers/acpi/tables/tbrsdt.c @@ -190,6 +190,7 @@ acpi_status acpi_tb_validate_rsdt(struct } if (no_match) { + /* Invalid RSDT or XSDT signature */ ACPI_ERROR((AE_INFO, diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index bc57159..b463d4b 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -96,6 +96,7 @@ acpi_status acpi_tb_is_table_installed(s (!ACPI_MEMCMP (table_desc->pointer, new_table_desc->pointer, new_table_desc->pointer->length))) { + /* Match: this table is already installed */ ACPI_DEBUG_PRINT((ACPI_DB_TABLES, @@ -249,6 +250,7 @@ u8 acpi_tb_generate_checksum(void *buffe u8 sum = 0; if (buffer && length) { + /* Buffer and Length are valid */ end_buffer = ACPI_ADD_PTR(u8, buffer, length); diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index 9fe53c9..53c627e 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c @@ -42,8 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include #include @@ -123,6 +121,8 @@ acpi_status acpi_load_tables(void) return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_load_tables) + #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -139,7 +139,6 @@ #ifdef ACPI_FUTURE_USAGE * is determined that the table is invalid, the call will fail. * ******************************************************************************/ - acpi_status acpi_load_table(struct acpi_table_header *table_ptr) { acpi_status status; @@ -174,6 +173,7 @@ acpi_status acpi_load_table(struct acpi_ status = acpi_tb_install_table(&table_info); if (ACPI_FAILURE(status)) { if (status == AE_ALREADY_EXISTS) { + /* Table already exists, no error */ status = AE_OK; @@ -208,6 +208,7 @@ acpi_status acpi_load_table(struct acpi_ } if (ACPI_FAILURE(status)) { + /* Uninstall table and free the buffer */ (void)acpi_tb_uninstall_table(table_info.installed_desc); @@ -216,6 +217,8 @@ acpi_status acpi_load_table(struct acpi_ return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_load_table) + /******************************************************************************* * * FUNCTION: acpi_unload_table @@ -227,7 +230,6 @@ acpi_status acpi_load_table(struct acpi_ * DESCRIPTION: This routine is used to force the unload of a table * ******************************************************************************/ - acpi_status acpi_unload_table(acpi_table_type table_type) { struct acpi_table_desc *table_desc; @@ -261,6 +263,8 @@ acpi_status acpi_unload_table(acpi_table return_ACPI_STATUS(AE_OK); } +ACPI_EXPORT_SYMBOL(acpi_unload_table) + /******************************************************************************* * * FUNCTION: acpi_get_table_header @@ -281,7 +285,6 @@ acpi_status acpi_unload_table(acpi_table * have a standard header and is fixed length. * ******************************************************************************/ - acpi_status acpi_get_table_header(acpi_table_type table_type, u32 instance, struct acpi_table_header *out_table_header) @@ -325,6 +328,7 @@ acpi_get_table_header(acpi_table_type ta return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_get_table_header) #endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* @@ -349,7 +353,6 @@ #endif /* ACPI_FUTURE_USAGE */ * a complete table including the header. * ******************************************************************************/ - acpi_status acpi_get_table(acpi_table_type table_type, u32 instance, struct acpi_buffer *ret_buffer) @@ -397,6 +400,7 @@ acpi_get_table(acpi_table_type table_typ /* Get the table length */ if (table_type == ACPI_TABLE_RSDP) { + /* RSD PTR is the only "table" without a header */ table_length = sizeof(struct rsdp_descriptor); @@ -417,4 +421,4 @@ acpi_get_table(acpi_table_type table_typ return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_get_table); +ACPI_EXPORT_SYMBOL(acpi_get_table) diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index a62db6a..1b6d8c5 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include @@ -75,6 +73,7 @@ acpi_status acpi_tb_validate_rsdp(struct * The signature and checksum must both be correct */ if (ACPI_STRNCMP((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) { + /* Nope, BAD Signature */ return (AE_BAD_SIGNATURE); @@ -217,6 +216,7 @@ acpi_get_firmware_table(acpi_string sign /* Ensure that we have a RSDP */ if (!acpi_gbl_RSDP) { + /* Get the RSDP */ status = acpi_os_get_root_pointer(flags, &address); @@ -261,7 +261,7 @@ acpi_get_firmware_table(acpi_string sign /* Get and validate the RSDT */ - rsdt_info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_table_desc)); + rsdt_info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_table_desc)); if (!rsdt_info) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -278,13 +278,13 @@ acpi_get_firmware_table(acpi_string sign /* Allocate a scratch table header and table descriptor */ - header = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_header)); + header = ACPI_ALLOCATE(sizeof(struct acpi_table_header)); if (!header) { status = AE_NO_MEMORY; goto cleanup; } - table_info = ACPI_MEM_ALLOCATE(sizeof(struct acpi_table_desc)); + table_info = ACPI_ALLOCATE(sizeof(struct acpi_table_desc)); if (!table_info) { status = AE_NO_MEMORY; goto cleanup; @@ -327,10 +327,12 @@ acpi_get_firmware_table(acpi_string sign /* Compare table signatures and table instance */ if (!ACPI_STRNCMP(header->signature, signature, ACPI_NAME_SIZE)) { + /* An instance of the table was found */ j++; if (j >= instance) { + /* Found the correct instance, get the entire table */ status = @@ -355,23 +357,21 @@ acpi_get_firmware_table(acpi_string sign acpi_os_unmap_memory(rsdt_info->pointer, (acpi_size) rsdt_info->pointer->length); } - ACPI_MEM_FREE(rsdt_info); + ACPI_FREE(rsdt_info); if (header) { - ACPI_MEM_FREE(header); + ACPI_FREE(header); } if (table_info) { - ACPI_MEM_FREE(table_info); + ACPI_FREE(table_info); } return_ACPI_STATUS(status); } -EXPORT_SYMBOL(acpi_get_firmware_table); +ACPI_EXPORT_SYMBOL(acpi_get_firmware_table) /* TBD: Move to a new file */ - #if ACPI_MACHINE_WIDTH != 16 - /******************************************************************************* * * FUNCTION: acpi_find_root_pointer @@ -384,7 +384,6 @@ #if ACPI_MACHINE_WIDTH != 16 * DESCRIPTION: Find the RSDP * ******************************************************************************/ - acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address) { struct acpi_table_desc table_info; @@ -407,6 +406,8 @@ acpi_status acpi_find_root_pointer(u32 f return_ACPI_STATUS(AE_OK); } +ACPI_EXPORT_SYMBOL(acpi_find_root_pointer) + /******************************************************************************* * * FUNCTION: acpi_tb_scan_memory_for_rsdp @@ -419,7 +420,6 @@ acpi_status acpi_find_root_pointer(u32 f * DESCRIPTION: Search a block of memory for the RSDP signature * ******************************************************************************/ - static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length) { acpi_status status; @@ -434,12 +434,14 @@ static u8 *acpi_tb_scan_memory_for_rsdp( for (mem_rover = start_address; mem_rover < end_address; mem_rover += ACPI_RSDP_SCAN_STEP) { + /* The RSDP signature and checksum must both be correct */ status = acpi_tb_validate_rsdp(ACPI_CAST_PTR (struct rsdp_descriptor, mem_rover)); if (ACPI_SUCCESS(status)) { + /* Sig and checksum valid, we have found a real RSDP */ ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -495,6 +497,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc * Scan supports either logical addressing or physical addressing */ if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { + /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ status = acpi_os_map_memory((acpi_physical_address) @@ -542,6 +545,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE); if (mem_rover) { + /* Return the physical address */ physical_address += @@ -576,6 +580,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); if (mem_rover) { + /* Return the physical address */ physical_address = @@ -609,6 +614,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc (physical_address), ACPI_EBDA_WINDOW_SIZE); if (mem_rover) { + /* Return the physical address */ table_info->physical_address = @@ -624,6 +630,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc (ACPI_HI_RSDP_WINDOW_BASE), ACPI_HI_RSDP_WINDOW_SIZE); if (mem_rover) { + /* Found it, return the physical address */ table_info->physical_address = diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 19f3ea4..ed8cc11 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -82,6 +82,7 @@ MODULE_PARM_DESC(tzp, "Thermal zone poll static int acpi_thermal_add(struct acpi_device *device); static int acpi_thermal_remove(struct acpi_device *device, int type); +static int acpi_thermal_resume(struct acpi_device *device, int state); static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); @@ -103,6 +104,7 @@ static struct acpi_driver acpi_thermal_d .ops = { .add = acpi_thermal_add, .remove = acpi_thermal_remove, + .resume = acpi_thermal_resume, }, }; @@ -220,51 +222,45 @@ static int acpi_thermal_get_temperature( { acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature"); - if (!tz) - return_VALUE(-EINVAL); + return -EINVAL; tz->last_temperature = tz->temperature; status = acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", tz->temperature)); - return_VALUE(0); + return 0; } static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) { acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency"); - if (!tz) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_evaluate_integer(tz->handle, "_TZP", NULL, &tz->polling_frequency); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", tz->polling_frequency)); - return_VALUE(0); + return 0; } static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) { - ACPI_FUNCTION_TRACE("acpi_thermal_set_polling"); - if (!tz) - return_VALUE(-EINVAL); + return -EINVAL; tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ @@ -272,7 +268,7 @@ static int acpi_thermal_set_polling(stru "Polling frequency set to %lu seconds\n", tz->polling_frequency)); - return_VALUE(0); + return 0; } static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) @@ -282,29 +278,27 @@ static int acpi_thermal_set_cooling_mode struct acpi_object_list arg_list = { 1, &arg0 }; acpi_handle handle = NULL; - ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode"); - if (!tz) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_get_handle(tz->handle, "_SCP", &handle); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); - return_VALUE(-ENODEV); + return -ENODEV; } arg0.integer.value = mode; status = acpi_evaluate_object(handle, NULL, &arg_list, NULL); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; tz->cooling_mode = mode; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", mode ? "passive" : "active")); - return_VALUE(0); + return 0; } static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) @@ -312,10 +306,8 @@ static int acpi_thermal_get_trip_points( acpi_status status = AE_OK; int i = 0; - ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points"); - if (!tz) - return_VALUE(-EINVAL); + return -EINVAL; /* Critical Shutdown (required) */ @@ -323,8 +315,8 @@ static int acpi_thermal_get_trip_points( &tz->trips.critical.temperature); if (ACPI_FAILURE(status)) { tz->trips.critical.flags.valid = 0; - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n")); - return_VALUE(-ENODEV); + ACPI_EXCEPTION((AE_INFO, status, "No critical threshold")); + return -ENODEV; } else { tz->trips.critical.flags.valid = 1; ACPI_DEBUG_PRINT((ACPI_DB_INFO, @@ -382,8 +374,7 @@ static int acpi_thermal_get_trip_points( tz->trips.passive.flags.valid = 0; if (!tz->trips.passive.flags.valid) - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Invalid passive threshold\n")); + ACPI_WARNING((AE_INFO, "Invalid passive threshold")); else ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found passive threshold [%lu]\n", @@ -412,29 +403,26 @@ static int acpi_thermal_get_trip_points( "Found active threshold [%d]:[%lu]\n", i, tz->trips.active[i].temperature)); } else - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid active threshold [%d]\n", - i)); + ACPI_EXCEPTION((AE_INFO, status, + "Invalid active threshold [%d]", i)); } - return_VALUE(0); + return 0; } static int acpi_thermal_get_devices(struct acpi_thermal *tz) { acpi_status status = AE_OK; - ACPI_FUNCTION_TRACE("acpi_thermal_get_devices"); - if (!tz) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; - return_VALUE(0); + return 0; } static int acpi_thermal_call_usermode(char *path) @@ -442,10 +430,8 @@ static int acpi_thermal_call_usermode(ch char *argv[2] = { NULL, NULL }; char *envp[3] = { NULL, NULL, NULL }; - ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode"); - if (!path) - return_VALUE(-EINVAL); + return -EINVAL; argv[0] = path; @@ -455,7 +441,7 @@ static int acpi_thermal_call_usermode(ch call_usermodehelper(argv[0], argv, envp, 0); - return_VALUE(0); + return 0; } static int acpi_thermal_critical(struct acpi_thermal *tz) @@ -463,20 +449,18 @@ static int acpi_thermal_critical(struct int result = 0; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_thermal_critical"); - if (!tz || !tz->trips.critical.flags.valid) - return_VALUE(-EINVAL); + return -EINVAL; if (tz->temperature >= tz->trips.critical.temperature) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n")); + ACPI_WARNING((AE_INFO, "Critical trip point")); tz->trips.critical.flags.enabled = 1; } else if (tz->trips.critical.flags.enabled) tz->trips.critical.flags.enabled = 0; result = acpi_bus_get_device(tz->handle, &device); if (result) - return_VALUE(result); + return result; printk(KERN_EMERG "Critical temperature reached (%ld C), shutting down.\n", @@ -486,7 +470,7 @@ static int acpi_thermal_critical(struct acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); - return_VALUE(0); + return 0; } static int acpi_thermal_hot(struct acpi_thermal *tz) @@ -494,27 +478,25 @@ static int acpi_thermal_hot(struct acpi_ int result = 0; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_thermal_hot"); - if (!tz || !tz->trips.hot.flags.valid) - return_VALUE(-EINVAL); + return -EINVAL; if (tz->temperature >= tz->trips.hot.temperature) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n")); + ACPI_WARNING((AE_INFO, "Hot trip point")); tz->trips.hot.flags.enabled = 1; } else if (tz->trips.hot.flags.enabled) tz->trips.hot.flags.enabled = 0; result = acpi_bus_get_device(tz->handle, &device); if (result) - return_VALUE(result); + return result; acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); /* TBD: Call user-mode "sleep(S4)" function */ - return_VALUE(0); + return 0; } static void acpi_thermal_passive(struct acpi_thermal *tz) @@ -524,8 +506,6 @@ static void acpi_thermal_passive(struct int trend = 0; int i = 0; - ACPI_FUNCTION_TRACE("acpi_thermal_passive"); - if (!tz || !tz->trips.passive.flags.valid) return; @@ -613,8 +593,6 @@ static void acpi_thermal_active(struct a int j = 0; unsigned long maxtemp = 0; - ACPI_FUNCTION_TRACE("acpi_thermal_active"); - if (!tz) return; @@ -640,10 +618,10 @@ static void acpi_thermal_active(struct a handles[j], ACPI_STATE_D0); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Unable to turn cooling device [%p] 'on'\n", - active->devices. - handles[j])); + ACPI_WARNING((AE_INFO, + "Unable to turn cooling device [%p] 'on'", + active->devices. + handles[j])); continue; } active->flags.enabled = 1; @@ -665,9 +643,9 @@ static void acpi_thermal_active(struct a result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3); if (result) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Unable to turn cooling device [%p] 'off'\n", - active->devices.handles[j])); + ACPI_WARNING((AE_INFO, + "Unable to turn cooling device [%p] 'off'", + active->devices.handles[j])); continue; } active->flags.enabled = 0; @@ -684,8 +662,7 @@ static void acpi_thermal_run(unsigned lo { struct acpi_thermal *tz = (struct acpi_thermal *)data; if (!tz->zombie) - acpi_os_queue_for_execution(OSD_PRIORITY_GPE, - acpi_thermal_check, (void *)data); + acpi_os_execute(OSL_GPE_HANDLER, acpi_thermal_check, (void *)data); } static void acpi_thermal_check(void *data) @@ -696,18 +673,16 @@ static void acpi_thermal_check(void *dat int i = 0; struct acpi_thermal_state state; - ACPI_FUNCTION_TRACE("acpi_thermal_check"); - if (!tz) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); - return_VOID; + ACPI_ERROR((AE_INFO, "Invalid (NULL) context")); + return; } state = tz->state; result = acpi_thermal_get_temperature(tz); if (result) - return_VOID; + return; memset(&tz->state, 0, sizeof(tz->state)); @@ -796,7 +771,6 @@ static void acpi_thermal_check(void *dat } } - return_VOID; } /* -------------------------------------------------------------------------- @@ -809,8 +783,6 @@ static int acpi_thermal_state_seq_show(s { struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; - ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show"); - if (!tz) goto end; @@ -832,7 +804,7 @@ static int acpi_thermal_state_seq_show(s } end: - return_VALUE(0); + return 0; } static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file) @@ -845,8 +817,6 @@ static int acpi_thermal_temp_seq_show(st int result = 0; struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; - ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show"); - if (!tz) goto end; @@ -858,7 +828,7 @@ static int acpi_thermal_temp_seq_show(st KELVIN_TO_CELSIUS(tz->temperature)); end: - return_VALUE(0); + return 0; } static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file) @@ -872,8 +842,6 @@ static int acpi_thermal_trip_seq_show(st int i = 0; int j = 0; - ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show"); - if (!tz) goto end; @@ -912,7 +880,7 @@ static int acpi_thermal_trip_seq_show(st } end: - return_VALUE(0); + return 0; } static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file) @@ -933,26 +901,24 @@ acpi_thermal_write_trip_points(struct fi int *active; int i = 0; - ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points"); - limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); if (!limit_string) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN); active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); - if (!active) - return_VALUE(-ENOMEM); + if (!active) { + kfree(limit_string); + return -ENOMEM; + } if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n")); count = -EINVAL; goto end; } if (copy_from_user(limit_string, buffer, count)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); count = -EFAULT; goto end; } @@ -965,7 +931,6 @@ acpi_thermal_write_trip_points(struct fi &active[5], &active[6], &active[7], &active[8], &active[9]); if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); count = -EINVAL; goto end; } @@ -982,15 +947,13 @@ acpi_thermal_write_trip_points(struct fi end: kfree(active); kfree(limit_string); - return_VALUE(count); + return count; } static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) { struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; - ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show"); - if (!tz) goto end; @@ -1005,7 +968,7 @@ static int acpi_thermal_cooling_seq_show tz->cooling_mode ? "passive" : "active"); end: - return_VALUE(0); + return 0; } static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file) @@ -1024,16 +987,14 @@ acpi_thermal_write_cooling_mode(struct f int result = 0; char mode_string[12] = { '\0' }; - ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode"); - if (!tz || (count > sizeof(mode_string) - 1)) - return_VALUE(-EINVAL); + return -EINVAL; if (!tz->flags.cooling_mode) - return_VALUE(-ENODEV); + return -ENODEV; if (copy_from_user(mode_string, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; mode_string[count] = '\0'; @@ -1041,19 +1002,17 @@ acpi_thermal_write_cooling_mode(struct f simple_strtoul(mode_string, NULL, 0)); if (result) - return_VALUE(result); + return result; acpi_thermal_check(tz); - return_VALUE(count); + return count; } static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) { struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; - ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show"); - if (!tz) goto end; @@ -1066,7 +1025,7 @@ static int acpi_thermal_polling_seq_show (tz->polling_frequency / 10)); end: - return_VALUE(0); + return 0; } static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file) @@ -1086,13 +1045,11 @@ acpi_thermal_write_polling(struct file * char polling_string[12] = { '\0' }; int seconds = 0; - ACPI_FUNCTION_TRACE("acpi_thermal_write_polling"); - if (!tz || (count > sizeof(polling_string) - 1)) - return_VALUE(-EINVAL); + return -EINVAL; if (copy_from_user(polling_string, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; polling_string[count] = '\0'; @@ -1100,24 +1057,22 @@ acpi_thermal_write_polling(struct file * result = acpi_thermal_set_polling(tz, seconds); if (result) - return_VALUE(result); + return result; acpi_thermal_check(tz); - return_VALUE(count); + return count; } static int acpi_thermal_add_fs(struct acpi_device *device) { struct proc_dir_entry *entry = NULL; - ACPI_FUNCTION_TRACE("acpi_thermal_add_fs"); - if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_thermal_dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; acpi_device_dir(device)->owner = THIS_MODULE; } @@ -1125,9 +1080,7 @@ static int acpi_thermal_add_fs(struct ac entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_STATE)); + return -ENODEV; else { entry->proc_fops = &acpi_thermal_state_fops; entry->data = acpi_driver_data(device); @@ -1138,9 +1091,7 @@ static int acpi_thermal_add_fs(struct ac entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_TEMPERATURE)); + return -ENODEV; else { entry->proc_fops = &acpi_thermal_temp_fops; entry->data = acpi_driver_data(device); @@ -1152,9 +1103,7 @@ static int acpi_thermal_add_fs(struct ac S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_TRIP_POINTS)); + return -ENODEV; else { entry->proc_fops = &acpi_thermal_trip_fops; entry->data = acpi_driver_data(device); @@ -1166,9 +1115,7 @@ static int acpi_thermal_add_fs(struct ac S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_COOLING_MODE)); + return -ENODEV; else { entry->proc_fops = &acpi_thermal_cooling_fops; entry->data = acpi_driver_data(device); @@ -1180,22 +1127,18 @@ static int acpi_thermal_add_fs(struct ac S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create '%s' fs entry\n", - ACPI_THERMAL_FILE_POLLING_FREQ)); + return -ENODEV; else { entry->proc_fops = &acpi_thermal_polling_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return_VALUE(0); + return 0; } static int acpi_thermal_remove_fs(struct acpi_device *device) { - ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs"); - if (acpi_device_dir(device)) { remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, acpi_device_dir(device)); @@ -1211,7 +1154,7 @@ static int acpi_thermal_remove_fs(struct acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -1223,13 +1166,11 @@ static void acpi_thermal_notify(acpi_han struct acpi_thermal *tz = (struct acpi_thermal *)data; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_thermal_notify"); - if (!tz) - return_VOID; + return; if (acpi_bus_get_device(tz->handle, &device)) - return_VOID; + return; switch (event) { case ACPI_THERMAL_NOTIFY_TEMPERATURE: @@ -1251,27 +1192,24 @@ static void acpi_thermal_notify(acpi_han break; } - return_VOID; } static int acpi_thermal_get_info(struct acpi_thermal *tz) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_thermal_get_info"); - if (!tz) - return_VALUE(-EINVAL); + return -EINVAL; /* Get temperature [_TMP] (required) */ result = acpi_thermal_get_temperature(tz); if (result) - return_VALUE(result); + return result; /* Get trip points [_CRT, _PSV, etc.] (required) */ result = acpi_thermal_get_trip_points(tz); if (result) - return_VALUE(result); + return result; /* Set the cooling mode [_SCP] to active cooling (default) */ result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); @@ -1311,7 +1249,7 @@ static int acpi_thermal_get_info(struct if (!result) tz->flags.devices = 1; - return_VALUE(0); + return 0; } static int acpi_thermal_add(struct acpi_device *device) @@ -1320,14 +1258,12 @@ static int acpi_thermal_add(struct acpi_ acpi_status status = AE_OK; struct acpi_thermal *tz = NULL; - ACPI_FUNCTION_TRACE("acpi_thermal_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL); if (!tz) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(tz, 0, sizeof(struct acpi_thermal)); tz->handle = device->handle; @@ -1342,7 +1278,7 @@ static int acpi_thermal_add(struct acpi_ result = acpi_thermal_add_fs(device); if (result) - return_VALUE(result); + goto end; init_timer(&tz->timer); @@ -1352,8 +1288,6 @@ static int acpi_thermal_add(struct acpi_ ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error installing notify handler\n")); result = -ENODEV; goto end; } @@ -1368,7 +1302,7 @@ static int acpi_thermal_add(struct acpi_ kfree(tz); } - return_VALUE(result); + return result; } static int acpi_thermal_remove(struct acpi_device *device, int type) @@ -1376,10 +1310,8 @@ static int acpi_thermal_remove(struct ac acpi_status status = AE_OK; struct acpi_thermal *tz = NULL; - ACPI_FUNCTION_TRACE("acpi_thermal_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; tz = (struct acpi_thermal *)acpi_driver_data(device); @@ -1395,9 +1327,6 @@ static int acpi_thermal_remove(struct ac status = acpi_remove_notify_handler(tz->handle, ACPI_DEVICE_NOTIFY, acpi_thermal_notify); - if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); /* Terminate policy */ if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) { @@ -1413,38 +1342,47 @@ static int acpi_thermal_remove(struct ac acpi_thermal_remove_fs(device); kfree(tz); - return_VALUE(0); + return 0; +} + +static int acpi_thermal_resume(struct acpi_device *device, int state) +{ + struct acpi_thermal *tz = NULL; + + if (!device || !acpi_driver_data(device)) + return_VALUE(-EINVAL); + + tz = (struct acpi_thermal *)acpi_driver_data(device); + + acpi_thermal_check(tz); + + return AE_OK; } static int __init acpi_thermal_init(void) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_thermal_init"); - acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); if (!acpi_thermal_dir) - return_VALUE(-ENODEV); + return -ENODEV; acpi_thermal_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_thermal_driver); if (result < 0) { remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } static void __exit acpi_thermal_exit(void) { - ACPI_FUNCTION_TRACE("acpi_thermal_exit"); - acpi_bus_unregister_driver(&acpi_thermal_driver); remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); - return_VOID; } module_init(acpi_thermal_init); diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 03b0044..41d7617 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -238,7 +238,7 @@ acpi_ut_initialize_buffer(struct acpi_bu /* Allocate a new buffer */ - buffer->pointer = acpi_os_allocate(required_length); + buffer->pointer = ACPI_ALLOCATE(required_length); if (!buffer->pointer) { return (AE_NO_MEMORY); } @@ -252,7 +252,7 @@ acpi_ut_initialize_buffer(struct acpi_bu /* Allocate a new buffer with local interface to allow tracking */ - buffer->pointer = ACPI_MEM_CALLOCATE(required_length); + buffer->pointer = ACPI_ALLOCATE_ZEROED(required_length); if (!buffer->pointer) { return (AE_NO_MEMORY); } @@ -277,6 +277,7 @@ acpi_ut_initialize_buffer(struct acpi_bu return (status); } +#ifdef UNUSED /******************************************************************************* * * FUNCTION: acpi_ut_allocate @@ -306,8 +307,9 @@ void *acpi_ut_allocate(acpi_size size, u size = 1; } - allocation = acpi_os_allocate(size); + allocation = ACPI_ALLOCATE(size); if (!allocation) { + /* Report allocation error */ ACPI_ERROR((module, line, @@ -349,8 +351,9 @@ void *acpi_ut_callocate(acpi_size size, size = 1; } - allocation = acpi_os_allocate(size); + allocation = ACPI_ALLOCATE(size); if (!allocation) { + /* Report allocation error */ ACPI_ERROR((module, line, @@ -396,7 +399,7 @@ acpi_ut_create_list(char *list_name, { struct acpi_memory_list *cache; - cache = acpi_os_allocate(sizeof(struct acpi_memory_list)); + cache = ACPI_ALLOCATE(sizeof(struct acpi_memory_list)); if (!cache) { return (AE_NO_MEMORY); } @@ -442,7 +445,7 @@ void *acpi_ut_allocate_and_track(acpi_si ACPI_MEM_MALLOC, component, module, line); if (ACPI_FAILURE(status)) { - acpi_os_free(allocation); + kfree(allocation); return (NULL); } @@ -477,6 +480,7 @@ void *acpi_ut_callocate_and_track(acpi_s acpi_ut_callocate(size + sizeof(struct acpi_debug_mem_header), component, module, line); if (!allocation) { + /* Report allocation error */ ACPI_ERROR((module, line, @@ -488,7 +492,7 @@ void *acpi_ut_callocate_and_track(acpi_s ACPI_MEM_CALLOC, component, module, line); if (ACPI_FAILURE(status)) { - acpi_os_free(allocation); + kfree(allocation); return (NULL); } @@ -540,7 +544,7 @@ acpi_ut_free_and_track(void *allocation, ACPI_EXCEPTION((AE_INFO, status, "Could not free memory")); } - acpi_os_free(debug_block); + kfree(debug_block); ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); return_VOID; } @@ -681,6 +685,7 @@ acpi_ut_remove_allocation(struct acpi_de mem_list = acpi_gbl_global_list; if (NULL == mem_list->list_head) { + /* No allocations! */ ACPI_ERROR((module, line, @@ -729,7 +734,6 @@ acpi_ut_remove_allocation(struct acpi_de * ******************************************************************************/ -#ifdef ACPI_FUTURE_USAGE void acpi_ut_dump_allocation_info(void) { /* @@ -772,7 +776,6 @@ void acpi_ut_dump_allocation_info(void) */ return_VOID; } -#endif /* ACPI_FUTURE_USAGE */ /******************************************************************************* * @@ -807,6 +810,7 @@ void acpi_ut_dump_allocations(u32 compon if ((element->component & component) && ((module == NULL) || (0 == ACPI_STRCMP(module, element->module)))) { + /* Ignore allocated objects that are in a cache */ descriptor = @@ -870,3 +874,4 @@ void acpi_ut_dump_allocations(u32 compon } #endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ +#endif /* UNUSED */ diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c index 2177cb1..b522df1 100644 --- a/drivers/acpi/utilities/utcache.c +++ b/drivers/acpi/utilities/utcache.c @@ -76,7 +76,7 @@ acpi_os_create_cache(char *cache_name, /* Create the cache object */ - cache = acpi_os_allocate(sizeof(struct acpi_memory_list)); + cache = ACPI_ALLOCATE(sizeof(struct acpi_memory_list)); if (!cache) { return (AE_NO_MEMORY); } @@ -118,13 +118,14 @@ acpi_status acpi_os_purge_cache(struct a /* Walk the list of objects in this cache */ while (cache->list_head) { + /* Delete and unlink one cached state object */ next = *(ACPI_CAST_INDIRECT_PTR(char, &(((char *)cache-> list_head)[cache-> link_offset]))); - ACPI_MEM_FREE(cache->list_head); + ACPI_FREE(cache->list_head); cache->list_head = next; cache->current_depth--; @@ -161,7 +162,7 @@ acpi_status acpi_os_delete_cache(struct /* Now we can delete the cache object */ - acpi_os_free(cache); + kfree(cache); return (AE_OK); } @@ -193,7 +194,7 @@ acpi_os_release_object(struct acpi_memor /* If cache is full, just free this object */ if (cache->current_depth >= cache->max_depth) { - ACPI_MEM_FREE(object); + ACPI_FREE(object); ACPI_MEM_TRACKING(cache->total_freed++); } @@ -259,6 +260,7 @@ void *acpi_os_acquire_object(struct acpi /* Check the cache first */ if (cache->list_head) { + /* There is an object available, use it */ object = cache->list_head; @@ -287,14 +289,14 @@ void *acpi_os_acquire_object(struct acpi ACPI_MEM_TRACKING(cache->total_allocated++); - /* Avoid deadlock with ACPI_MEM_CALLOCATE */ + /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ status = acpi_ut_release_mutex(ACPI_MTX_CACHES); if (ACPI_FAILURE(status)) { return (NULL); } - object = ACPI_MEM_CALLOCATE(cache->object_size); + object = ACPI_ALLOCATE_ZEROED(cache->object_size); if (!object) { return (NULL); } diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index df2d320..371cddc 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c @@ -472,8 +472,8 @@ acpi_ut_copy_esimple_to_isimple(union ac case ACPI_TYPE_STRING: internal_object->string.pointer = - ACPI_MEM_CALLOCATE((acpi_size) external_object->string. - length + 1); + ACPI_ALLOCATE_ZEROED((acpi_size) external_object->string. + length + 1); if (!internal_object->string.pointer) { goto error_exit; } @@ -488,7 +488,7 @@ acpi_ut_copy_esimple_to_isimple(union ac case ACPI_TYPE_BUFFER: internal_object->buffer.pointer = - ACPI_MEM_CALLOCATE(external_object->buffer.length); + ACPI_ALLOCATE_ZEROED(external_object->buffer.length); if (!internal_object->buffer.pointer) { goto error_exit; } @@ -676,7 +676,7 @@ acpi_ut_copy_simple_object(union acpi_op if ((source_desc->buffer.pointer) && (source_desc->buffer.length)) { dest_desc->buffer.pointer = - ACPI_MEM_ALLOCATE(source_desc->buffer.length); + ACPI_ALLOCATE(source_desc->buffer.length); if (!dest_desc->buffer.pointer) { return (AE_NO_MEMORY); } @@ -697,8 +697,8 @@ acpi_ut_copy_simple_object(union acpi_op */ if (source_desc->string.pointer) { dest_desc->string.pointer = - ACPI_MEM_ALLOCATE((acpi_size) source_desc->string. - length + 1); + ACPI_ALLOCATE((acpi_size) source_desc->string. + length + 1); if (!dest_desc->string.pointer) { return (AE_NO_MEMORY); } @@ -805,9 +805,7 @@ acpi_ut_copy_ielement_to_ielement(u8 obj /* * Create the object array */ - target_object->package.elements = - ACPI_MEM_CALLOCATE(((acpi_size) source_object->package. - count + 1) * sizeof(void *)); + target_object->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) source_object->package.count + 1) * sizeof(void *)); if (!target_object->package.elements) { status = AE_NO_MEMORY; goto error_exit; @@ -865,10 +863,10 @@ acpi_ut_copy_ipackage_to_ipackage(union /* * Create the object array and walk the source package tree */ - dest_obj->package.elements = ACPI_MEM_CALLOCATE(((acpi_size) - source_obj->package. - count + - 1) * sizeof(void *)); + dest_obj->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) + source_obj->package. + count + + 1) * sizeof(void *)); if (!dest_obj->package.elements) { ACPI_ERROR((AE_INFO, "Package allocation failure")); return_ACPI_STATUS(AE_NO_MEMORY); @@ -882,6 +880,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_ut_copy_ielement_to_ielement, walk_state); if (ACPI_FAILURE(status)) { + /* On failure, delete the destination package object */ acpi_ut_remove_reference(dest_obj); diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index 35f3d58..a8c3506 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #define _COMPONENT ACPI_UTILITIES @@ -123,12 +121,14 @@ static const char *acpi_ut_trim_function /* All Function names are longer than 4 chars, check is safe */ if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_MIXED) { + /* This is the case where the original source has not been modified */ return (function_name + 4); } if (*(ACPI_CAST_PTR(u32, function_name)) == ACPI_PREFIX_LOWER) { + /* This is the case where the source has been 'linuxized' */ return (function_name + 5); @@ -162,7 +162,7 @@ acpi_ut_debug_print(u32 requested_debug_ const char *function_name, char *module_name, u32 component_id, char *format, ...) { - u32 thread_id; + acpi_thread_id thread_id; va_list args; /* @@ -177,7 +177,6 @@ acpi_ut_debug_print(u32 requested_debug_ * Thread tracking and context switch notification */ thread_id = acpi_os_get_thread_id(); - if (thread_id != acpi_gbl_prev_thread_id) { if (ACPI_LV_THREADS & acpi_dbg_level) { acpi_os_printf @@ -206,7 +205,7 @@ acpi_ut_debug_print(u32 requested_debug_ acpi_os_vprintf(format, args); } -EXPORT_SYMBOL(acpi_ut_debug_print); +ACPI_EXPORT_SYMBOL(acpi_ut_debug_print) /******************************************************************************* * @@ -226,7 +225,6 @@ EXPORT_SYMBOL(acpi_ut_debug_print); * debug_print so that the same macros can be used. * ******************************************************************************/ - void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print_raw(u32 requested_debug_level, u32 line_number, @@ -244,7 +242,7 @@ acpi_ut_debug_print_raw(u32 requested_de acpi_os_vprintf(format, args); } -EXPORT_SYMBOL(acpi_ut_debug_print_raw); +ACPI_EXPORT_SYMBOL(acpi_ut_debug_print_raw) /******************************************************************************* * @@ -261,7 +259,6 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw); * set in debug_level * ******************************************************************************/ - void acpi_ut_trace(u32 line_number, const char *function_name, char *module_name, u32 component_id) @@ -275,7 +272,7 @@ acpi_ut_trace(u32 line_number, component_id, "%s\n", acpi_gbl_fn_entry_str); } -EXPORT_SYMBOL(acpi_ut_trace); +ACPI_EXPORT_SYMBOL(acpi_ut_trace) /******************************************************************************* * @@ -293,7 +290,6 @@ EXPORT_SYMBOL(acpi_ut_trace); * set in debug_level * ******************************************************************************/ - void acpi_ut_trace_ptr(u32 line_number, const char *function_name, @@ -400,7 +396,7 @@ acpi_ut_exit(u32 line_number, acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_exit); +ACPI_EXPORT_SYMBOL(acpi_ut_exit) /******************************************************************************* * @@ -418,7 +414,6 @@ EXPORT_SYMBOL(acpi_ut_exit); * set in debug_level. Prints exit status also. * ******************************************************************************/ - void acpi_ut_status_exit(u32 line_number, const char *function_name, @@ -442,7 +437,7 @@ acpi_ut_status_exit(u32 line_number, acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_status_exit); +ACPI_EXPORT_SYMBOL(acpi_ut_status_exit) /******************************************************************************* * @@ -460,7 +455,6 @@ EXPORT_SYMBOL(acpi_ut_status_exit); * set in debug_level. Prints exit value also. * ******************************************************************************/ - void acpi_ut_value_exit(u32 line_number, const char *function_name, @@ -475,7 +469,7 @@ acpi_ut_value_exit(u32 line_number, acpi_gbl_nesting_level--; } -EXPORT_SYMBOL(acpi_ut_value_exit); +ACPI_EXPORT_SYMBOL(acpi_ut_value_exit) /******************************************************************************* * @@ -493,7 +487,6 @@ EXPORT_SYMBOL(acpi_ut_value_exit); * set in debug_level. Prints exit value also. * ******************************************************************************/ - void acpi_ut_ptr_exit(u32 line_number, const char *function_name, @@ -545,6 +538,7 @@ void acpi_ut_dump_buffer(u8 * buffer, u3 /* Nasty little dump buffer routine! */ while (i < count) { + /* Print current offset */ acpi_os_printf("%6.4X: ", (u32) i); @@ -553,6 +547,7 @@ void acpi_ut_dump_buffer(u8 * buffer, u3 for (j = 0; j < 16;) { if (i + j >= count) { + /* Dump fill spaces */ acpi_os_printf("%*s", ((display * 2) + 1), " "); diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index 1db9695..9c6867f 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c @@ -96,6 +96,7 @@ static void acpi_ut_delete_internal_obj( /* Free the actual string buffer */ if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) { + /* But only if it is NOT a pointer into an ACPI table */ obj_pointer = object->string.pointer; @@ -111,6 +112,7 @@ static void acpi_ut_delete_internal_obj( /* Free the actual buffer */ if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) { + /* But only if it is NOT a pointer into an ACPI table */ obj_pointer = object->buffer.pointer; @@ -234,7 +236,7 @@ static void acpi_ut_delete_internal_obj( if (obj_pointer) { ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", obj_pointer)); - ACPI_MEM_FREE(obj_pointer); + ACPI_FREE(obj_pointer); } /* Now the object can be safely deleted */ @@ -273,7 +275,7 @@ void acpi_ut_delete_internal_object_list /* Free the combined parameter pointer list and object array */ - ACPI_MEM_FREE(obj_list); + ACPI_FREE(obj_list); return_VOID; } @@ -415,6 +417,7 @@ acpi_ut_update_object_reference(union ac ACPI_FUNCTION_TRACE_PTR("ut_update_object_reference", object); while (object) { + /* Make sure that this isn't a namespace handle */ if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) { diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c index 106cc97..68b9eff 100644 --- a/drivers/acpi/utilities/uteval.c +++ b/drivers/acpi/utilities/uteval.c @@ -98,6 +98,7 @@ acpi_status acpi_ut_osi_implementation(s ACPI_CAST_PTR(char, acpi_gbl_valid_osi_strings[i]))) { + /* This string is supported */ return_desc->integer.value = 0xFFFFFFFF; @@ -343,6 +344,7 @@ acpi_ut_execute_HID(struct acpi_namespac } if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + /* Convert the Numeric HID to string */ acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, @@ -459,7 +461,7 @@ acpi_ut_execute_CID(struct acpi_namespac size = (((count - 1) * sizeof(struct acpi_compatible_id)) + sizeof(struct acpi_compatible_id_list)); - cid_list = ACPI_MEM_CALLOCATE((acpi_size) size); + cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size); if (!cid_list) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -479,6 +481,7 @@ acpi_ut_execute_CID(struct acpi_namespac /* The _CID object can be either a single CID or a package (list) of CIDs */ if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { + /* Translate each package element */ for (i = 0; i < count; i++) { @@ -499,7 +502,7 @@ acpi_ut_execute_CID(struct acpi_namespac /* Cleanup on error */ if (ACPI_FAILURE(status)) { - ACPI_MEM_FREE(cid_list); + ACPI_FREE(cid_list); } else { *return_cid_list = cid_list; } @@ -543,6 +546,7 @@ acpi_ut_execute_UID(struct acpi_namespac } if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { + /* Convert the Numeric UID to string */ acpi_ex_unsigned_integer_to_string(obj_desc->integer.value, diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index ffd1338..5bc8da7 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -43,7 +43,6 @@ #define DEFINE_ACPI_GLOBALS -#include #include #include @@ -119,6 +118,7 @@ const char *acpi_format_exception(acpi_s } if (!exception) { + /* Exception code was not recognized */ ACPI_ERROR((AE_INFO, @@ -143,12 +143,10 @@ const char *acpi_format_exception(acpi_s /* Debug switch - level and trace mask */ u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT; -EXPORT_SYMBOL(acpi_dbg_level); /* Debug switch - layer (component) mask */ u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; -EXPORT_SYMBOL(acpi_dbg_layer); u32 acpi_gbl_nesting_level = 0; /* Debugger globals */ @@ -747,6 +745,7 @@ u8 acpi_ut_valid_object_type(acpi_object { if (type > ACPI_TYPE_LOCAL_MAX) { + /* Note: Assumes all TYPEs are contiguous (external/local) */ return (FALSE); @@ -869,3 +868,6 @@ #endif return_VOID; } + +ACPI_EXPORT_SYMBOL(acpi_dbg_level) +ACPI_EXPORT_SYMBOL(acpi_dbg_layer) diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c index ba771b4..40313de 100644 --- a/drivers/acpi/utilities/utinit.c +++ b/drivers/acpi/utilities/utinit.c @@ -186,14 +186,14 @@ static void acpi_ut_terminate(void) gpe_block = gpe_xrupt_info->gpe_block_list_head; while (gpe_block) { next_gpe_block = gpe_block->next; - ACPI_MEM_FREE(gpe_block->event_info); - ACPI_MEM_FREE(gpe_block->register_info); - ACPI_MEM_FREE(gpe_block); + ACPI_FREE(gpe_block->event_info); + ACPI_FREE(gpe_block->register_info); + ACPI_FREE(gpe_block); gpe_block = next_gpe_block; } next_gpe_xrupt_info = gpe_xrupt_info->next; - ACPI_MEM_FREE(gpe_xrupt_info); + ACPI_FREE(gpe_xrupt_info); gpe_xrupt_info = next_gpe_xrupt_info; } diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 7364f5f..2c0ecdb 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -41,6 +41,8 @@ * POSSIBILITY OF SUCH DAMAGES. */ +#include + #include #include @@ -97,6 +99,7 @@ acpi_status acpi_ut_allocate_owner_id(ac for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) { if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) { + /* There are no free IDs in this mask */ break; @@ -273,6 +276,7 @@ void acpi_ut_print_string(char *string, acpi_os_printf("\""); for (i = 0; string[i] && (i < max_length); i++) { + /* Escape sequences */ switch (string[i]) { @@ -461,7 +465,7 @@ acpi_ut_display_init_pathname(u8 type, } acpi_os_printf("\n"); - ACPI_MEM_FREE(buffer.pointer); + ACPI_FREE(buffer.pointer); } #endif @@ -601,11 +605,13 @@ acpi_ut_strtoul64(char *string, u32 base while (*string) { if (ACPI_IS_DIGIT(*string)) { + /* Convert ASCII 0-9 to Decimal value */ this_digit = ((u8) * string) - '0'; } else { if (base == 10) { + /* Digit is out of range */ goto error_exit; @@ -613,6 +619,7 @@ acpi_ut_strtoul64(char *string, u32 base this_digit = (u8) ACPI_TOUPPER(*string); if (ACPI_IS_XDIGIT((char)this_digit)) { + /* Convert ASCII Hex char to value */ this_digit = this_digit - 'A' + 10; @@ -727,6 +734,7 @@ acpi_ut_walk_package_tree(union acpi_ope } while (state) { + /* Get one element of the package */ this_index = state->pkg.index; @@ -814,31 +822,6 @@ acpi_ut_walk_package_tree(union acpi_ope /******************************************************************************* * - * FUNCTION: acpi_ut_generate_checksum - * - * PARAMETERS: Buffer - Buffer to be scanned - * Length - number of bytes to examine - * - * RETURN: The generated checksum - * - * DESCRIPTION: Generate a checksum on a raw buffer - * - ******************************************************************************/ - -u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) -{ - u32 i; - signed char sum = 0; - - for (i = 0; i < length; i++) { - sum = (signed char)(sum + buffer[i]); - } - - return ((u8) (0 - sum)); -} - -/******************************************************************************* - * * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info * * PARAMETERS: module_name - Caller's module name (for error output) @@ -862,6 +845,7 @@ acpi_ut_error(char *module_name, u32 lin acpi_os_vprintf(format, args); acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); } +EXPORT_SYMBOL(acpi_ut_error); void ACPI_INTERNAL_VAR_XFACE acpi_ut_exception(char *module_name, @@ -876,6 +860,7 @@ acpi_ut_exception(char *module_name, acpi_os_vprintf(format, args); acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); } +EXPORT_SYMBOL(acpi_ut_exception); void ACPI_INTERNAL_VAR_XFACE acpi_ut_warning(char *module_name, u32 line_number, char *format, ...) @@ -888,7 +873,7 @@ acpi_ut_warning(char *module_name, u32 l acpi_os_vprintf(format, args); acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); } - +EXPORT_SYMBOL(acpi_ut_warning); void ACPI_INTERNAL_VAR_XFACE acpi_ut_info(char *module_name, u32 line_number, char *format, ...) { diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c index 45a7244..0ac6700 100644 --- a/drivers/acpi/utilities/utmutex.c +++ b/drivers/acpi/utilities/utmutex.c @@ -192,7 +192,7 @@ static acpi_status acpi_ut_delete_mutex( acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) { acpi_status status; - u32 this_thread_id; + acpi_thread_id this_thread_id; ACPI_FUNCTION_NAME("ut_acquire_mutex"); @@ -275,7 +275,7 @@ #endif acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) { acpi_status status; - u32 this_thread_id; + acpi_thread_id this_thread_id; ACPI_FUNCTION_NAME("ut_release_mutex"); diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c index 7ee2d1d..8e3dcbd 100644 --- a/drivers/acpi/utilities/utobject.c +++ b/drivers/acpi/utilities/utobject.c @@ -173,9 +173,10 @@ union acpi_operand_object *acpi_ut_creat /* Create an actual buffer only if size > 0 */ if (buffer_size > 0) { + /* Allocate the actual buffer */ - buffer = ACPI_MEM_CALLOCATE(buffer_size); + buffer = ACPI_ALLOCATE_ZEROED(buffer_size); if (!buffer) { ACPI_ERROR((AE_INFO, "Could not allocate size %X", (u32) buffer_size)); @@ -227,7 +228,7 @@ union acpi_operand_object *acpi_ut_creat * Allocate the actual string buffer -- (Size + 1) for NULL terminator. * NOTE: Zero-length strings are NULL terminated */ - string = ACPI_MEM_CALLOCATE(string_size + 1); + string = ACPI_ALLOCATE_ZEROED(string_size + 1); if (!string) { ACPI_ERROR((AE_INFO, "Could not allocate size %X", (u32) string_size)); @@ -319,6 +320,7 @@ void *acpi_ut_allocate_object_desc_dbg(c } /* Mark the descriptor type */ + memset(object, 0, sizeof(union acpi_operand_object)); ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_OPERAND); @@ -397,6 +399,7 @@ acpi_ut_get_simple_object_size(union acp length = sizeof(union acpi_object); if (ACPI_GET_DESCRIPTOR_TYPE(internal_object) == ACPI_DESC_TYPE_NAMED) { + /* Object is a named object (reference), just return the length */ *obj_length = ACPI_ROUND_UP_TO_NATIVE_WORD(length); diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c index 1646131..27158dd 100644 --- a/drivers/acpi/utilities/utresrc.c +++ b/drivers/acpi/utilities/utresrc.c @@ -273,6 +273,7 @@ acpi_status acpi_ut_validate_resource(vo * Examine the large/small bit in the resource header */ if (resource_type & ACPI_RESOURCE_NAME_LARGE) { + /* Verify the large resource type (name) against the max */ if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { @@ -376,6 +377,7 @@ u8 acpi_ut_get_resource_type(void *aml) * Examine the large/small bit in the resource header */ if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource Type -- bits 6:0 contain the name */ return (ACPI_GET8(aml)); @@ -411,6 +413,7 @@ u16 acpi_ut_get_resource_length(void *am * Examine the large/small bit in the resource header */ if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1)); @@ -515,6 +518,7 @@ acpi_ut_get_resource_end_tag(union acpi_ /* Walk the resource template, one descriptor per iteration */ while (aml < end_aml) { + /* Validate the Resource Type and Resource Length */ status = acpi_ut_validate_resource(aml, NULL); diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c index 4b134a7..69f2bfd 100644 --- a/drivers/acpi/utilities/utstate.c +++ b/drivers/acpi/utilities/utstate.c @@ -129,6 +129,7 @@ union acpi_generic_state *acpi_ut_pop_ge state = *list_head; if (state) { + /* Update the list head */ *list_head = state->common.next; @@ -158,6 +159,7 @@ union acpi_generic_state *acpi_ut_create state = acpi_os_acquire_object(acpi_gbl_state_cache); if (state) { + /* Initialize */ memset(state, 0, sizeof(union acpi_generic_state)); state->common.data_type = ACPI_DESC_TYPE_STATE; diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index 308a960..ac90048 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c @@ -41,8 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include - #include #include #include @@ -109,6 +107,8 @@ acpi_status acpi_initialize_subsystem(vo return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_initialize_subsystem) + /******************************************************************************* * * FUNCTION: acpi_enable_subsystem @@ -121,7 +121,6 @@ acpi_status acpi_initialize_subsystem(vo * Puts system into ACPI mode if it isn't already. * ******************************************************************************/ - acpi_status acpi_enable_subsystem(u32 flags) { acpi_status status = AE_OK; @@ -229,6 +228,8 @@ acpi_status acpi_enable_subsystem(u32 fl return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_enable_subsystem) + /******************************************************************************* * * FUNCTION: acpi_initialize_objects @@ -241,7 +242,6 @@ acpi_status acpi_enable_subsystem(u32 fl * objects and executing AML code for Regions, buffers, etc. * ******************************************************************************/ - acpi_status acpi_initialize_objects(u32 flags) { acpi_status status = AE_OK; @@ -305,6 +305,8 @@ acpi_status acpi_initialize_objects(u32 return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_initialize_objects) + /******************************************************************************* * * FUNCTION: acpi_terminate @@ -316,7 +318,6 @@ acpi_status acpi_initialize_objects(u32 * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources. * ******************************************************************************/ - acpi_status acpi_terminate(void) { acpi_status status; @@ -348,6 +349,8 @@ #endif return_ACPI_STATUS(status); } +ACPI_EXPORT_SYMBOL(acpi_terminate) + #ifdef ACPI_FUTURE_USAGE /******************************************************************************* * @@ -362,7 +365,6 @@ #ifdef ACPI_FUTURE_USAGE * initialized successfully. * ******************************************************************************/ - acpi_status acpi_subsystem_status(void) { @@ -373,6 +375,8 @@ acpi_status acpi_subsystem_status(void) } } +ACPI_EXPORT_SYMBOL(acpi_subsystem_status) + /******************************************************************************* * * FUNCTION: acpi_get_system_info @@ -390,7 +394,6 @@ acpi_status acpi_subsystem_status(void) * and the value of out_buffer is undefined. * ******************************************************************************/ - acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer) { struct acpi_system_info *info_ptr; @@ -456,7 +459,7 @@ acpi_status acpi_get_system_info(struct return_ACPI_STATUS(AE_OK); } -EXPORT_SYMBOL(acpi_get_system_info); +ACPI_EXPORT_SYMBOL(acpi_get_system_info) /***************************************************************************** * @@ -472,7 +475,6 @@ EXPORT_SYMBOL(acpi_get_system_info); * TBD: When a second function is added, must save the Function also. * ****************************************************************************/ - acpi_status acpi_install_initialization_handler(acpi_init_handler handler, u32 function) { @@ -489,6 +491,7 @@ acpi_install_initialization_handler(acpi return AE_OK; } +ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler) #endif /* ACPI_FUTURE_USAGE */ /***************************************************************************** @@ -502,7 +505,6 @@ #endif /* ACPI_FUTURE_USAGE */ * DESCRIPTION: Empty all caches (delete the cached objects) * ****************************************************************************/ - acpi_status acpi_purge_cached_objects(void) { ACPI_FUNCTION_TRACE("acpi_purge_cached_objects"); @@ -513,3 +515,5 @@ acpi_status acpi_purge_cached_objects(vo (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache); return_ACPI_STATUS(AE_OK); } + +ACPI_EXPORT_SYMBOL(acpi_purge_cached_objects) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 6458c47..5d89b77 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -58,31 +58,28 @@ acpi_extract_package(union acpi_object * u8 *head = NULL; u8 *tail = NULL; - ACPI_FUNCTION_TRACE("acpi_extract_package"); - if (!package || (package->type != ACPI_TYPE_PACKAGE) || (package->package.count < 1)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Invalid 'package' argument\n")); - return_ACPI_STATUS(AE_BAD_PARAMETER); + ACPI_WARNING((AE_INFO, "Invalid package argument")); + return AE_BAD_PARAMETER; } if (!format || !format->pointer || (format->length < 1)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); - return_ACPI_STATUS(AE_BAD_PARAMETER); + ACPI_WARNING((AE_INFO, "Invalid format argument")); + return AE_BAD_PARAMETER; } if (!buffer) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); - return_ACPI_STATUS(AE_BAD_PARAMETER); + ACPI_WARNING((AE_INFO, "Invalid buffer argument")); + return AE_BAD_PARAMETER; } format_count = (format->length / sizeof(char)) - 1; if (format_count > package->package.count) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Format specifies more objects [%d] than exist in package [%d].", - format_count, package->package.count)); - return_ACPI_STATUS(AE_BAD_DATA); + ACPI_WARNING((AE_INFO, "Format specifies more objects [%d]" + " than exist in package [%d].", + format_count, package->package.count)); + return AE_BAD_DATA; } format_string = (char *)format->pointer; @@ -95,7 +92,7 @@ acpi_extract_package(union acpi_object * union acpi_object *element = &(package->package.elements[i]); if (!element) { - return_ACPI_STATUS(AE_BAD_DATA); + return AE_BAD_DATA; } switch (element->type) { @@ -113,10 +110,11 @@ acpi_extract_package(union acpi_object * tail_offset += sizeof(char *); break; default: - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Invalid package element [%d]: got number, expecing [%c].\n", - i, format_string[i])); - return_ACPI_STATUS(AE_BAD_DATA); + ACPI_WARNING((AE_INFO, "Invalid package element" + " [%d]: got number, expecing" + " [%c]", + i, format_string[i])); + return AE_BAD_DATA; break; } break; @@ -138,10 +136,11 @@ acpi_extract_package(union acpi_object * tail_offset += sizeof(u8 *); break; default: - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Invalid package element [%d] got string/buffer, expecing [%c].\n", - i, format_string[i])); - return_ACPI_STATUS(AE_BAD_DATA); + ACPI_WARNING((AE_INFO, "Invalid package element" + " [%d] got string/buffer," + " expecing [%c]", + i, format_string[i])); + return AE_BAD_DATA; break; } break; @@ -152,7 +151,7 @@ acpi_extract_package(union acpi_object * "Found unsupported element at index=%d\n", i)); /* TBD: handle nested packages... */ - return_ACPI_STATUS(AE_SUPPORT); + return AE_SUPPORT; break; } } @@ -162,9 +161,9 @@ acpi_extract_package(union acpi_object * */ if (buffer->length < size_required) { buffer->length = size_required; - return_ACPI_STATUS(AE_BUFFER_OVERFLOW); + return AE_BUFFER_OVERFLOW; } else if (buffer->length != size_required || !buffer->pointer) { - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; } head = buffer->pointer; @@ -179,7 +178,7 @@ acpi_extract_package(union acpi_object * union acpi_object *element = &(package->package.elements[i]); if (!element) { - return_ACPI_STATUS(AE_BAD_DATA); + return AE_BAD_DATA; } switch (element->type) { @@ -244,7 +243,7 @@ acpi_extract_package(union acpi_object * } } - return_ACPI_STATUS(AE_OK); + return AE_OK; } EXPORT_SYMBOL(acpi_extract_package); @@ -258,14 +257,12 @@ acpi_evaluate_integer(acpi_handle handle union acpi_object *element; struct acpi_buffer buffer = { 0, NULL }; - ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); - if (!data) - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); if (!element) - return_ACPI_STATUS(AE_NO_MEMORY); + return AE_NO_MEMORY; memset(element, 0, sizeof(union acpi_object)); buffer.length = sizeof(union acpi_object); @@ -273,12 +270,14 @@ acpi_evaluate_integer(acpi_handle handle status = acpi_evaluate_object(handle, pathname, arguments, &buffer); if (ACPI_FAILURE(status)) { acpi_util_eval_error(handle, pathname, status); - return_ACPI_STATUS(status); + kfree(element); + return status; } if (element->type != ACPI_TYPE_INTEGER) { acpi_util_eval_error(handle, pathname, AE_BAD_DATA); - return_ACPI_STATUS(AE_BAD_DATA); + kfree(element); + return AE_BAD_DATA; } *data = element->integer.value; @@ -286,7 +285,7 @@ acpi_evaluate_integer(acpi_handle handle ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); - return_ACPI_STATUS(AE_OK); + return AE_OK; } EXPORT_SYMBOL(acpi_evaluate_integer); @@ -301,15 +300,13 @@ acpi_evaluate_string(acpi_handle handle, acpi_object *element = NULL; acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; - ACPI_FUNCTION_TRACE("acpi_evaluate_string"); - if (!data) - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; status = acpi_evaluate_object(handle, pathname, arguments, &buffer); if (ACPI_FAILURE(status)) { acpi_util_eval_error(handle, pathname, status); - return_ACPI_STATUS(status); + return status; } element = (acpi_object *) buffer.pointer; @@ -318,13 +315,13 @@ acpi_evaluate_string(acpi_handle handle, || (element->type != ACPI_TYPE_BUFFER) || !element->string.length) { acpi_util_eval_error(handle, pathname, AE_BAD_DATA); - return_ACPI_STATUS(AE_BAD_DATA); + return AE_BAD_DATA; } *data = kmalloc(element->string.length + 1, GFP_KERNEL); if (!data) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); - return_VALUE(-ENOMEM); + ACPI_ERROR((AE_INFO, "Memory allocation")); + return -ENOMEM; } memset(*data, 0, element->string.length + 1); @@ -332,9 +329,9 @@ acpi_evaluate_string(acpi_handle handle, ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%s]\n", *data)); - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); - return_ACPI_STATUS(AE_OK); + return AE_OK; } #endif @@ -350,10 +347,8 @@ acpi_evaluate_reference(acpi_handle hand struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; u32 i = 0; - ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); - if (!list) { - return_ACPI_STATUS(AE_BAD_PARAMETER); + return AE_BAD_PARAMETER; } /* Evaluate object. */ @@ -365,32 +360,29 @@ acpi_evaluate_reference(acpi_handle hand package = (union acpi_object *)buffer.pointer; if ((buffer.length == 0) || !package) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No return object (len %X ptr %p)\n", - (unsigned)buffer.length, package)); + ACPI_ERROR((AE_INFO, "No return object (len %X ptr %p)", + (unsigned)buffer.length, package)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (package->type != ACPI_TYPE_PACKAGE) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Expecting a [Package], found type %X\n", - package->type)); + ACPI_ERROR((AE_INFO, "Expecting a [Package], found type %X", + package->type)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (!package->package.count) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "[Package] has zero elements (%p)\n", - package)); + ACPI_ERROR((AE_INFO, "[Package] has zero elements (%p)", + package)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; } if (package->package.count > ACPI_MAX_HANDLES) { - return_ACPI_STATUS(AE_NO_MEMORY); + return AE_NO_MEMORY; } list->count = package->package.count; @@ -402,9 +394,9 @@ acpi_evaluate_reference(acpi_handle hand if (element->type != ACPI_TYPE_ANY) { status = AE_BAD_DATA; - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Expecting a [Reference] package element, found type %X\n", - element->type)); + ACPI_ERROR((AE_INFO, + "Expecting a [Reference] package element, found type %X", + element->type)); acpi_util_eval_error(handle, pathname, status); break; } @@ -422,9 +414,9 @@ acpi_evaluate_reference(acpi_handle hand //kfree(list->handles); } - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); - return_ACPI_STATUS(status); + return status; } EXPORT_SYMBOL(acpi_evaluate_reference); diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bd48875..42ddc10 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -272,10 +272,10 @@ static int acpi_video_device_query(struct acpi_video_device *device, unsigned long *state) { int status; - ACPI_FUNCTION_TRACE("acpi_video_device_query"); + status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state); - return_VALUE(status); + return status; } static int @@ -284,11 +284,9 @@ acpi_video_device_get_state(struct acpi_ { int status; - ACPI_FUNCTION_TRACE("acpi_video_device_get_state"); - status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state); - return_VALUE(status); + return status; } static int @@ -299,12 +297,10 @@ acpi_video_device_set_state(struct acpi_ struct acpi_object_list args = { 1, &arg0 }; unsigned long ret; - ACPI_FUNCTION_TRACE("acpi_video_device_set_state"); - arg0.integer.value = state; status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret); - return_VALUE(status); + return status; } static int @@ -315,28 +311,26 @@ acpi_video_device_lcd_query_levels(struc struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *obj; - ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels"); - *levels = NULL; status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer); if (!ACPI_SUCCESS(status)) - return_VALUE(status); + return status; obj = (union acpi_object *)buffer.pointer; - if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n")); + if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { + ACPI_ERROR((AE_INFO, "Invalid _BCL data")); status = -EFAULT; goto err; } *levels = obj; - return_VALUE(0); + return 0; err: kfree(buffer.pointer); - return_VALUE(status); + return (status); } static int @@ -346,13 +340,11 @@ acpi_video_device_lcd_set_level(struct a union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; - ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level"); - arg0.integer.value = level; status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL); printk(KERN_DEBUG "set_level status: %x\n", status); - return_VALUE(status); + return (status); } static int @@ -360,11 +352,10 @@ acpi_video_device_lcd_get_level_current( unsigned long *level) { int status; - ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current"); status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level); - return_VALUE(status); + return (status); } static int @@ -377,34 +368,32 @@ acpi_video_device_EDID(struct acpi_video union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; - ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID"); - *edid = NULL; if (!device) - return_VALUE(-ENODEV); + return -ENODEV; if (length == 128) arg0.integer.value = 1; else if (length == 256) arg0.integer.value = 2; else - return_VALUE(-EINVAL); + return (-EINVAL); status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer); if (ACPI_FAILURE(status)) - return_VALUE(-ENODEV); + return -ENODEV; obj = (union acpi_object *)buffer.pointer; if (obj && obj->type == ACPI_TYPE_BUFFER) *edid = obj; else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n")); + ACPI_ERROR((AE_INFO, "Invalid _DDC data")); status = -EFAULT; kfree(obj); } - return_VALUE(status); + return (status); } /* bus */ @@ -417,15 +406,13 @@ acpi_video_bus_set_POST(struct acpi_vide union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; - ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST"); - arg0.integer.value = option; status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp); if (ACPI_SUCCESS(status)) status = tmp ? (-EINVAL) : (AE_OK); - return_VALUE(status); + return (status); } static int @@ -433,11 +420,9 @@ acpi_video_bus_get_POST(struct acpi_vide { int status; - ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST"); - status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id); - return_VALUE(status); + return (status); } static int @@ -445,12 +430,11 @@ acpi_video_bus_POST_options(struct acpi_ unsigned long *options) { int status; - ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options"); status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options); *options &= 3; - return_VALUE(status); + return (status); } /* @@ -481,8 +465,6 @@ acpi_video_bus_DOS(struct acpi_video_bus union acpi_object arg0 = { ACPI_TYPE_INTEGER }; struct acpi_object_list args = { 1, &arg0 }; - ACPI_FUNCTION_TRACE("acpi_video_bus_DOS"); - if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) { status = -1; goto Failed; @@ -492,7 +474,7 @@ acpi_video_bus_DOS(struct acpi_video_bus acpi_evaluate_object(video->handle, "_DOS", &args, NULL); Failed: - return_VALUE(status); + return (status); } /* @@ -514,8 +496,6 @@ static void acpi_video_device_find_cap(s union acpi_object *obj = NULL; struct acpi_video_device_brightness *br = NULL; - ACPI_FUNCTION_TRACE("acpi_video_device_find_cap"); - memset(&device->cap, 0, 4); if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) { @@ -560,8 +540,7 @@ static void acpi_video_device_find_cap(s o = (union acpi_object *)&obj->package. elements[i]; if (o->type != ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid data\n")); + ACPI_ERROR((AE_INFO, "Invalid data")); continue; } br->levels[count] = (u32) o->integer.value; @@ -583,7 +562,7 @@ static void acpi_video_device_find_cap(s kfree(obj); - return_VOID; + return; } /* @@ -630,10 +609,8 @@ static int acpi_video_bus_check(struct a { acpi_status status = -ENOENT; - ACPI_FUNCTION_TRACE("acpi_video_bus_check"); - if (!video) - return_VALUE(-EINVAL); + return (-EINVAL); /* Since there is no HID, CID and so on for VGA driver, we have * to check well known required nodes. @@ -657,7 +634,7 @@ static int acpi_video_bus_check(struct a status = 0; } - return_VALUE(status); + return (status); } /* -------------------------------------------------------------------------- @@ -673,8 +650,6 @@ static int acpi_video_device_info_seq_sh struct acpi_video_device *dev = (struct acpi_video_device *)seq->private; - ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show"); - if (!dev) goto end; @@ -692,7 +667,7 @@ static int acpi_video_device_info_seq_sh seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no"); end: - return_VALUE(0); + return 0; } static int @@ -709,8 +684,6 @@ static int acpi_video_device_state_seq_s (struct acpi_video_device *)seq->private; unsigned long state; - ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show"); - if (!dev) goto end; @@ -729,7 +702,7 @@ static int acpi_video_device_state_seq_s seq_printf(seq, "\n"); end: - return_VALUE(0); + return 0; } static int @@ -750,13 +723,11 @@ acpi_video_device_write_state(struct fil char str[12] = { 0 }; u32 state = 0; - ACPI_FUNCTION_TRACE("acpi_video_device_write_state"); - if (!dev || count + 1 > sizeof str) - return_VALUE(-EINVAL); + return (-EINVAL); if (copy_from_user(str, buffer, count)) - return_VALUE(-EFAULT); + return (-EFAULT); str[count] = 0; state = simple_strtoul(str, NULL, 0); @@ -765,9 +736,9 @@ acpi_video_device_write_state(struct fil status = acpi_video_device_set_state(dev, state); if (status) - return_VALUE(-EFAULT); + return (-EFAULT); - return_VALUE(count); + return (count); } static int @@ -777,11 +748,9 @@ acpi_video_device_brightness_seq_show(st (struct acpi_video_device *)seq->private; int i; - ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show"); - if (!dev || !dev->brightness) { seq_printf(seq, "\n"); - return_VALUE(0); + return 0; } seq_printf(seq, "levels: "); @@ -789,7 +758,7 @@ acpi_video_device_brightness_seq_show(st seq_printf(seq, " %d", dev->brightness->levels[i]); seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr); - return_VALUE(0); + return 0; } static int @@ -810,19 +779,17 @@ acpi_video_device_write_brightness(struc unsigned int level = 0; int i; - ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); - if (!dev || !dev->brightness || count + 1 > sizeof str) - return_VALUE(-EINVAL); + return (-EINVAL); if (copy_from_user(str, buffer, count)) - return_VALUE(-EFAULT); + return (-EFAULT); str[count] = 0; level = simple_strtoul(str, NULL, 0); if (level > 100) - return_VALUE(-EFAULT); + return (-EFAULT); /* validate though the list of available levels */ for (i = 0; i < dev->brightness->count; i++) @@ -833,7 +800,7 @@ acpi_video_device_write_brightness(struc break; } - return_VALUE(count); + return (count); } static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) @@ -844,8 +811,6 @@ static int acpi_video_device_EDID_seq_sh int i; union acpi_object *edid = NULL; - ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show"); - if (!dev) goto out; @@ -869,7 +834,7 @@ static int acpi_video_device_EDID_seq_sh else kfree(edid); - return_VALUE(0); + return 0; } static int @@ -884,28 +849,25 @@ static int acpi_video_device_add_fs(stru struct proc_dir_entry *entry = NULL; struct acpi_video_device *vid_dev; - ACPI_FUNCTION_TRACE("acpi_video_device_add_fs"); - if (!device) - return_VALUE(-ENODEV); + return -ENODEV; vid_dev = (struct acpi_video_device *)acpi_driver_data(device); if (!vid_dev) - return_VALUE(-ENODEV); + return -ENODEV; if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), vid_dev->video->dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; acpi_device_dir(device)->owner = THIS_MODULE; } /* 'info' [R] */ entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'info' fs entry\n")); + return -ENODEV; else { entry->proc_fops = &acpi_video_device_info_fops; entry->data = acpi_driver_data(device); @@ -917,8 +879,7 @@ static int acpi_video_device_add_fs(stru create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'state' fs entry\n")); + return -ENODEV; else { acpi_video_device_state_fops.write = acpi_video_device_write_state; entry->proc_fops = &acpi_video_device_state_fops; @@ -931,8 +892,7 @@ static int acpi_video_device_add_fs(stru create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'brightness' fs entry\n")); + return -ENODEV; else { acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness; entry->proc_fops = &acpi_video_device_brightness_fops; @@ -943,25 +903,23 @@ static int acpi_video_device_add_fs(stru /* 'EDID' [R] */ entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'brightness' fs entry\n")); + return -ENODEV; else { entry->proc_fops = &acpi_video_device_EDID_fops; entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } - return_VALUE(0); + return 0; } static int acpi_video_device_remove_fs(struct acpi_device *device) { struct acpi_video_device *vid_dev; - ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs"); vid_dev = (struct acpi_video_device *)acpi_driver_data(device); if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) - return_VALUE(-ENODEV); + return -ENODEV; if (acpi_device_dir(device)) { remove_proc_entry("info", acpi_device_dir(device)); @@ -972,7 +930,7 @@ static int acpi_video_device_remove_fs(s acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* video bus */ @@ -980,8 +938,6 @@ static int acpi_video_bus_info_seq_show( { struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; - ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show"); - if (!video) goto end; @@ -993,7 +949,7 @@ static int acpi_video_bus_info_seq_show( video->flags.post ? "yes" : "no"); end: - return_VALUE(0); + return 0; } static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file) @@ -1006,8 +962,6 @@ static int acpi_video_bus_ROM_seq_show(s { struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; - ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show"); - if (!video) goto end; @@ -1015,7 +969,7 @@ static int acpi_video_bus_ROM_seq_show(s seq_printf(seq, "\n"); end: - return_VALUE(0); + return 0; } static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file) @@ -1029,8 +983,6 @@ static int acpi_video_bus_POST_info_seq_ unsigned long options; int status; - ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show"); - if (!video) goto end; @@ -1052,7 +1004,7 @@ static int acpi_video_bus_POST_info_seq_ } else seq_printf(seq, "\n"); end: - return_VALUE(0); + return 0; } static int @@ -1068,8 +1020,6 @@ static int acpi_video_bus_POST_seq_show( int status; unsigned long id; - ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show"); - if (!video) goto end; @@ -1081,18 +1031,16 @@ static int acpi_video_bus_POST_seq_show( seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]); end: - return_VALUE(0); + return 0; } static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset) { struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; - ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show"); - seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting); - return_VALUE(0); + return 0; } static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file) @@ -1117,22 +1065,20 @@ acpi_video_bus_write_POST(struct file *f char str[12] = { 0 }; unsigned long opt, options; - ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST"); - if (!video || count + 1 > sizeof str) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_video_bus_POST_options(video, &options); if (!ACPI_SUCCESS(status)) - return_VALUE(-EINVAL); + return -EINVAL; if (copy_from_user(str, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; str[count] = 0; opt = strtoul(str, NULL, 0); if (opt > 3) - return_VALUE(-EFAULT); + return -EFAULT; /* just in case an OEM 'forget' the motherboard... */ options |= 1; @@ -1140,11 +1086,11 @@ acpi_video_bus_write_POST(struct file *f if (options & (1ul << opt)) { status = acpi_video_bus_set_POST(video, opt); if (!ACPI_SUCCESS(status)) - return_VALUE(-EFAULT); + return -EFAULT; } - return_VALUE(count); + return count; } static ssize_t @@ -1158,25 +1104,23 @@ acpi_video_bus_write_DOS(struct file *fi char str[12] = { 0 }; unsigned long opt; - ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS"); - if (!video || count + 1 > sizeof str) - return_VALUE(-EINVAL); + return -EINVAL; if (copy_from_user(str, buffer, count)) - return_VALUE(-EFAULT); + return -EFAULT; str[count] = 0; opt = strtoul(str, NULL, 0); if (opt > 7) - return_VALUE(-EFAULT); + return -EFAULT; status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2); if (!ACPI_SUCCESS(status)) - return_VALUE(-EFAULT); + return -EFAULT; - return_VALUE(count); + return count; } static int acpi_video_bus_add_fs(struct acpi_device *device) @@ -1184,15 +1128,13 @@ static int acpi_video_bus_add_fs(struct struct proc_dir_entry *entry = NULL; struct acpi_video_bus *video; - ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs"); - video = (struct acpi_video_bus *)acpi_driver_data(device); if (!acpi_device_dir(device)) { acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_video_dir); if (!acpi_device_dir(device)) - return_VALUE(-ENODEV); + return -ENODEV; video->dir = acpi_device_dir(device); acpi_device_dir(device)->owner = THIS_MODULE; } @@ -1200,8 +1142,7 @@ static int acpi_video_bus_add_fs(struct /* 'info' [R] */ entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'info' fs entry\n")); + return -ENODEV; else { entry->proc_fops = &acpi_video_bus_info_fops; entry->data = acpi_driver_data(device); @@ -1211,8 +1152,7 @@ static int acpi_video_bus_add_fs(struct /* 'ROM' [R] */ entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'ROM' fs entry\n")); + return -ENODEV; else { entry->proc_fops = &acpi_video_bus_ROM_fops; entry->data = acpi_driver_data(device); @@ -1223,8 +1163,7 @@ static int acpi_video_bus_add_fs(struct entry = create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'POST_info' fs entry\n")); + return -ENODEV; else { entry->proc_fops = &acpi_video_bus_POST_info_fops; entry->data = acpi_driver_data(device); @@ -1236,8 +1175,7 @@ static int acpi_video_bus_add_fs(struct create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'POST' fs entry\n")); + return -ENODEV; else { acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST; entry->proc_fops = &acpi_video_bus_POST_fops; @@ -1250,8 +1188,7 @@ static int acpi_video_bus_add_fs(struct create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR, acpi_device_dir(device)); if (!entry) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unable to create 'DOS' fs entry\n")); + return -ENODEV; else { acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS; entry->proc_fops = &acpi_video_bus_DOS_fops; @@ -1259,15 +1196,13 @@ static int acpi_video_bus_add_fs(struct entry->owner = THIS_MODULE; } - return_VALUE(0); + return 0; } static int acpi_video_bus_remove_fs(struct acpi_device *device) { struct acpi_video_bus *video; - ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs"); - video = (struct acpi_video_bus *)acpi_driver_data(device); if (acpi_device_dir(device)) { @@ -1280,7 +1215,7 @@ static int acpi_video_bus_remove_fs(stru acpi_device_dir(device) = NULL; } - return_VALUE(0); + return 0; } /* -------------------------------------------------------------------------- @@ -1294,13 +1229,11 @@ acpi_video_bus_get_one_device(struct acp struct acpi_video_bus *video) { unsigned long device_id; - int status, result; + int status; struct acpi_video_device *data; - ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device"); - if (!device || !video) - return_VALUE(-EINVAL); + return -EINVAL; status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); @@ -1308,7 +1241,7 @@ acpi_video_bus_get_one_device(struct acp data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL); if (!data) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(data, 0, sizeof(struct acpi_video_device)); @@ -1346,8 +1279,11 @@ acpi_video_bus_get_one_device(struct acp if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error installing notify handler\n")); - result = -ENODEV; - goto end; + if(data->brightness) + kfree(data->brightness->levels); + kfree(data->brightness); + kfree(data); + return -ENODEV; } down(&video->sem); @@ -1356,11 +1292,10 @@ acpi_video_bus_get_one_device(struct acp acpi_video_device_add_fs(device); - return_VALUE(0); + return 0; } - end: - return_VALUE(-ENOENT); + return -ENOENT; } /* @@ -1403,7 +1338,6 @@ acpi_video_device_bind(struct acpi_video struct acpi_video_device *device) { int i; - ACPI_FUNCTION_TRACE("acpi_video_device_bind"); #define IDS_VAL(i) video->attached_array[i].value.int_val #define IDS_BIND(i) video->attached_array[i].bind_info @@ -1440,17 +1374,15 @@ static int acpi_video_device_enumerate(s union acpi_object *dod = NULL; union acpi_object *obj; - ACPI_FUNCTION_TRACE("acpi_video_device_enumerate"); - status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer); if (!ACPI_SUCCESS(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _DOD\n")); - return_VALUE(status); + ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD")); + return status; } dod = (union acpi_object *)buffer.pointer; if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); + ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data")); status = -EFAULT; goto out; } @@ -1474,8 +1406,7 @@ static int acpi_video_device_enumerate(s obj = (union acpi_object *)&dod->package.elements[i]; if (obj->type != ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid _DOD data\n")); + ACPI_ERROR((AE_INFO, "Invalid _DOD data")); active_device_list[i].value.int_val = ACPI_VIDEO_HEAD_INVALID; } @@ -1492,8 +1423,8 @@ static int acpi_video_device_enumerate(s video->attached_array = active_device_list; video->attached_count = count; out: - acpi_os_free(buffer.pointer); - return_VALUE(status); + kfree(buffer.pointer); + return status; } /* @@ -1518,8 +1449,6 @@ static int acpi_video_switch_output(stru unsigned long state; int status = 0; - ACPI_FUNCTION_TRACE("acpi_video_switch_output"); - list_for_each_safe(node, next, &video->video_device_list) { dev = container_of(node, struct acpi_video_device, entry); status = acpi_video_device_get_state(dev, &state); @@ -1549,7 +1478,7 @@ static int acpi_video_switch_output(stru break; } - return_VALUE(status); + return status; } static int @@ -1576,8 +1505,6 @@ acpi_video_bus_get_devices(struct acpi_v int status = 0; struct list_head *node, *next; - ACPI_FUNCTION_TRACE("acpi_video_get_devices"); - acpi_video_device_enumerate(video); list_for_each_safe(node, next, &device->children) { @@ -1589,13 +1516,12 @@ acpi_video_bus_get_devices(struct acpi_v status = acpi_video_bus_get_one_device(dev, video); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Cant attach device\n")); + ACPI_EXCEPTION((AE_INFO, status, "Cant attach device")); continue; } } - return_VALUE(status); + return status; } static int acpi_video_bus_put_one_device(struct acpi_video_device *device) @@ -1603,10 +1529,8 @@ static int acpi_video_bus_put_one_device acpi_status status; struct acpi_video_bus *video; - ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device"); - if (!device || !device->video) - return_VALUE(-ENOENT); + return -ENOENT; video = device->video; @@ -1618,11 +1542,8 @@ static int acpi_video_bus_put_one_device status = acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_video_device_notify); - if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); - return_VALUE(0); + return 0; } static int acpi_video_bus_put_devices(struct acpi_video_bus *video) @@ -1630,8 +1551,6 @@ static int acpi_video_bus_put_devices(st int status; struct list_head *node, *next; - ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices"); - list_for_each_safe(node, next, &video->video_device_list) { struct acpi_video_device *data = list_entry(node, struct acpi_video_device, entry); @@ -1643,12 +1562,13 @@ static int acpi_video_bus_put_devices(st printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n"); + if (data->brightness); + kfree(data->brightness->levels); kfree(data->brightness); - kfree(data); } - return_VALUE(0); + return 0; } /* acpi_video interface */ @@ -1668,14 +1588,11 @@ static void acpi_video_bus_notify(acpi_h struct acpi_video_bus *video = (struct acpi_video_bus *)data; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_video_bus_notify"); - printk("video bus notify\n"); - if (!video) - return_VOID; + return; if (acpi_bus_get_device(handle, &device)) - return_VOID; + return; switch (event) { case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur, @@ -1704,7 +1621,7 @@ static void acpi_video_bus_notify(acpi_h break; } - return_VOID; + return; } static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) @@ -1713,14 +1630,11 @@ static void acpi_video_device_notify(acp (struct acpi_video_device *)data; struct acpi_device *device = NULL; - ACPI_FUNCTION_TRACE("acpi_video_device_notify"); - - printk("video device notify\n"); if (!video_device) - return_VOID; + return; if (acpi_bus_get_device(handle, &device)) - return_VOID; + return; switch (event) { case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ @@ -1740,7 +1654,7 @@ static void acpi_video_device_notify(acp "Unsupported event [0x%x]\n", event)); break; } - return_VOID; + return; } static int acpi_video_bus_add(struct acpi_device *device) @@ -1749,14 +1663,12 @@ static int acpi_video_bus_add(struct acp acpi_status status = 0; struct acpi_video_bus *video = NULL; - ACPI_FUNCTION_TRACE("acpi_video_bus_add"); - if (!device) - return_VALUE(-EINVAL); + return -EINVAL; video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); if (!video) - return_VALUE(-ENOMEM); + return -ENOMEM; memset(video, 0, sizeof(struct acpi_video_bus)); video->handle = device->handle; @@ -1785,6 +1697,10 @@ static int acpi_video_bus_add(struct acp if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error installing notify handler\n")); + acpi_video_bus_stop_devices(video); + acpi_video_bus_put_devices(video); + kfree(video->attached_array); + acpi_video_bus_remove_fs(device); result = -ENODEV; goto end; } @@ -1796,12 +1712,10 @@ static int acpi_video_bus_add(struct acp video->flags.post ? "yes" : "no"); end: - if (result) { - acpi_video_bus_remove_fs(device); + if (result) kfree(video); - } - return_VALUE(result); + return result; } static int acpi_video_bus_remove(struct acpi_device *device, int type) @@ -1809,10 +1723,8 @@ static int acpi_video_bus_remove(struct acpi_status status = 0; struct acpi_video_bus *video = NULL; - ACPI_FUNCTION_TRACE("acpi_video_bus_remove"); - if (!device || !acpi_driver_data(device)) - return_VALUE(-EINVAL); + return -EINVAL; video = (struct acpi_video_bus *)acpi_driver_data(device); @@ -1821,9 +1733,6 @@ static int acpi_video_bus_remove(struct status = acpi_remove_notify_handler(video->handle, ACPI_DEVICE_NOTIFY, acpi_video_bus_notify); - if (ACPI_FAILURE(status)) - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Error removing notify handler\n")); acpi_video_bus_put_devices(video); acpi_video_bus_remove_fs(device); @@ -1831,7 +1740,7 @@ static int acpi_video_bus_remove(struct kfree(video->attached_array); kfree(video); - return_VALUE(0); + return 0; } static int @@ -1841,10 +1750,8 @@ acpi_video_bus_match(struct acpi_device acpi_handle h_dummy2; acpi_handle h_dummy3; - ACPI_FUNCTION_TRACE("acpi_video_bus_match"); - if (!device || !driver) - return_VALUE(-EINVAL); + return -EINVAL; /* Since there is no HID, CID for ACPI Video drivers, we have * to check well known required nodes for each feature we support. @@ -1853,27 +1760,25 @@ acpi_video_bus_match(struct acpi_device /* Does this device able to support video switching ? */ if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) && ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2))) - return_VALUE(0); + return 0; /* Does this device able to retrieve a video ROM ? */ if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1))) - return_VALUE(0); + return 0; /* Does this device able to configure which video head to be POSTed ? */ if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) && ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) && ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) - return_VALUE(0); + return 0; - return_VALUE(-ENODEV); + return -ENODEV; } static int __init acpi_video_init(void) { int result = 0; - ACPI_FUNCTION_TRACE("acpi_video_init"); - /* acpi_dbg_level = 0xFFFFFFFF; acpi_dbg_layer = 0x08000000; @@ -1881,27 +1786,25 @@ static int __init acpi_video_init(void) acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); if (!acpi_video_dir) - return_VALUE(-ENODEV); + return -ENODEV; acpi_video_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_video_bus); if (result < 0) { remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); - return_VALUE(-ENODEV); + return -ENODEV; } - return_VALUE(0); + return 0; } static void __exit acpi_video_exit(void) { - ACPI_FUNCTION_TRACE("acpi_video_exit"); - acpi_bus_unregister_driver(&acpi_video_bus); remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); - return_VOID; + return; } module_init(acpi_video_init); diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c index 8c4c6ef..907fb66 100644 --- a/drivers/char/agp/hp-agp.c +++ b/drivers/char/agp/hp-agp.c @@ -497,7 +497,7 @@ zx1_gart_probe (acpi_handle obj, u32 dep info = buffer.pointer; info->hardware_id.value[sizeof(info->hardware_id)-1] = '\0'; match = (strcmp(info->hardware_id.value, "HWP0001") == 0); - ACPI_MEM_FREE(info); + kfree(info); if (match) { status = hp_acpi_csr_space(handle, &sba_hpa, &length); if (ACPI_SUCCESS(status)) diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index ef140eb..07473cd 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -925,11 +925,8 @@ static acpi_status hpet_resources(struct status = acpi_resource_to_address64(res, &addr); if (ACPI_SUCCESS(status)) { - unsigned long size; - - size = addr.maximum - addr.minimum + 1; hdp->hd_phys_address = addr.minimum; - hdp->hd_address = ioremap(addr.minimum, size); + hdp->hd_address = ioremap(addr.minimum, addr.address_length); if (hpet_is_known(hdp)) { printk(KERN_DEBUG "%s: 0x%lx is busy\n", diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index a90f5d9..43dfd86 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c @@ -512,7 +512,7 @@ #endif /* CONFIG_ACPI */ #ifdef CONFIG_ACPI static struct acpi_device *sonypi_acpi_device; -static int acpi_enabled; +static int acpi_driver_registered; #endif static int sonypi_ec_write(u8 addr, u8 value) @@ -869,7 +869,7 @@ found: sonypi_report_input_event(event); #ifdef CONFIG_ACPI - if (acpi_enabled) + if (sonypi_acpi_device) acpi_bus_generate_event(sonypi_acpi_device, 1, event); #endif @@ -1551,8 +1551,8 @@ static int __init sonypi_init(void) goto err_free_device; #ifdef CONFIG_ACPI - if (acpi_bus_register_driver(&sonypi_acpi_driver) > 0) - acpi_enabled = 1; + if (acpi_bus_register_driver(&sonypi_acpi_driver) >= 0) + acpi_driver_registered = 1; #endif return 0; @@ -1567,7 +1567,7 @@ #endif static void __exit sonypi_exit(void) { #ifdef CONFIG_ACPI - if (acpi_enabled) + if (acpi_driver_registered) acpi_bus_unregister_driver(&sonypi_acpi_driver); #endif platform_device_unregister(sonypi_platform_device); diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c index 39af9c3..64cb30d 100644 --- a/drivers/pci/hotplug/acpi_pcihp.c +++ b/drivers/pci/hotplug/acpi_pcihp.c @@ -58,7 +58,7 @@ acpi_run_hpp(acpi_handle handle, struct if (!ret_buf.pointer) { printk(KERN_ERR "%s:%s alloc for _HPP fail\n", __FUNCTION__, (char *)string.pointer); - acpi_os_free(string.pointer); + kfree(string.pointer); return AE_NO_MEMORY; } status = acpi_evaluate_object(handle, METHOD_NAME__HPP, @@ -69,7 +69,7 @@ acpi_run_hpp(acpi_handle handle, struct if (ACPI_FAILURE(status)) { pr_debug("%s:%s _HPP fail=0x%x\n", __FUNCTION__, (char *)string.pointer, status); - acpi_os_free(string.pointer); + kfree(string.pointer); return status; } } @@ -109,8 +109,8 @@ acpi_run_hpp(acpi_handle handle, struct pr_debug(" _HPP: enable PERR =0x%x\n", hpp->enable_perr); free_and_return: - acpi_os_free(string.pointer); - acpi_os_free(ret_buf.pointer); + kfree(string.pointer); + kfree(ret_buf.pointer); return status; } @@ -136,7 +136,7 @@ acpi_status acpi_run_oshp(acpi_handle ha pr_debug("%s:%s OSHP passes\n", __FUNCTION__, (char *)string.pointer); - acpi_os_free(string.pointer); + kfree(string.pointer); return status; } EXPORT_SYMBOL_GPL(acpi_run_oshp); @@ -192,19 +192,19 @@ int acpi_root_bridge(acpi_handle handle) if ((info->valid & ACPI_VALID_HID) && !strcmp(PCI_ROOT_HID_STRING, info->hardware_id.value)) { - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return 1; } if (info->valid & ACPI_VALID_CID) { for (i=0; i < info->compatibility_id.count; i++) { if (!strcmp(PCI_ROOT_HID_STRING, info->compatibility_id.id[i].value)) { - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return 1; } } } - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); } return 0; } diff --git a/drivers/pci/hotplug/acpiphp_dock.c b/drivers/pci/hotplug/acpiphp_dock.c index 4f1aaf1..a8bed39 100644 --- a/drivers/pci/hotplug/acpiphp_dock.c +++ b/drivers/pci/hotplug/acpiphp_dock.c @@ -173,7 +173,7 @@ static acpi_status handle_dock(int dock) &arg_list, &buffer); if (ACPI_FAILURE(status)) err("%s: failed to execute _DCK\n", __FUNCTION__); - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return status; } @@ -347,7 +347,7 @@ find_dock_ejd(acpi_handle handle, u32 lv } find_ejd_out: - acpi_os_free(ejd_buffer.pointer); + kfree(ejd_buffer.pointer); return AE_OK; } diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 053ee84..ab91d7a 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -634,7 +634,7 @@ static int get_gsi_base(acpi_handle hand break; } out: - acpi_os_free(buffer.pointer); + kfree(buffer.pointer); return result; } diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 6c14d9e..7f459df 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -1288,7 +1288,7 @@ int pciehp_acpi_get_hp_hw_control_from_f if (ACPI_SUCCESS(status)) { dbg("Gained control for hotplug HW for pci %s (%s)\n", pci_name(dev), (char *)string.pointer); - acpi_os_free(string.pointer); + kfree(string.pointer); return 0; } if (acpi_root_bridge(handle)) @@ -1302,7 +1302,7 @@ int pciehp_acpi_get_hp_hw_control_from_f err("Cannot get control of hotplug hardware for pci %s\n", pci_name(dev)); - acpi_os_free(string.pointer); + kfree(string.pointer); return -1; } #endif diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 407b4ea..3a4a644 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -36,13 +36,13 @@ static int irq_flags(int triggering, int { int flag; if (triggering == ACPI_LEVEL_SENSITIVE) { - if(polarity == ACPI_ACTIVE_LOW) + if (polarity == ACPI_ACTIVE_LOW) flag = IORESOURCE_IRQ_LOWLEVEL; else flag = IORESOURCE_IRQ_HIGHLEVEL; } else { - if(polarity == ACPI_ACTIVE_LOW) + if (polarity == ACPI_ACTIVE_LOW) flag = IORESOURCE_IRQ_LOWEDGE; else flag = IORESOURCE_IRQ_HIGHEDGE; @@ -57,7 +57,7 @@ static void decode_irq_flags(int flag, i *triggering = ACPI_LEVEL_SENSITIVE; *polarity = ACPI_ACTIVE_LOW; break; - case IORESOURCE_IRQ_HIGHLEVEL: + case IORESOURCE_IRQ_HIGHLEVEL: *triggering = ACPI_LEVEL_SENSITIVE; *polarity = ACPI_ACTIVE_HIGH; break; @@ -73,7 +73,7 @@ static void decode_irq_flags(int flag, i } static void -pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, +pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, int triggering, int polarity) { int i = 0; @@ -101,7 +101,7 @@ pnpacpi_parse_allocated_irqresource(stru } static void -pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, u32 dma) +pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma) { int i = 0; while (i < PNP_MAX_DMA && @@ -119,8 +119,8 @@ pnpacpi_parse_allocated_dmaresource(stru } static void -pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res, - u32 io, u32 len) +pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, + u64 io, u64 len) { int i = 0; while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && @@ -138,7 +138,7 @@ pnpacpi_parse_allocated_ioresource(struc } static void -pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res, +pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, u64 mem, u64 len) { int i = 0; @@ -156,11 +156,32 @@ pnpacpi_parse_allocated_memresource(stru } } +static void +pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, + struct acpi_resource *res) +{ + struct acpi_resource_address64 addr, *p = &addr; + acpi_status status; + + status = acpi_resource_to_address64(res, p); + if (!ACPI_SUCCESS(status)) { + pnp_warn("PnPACPI: failed to convert resource type %d", + res->type); + return; + } + + if (p->resource_type == ACPI_MEMORY_RANGE) + pnpacpi_parse_allocated_memresource(res_table, + p->minimum, p->address_length); + else if (p->resource_type == ACPI_IO_RANGE) + pnpacpi_parse_allocated_ioresource(res_table, + p->minimum, p->address_length); +} static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, void *data) { - struct pnp_resource_table * res_table = (struct pnp_resource_table *)data; + struct pnp_resource_table *res_table = (struct pnp_resource_table *)data; int i; switch (res->type) { @@ -221,19 +242,9 @@ static acpi_status pnpacpi_allocated_res res->data.fixed_memory32.address_length); break; case ACPI_RESOURCE_TYPE_ADDRESS16: - pnpacpi_parse_allocated_memresource(res_table, - res->data.address16.minimum, - res->data.address16.address_length); - break; case ACPI_RESOURCE_TYPE_ADDRESS32: - pnpacpi_parse_allocated_memresource(res_table, - res->data.address32.minimum, - res->data.address32.address_length); - break; case ACPI_RESOURCE_TYPE_ADDRESS64: - pnpacpi_parse_allocated_memresource(res_table, - res->data.address64.minimum, - res->data.address64.address_length); + pnpacpi_parse_allocated_address_space(res_table, res); break; case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: @@ -255,11 +266,11 @@ static acpi_status pnpacpi_allocated_res pnp_warn("PnPACPI: unknown resource type %d", res->type); return AE_ERROR; } - + return AE_OK; } -acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table * res) +acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table *res) { /* Blank the resource table values */ pnp_init_resource_table(res); @@ -317,17 +328,17 @@ static void pnpacpi_parse_dma_option(str pnp_err("Invalid DMA transfer type"); } - pnp_register_dma_resource(option,dma); + pnp_register_dma_resource(option, dma); return; } - + static void pnpacpi_parse_irq_option(struct pnp_option *option, struct acpi_resource_irq *p) { int i; - struct pnp_irq * irq; - + struct pnp_irq *irq; + if (p->interrupt_count == 0) return; irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); @@ -347,7 +358,7 @@ static void pnpacpi_parse_ext_irq_option struct acpi_resource_extended_irq *p) { int i; - struct pnp_irq * irq; + struct pnp_irq *irq; if (p->interrupt_count == 0) return; @@ -368,7 +379,7 @@ static void pnpacpi_parse_port_option(struct pnp_option *option, struct acpi_resource_io *io) { - struct pnp_port * port; + struct pnp_port *port; if (io->address_length == 0) return; @@ -381,7 +392,7 @@ pnpacpi_parse_port_option(struct pnp_opt port->size = io->address_length; port->flags = ACPI_DECODE_16 == io->io_decode ? PNP_PORT_FLAG_16BITADDR : 0; - pnp_register_port_resource(option,port); + pnp_register_port_resource(option, port); return; } @@ -389,7 +400,7 @@ static void pnpacpi_parse_fixed_port_option(struct pnp_option *option, struct acpi_resource_fixed_io *io) { - struct pnp_port * port; + struct pnp_port *port; if (io->address_length == 0) return; @@ -400,7 +411,7 @@ pnpacpi_parse_fixed_port_option(struct p port->size = io->address_length; port->align = 0; port->flags = PNP_PORT_FLAG_FIXED; - pnp_register_port_resource(option,port); + pnp_register_port_resource(option, port); return; } @@ -408,7 +419,7 @@ static void pnpacpi_parse_mem24_option(struct pnp_option *option, struct acpi_resource_memory24 *p) { - struct pnp_mem * mem; + struct pnp_mem *mem; if (p->address_length == 0) return; @@ -423,7 +434,7 @@ pnpacpi_parse_mem24_option(struct pnp_op mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; - pnp_register_mem_resource(option,mem); + pnp_register_mem_resource(option, mem); return; } @@ -431,7 +442,7 @@ static void pnpacpi_parse_mem32_option(struct pnp_option *option, struct acpi_resource_memory32 *p) { - struct pnp_mem * mem; + struct pnp_mem *mem; if (p->address_length == 0) return; @@ -446,7 +457,7 @@ pnpacpi_parse_mem32_option(struct pnp_op mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; - pnp_register_mem_resource(option,mem); + pnp_register_mem_resource(option, mem); return; } @@ -454,7 +465,7 @@ static void pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, struct acpi_resource_fixed_memory32 *p) { - struct pnp_mem * mem; + struct pnp_mem *mem; if (p->address_length == 0) return; @@ -468,7 +479,7 @@ pnpacpi_parse_fixed_mem32_option(struct mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; - pnp_register_mem_resource(option,mem); + pnp_register_mem_resource(option, mem); return; } @@ -477,8 +488,8 @@ pnpacpi_parse_address_option(struct pnp_ { struct acpi_resource_address64 addr, *p = &addr; acpi_status status; - struct pnp_mem * mem; - struct pnp_port * port; + struct pnp_mem *mem; + struct pnp_port *port; status = acpi_resource_to_address64(r, p); if (!ACPI_SUCCESS(status)) { @@ -498,7 +509,7 @@ pnpacpi_parse_address_option(struct pnp_ mem->align = 0; mem->flags = (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; - pnp_register_mem_resource(option,mem); + pnp_register_mem_resource(option, mem); } else if (p->resource_type == ACPI_IO_RANGE) { port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) @@ -507,7 +518,7 @@ pnpacpi_parse_address_option(struct pnp_ port->size = p->address_length; port->align = 0; port->flags = PNP_PORT_FLAG_FIXED; - pnp_register_port_resource(option,port); + pnp_register_port_resource(option, port); } } @@ -531,7 +542,7 @@ static acpi_status pnpacpi_option_resour break; case ACPI_RESOURCE_TYPE_DMA: - pnpacpi_parse_dma_option(option, &res->data.dma); + pnpacpi_parse_dma_option(option, &res->data.dma); break; case ACPI_RESOURCE_TYPE_START_DEPENDENT: @@ -539,7 +550,7 @@ static acpi_status pnpacpi_option_resour case ACPI_GOOD_CONFIGURATION: priority = PNP_RES_PRIORITY_PREFERRED; break; - + case ACPI_ACCEPTABLE_CONFIGURATION: priority = PNP_RES_PRIORITY_ACCEPTABLE; break; @@ -555,7 +566,7 @@ static acpi_status pnpacpi_option_resour option = pnp_register_dependent_option(dev, priority); if (!option) return AE_ERROR; - parse_data->option = option; + parse_data->option = option; break; case ACPI_RESOURCE_TYPE_END_DEPENDENT: @@ -615,7 +626,7 @@ static acpi_status pnpacpi_option_resour pnp_warn("PnPACPI: unknown resource type %d", res->type); return AE_ERROR; } - + return AE_OK; } @@ -636,13 +647,8 @@ acpi_status pnpacpi_parse_resource_optio return status; } -/* - * Set resource - */ -static acpi_status pnpacpi_count_resources(struct acpi_resource *res, - void *data) +static int pnpacpi_supported_resource(struct acpi_resource *res) { - int *res_cnt = (int *)data; switch (res->type) { case ACPI_RESOURCE_TYPE_IRQ: case ACPI_RESOURCE_TYPE_DMA: @@ -655,43 +661,32 @@ static acpi_status pnpacpi_count_resourc case ACPI_RESOURCE_TYPE_ADDRESS32: case ACPI_RESOURCE_TYPE_ADDRESS64: case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: - (*res_cnt) ++; - case ACPI_RESOURCE_TYPE_START_DEPENDENT: - case ACPI_RESOURCE_TYPE_END_DEPENDENT: - case ACPI_RESOURCE_TYPE_VENDOR: - case ACPI_RESOURCE_TYPE_END_TAG: - case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: - default: - return AE_OK; + return 1; } - return AE_OK; + return 0; } -static acpi_status pnpacpi_type_resources(struct acpi_resource *res, +/* + * Set resource + */ +static acpi_status pnpacpi_count_resources(struct acpi_resource *res, void *data) { - struct acpi_resource **resource = (struct acpi_resource **)data; - switch (res->type) { - case ACPI_RESOURCE_TYPE_IRQ: - case ACPI_RESOURCE_TYPE_DMA: - case ACPI_RESOURCE_TYPE_IO: - case ACPI_RESOURCE_TYPE_FIXED_IO: - case ACPI_RESOURCE_TYPE_MEMORY24: - case ACPI_RESOURCE_TYPE_MEMORY32: - case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: - case ACPI_RESOURCE_TYPE_ADDRESS16: - case ACPI_RESOURCE_TYPE_ADDRESS32: - case ACPI_RESOURCE_TYPE_ADDRESS64: - case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + int *res_cnt = (int *)data; + + if (pnpacpi_supported_resource(res)) + (*res_cnt)++; + return AE_OK; +} + +static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data) +{ + struct acpi_resource **resource = (struct acpi_resource **)data; + + if (pnpacpi_supported_resource(res)) { (*resource)->type = res->type; + (*resource)->length = sizeof(struct acpi_resource); (*resource)++; - case ACPI_RESOURCE_TYPE_START_DEPENDENT: - case ACPI_RESOURCE_TYPE_END_DEPENDENT: - case ACPI_RESOURCE_TYPE_VENDOR: - case ACPI_RESOURCE_TYPE_END_TAG: - case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: - default: - return AE_OK; } return AE_OK; @@ -735,11 +730,8 @@ static void pnpacpi_encode_irq(struct ac struct resource *p) { int triggering, polarity; - - decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, - &polarity); - resource->type = ACPI_RESOURCE_TYPE_IRQ; - resource->length = sizeof(struct acpi_resource); + + decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity); resource->data.irq.triggering = triggering; resource->data.irq.polarity = polarity; if (triggering == ACPI_EDGE_SENSITIVE) @@ -754,11 +746,8 @@ static void pnpacpi_encode_ext_irq(struc struct resource *p) { int triggering, polarity; - - decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, - &polarity); - resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; - resource->length = sizeof(struct acpi_resource); + + decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity); resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; resource->data.extended_irq.triggering = triggering; resource->data.extended_irq.polarity = polarity; @@ -773,8 +762,6 @@ static void pnpacpi_encode_ext_irq(struc static void pnpacpi_encode_dma(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RESOURCE_TYPE_DMA; - resource->length = sizeof(struct acpi_resource); /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ if (p->flags & IORESOURCE_DMA_COMPATIBLE) resource->data.dma.type = ACPI_COMPATIBILITY; @@ -798,8 +785,6 @@ static void pnpacpi_encode_dma(struct ac static void pnpacpi_encode_io(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RESOURCE_TYPE_IO; - resource->length = sizeof(struct acpi_resource); /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? ACPI_DECODE_16 : ACPI_DECODE_10; @@ -812,8 +797,6 @@ static void pnpacpi_encode_io(struct acp static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; - resource->length = sizeof(struct acpi_resource); resource->data.fixed_io.address = p->start; resource->data.fixed_io.address_length = p->end - p->start + 1; } @@ -821,8 +804,6 @@ static void pnpacpi_encode_fixed_io(stru static void pnpacpi_encode_mem24(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RESOURCE_TYPE_MEMORY24; - resource->length = sizeof(struct acpi_resource); /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ resource->data.memory24.write_protect = (p->flags & IORESOURCE_MEM_WRITEABLE) ? @@ -836,8 +817,6 @@ static void pnpacpi_encode_mem24(struct static void pnpacpi_encode_mem32(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RESOURCE_TYPE_MEMORY32; - resource->length = sizeof(struct acpi_resource); resource->data.memory32.write_protect = (p->flags & IORESOURCE_MEM_WRITEABLE) ? ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; @@ -850,8 +829,6 @@ static void pnpacpi_encode_mem32(struct static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; - resource->length = sizeof(struct acpi_resource); resource->data.fixed_memory32.write_protect = (p->flags & IORESOURCE_MEM_WRITEABLE) ? ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; @@ -882,37 +859,37 @@ int pnpacpi_encode_resources(struct pnp_ pnp_dbg("Encode dma"); pnpacpi_encode_dma(resource, &res_table->dma_resource[dma]); - dma ++; + dma++; break; case ACPI_RESOURCE_TYPE_IO: pnp_dbg("Encode io"); pnpacpi_encode_io(resource, &res_table->port_resource[port]); - port ++; + port++; break; case ACPI_RESOURCE_TYPE_FIXED_IO: pnp_dbg("Encode fixed io"); pnpacpi_encode_fixed_io(resource, &res_table->port_resource[port]); - port ++; + port++; break; case ACPI_RESOURCE_TYPE_MEMORY24: pnp_dbg("Encode mem24"); pnpacpi_encode_mem24(resource, &res_table->mem_resource[mem]); - mem ++; + mem++; break; case ACPI_RESOURCE_TYPE_MEMORY32: pnp_dbg("Encode mem32"); pnpacpi_encode_mem32(resource, &res_table->mem_resource[mem]); - mem ++; + mem++; break; case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: pnp_dbg("Encode fixed mem32"); pnpacpi_encode_fixed_mem32(resource, &res_table->mem_resource[mem]); - mem ++; + mem++; break; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: pnp_dbg("Encode ext irq"); @@ -933,8 +910,8 @@ int pnpacpi_encode_resources(struct pnp_ pnp_warn("unknown resource type %d", resource->type); return -EINVAL; } - resource ++; - i ++; + resource++; + i++; } return 0; } diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index e27dc8f..ebe793f 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ #define _ACCONFIG_H /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20060127 +#define ACPI_CA_VERSION 0x20060310 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, @@ -102,9 +102,9 @@ #define ACPI_CA_SUPPORT_LEVEL #define ACPI_MAX_SEMAPHORE_COUNT 256 -/* Max reference count (for debug only) */ +/* Maximum object reference count (detects object deletion issues) */ -#define ACPI_MAX_REFERENCE_COUNT 0x400 +#define ACPI_MAX_REFERENCE_COUNT 0x800 /* Size of cached memory mapping for system memory operation region */ diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index 11a8fe3..f004461 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -50,6 +50,7 @@ #define BLOCK_NONE 0 #define BLOCK_PAREN 1 #define BLOCK_BRACE 2 #define BLOCK_COMMA_LIST 4 +#define ACPI_DEFAULT_RESNAME *(u32 *) "__RD" struct acpi_external_list { char *path; @@ -70,6 +71,7 @@ extern const char *acpi_gbl_match_ops[AC struct acpi_op_walk_info { u32 level; u32 bit_offset; + u32 flags; struct acpi_walk_state *walk_state; }; @@ -77,6 +79,11 @@ typedef acpi_status(*asl_walk_callback) (union acpi_parse_object * op, u32 level, void *context); +struct acpi_resource_tag { + u32 bit_index; + char *tag; +}; + /* * dmwalk */ @@ -84,6 +91,11 @@ void acpi_dm_disassemble(struct acpi_walk_state *walk_state, union acpi_parse_object *origin, u32 num_opcodes); +void +acpi_dm_walk_parse_tree(union acpi_parse_object *op, + asl_walk_callback descending_callback, + asl_walk_callback ascending_callback, void *context); + /* * dmopcode */ @@ -166,6 +178,7 @@ void acpi_dm_dump_integer64(u64 value, c void acpi_dm_resource_template(struct acpi_op_walk_info *info, + union acpi_parse_object *op, u8 * byte_data, u32 byte_count); u8 acpi_dm_is_resource_template(union acpi_parse_object *op); @@ -176,6 +189,8 @@ void acpi_dm_bit_list(u16 mask); void acpi_dm_decode_attribute(u8 attribute); +void acpi_dm_descriptor_name(void); + /* * dmresrcl */ @@ -250,4 +265,13 @@ acpi_dm_vendor_small_descriptor(union am */ void acpi_dm_add_to_external_list(char *path); +/* + * dmrestag + */ +void acpi_dm_find_resources(union acpi_parse_object *root); + +void +acpi_dm_check_resource_reference(union acpi_parse_object *op, + struct acpi_walk_state *walk_state); + #endif /* __ACDISASM_H__ */ diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 8361820..94fbf96 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -129,7 +129,7 @@ #define ACPI_MUTEX_NOT_ACQUIRED struct acpi_mutex_info { acpi_mutex mutex; u32 use_count; - u32 thread_id; + acpi_thread_id thread_id; }; /* Lock flag parameter for various interfaces */ @@ -181,9 +181,9 @@ struct acpi_namespace_node { u8 owner_id; /* Who created this node */ u8 flags; - /* Fields used by the ASL compiler only */ + /* Fields used by the ASL compiler and disassembler only */ -#ifdef ACPI_ASL_COMPILER +#ifdef ACPI_LARGE_NAMESPACE_NODE u32 value; union acpi_parse_object *op; #endif @@ -479,7 +479,7 @@ struct acpi_pscope_state { struct acpi_thread_state { ACPI_STATE_COMMON struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */ union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */ - u32 thread_id; /* Running thread ID */ + acpi_thread_id thread_id; /* Running thread ID */ u8 current_sync_level; /* Mutex Sync (nested acquire) level */ }; diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index f2be2a8..edb3097 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -341,29 +341,33 @@ #define ACPI_MOD_32(a) /* * Rounding macros (Power of two boundaries only) */ -#define ACPI_ROUND_DOWN(value,boundary) (((acpi_native_uint)(value)) & \ +#define ACPI_ROUND_DOWN(value,boundary) (((acpi_native_uint)(value)) & \ (~(((acpi_native_uint) boundary)-1))) -#define ACPI_ROUND_UP(value,boundary) ((((acpi_native_uint)(value)) + \ +#define ACPI_ROUND_UP(value,boundary) ((((acpi_native_uint)(value)) + \ (((acpi_native_uint) boundary)-1)) & \ (~(((acpi_native_uint) boundary)-1))) -#define ACPI_ROUND_DOWN_TO_32_BITS(a) ACPI_ROUND_DOWN(a,4) -#define ACPI_ROUND_DOWN_TO_64_BITS(a) ACPI_ROUND_DOWN(a,8) -#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) +/* Note: sizeof(acpi_native_uint) evaluates to either 2, 4, or 8 */ -#define ACPI_ROUND_UP_to_32_bITS(a) ACPI_ROUND_UP(a,4) -#define ACPI_ROUND_UP_to_64_bITS(a) ACPI_ROUND_UP(a,8) -#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) +#define ACPI_ROUND_DOWN_to_32_bIT(a) ACPI_ROUND_DOWN(a,4) +#define ACPI_ROUND_DOWN_to_64_bIT(a) ACPI_ROUND_DOWN(a,8) +#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a,sizeof(acpi_native_uint)) -#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) -#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) +#define ACPI_ROUND_UP_to_32_bIT(a) ACPI_ROUND_UP(a,4) +#define ACPI_ROUND_UP_to_64_bIT(a) ACPI_ROUND_UP(a,8) +#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,sizeof(acpi_native_uint)) -#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) +#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) +#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) + +#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) /* Generic (non-power-of-two) rounding */ -#define ACPI_ROUND_UP_TO(value,boundary) (((value) + ((boundary)-1)) / (boundary)) +#define ACPI_ROUND_UP_TO(value,boundary) (((value) + ((boundary)-1)) / (boundary)) + +#define ACPI_IS_MISALIGNED(value) (((acpi_native_uint)value) & (sizeof(acpi_native_uint)-1)) /* * Bitmask creation @@ -371,10 +375,10 @@ #define ACPI_ROUND_UP_TO(value,boundary) * MASK_BITS_ABOVE creates a mask starting AT the position and above * MASK_BITS_BELOW creates a mask starting one bit BELOW the position */ -#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position)))) -#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position))) +#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position)))) +#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position))) -#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) +#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) /* Bitfields within ACPI registers */ @@ -702,6 +706,7 @@ #else #define ACPI_ADD_OBJECT_NAME(a,b) #endif +#ifdef UNUSED /* * Memory allocation tracking (DEBUG ONLY) */ @@ -709,20 +714,21 @@ #ifndef ACPI_DBG_TRACK_ALLOCATIONS /* Memory allocation */ -#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) -#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) -#define ACPI_MEM_FREE(a) acpi_os_free(a) +#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) +#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) +#define ACPI_FREE(a) acpi_os_free(a) #define ACPI_MEM_TRACKING(a) #else /* Memory allocation */ -#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) -#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) -#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__) +#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) +#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) +#define ACPI_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__) #define ACPI_MEM_TRACKING(a) a #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ +#endif /* UNUSED */ #endif /* ACMACROS_H */ diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h index b667a80..132d64a 100644 --- a/include/acpi/acnamesp.h +++ b/include/acpi/acnamesp.h @@ -63,6 +63,7 @@ #define ACPI_NS_SEARCH_PARENT 0x01 #define ACPI_NS_DONT_OPEN_SCOPE 0x02 #define ACPI_NS_NO_PEER_SEARCH 0x04 #define ACPI_NS_ERROR_IF_FOUND 0x08 +#define ACPI_NS_PREFIX_IS_SCOPE 0x10 #define ACPI_NS_WALK_UNLOCK TRUE #define ACPI_NS_WALK_NO_UNLOCK FALSE @@ -184,6 +185,10 @@ acpi_ns_evaluate_relative(char *pathname */ u32 acpi_ns_opens_scope(acpi_object_type type); +void +acpi_ns_build_external_path(struct acpi_namespace_node *node, + acpi_size size, char *name_buffer); + char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node); char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state); diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 6dca3d5..2731bbc 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -26,7 +26,7 @@ #ifndef __ACPI_BUS_H__ #define __ACPI_BUS_H__ -#include +#include #include @@ -169,7 +169,8 @@ struct acpi_device_flags { u32 power_manageable:1; u32 performance_manageable:1; u32 wake_capable:1; /* Wakeup(_PRW) supported? */ - u32 reserved:20; + u32 force_power_state:1; + u32 reserved:19; }; /* File System */ @@ -296,6 +297,7 @@ struct acpi_device { struct acpi_driver *driver; void *driver_data; struct kobject kobj; + struct device dev; }; #define acpi_driver_data(d) ((d)->driver_data) @@ -327,7 +329,7 @@ int acpi_bus_set_power(acpi_handle handl int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data); int acpi_bus_receive_event(struct acpi_bus_event *event); int acpi_bus_register_driver(struct acpi_driver *driver); -int acpi_bus_unregister_driver(struct acpi_driver *driver); +void acpi_bus_unregister_driver(struct acpi_driver *driver); int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, acpi_handle handle, int type); int acpi_bus_trim(struct acpi_device *start, int rmdevice); diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index 970e9a6..301a355 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -50,12 +50,16 @@ #define __ACPIOSXF_H__ #include "platform/acenv.h" #include "actypes.h" -/* Priorities for acpi_os_queue_for_execution */ - -#define OSD_PRIORITY_GPE 1 -#define OSD_PRIORITY_HIGH 2 -#define OSD_PRIORITY_MED 3 -#define OSD_PRIORITY_LO 4 +/* Callback types for acpi_os_execute */ + +enum acpi_callback_type { + OSL_GLOBAL_LOCK_HANDLER, + OSL_NOTIFY_HANDLER, + OSL_GPE_HANDLER, + OSL_DEBUGGER_THREAD, + OSL_EC_POLL_HANDLER, + OSL_EC_BURST_HANDLER, +}; #define ACPI_NO_UNIT_LIMIT ((u32) -1) #define ACPI_MUTEX_SEM 1 @@ -113,11 +117,8 @@ acpi_cpu_flags acpi_os_acquire_lock(acpi void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags); /* - * Memory allocation and mapping + * Memory mapping */ -void *acpi_os_allocate(acpi_size size); - -void acpi_os_free(void *memory); acpi_status acpi_os_map_memory(acpi_physical_address physical_address, @@ -161,11 +162,10 @@ acpi_os_remove_interrupt_handler(u32 gsi /* * Threads and Scheduling */ -u32 acpi_os_get_thread_id(void); +acpi_thread_id acpi_os_get_thread_id(void); -acpi_status -acpi_os_queue_for_execution(u32 priority, - acpi_osd_exec_callback function, void *context); +acpi_status acpi_os_execute(enum acpi_callback_type, + acpi_osd_exec_callback function, void *context); void acpi_os_wait_events_complete(void *context); diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 7ca89cd..520f315 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -154,7 +154,6 @@ typedef u64 acpi_physical_address; #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX -#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 #define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ /* @@ -195,8 +194,6 @@ typedef u64 acpi_physical_address; #define ACPI_MAX_PTR ACPI_UINT32_MAX #define ACPI_SIZE_MAX ACPI_UINT32_MAX -#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 - /******************************************************************************* * * Types specific to 16-bit targets @@ -223,7 +220,6 @@ typedef char *acpi_physical_address; #define ACPI_MAX_PTR ACPI_UINT16_MAX #define ACPI_SIZE_MAX ACPI_UINT16_MAX -#define ALIGNED_ADDRESS_BOUNDARY 0x00000002 #define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ /* 64-bit integers cannot be supported */ @@ -292,6 +288,21 @@ #ifndef ACPI_UNUSED_VAR #define ACPI_UNUSED_VAR #endif +/* + * All ACPICA functions that are available to the rest of the kernel are + * tagged with this macro which can be defined as appropriate for the host. + */ +#ifndef ACPI_EXPORT_SYMBOL +#define ACPI_EXPORT_SYMBOL(symbol) +#endif + +/* + * thread_id is returned by acpi_os_get_thread_id. + */ +#ifndef acpi_thread_id +#define acpi_thread_id acpi_native_uint +#endif + /******************************************************************************* * * Independent types @@ -1297,12 +1308,6 @@ #define ACPI_RS_SIZE(type) #define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length) -#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED -#define ACPI_ALIGN_RESOURCE_SIZE(length) (length) -#else -#define ACPI_ALIGN_RESOURCE_SIZE(length) ACPI_ROUND_UP_TO_NATIVE_WORD(length) -#endif - /* * END: of definitions for Resource Attributes */ diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index 0927765..9d70c4a 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -483,8 +483,6 @@ acpi_status acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 ** end_tag); -u8 acpi_ut_generate_checksum(u8 * buffer, u32 length); - u32 acpi_ut_dword_byte_swap(u32 value); void acpi_ut_set_integer_width(u8 revision); @@ -521,6 +519,7 @@ acpi_status acpi_ut_initialize_buffer(struct acpi_buffer *buffer, acpi_size required_length); +#ifdef UNUSED void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line); void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line); @@ -535,11 +534,10 @@ void *acpi_ut_callocate_and_track(acpi_s void acpi_ut_free_and_track(void *address, u32 component, char *module, u32 line); -#ifdef ACPI_FUTURE_USAGE void acpi_ut_dump_allocation_info(void); -#endif /* ACPI_FUTURE_USAGE */ void acpi_ut_dump_allocations(u32 component, char *module); +#endif /* UNUSED */ #endif #endif /* _ACUTILS_H */ diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h index fb47353..e5b42eb 100644 --- a/include/acpi/amlresrc.h +++ b/include/acpi/amlresrc.h @@ -45,36 +45,36 @@ #ifndef __AMLRESRC_H #define __AMLRESRC_H -#define ASL_RESNAME_ADDRESS "_ADR" -#define ASL_RESNAME_ALIGNMENT "_ALN" -#define ASL_RESNAME_ADDRESSSPACE "_ASI" -#define ASL_RESNAME_ACCESSSIZE "_ASZ" -#define ASL_RESNAME_TYPESPECIFICATTRIBUTES "_ATT" -#define ASL_RESNAME_BASEADDRESS "_BAS" -#define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */ -#define ASL_RESNAME_DECODE "_DEC" -#define ASL_RESNAME_DMA "_DMA" -#define ASL_RESNAME_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ -#define ASL_RESNAME_GRANULARITY "_GRA" -#define ASL_RESNAME_INTERRUPT "_INT" -#define ASL_RESNAME_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */ -#define ASL_RESNAME_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */ -#define ASL_RESNAME_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ -#define ASL_RESNAME_LENGTH "_LEN" -#define ASL_RESNAME_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ -#define ASL_RESNAME_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ -#define ASL_RESNAME_MAXADDR "_MAX" -#define ASL_RESNAME_MINADDR "_MIN" -#define ASL_RESNAME_MAXTYPE "_MAF" -#define ASL_RESNAME_MINTYPE "_MIF" -#define ASL_RESNAME_REGISTERBITOFFSET "_RBO" -#define ASL_RESNAME_REGISTERBITWIDTH "_RBW" -#define ASL_RESNAME_RANGETYPE "_RNG" -#define ASL_RESNAME_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */ -#define ASL_RESNAME_TRANSLATION "_TRA" -#define ASL_RESNAME_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ -#define ASL_RESNAME_TYPE "_TTP" /* Translation(1), Static (0) */ -#define ASL_RESNAME_XFERTYPE "_SIz" /* 8(0), 8_and16(1), 16(2) */ +#define ACPI_RESTAG_ADDRESS "_ADR" +#define ACPI_RESTAG_ALIGNMENT "_ALN" +#define ACPI_RESTAG_ADDRESSSPACE "_ASI" +#define ACPI_RESTAG_ACCESSSIZE "_ASZ" +#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" +#define ACPI_RESTAG_BASEADDRESS "_BAS" +#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ +#define ACPI_RESTAG_DECODE "_DEC" +#define ACPI_RESTAG_DMA "_DMA" +#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ +#define ACPI_RESTAG_GRANULARITY "_GRA" +#define ACPI_RESTAG_INTERRUPT "_INT" +#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */ +#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */ +#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ +#define ACPI_RESTAG_LENGTH "_LEN" +#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ +#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ +#define ACPI_RESTAG_MAXADDR "_MAX" +#define ACPI_RESTAG_MINADDR "_MIN" +#define ACPI_RESTAG_MAXTYPE "_MAF" +#define ACPI_RESTAG_MINTYPE "_MIF" +#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" +#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" +#define ACPI_RESTAG_RANGETYPE "_RNG" +#define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */ +#define ACPI_RESTAG_TRANSLATION "_TRA" +#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ +#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ +#define ACPI_RESTAG_XFERTYPE "_SIz" /* 8(0), 8_and16(1), 16(2) */ /* Default sizes for "small" resource descriptors */ @@ -266,6 +266,7 @@ #pragma pack() union aml_resource { /* Descriptor headers */ + u8 descriptor_type; struct aml_resource_small_header small_header; struct aml_resource_large_header large_header; diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h index 3fa81d5..c5472be 100644 --- a/include/acpi/pdc_intel.h +++ b/include/acpi/pdc_intel.h @@ -18,6 +18,11 @@ #define ACPI_PDC_EST_CAPABILITY_SMP (ACP ACPI_PDC_C_C1_HALT | \ ACPI_PDC_P_FFH) +#define ACPI_PDC_EST_CAPABILITY_SWSMP (ACPI_PDC_SMP_C1PT | \ + ACPI_PDC_C_C1_HALT | \ + ACPI_PDC_SMP_P_SWCOORD | \ + ACPI_PDC_P_FFH) + #define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \ ACPI_PDC_SMP_C1PT | \ ACPI_PDC_C_C1_HALT) diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 223ec64..d53642d 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -59,6 +59,7 @@ #endif #define ACPI_APPLICATION #define ACPI_DISASSEMBLER #define ACPI_NO_METHOD_EXECUTION +#define ACPI_LARGE_NAMESPACE_NODE #endif #ifdef ACPI_EXEC_APP @@ -76,6 +77,7 @@ #define ACPI_DEBUG_OUTPUT #define ACPI_APPLICATION #define ACPI_DISASSEMBLER #define ACPI_CONSTANT_EVAL_ONLY +#define ACPI_LARGE_NAMESPACE_NODE #endif #ifdef ACPI_APPLICATION @@ -165,10 +167,10 @@ #endif /* * Memory allocation tracking. Used only if - * 1) This is the debug version + * 1) This is the Debugger * 2) This is NOT a 16-bit version of the code (not enough real-mode memory) */ -#ifdef ACPI_DEBUG_OUTPUT +#ifdef ACPI_DEBUGGER #if ACPI_MACHINE_WIDTH != 16 #define ACPI_DBG_TRACK_ALLOCATIONS #endif @@ -271,8 +273,8 @@ #endif /* _VALIST */ /* * Storage alignment properties */ -#define _AUPBND (sizeof (acpi_native_uint) - 1) -#define _ADNBND (sizeof (acpi_native_uint) - 1) +#define _AUPBND (sizeof (acpi_native_int) - 1) +#define _ADNBND (sizeof (acpi_native_int) - 1) /* * Variable argument list macro definitions diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index 2e6d545..ef6ec09 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -52,27 +52,22 @@ #ifdef __KERNEL__ #include #include #include +#include #include #include #include #include #include +#include -#define strtoul simple_strtoul - -#define ACPI_MACHINE_WIDTH BITS_PER_LONG - -/* Type(s) for the OSL */ +/* Host-dependent types and defines */ -#ifdef ACPI_USE_LOCAL_CACHE -#define acpi_cache_t struct acpi_memory_list -#else -#include -#define acpi_cache_t kmem_cache_t -#endif +#define ACPI_MACHINE_WIDTH BITS_PER_LONG +#define acpi_cache_t kmem_cache_t +#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); +#define strtoul simple_strtoul /* Full namespace pathname length limit - arbitrary */ - #define ACPI_PATHNAME_MAX 256 #else /* !__KERNEL__ */ @@ -104,4 +99,13 @@ #include "acgcc.h" #define acpi_cpu_flags unsigned long +#define acpi_thread_id u32 + +static inline acpi_thread_id acpi_os_get_thread_id(void) { return 0; } + +#define ACPI_ALLOCATE(a) kmalloc((a), GFP_KERNEL) +#define ACPI_ALLOCATE_ZEROED(a) kzalloc((a), GFP_KERNEL) +#define ACPI_FREE(a) kfree(a) +#define ACPI_MEM_TRACKING(a) + #endif /* __ACLINUX_H__ */ diff --git a/include/acpi/processor.h b/include/acpi/processor.h index badf027..0c46d1b 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -3,6 +3,7 @@ #define __ACPI_PROCESSOR_H #include #include +#include #include @@ -18,6 +19,17 @@ #define ACPI_PROCESSOR_MAX_DUTY_WIDTH 4 #define ACPI_PDC_REVISION_ID 0x1 +#define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */ +#define ACPI_PSD_REV0_ENTRIES 5 + +/* + * Types of coordination defined in ACPI 3.0. Same macros can be used across + * P, C and T states + */ +#define DOMAIN_COORD_TYPE_SW_ALL 0xfc +#define DOMAIN_COORD_TYPE_SW_ANY 0xfd +#define DOMAIN_COORD_TYPE_HW_ALL 0xfe + /* Power Management */ struct acpi_processor_cx; @@ -66,6 +78,14 @@ struct acpi_processor_power { /* Performance Management */ +struct acpi_psd_package { + acpi_integer num_entries; + acpi_integer revision; + acpi_integer domain; + acpi_integer coord_type; + acpi_integer num_processors; +} __attribute__ ((packed)); + struct acpi_pct_register { u8 descriptor; u16 length; @@ -92,7 +112,9 @@ struct acpi_processor_performance { struct acpi_pct_register status_register; unsigned int state_count; struct acpi_processor_px *states; - + struct acpi_psd_package domain_info; + cpumask_t shared_cpu_map; + unsigned int shared_type; }; /* Throttling Control */ @@ -161,6 +183,9 @@ struct acpi_processor_errata { } piix4; }; +extern int acpi_processor_preregister_performance( + struct acpi_processor_performance **performance); + extern int acpi_processor_register_performance(struct acpi_processor_performance *performance, unsigned int cpu); extern void acpi_processor_unregister_performance(struct diff --git a/include/asm-i386/apicdef.h b/include/asm-i386/apicdef.h index 5e4a35a..9f69953 100644 --- a/include/asm-i386/apicdef.h +++ b/include/asm-i386/apicdef.h @@ -121,7 +121,6 @@ #define MAX_IO_APICS 64 */ #define u32 unsigned int -#define lapic ((volatile struct local_apic *)APIC_BASE) struct local_apic { diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h index aa1c7b2..2c95a31 100644 --- a/include/asm-x86_64/acpi.h +++ b/include/asm-x86_64/acpi.h @@ -162,6 +162,8 @@ extern int acpi_pci_disabled; extern u8 x86_acpiid_to_apicid[]; +#define ARCH_HAS_POWER_INIT 1 + extern int acpi_skip_timer_override; #endif /*__KERNEL__*/ diff --git a/include/asm-x86_64/apicdef.h b/include/asm-x86_64/apicdef.h index 5a48e9b..1dd4006 100644 --- a/include/asm-x86_64/apicdef.h +++ b/include/asm-x86_64/apicdef.h @@ -137,8 +137,6 @@ #define NUM_APIC_CLUSTERS ((BAD_APICID + */ #define u32 unsigned int -#define lapic ((volatile struct local_apic *)APIC_BASE) - struct local_apic { /*000*/ struct { u32 __reserved[4]; } __reserved_01; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 17866d7..f7d9883 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -73,6 +73,8 @@ struct cpufreq_real_policy { struct cpufreq_policy { cpumask_t cpus; /* affected CPUs */ + unsigned int shared_type; /* ANY or ALL affected CPUs + should set cpufreq */ unsigned int cpu; /* cpu nr of registered CPU */ struct cpufreq_cpuinfo cpuinfo;/* see above */ @@ -99,6 +101,8 @@ #define CPUFREQ_ADJUST (0) #define CPUFREQ_INCOMPATIBLE (1) #define CPUFREQ_NOTIFY (2) +#define CPUFREQ_SHARED_TYPE_ALL (0) /* All dependent CPUs should set freq */ +#define CPUFREQ_SHARED_TYPE_ANY (1) /* Freq can be set from any dependent CPU */ /******************** cpufreq transition notifiers *******************/