aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
committerLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
commit3d5271f9883cba7b54762bc4fe027d4172f06db7 (patch)
treeab8a881a14478598a0c8bda0d26c62cdccfffd6d /drivers/acpi
parent378b2556f4e09fa6f87ff0cb5c4395ff28257d02 (diff)
parent9115a6c787596e687df03010d97fccc5e0762506 (diff)
Pull release into acpica branch
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/acpi_memhotplug.c5
-rw-r--r--drivers/acpi/bus.c3
-rw-r--r--drivers/acpi/container.c6
-rw-r--r--drivers/acpi/event.c5
-rw-r--r--drivers/acpi/glue.c9
-rw-r--r--drivers/acpi/osl.c6
-rw-r--r--drivers/acpi/processor_core.c15
-rw-r--r--drivers/acpi/processor_idle.c99
-rw-r--r--drivers/acpi/processor_thermal.c38
-rw-r--r--drivers/acpi/resources/rsinfo.c228
-rw-r--r--drivers/acpi/scan.c8
-rw-r--r--drivers/acpi/sleep/main.c8
-rw-r--r--drivers/acpi/thermal.c163
-rw-r--r--drivers/acpi/video.c14
16 files changed, 453 insertions, 157 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index fe1e8126fbae..fce21c257523 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -197,7 +197,6 @@ config ACPI_ASUS
197config ACPI_IBM 197config ACPI_IBM
198 tristate "IBM ThinkPad Laptop Extras" 198 tristate "IBM ThinkPad Laptop Extras"
199 depends on X86 199 depends on X86
200 default y
201 ---help--- 200 ---help---
202 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds 201 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds
203 support for Fn-Fx key combinations, Bluetooth control, video 202 support for Fn-Fx key combinations, Bluetooth control, video
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index a18243488c66..5984b4f6715a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -16,7 +16,7 @@ EXTRA_CFLAGS += $(ACPI_CFLAGS)
16# ACPI Boot-Time Table Parsing 16# ACPI Boot-Time Table Parsing
17# 17#
18obj-y += tables.o 18obj-y += tables.o
19obj-y += blacklist.o 19obj-$(CONFIG_X86) += blacklist.o
20 20
21# 21#
22# ACPI Core Subsystem (Interpreter) 22# ACPI Core Subsystem (Interpreter)
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 01a1bd239263..2143609d2936 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -200,8 +200,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
200 * Note: Assume that this function returns zero on success 200 * Note: Assume that this function returns zero on success
201 */ 201 */
202 result = add_memory(mem_device->start_addr, 202 result = add_memory(mem_device->start_addr,
203 (mem_device->end_addr - mem_device->start_addr) + 1, 203 (mem_device->end_addr - mem_device->start_addr) + 1);
204 mem_device->read_write_attribute);
205 if (result) { 204 if (result) {
206 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n")); 205 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n"));
207 mem_device->state = MEMORY_INVALID_STATE; 206 mem_device->state = MEMORY_INVALID_STATE;
@@ -259,7 +258,7 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
259 * Ask the VM to offline this memory range. 258 * Ask the VM to offline this memory range.
260 * Note: Assume that this function returns zero on success 259 * Note: Assume that this function returns zero on success
261 */ 260 */
262 result = remove_memory(start, len, attr); 261 result = remove_memory(start, len);
263 if (result) { 262 if (result) {
264 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Hot-Remove failed.\n")); 263 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Hot-Remove failed.\n"));
265 return_VALUE(result); 264 return_VALUE(result);
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 6a4da417c16b..606f8733a776 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -28,6 +28,7 @@
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/pm.h> 30#include <linux/pm.h>
31#include <linux/pm_legacy.h>
31#include <linux/device.h> 32#include <linux/device.h>
32#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
33#ifdef CONFIG_X86 34#ifdef CONFIG_X86
@@ -754,7 +755,7 @@ static int __init acpi_init(void)
754 result = acpi_bus_init(); 755 result = acpi_bus_init();
755 756
756 if (!result) { 757 if (!result) {
757#ifdef CONFIG_PM 758#ifdef CONFIG_PM_LEGACY
758 if (!PM_IS_ACTIVE()) 759 if (!PM_IS_ACTIVE())
759 pm_active = 1; 760 pm_active = 1;
760 else { 761 else {
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 10dd695a1dd9..27ec12c1fab0 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -118,11 +118,9 @@ static int acpi_container_remove(struct acpi_device *device, int type)
118{ 118{
119 acpi_status status = AE_OK; 119 acpi_status status = AE_OK;
120 struct acpi_container *pc = NULL; 120 struct acpi_container *pc = NULL;
121 pc = (struct acpi_container *)acpi_driver_data(device);
122
123 if (pc)
124 kfree(pc);
125 121
122 pc = (struct acpi_container *)acpi_driver_data(device);
123 kfree(pc);
126 return status; 124 return status;
127} 125}
128 126
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index bfa8b76de403..2dbb1b0f11d5 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -58,9 +58,8 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
58 return_VALUE(-EAGAIN); 58 return_VALUE(-EAGAIN);
59 59
60 result = acpi_bus_receive_event(&event); 60 result = acpi_bus_receive_event(&event);
61 if (result) { 61 if (result)
62 return_VALUE(-EIO); 62 return_VALUE(result);
63 }
64 63
65 chars_remaining = sprintf(str, "%s %s %08x %08x\n", 64 chars_remaining = sprintf(str, "%s %s %08x %08x\n",
66 event.device_class ? event. 65 event.device_class ? event.
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 00aeb4801d7a..fcb881db5b0b 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -96,7 +96,7 @@ struct acpi_find_pci_root {
96static acpi_status 96static acpi_status
97do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) 97do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
98{ 98{
99 int *busnr = (int *)data; 99 unsigned long *busnr = (unsigned long *)data;
100 struct acpi_resource_address64 address; 100 struct acpi_resource_address64 address;
101 101
102 if (resource->type != ACPI_RSTYPE_ADDRESS16 && 102 if (resource->type != ACPI_RSTYPE_ADDRESS16 &&
@@ -115,13 +115,13 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
115static int get_root_bridge_busnr(acpi_handle handle) 115static int get_root_bridge_busnr(acpi_handle handle)
116{ 116{
117 acpi_status status; 117 acpi_status status;
118 int bus, bbn; 118 unsigned long bus, bbn;
119 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 119 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
120 120
121 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 121 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
122 122
123 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL, 123 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL,
124 (unsigned long *)&bbn); 124 &bbn);
125 if (status == AE_NOT_FOUND) { 125 if (status == AE_NOT_FOUND) {
126 /* Assume bus = 0 */ 126 /* Assume bus = 0 */
127 printk(KERN_INFO PREFIX 127 printk(KERN_INFO PREFIX
@@ -153,7 +153,7 @@ static int get_root_bridge_busnr(acpi_handle handle)
153 } 153 }
154 exit: 154 exit:
155 acpi_os_free(buffer.pointer); 155 acpi_os_free(buffer.pointer);
156 return bbn; 156 return (int)bbn;
157} 157}
158 158
159static acpi_status 159static acpi_status
@@ -203,6 +203,7 @@ acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
203 acpi_get_devices(PCI_ROOT_HID_STRING, find_pci_rootbridge, &find, NULL); 203 acpi_get_devices(PCI_ROOT_HID_STRING, find_pci_rootbridge, &find, NULL);
204 return find.handle; 204 return find.handle;
205} 205}
206EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle);
206 207
207/* Get device's handler per its address under its parent */ 208/* Get device's handler per its address under its parent */
208struct acpi_find_child { 209struct acpi_find_child {
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index d528c750a380..e3cd0b16031a 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -313,8 +313,7 @@ acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
313 313
314void acpi_os_sleep(acpi_integer ms) 314void acpi_os_sleep(acpi_integer ms)
315{ 315{
316 current->state = TASK_INTERRUPTIBLE; 316 schedule_timeout_interruptible(msecs_to_jiffies(ms));
317 schedule_timeout(((signed long)ms * HZ) / 1000);
318} 317}
319 318
320EXPORT_SYMBOL(acpi_os_sleep); 319EXPORT_SYMBOL(acpi_os_sleep);
@@ -838,8 +837,7 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
838 837
839 ret = down_trylock(sem); 838 ret = down_trylock(sem);
840 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { 839 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
841 current->state = TASK_INTERRUPTIBLE; 840 schedule_timeout_interruptible(1);
842 schedule_timeout(1);
843 ret = down_trylock(sem); 841 ret = down_trylock(sem);
844 } 842 }
845 843
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 421792562642..0c561c571f29 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -543,6 +543,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
543 return_VALUE(0); 543 return_VALUE(0);
544} 544}
545 545
546static void *processor_device_array[NR_CPUS];
547
546static int acpi_processor_start(struct acpi_device *device) 548static int acpi_processor_start(struct acpi_device *device)
547{ 549{
548 int result = 0; 550 int result = 0;
@@ -561,6 +563,19 @@ static int acpi_processor_start(struct acpi_device *device)
561 563
562 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); 564 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
563 565
566 /*
567 * Buggy BIOS check
568 * ACPI id of processors can be reported wrongly by the BIOS.
569 * Don't trust it blindly
570 */
571 if (processor_device_array[pr->id] != NULL &&
572 processor_device_array[pr->id] != (void *)device) {
573 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "BIOS reporting wrong ACPI id"
574 "for the processor\n"));
575 return_VALUE(-ENODEV);
576 }
577 processor_device_array[pr->id] = (void *)device;
578
564 processors[pr->id] = pr; 579 processors[pr->id] = pr;
565 580
566 result = acpi_processor_add_fs(device); 581 result = acpi_processor_add_fs(device);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 26a3a4016115..807b0df308f1 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -37,6 +37,7 @@
37#include <linux/acpi.h> 37#include <linux/acpi.h>
38#include <linux/dmi.h> 38#include <linux/dmi.h>
39#include <linux/moduleparam.h> 39#include <linux/moduleparam.h>
40#include <linux/sched.h> /* need_resched() */
40 41
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
@@ -166,6 +167,15 @@ acpi_processor_power_activate(struct acpi_processor *pr,
166 return; 167 return;
167} 168}
168 169
170static void acpi_safe_halt(void)
171{
172 clear_thread_flag(TIF_POLLING_NRFLAG);
173 smp_mb__after_clear_bit();
174 if (!need_resched())
175 safe_halt();
176 set_thread_flag(TIF_POLLING_NRFLAG);
177}
178
169static atomic_t c3_cpu_count; 179static atomic_t c3_cpu_count;
170 180
171static void acpi_processor_idle(void) 181static void acpi_processor_idle(void)
@@ -176,7 +186,7 @@ static void acpi_processor_idle(void)
176 int sleep_ticks = 0; 186 int sleep_ticks = 0;
177 u32 t1, t2 = 0; 187 u32 t1, t2 = 0;
178 188
179 pr = processors[raw_smp_processor_id()]; 189 pr = processors[smp_processor_id()];
180 if (!pr) 190 if (!pr)
181 return; 191 return;
182 192
@@ -196,8 +206,13 @@ static void acpi_processor_idle(void)
196 } 206 }
197 207
198 cx = pr->power.state; 208 cx = pr->power.state;
199 if (!cx) 209 if (!cx) {
200 goto easy_out; 210 if (pm_idle_save)
211 pm_idle_save();
212 else
213 acpi_safe_halt();
214 return;
215 }
201 216
202 /* 217 /*
203 * Check BM Activity 218 * Check BM Activity
@@ -259,6 +274,17 @@ static void acpi_processor_idle(void)
259 } 274 }
260 } 275 }
261 276
277#ifdef CONFIG_HOTPLUG_CPU
278 /*
279 * Check for P_LVL2_UP flag before entering C2 and above on
280 * an SMP system. We do it here instead of doing it at _CST/P_LVL
281 * detection phase, to work cleanly with logical CPU hotplug.
282 */
283 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
284 !pr->flags.has_cst && !acpi_fadt.plvl2_up)
285 cx = &pr->power.states[ACPI_STATE_C1];
286#endif
287
262 cx->usage++; 288 cx->usage++;
263 289
264 /* 290 /*
@@ -266,6 +292,16 @@ static void acpi_processor_idle(void)
266 * ------ 292 * ------
267 * Invoke the current Cx state to put the processor to sleep. 293 * Invoke the current Cx state to put the processor to sleep.
268 */ 294 */
295 if (cx->type == ACPI_STATE_C2 || cx->type == ACPI_STATE_C3) {
296 clear_thread_flag(TIF_POLLING_NRFLAG);
297 smp_mb__after_clear_bit();
298 if (need_resched()) {
299 set_thread_flag(TIF_POLLING_NRFLAG);
300 local_irq_enable();
301 return;
302 }
303 }
304
269 switch (cx->type) { 305 switch (cx->type) {
270 306
271 case ACPI_STATE_C1: 307 case ACPI_STATE_C1:
@@ -277,7 +313,8 @@ static void acpi_processor_idle(void)
277 if (pm_idle_save) 313 if (pm_idle_save)
278 pm_idle_save(); 314 pm_idle_save();
279 else 315 else
280 safe_halt(); 316 acpi_safe_halt();
317
281 /* 318 /*
282 * TBD: Can't get time duration while in C1, as resumes 319 * TBD: Can't get time duration while in C1, as resumes
283 * go to an ISR rather than here. Need to instrument 320 * go to an ISR rather than here. Need to instrument
@@ -297,6 +334,7 @@ static void acpi_processor_idle(void)
297 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 334 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
298 /* Re-enable interrupts */ 335 /* Re-enable interrupts */
299 local_irq_enable(); 336 local_irq_enable();
337 set_thread_flag(TIF_POLLING_NRFLAG);
300 /* Compute time (ticks) that we were actually asleep */ 338 /* Compute time (ticks) that we were actually asleep */
301 sleep_ticks = 339 sleep_ticks =
302 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; 340 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
@@ -336,6 +374,7 @@ static void acpi_processor_idle(void)
336 374
337 /* Re-enable interrupts */ 375 /* Re-enable interrupts */
338 local_irq_enable(); 376 local_irq_enable();
377 set_thread_flag(TIF_POLLING_NRFLAG);
339 /* Compute time (ticks) that we were actually asleep */ 378 /* Compute time (ticks) that we were actually asleep */
340 sleep_ticks = 379 sleep_ticks =
341 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; 380 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
@@ -348,6 +387,15 @@ static void acpi_processor_idle(void)
348 387
349 next_state = pr->power.state; 388 next_state = pr->power.state;
350 389
390#ifdef CONFIG_HOTPLUG_CPU
391 /* Don't do promotion/demotion */
392 if ((cx->type == ACPI_STATE_C1) && (num_online_cpus() > 1) &&
393 !pr->flags.has_cst && !acpi_fadt.plvl2_up) {
394 next_state = cx;
395 goto end;
396 }
397#endif
398
351 /* 399 /*
352 * Promotion? 400 * Promotion?
353 * ---------- 401 * ----------
@@ -413,16 +461,6 @@ static void acpi_processor_idle(void)
413 */ 461 */
414 if (next_state != pr->power.state) 462 if (next_state != pr->power.state)
415 acpi_processor_power_activate(pr, next_state); 463 acpi_processor_power_activate(pr, next_state);
416
417 return;
418
419 easy_out:
420 /* do C1 instead of busy loop */
421 if (pm_idle_save)
422 pm_idle_save();
423 else
424 safe_halt();
425 return;
426} 464}
427 465
428static int acpi_processor_set_power_policy(struct acpi_processor *pr) 466static int acpi_processor_set_power_policy(struct acpi_processor *pr)
@@ -504,8 +542,6 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
504 542
505static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) 543static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
506{ 544{
507 int i;
508
509 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt"); 545 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt");
510 546
511 if (!pr) 547 if (!pr)
@@ -514,8 +550,7 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
514 if (!pr->pblk) 550 if (!pr->pblk)
515 return_VALUE(-ENODEV); 551 return_VALUE(-ENODEV);
516 552
517 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 553 memset(pr->power.states, 0, sizeof(pr->power.states));
518 memset(pr->power.states, 0, sizeof(struct acpi_processor_cx));
519 554
520 /* if info is obtained from pblk/fadt, type equals state */ 555 /* if info is obtained from pblk/fadt, type equals state */
521 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 556 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
@@ -527,6 +562,15 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
527 pr->power.states[ACPI_STATE_C0].valid = 1; 562 pr->power.states[ACPI_STATE_C0].valid = 1;
528 pr->power.states[ACPI_STATE_C1].valid = 1; 563 pr->power.states[ACPI_STATE_C1].valid = 1;
529 564
565#ifndef CONFIG_HOTPLUG_CPU
566 /*
567 * Check for P_LVL2_UP flag before entering C2 and above on
568 * an SMP system.
569 */
570 if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up)
571 return_VALUE(-ENODEV);
572#endif
573
530 /* determine C2 and C3 address from pblk */ 574 /* determine C2 and C3 address from pblk */
531 pr->power.states[ACPI_STATE_C2].address = pr->pblk + 4; 575 pr->power.states[ACPI_STATE_C2].address = pr->pblk + 4;
532 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5; 576 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5;
@@ -545,13 +589,9 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
545 589
546static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) 590static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
547{ 591{
548 int i;
549
550 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); 592 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
551 593
552 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 594 memset(pr->power.states, 0, sizeof(pr->power.states));
553 memset(&(pr->power.states[i]), 0,
554 sizeof(struct acpi_processor_cx));
555 595
556 /* if info is obtained from pblk/fadt, type equals state */ 596 /* if info is obtained from pblk/fadt, type equals state */
557 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 597 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
@@ -687,7 +727,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
687 727
688 /* Validate number of power states discovered */ 728 /* Validate number of power states discovered */
689 if (pr->power.count < 2) 729 if (pr->power.count < 2)
690 status = -ENODEV; 730 status = -EFAULT;
691 731
692 end: 732 end:
693 acpi_os_free(buffer.pointer); 733 acpi_os_free(buffer.pointer);
@@ -838,11 +878,11 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
838 * this function */ 878 * this function */
839 879
840 result = acpi_processor_get_power_info_cst(pr); 880 result = acpi_processor_get_power_info_cst(pr);
841 if ((result) || (acpi_processor_power_verify(pr) < 2)) { 881 if (result == -ENODEV)
842 result = acpi_processor_get_power_info_fadt(pr); 882 result = acpi_processor_get_power_info_fadt(pr);
843 if ((result) || (acpi_processor_power_verify(pr) < 2)) 883
844 result = acpi_processor_get_power_info_default_c1(pr); 884 if ((result) || (acpi_processor_power_verify(pr) < 2))
845 } 885 result = acpi_processor_get_power_info_default_c1(pr);
846 886
847 /* 887 /*
848 * Set Default Policy 888 * Set Default Policy
@@ -863,7 +903,8 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
863 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 903 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
864 if (pr->power.states[i].valid) { 904 if (pr->power.states[i].valid) {
865 pr->power.count = i; 905 pr->power.count = i;
866 pr->flags.power = 1; 906 if (pr->power.states[i].type >= ACPI_STATE_C2)
907 pr->flags.power = 1;
867 } 908 }
868 } 909 }
869 910
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 37528c3b64b0..f37584015324 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -101,9 +101,7 @@ static unsigned int acpi_thermal_cpufreq_is_init = 0;
101static int cpu_has_cpufreq(unsigned int cpu) 101static int cpu_has_cpufreq(unsigned int cpu)
102{ 102{
103 struct cpufreq_policy policy; 103 struct cpufreq_policy policy;
104 if (!acpi_thermal_cpufreq_is_init) 104 if (!acpi_thermal_cpufreq_is_init || cpufreq_get_policy(&policy, cpu))
105 return -ENODEV;
106 if (!cpufreq_get_policy(&policy, cpu))
107 return -ENODEV; 105 return -ENODEV;
108 return 0; 106 return 0;
109} 107}
@@ -127,13 +125,13 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
127 if (!cpu_has_cpufreq(cpu)) 125 if (!cpu_has_cpufreq(cpu))
128 return -ENODEV; 126 return -ENODEV;
129 127
130 if (cpufreq_thermal_reduction_pctg[cpu] >= 20) { 128 if (cpufreq_thermal_reduction_pctg[cpu] > 20)
131 cpufreq_thermal_reduction_pctg[cpu] -= 20; 129 cpufreq_thermal_reduction_pctg[cpu] -= 20;
132 cpufreq_update_policy(cpu); 130 else
133 return 0; 131 cpufreq_thermal_reduction_pctg[cpu] = 0;
134 } 132 cpufreq_update_policy(cpu);
135 133 /* We reached max freq again and can leave passive mode */
136 return -ERANGE; 134 return !cpufreq_thermal_reduction_pctg[cpu];
137} 135}
138 136
139static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, 137static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
@@ -200,7 +198,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
200 int result = 0; 198 int result = 0;
201 struct acpi_processor *pr = NULL; 199 struct acpi_processor *pr = NULL;
202 struct acpi_device *device = NULL; 200 struct acpi_device *device = NULL;
203 int tx = 0; 201 int tx = 0, max_tx_px = 0;
204 202
205 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit"); 203 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
206 204
@@ -259,19 +257,27 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
259 /* if going down: T-states first, P-states later */ 257 /* if going down: T-states first, P-states later */
260 258
261 if (pr->flags.throttling) { 259 if (pr->flags.throttling) {
262 if (tx == 0) 260 if (tx == 0) {
261 max_tx_px = 1;
263 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 262 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
264 "At minimum throttling state\n")); 263 "At minimum throttling state\n"));
265 else { 264 } else {
266 tx--; 265 tx--;
267 goto end; 266 goto end;
268 } 267 }
269 } 268 }
270 269
271 result = acpi_thermal_cpufreq_decrease(pr->id); 270 result = acpi_thermal_cpufreq_decrease(pr->id);
272 if (result == -ERANGE) 271 if (result) {
272 /*
273 * We only could get -ERANGE, 1 or 0.
274 * In the first two cases we reached max freq again.
275 */
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 276 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
274 "At minimum performance state\n")); 277 "At minimum performance state\n"));
278 max_tx_px = 1;
279 } else
280 max_tx_px = 0;
275 281
276 break; 282 break;
277 } 283 }
@@ -290,8 +296,10 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
290 pr->limit.thermal.px, pr->limit.thermal.tx)); 296 pr->limit.thermal.px, pr->limit.thermal.tx));
291 } else 297 } else
292 result = 0; 298 result = 0;
293 299 if (max_tx_px)
294 return_VALUE(result); 300 return_VALUE(1);
301 else
302 return_VALUE(result);
295} 303}
296 304
297int acpi_processor_get_limit_info(struct acpi_processor *pr) 305int acpi_processor_get_limit_info(struct acpi_processor *pr)
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c
new file mode 100644
index 000000000000..49a5f81c727b
--- /dev/null
+++ b/drivers/acpi/resources/rsinfo.c
@@ -0,0 +1,228 @@
1/*******************************************************************************
2 *
3 * Module Name: rsinfo - Dispatch and Info tables
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsinfo")
49
50/*
51 * Resource dispatch and information tables. Any new resource types (either
52 * Large or Small) must be reflected in each of these tables, so they are here
53 * in one place.
54 *
55 * The tables for Large descriptors are indexed by bits 6:0 of the AML
56 * descriptor type byte. The tables for Small descriptors are indexed by
57 * bits 6:3 of the descriptor byte. The tables for internal resource
58 * descriptors are indexed by the acpi_resource_type field.
59 */
60/* Dispatch table for resource-to-AML (Set Resource) conversion functions */
61ACPI_SET_RESOURCE_HANDLER acpi_gbl_set_resource_dispatch[] = {
62 acpi_rs_set_irq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
63 acpi_rs_set_dma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */
64 acpi_rs_set_start_dpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
65 acpi_rs_set_end_dpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
66 acpi_rs_set_io, /* 0x04, ACPI_RESOURCE_TYPE_IO */
67 acpi_rs_set_fixed_io, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
68 acpi_rs_set_vendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
69 acpi_rs_set_end_tag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
70 acpi_rs_set_memory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
71 acpi_rs_set_memory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
72 acpi_rs_set_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
73 acpi_rs_set_address16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
74 acpi_rs_set_address32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
75 acpi_rs_set_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
76 acpi_rs_set_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
77 acpi_rs_set_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
78 acpi_rs_set_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
79};
80
81/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
82
83ACPI_GET_RESOURCE_HANDLER acpi_gbl_sm_get_resource_dispatch[] = {
84 NULL, /* 0x00, Reserved */
85 NULL, /* 0x01, Reserved */
86 NULL, /* 0x02, Reserved */
87 NULL, /* 0x03, Reserved */
88 acpi_rs_get_irq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */
89 acpi_rs_get_dma, /* 0x05, ACPI_RESOURCE_NAME_DMA */
90 acpi_rs_get_start_dpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
91 acpi_rs_get_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
92 acpi_rs_get_io, /* 0x08, ACPI_RESOURCE_NAME_IO */
93 acpi_rs_get_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
94 NULL, /* 0x0A, Reserved */
95 NULL, /* 0x0B, Reserved */
96 NULL, /* 0x0C, Reserved */
97 NULL, /* 0x0D, Reserved */
98 acpi_rs_get_vendor, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
99 acpi_rs_get_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
100};
101
102ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[] = {
103 NULL, /* 0x00, Reserved */
104 acpi_rs_get_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
105 acpi_rs_get_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
106 NULL, /* 0x03, Reserved */
107 acpi_rs_get_vendor, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
108 acpi_rs_get_memory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
109 acpi_rs_get_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
110 acpi_rs_get_address32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
111 acpi_rs_get_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
112 acpi_rs_get_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
113 acpi_rs_get_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
114 acpi_rs_get_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
115};
116
117#ifdef ACPI_FUTURE_USAGE
118#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
119
120/* Dispatch table for resource dump functions */
121
122ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[] = {
123 acpi_rs_dump_irq, /* ACPI_RESOURCE_TYPE_IRQ */
124 acpi_rs_dump_dma, /* ACPI_RESOURCE_TYPE_DMA */
125 acpi_rs_dump_start_dpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
126 acpi_rs_dump_end_dpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
127 acpi_rs_dump_io, /* ACPI_RESOURCE_TYPE_IO */
128 acpi_rs_dump_fixed_io, /* ACPI_RESOURCE_TYPE_FIXED_IO */
129 acpi_rs_dump_vendor, /* ACPI_RESOURCE_TYPE_VENDOR */
130 acpi_rs_dump_end_tag, /* ACPI_RESOURCE_TYPE_END_TAG */
131 acpi_rs_dump_memory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */
132 acpi_rs_dump_memory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */
133 acpi_rs_dump_fixed_memory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
134 acpi_rs_dump_address16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */
135 acpi_rs_dump_address32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */
136 acpi_rs_dump_address64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
137 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
138 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
139 acpi_rs_dump_generic_reg /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
140};
141#endif
142#endif /* ACPI_FUTURE_USAGE */
143
144/*
145 * Base sizes for external AML resource descriptors, indexed by internal type.
146 * Includes size of the descriptor header (1 byte for small descriptors,
147 * 3 bytes for large descriptors)
148 */
149u8 acpi_gbl_aml_resource_sizes[] = {
150 sizeof(struct aml_resource_irq), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
151 sizeof(struct aml_resource_dma), /* ACPI_RESOURCE_TYPE_DMA */
152 sizeof(struct aml_resource_start_dependent), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
153 sizeof(struct aml_resource_end_dependent), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
154 sizeof(struct aml_resource_io), /* ACPI_RESOURCE_TYPE_IO */
155 sizeof(struct aml_resource_fixed_io), /* ACPI_RESOURCE_TYPE_FIXED_IO */
156 sizeof(struct aml_resource_vendor_small), /* ACPI_RESOURCE_TYPE_VENDOR */
157 sizeof(struct aml_resource_end_tag), /* ACPI_RESOURCE_TYPE_END_TAG */
158 sizeof(struct aml_resource_memory24), /* ACPI_RESOURCE_TYPE_MEMORY24 */
159 sizeof(struct aml_resource_memory32), /* ACPI_RESOURCE_TYPE_MEMORY32 */
160 sizeof(struct aml_resource_fixed_memory32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
161 sizeof(struct aml_resource_address16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */
162 sizeof(struct aml_resource_address32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */
163 sizeof(struct aml_resource_address64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
164 sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
165 sizeof(struct aml_resource_extended_irq), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
166 sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
167};
168
169/* Macros used in the tables below */
170
171#define ACPI_RLARGE(r) sizeof (r) - sizeof (struct aml_resource_large_header)
172#define ACPI_RSMALL(r) sizeof (r) - sizeof (struct aml_resource_small_header)
173
174/*
175 * Base sizes of resource descriptors, both the AML stream resource length
176 * (minus size of header and length fields),and the size of the internal
177 * struct representation.
178 */
179struct acpi_resource_info acpi_gbl_sm_resource_info[] = {
180 {0, 0, 0},
181 {0, 0, 0},
182 {0, 0, 0},
183 {0, 0, 0},
184 {2, ACPI_RSMALL(struct aml_resource_irq),
185 ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)},
186 {0, ACPI_RSMALL(struct aml_resource_dma),
187 ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)},
188 {2, ACPI_RSMALL(struct aml_resource_start_dependent),
189 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent)},
190 {0, ACPI_RSMALL(struct aml_resource_end_dependent),
191 ACPI_RESOURCE_LENGTH},
192 {0, ACPI_RSMALL(struct aml_resource_io),
193 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)},
194 {0, ACPI_RSMALL(struct aml_resource_fixed_io),
195 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)},
196 {0, 0, 0},
197 {0, 0, 0},
198 {0, 0, 0},
199 {0, 0, 0},
200 {1, ACPI_RSMALL(struct aml_resource_vendor_small),
201 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)},
202 {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RESOURCE_LENGTH}
203};
204
205struct acpi_resource_info acpi_gbl_lg_resource_info[] = {
206 {0, 0, 0},
207 {0, ACPI_RLARGE(struct aml_resource_memory24),
208 ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)},
209 {0, ACPI_RLARGE(struct aml_resource_generic_register),
210 ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_registerister)},
211 {0, 0, 0},
212 {1, ACPI_RLARGE(struct aml_resource_vendor_large),
213 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)},
214 {0, ACPI_RLARGE(struct aml_resource_memory32),
215 ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32)},
216 {0, ACPI_RLARGE(struct aml_resource_fixed_memory32),
217 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32)},
218 {1, ACPI_RLARGE(struct aml_resource_address32),
219 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)},
220 {1, ACPI_RLARGE(struct aml_resource_address16),
221 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)},
222 {1, ACPI_RLARGE(struct aml_resource_extended_irq),
223 ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq)},
224 {1, ACPI_RLARGE(struct aml_resource_address64),
225 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)},
226 {0, ACPI_RLARGE(struct aml_resource_extended_address64),
227 ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64)}
228};
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c6db591479de..31218e1d2a18 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -28,8 +28,7 @@ static int acpi_bus_trim(struct acpi_device *start, int rmdevice);
28static void acpi_device_release(struct kobject *kobj) 28static void acpi_device_release(struct kobject *kobj)
29{ 29{
30 struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj); 30 struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj);
31 if (dev->pnp.cid_list) 31 kfree(dev->pnp.cid_list);
32 kfree(dev->pnp.cid_list);
33 kfree(dev); 32 kfree(dev);
34} 33}
35 34
@@ -1111,14 +1110,13 @@ acpi_add_single_object(struct acpi_device **child,
1111 * 1110 *
1112 * TBD: Assumes LDM provides driver hot-plug capability. 1111 * TBD: Assumes LDM provides driver hot-plug capability.
1113 */ 1112 */
1114 result = acpi_bus_find_driver(device); 1113 acpi_bus_find_driver(device);
1115 1114
1116 end: 1115 end:
1117 if (!result) 1116 if (!result)
1118 *child = device; 1117 *child = device;
1119 else { 1118 else {
1120 if (device->pnp.cid_list) 1119 kfree(device->pnp.cid_list);
1121 kfree(device->pnp.cid_list);
1122 kfree(device); 1120 kfree(device);
1123 } 1121 }
1124 1122
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index aee50b453265..930427fc0c4b 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -158,7 +158,15 @@ int acpi_suspend(u32 acpi_state)
158 return -EINVAL; 158 return -EINVAL;
159} 159}
160 160
161static int acpi_pm_state_valid(suspend_state_t pm_state)
162{
163 u32 acpi_state = acpi_suspend_states[pm_state];
164
165 return sleep_states[acpi_state];
166}
167
161static struct pm_ops acpi_pm_ops = { 168static struct pm_ops acpi_pm_ops = {
169 .valid = acpi_pm_state_valid,
162 .prepare = acpi_pm_prepare, 170 .prepare = acpi_pm_prepare,
163 .enter = acpi_pm_enter, 171 .enter = acpi_pm_enter,
164 .finish = acpi_pm_finish, 172 .finish = acpi_pm_finish,
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index a24847c08f7f..19f3ea48475e 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -72,7 +72,7 @@
72#define _COMPONENT ACPI_THERMAL_COMPONENT 72#define _COMPONENT ACPI_THERMAL_COMPONENT
73ACPI_MODULE_NAME("acpi_thermal") 73ACPI_MODULE_NAME("acpi_thermal")
74 74
75 MODULE_AUTHOR("Paul Diefenbaugh"); 75MODULE_AUTHOR("Paul Diefenbaugh");
76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); 76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78 78
@@ -517,9 +517,9 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
517 return_VALUE(0); 517 return_VALUE(0);
518} 518}
519 519
520static int acpi_thermal_passive(struct acpi_thermal *tz) 520static void acpi_thermal_passive(struct acpi_thermal *tz)
521{ 521{
522 int result = 0; 522 int result = 1;
523 struct acpi_thermal_passive *passive = NULL; 523 struct acpi_thermal_passive *passive = NULL;
524 int trend = 0; 524 int trend = 0;
525 int i = 0; 525 int i = 0;
@@ -527,7 +527,7 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
527 ACPI_FUNCTION_TRACE("acpi_thermal_passive"); 527 ACPI_FUNCTION_TRACE("acpi_thermal_passive");
528 528
529 if (!tz || !tz->trips.passive.flags.valid) 529 if (!tz || !tz->trips.passive.flags.valid)
530 return_VALUE(-EINVAL); 530 return;
531 531
532 passive = &(tz->trips.passive); 532 passive = &(tz->trips.passive);
533 533
@@ -547,7 +547,7 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
547 trend, passive->tc1, tz->temperature, 547 trend, passive->tc1, tz->temperature,
548 tz->last_temperature, passive->tc2, 548 tz->last_temperature, passive->tc2,
549 tz->temperature, passive->temperature)); 549 tz->temperature, passive->temperature));
550 tz->trips.passive.flags.enabled = 1; 550 passive->flags.enabled = 1;
551 /* Heating up? */ 551 /* Heating up? */
552 if (trend > 0) 552 if (trend > 0)
553 for (i = 0; i < passive->devices.count; i++) 553 for (i = 0; i < passive->devices.count; i++)
@@ -556,12 +556,32 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
556 handles[i], 556 handles[i],
557 ACPI_PROCESSOR_LIMIT_INCREMENT); 557 ACPI_PROCESSOR_LIMIT_INCREMENT);
558 /* Cooling off? */ 558 /* Cooling off? */
559 else if (trend < 0) 559 else if (trend < 0) {
560 for (i = 0; i < passive->devices.count; i++) 560 for (i = 0; i < passive->devices.count; i++)
561 acpi_processor_set_thermal_limit(passive-> 561 /*
562 devices. 562 * assume that we are on highest
563 handles[i], 563 * freq/lowest thrott and can leave
564 ACPI_PROCESSOR_LIMIT_DECREMENT); 564 * passive mode, even in error case
565 */
566 if (!acpi_processor_set_thermal_limit
567 (passive->devices.handles[i],
568 ACPI_PROCESSOR_LIMIT_DECREMENT))
569 result = 0;
570 /*
571 * Leave cooling mode, even if the temp might
572 * higher than trip point This is because some
573 * machines might have long thermal polling
574 * frequencies (tsp) defined. We will fall back
575 * into passive mode in next cycle (probably quicker)
576 */
577 if (result) {
578 passive->flags.enabled = 0;
579 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
580 "Disabling passive cooling, still above threshold,"
581 " but we are cooling down\n"));
582 }
583 }
584 return;
565 } 585 }
566 586
567 /* 587 /*
@@ -571,23 +591,21 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
571 * and avoid thrashing around the passive trip point. Note that we 591 * and avoid thrashing around the passive trip point. Note that we
572 * assume symmetry. 592 * assume symmetry.
573 */ 593 */
574 else if (tz->trips.passive.flags.enabled) { 594 if (!passive->flags.enabled)
575 for (i = 0; i < passive->devices.count; i++) 595 return;
576 result = 596 for (i = 0; i < passive->devices.count; i++)
577 acpi_processor_set_thermal_limit(passive->devices. 597 if (!acpi_processor_set_thermal_limit
578 handles[i], 598 (passive->devices.handles[i],
579 ACPI_PROCESSOR_LIMIT_DECREMENT); 599 ACPI_PROCESSOR_LIMIT_DECREMENT))
580 if (result == 1) { 600 result = 0;
581 tz->trips.passive.flags.enabled = 0; 601 if (result) {
582 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 602 passive->flags.enabled = 0;
583 "Disabling passive cooling (zone is cool)\n")); 603 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
584 } 604 "Disabling passive cooling (zone is cool)\n"));
585 } 605 }
586
587 return_VALUE(0);
588} 606}
589 607
590static int acpi_thermal_active(struct acpi_thermal *tz) 608static void acpi_thermal_active(struct acpi_thermal *tz)
591{ 609{
592 int result = 0; 610 int result = 0;
593 struct acpi_thermal_active *active = NULL; 611 struct acpi_thermal_active *active = NULL;
@@ -598,74 +616,66 @@ static int acpi_thermal_active(struct acpi_thermal *tz)
598 ACPI_FUNCTION_TRACE("acpi_thermal_active"); 616 ACPI_FUNCTION_TRACE("acpi_thermal_active");
599 617
600 if (!tz) 618 if (!tz)
601 return_VALUE(-EINVAL); 619 return;
602 620
603 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { 621 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
604
605 active = &(tz->trips.active[i]); 622 active = &(tz->trips.active[i]);
606 if (!active || !active->flags.valid) 623 if (!active || !active->flags.valid)
607 break; 624 break;
608
609 /*
610 * Above Threshold?
611 * ----------------
612 * If not already enabled, turn ON all cooling devices
613 * associated with this active threshold.
614 */
615 if (tz->temperature >= active->temperature) { 625 if (tz->temperature >= active->temperature) {
626 /*
627 * Above Threshold?
628 * ----------------
629 * If not already enabled, turn ON all cooling devices
630 * associated with this active threshold.
631 */
616 if (active->temperature > maxtemp) 632 if (active->temperature > maxtemp)
617 tz->state.active_index = i, maxtemp = 633 tz->state.active_index = i;
618 active->temperature; 634 maxtemp = active->temperature;
619 if (!active->flags.enabled) { 635 if (active->flags.enabled)
620 for (j = 0; j < active->devices.count; j++) { 636 continue;
621 result =
622 acpi_bus_set_power(active->devices.
623 handles[j],
624 ACPI_STATE_D0);
625 if (result) {
626 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
627 "Unable to turn cooling device [%p] 'on'\n",
628 active->
629 devices.
630 handles[j]));
631 continue;
632 }
633 active->flags.enabled = 1;
634 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
635 "Cooling device [%p] now 'on'\n",
636 active->devices.
637 handles[j]));
638 }
639 }
640 }
641 /*
642 * Below Threshold?
643 * ----------------
644 * Turn OFF all cooling devices associated with this
645 * threshold.
646 */
647 else if (active->flags.enabled) {
648 for (j = 0; j < active->devices.count; j++) { 637 for (j = 0; j < active->devices.count; j++) {
649 result = 638 result =
650 acpi_bus_set_power(active->devices. 639 acpi_bus_set_power(active->devices.
651 handles[j], 640 handles[j],
652 ACPI_STATE_D3); 641 ACPI_STATE_D0);
653 if (result) { 642 if (result) {
654 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 643 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
655 "Unable to turn cooling device [%p] 'off'\n", 644 "Unable to turn cooling device [%p] 'on'\n",
656 active->devices. 645 active->devices.
657 handles[j])); 646 handles[j]));
658 continue; 647 continue;
659 } 648 }
660 active->flags.enabled = 0; 649 active->flags.enabled = 1;
661 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 650 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
662 "Cooling device [%p] now 'off'\n", 651 "Cooling device [%p] now 'on'\n",
663 active->devices.handles[j])); 652 active->devices.handles[j]));
664 } 653 }
654 continue;
655 }
656 if (!active->flags.enabled)
657 continue;
658 /*
659 * Below Threshold?
660 * ----------------
661 * Turn OFF all cooling devices associated with this
662 * threshold.
663 */
664 for (j = 0; j < active->devices.count; j++) {
665 result = acpi_bus_set_power(active->devices.handles[j],
666 ACPI_STATE_D3);
667 if (result) {
668 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
669 "Unable to turn cooling device [%p] 'off'\n",
670 active->devices.handles[j]));
671 continue;
672 }
673 active->flags.enabled = 0;
674 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
675 "Cooling device [%p] now 'off'\n",
676 active->devices.handles[j]));
665 } 677 }
666 } 678 }
667
668 return_VALUE(0);
669} 679}
670 680
671static void acpi_thermal_check(void *context); 681static void acpi_thermal_check(void *context);
@@ -744,15 +754,12 @@ static void acpi_thermal_check(void *data)
744 * Again, separated from the above two to allow independent policy 754 * Again, separated from the above two to allow independent policy
745 * decisions. 755 * decisions.
746 */ 756 */
747 if (tz->trips.critical.flags.enabled) 757 tz->state.critical = tz->trips.critical.flags.enabled;
748 tz->state.critical = 1; 758 tz->state.hot = tz->trips.hot.flags.enabled;
749 if (tz->trips.hot.flags.enabled) 759 tz->state.passive = tz->trips.passive.flags.enabled;
750 tz->state.hot = 1; 760 tz->state.active = 0;
751 if (tz->trips.passive.flags.enabled)
752 tz->state.passive = 1;
753 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) 761 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
754 if (tz->trips.active[i].flags.enabled) 762 tz->state.active |= tz->trips.active[i].flags.enabled;
755 tz->state.active = 1;
756 763
757 /* 764 /*
758 * Calculate Sleep Time 765 * Calculate Sleep Time
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index e383d6109ae1..d10668f14699 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -334,8 +334,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
334 return_VALUE(0); 334 return_VALUE(0);
335 335
336 err: 336 err:
337 if (buffer.pointer) 337 kfree(buffer.pointer);
338 kfree(buffer.pointer);
339 338
340 return_VALUE(status); 339 return_VALUE(status);
341} 340}
@@ -813,7 +812,7 @@ acpi_video_device_write_brightness(struct file *file,
813 812
814 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); 813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
815 814
816 if (!dev || count + 1 > sizeof str) 815 if (!dev || !dev->brightness || count + 1 > sizeof str)
817 return_VALUE(-EINVAL); 816 return_VALUE(-EINVAL);
818 817
819 if (copy_from_user(str, buffer, count)) 818 if (copy_from_user(str, buffer, count))
@@ -1488,8 +1487,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1488 } 1487 }
1489 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END; 1488 active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
1490 1489
1491 if (video->attached_array) 1490 kfree(video->attached_array);
1492 kfree(video->attached_array);
1493 1491
1494 video->attached_array = active_device_list; 1492 video->attached_array = active_device_list;
1495 video->attached_count = count; 1493 video->attached_count = count;
@@ -1645,8 +1643,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1645 printk(KERN_WARNING PREFIX 1643 printk(KERN_WARNING PREFIX
1646 "hhuuhhuu bug in acpi video driver.\n"); 1644 "hhuuhhuu bug in acpi video driver.\n");
1647 1645
1648 if (data->brightness) 1646 kfree(data->brightness);
1649 kfree(data->brightness);
1650 1647
1651 kfree(data); 1648 kfree(data);
1652 } 1649 }
@@ -1831,8 +1828,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1831 acpi_video_bus_put_devices(video); 1828 acpi_video_bus_put_devices(video);
1832 acpi_video_bus_remove_fs(device); 1829 acpi_video_bus_remove_fs(device);
1833 1830
1834 if (video->attached_array) 1831 kfree(video->attached_array);
1835 kfree(video->attached_array);
1836 kfree(video); 1832 kfree(video);
1837 1833
1838 return_VALUE(0); 1834 return_VALUE(0);