aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Makefile4
-rw-r--r--drivers/acpi/ac.c1
-rw-r--r--drivers/acpi/acpi_memhotplug.c5
-rw-r--r--drivers/acpi/acpi_pad.c43
-rw-r--r--drivers/acpi/acpica/Makefile2
-rw-r--r--drivers/acpi/acpica/accommon.h2
-rw-r--r--drivers/acpi/acpica/acconfig.h2
-rw-r--r--drivers/acpi/acpica/acdebug.h2
-rw-r--r--drivers/acpi/acpica/acdispat.h2
-rw-r--r--drivers/acpi/acpica/acevents.h15
-rw-r--r--drivers/acpi/acpica/acglobal.h2
-rw-r--r--drivers/acpi/acpica/achware.h2
-rw-r--r--drivers/acpi/acpica/acinterp.h44
-rw-r--r--drivers/acpi/acpica/aclocal.h8
-rw-r--r--drivers/acpi/acpica/acmacros.h17
-rw-r--r--drivers/acpi/acpica/acnamesp.h33
-rw-r--r--drivers/acpi/acpica/acobject.h12
-rw-r--r--drivers/acpi/acpica/acopcode.h2
-rw-r--r--drivers/acpi/acpica/acparser.h2
-rw-r--r--drivers/acpi/acpica/acpredef.h2
-rw-r--r--drivers/acpi/acpica/acresrc.h2
-rw-r--r--drivers/acpi/acpica/acstruct.h2
-rw-r--r--drivers/acpi/acpica/actables.h2
-rw-r--r--drivers/acpi/acpica/acutils.h29
-rw-r--r--drivers/acpi/acpica/amlcode.h2
-rw-r--r--drivers/acpi/acpica/amlresrc.h2
-rw-r--r--drivers/acpi/acpica/dsfield.c12
-rw-r--r--drivers/acpi/acpica/dsinit.c4
-rw-r--r--drivers/acpi/acpica/dsmethod.c4
-rw-r--r--drivers/acpi/acpica/dsmthdat.c6
-rw-r--r--drivers/acpi/acpica/dsobject.c12
-rw-r--r--drivers/acpi/acpica/dsopcode.c2
-rw-r--r--drivers/acpi/acpica/dsutils.c2
-rw-r--r--drivers/acpi/acpica/dswexec.c2
-rw-r--r--drivers/acpi/acpica/dswload.c116
-rw-r--r--drivers/acpi/acpica/dswscope.c2
-rw-r--r--drivers/acpi/acpica/dswstate.c2
-rw-r--r--drivers/acpi/acpica/evevent.c2
-rw-r--r--drivers/acpi/acpica/evgpe.c168
-rw-r--r--drivers/acpi/acpica/evgpeblk.c97
-rw-r--r--drivers/acpi/acpica/evmisc.c14
-rw-r--r--drivers/acpi/acpica/evregion.c92
-rw-r--r--drivers/acpi/acpica/evrgnini.c19
-rw-r--r--drivers/acpi/acpica/evsci.c2
-rw-r--r--drivers/acpi/acpica/evxface.c195
-rw-r--r--drivers/acpi/acpica/evxfevnt.c102
-rw-r--r--drivers/acpi/acpica/evxfregn.c6
-rw-r--r--drivers/acpi/acpica/exconfig.c21
-rw-r--r--drivers/acpi/acpica/exconvrt.c24
-rw-r--r--drivers/acpi/acpica/excreate.c2
-rw-r--r--drivers/acpi/acpica/exdump.c2
-rw-r--r--drivers/acpi/acpica/exfield.c12
-rw-r--r--drivers/acpi/acpica/exfldio.c59
-rw-r--r--drivers/acpi/acpica/exmisc.c12
-rw-r--r--drivers/acpi/acpica/exmutex.c19
-rw-r--r--drivers/acpi/acpica/exnames.c2
-rw-r--r--drivers/acpi/acpica/exoparg1.c54
-rw-r--r--drivers/acpi/acpica/exoparg2.c6
-rw-r--r--drivers/acpi/acpica/exoparg3.c4
-rw-r--r--drivers/acpi/acpica/exoparg6.c13
-rw-r--r--drivers/acpi/acpica/exprep.c19
-rw-r--r--drivers/acpi/acpica/exregion.c35
-rw-r--r--drivers/acpi/acpica/exresnte.c2
-rw-r--r--drivers/acpi/acpica/exresolv.c2
-rw-r--r--drivers/acpi/acpica/exresop.c2
-rw-r--r--drivers/acpi/acpica/exstore.c2
-rw-r--r--drivers/acpi/acpica/exstoren.c2
-rw-r--r--drivers/acpi/acpica/exstorob.c2
-rw-r--r--drivers/acpi/acpica/exsystem.c4
-rw-r--r--drivers/acpi/acpica/exutils.c24
-rw-r--r--drivers/acpi/acpica/hwacpi.c2
-rw-r--r--drivers/acpi/acpica/hwgpe.c8
-rw-r--r--drivers/acpi/acpica/hwregs.c2
-rw-r--r--drivers/acpi/acpica/hwsleep.c2
-rw-r--r--drivers/acpi/acpica/hwtimer.c4
-rw-r--r--drivers/acpi/acpica/hwvalid.c2
-rw-r--r--drivers/acpi/acpica/hwxface.c2
-rw-r--r--drivers/acpi/acpica/nsaccess.c4
-rw-r--r--drivers/acpi/acpica/nsalloc.c2
-rw-r--r--drivers/acpi/acpica/nsdump.c8
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c5
-rw-r--r--drivers/acpi/acpica/nseval.c70
-rw-r--r--drivers/acpi/acpica/nsinit.c10
-rw-r--r--drivers/acpi/acpica/nsload.c2
-rw-r--r--drivers/acpi/acpica/nsnames.c4
-rw-r--r--drivers/acpi/acpica/nsobject.c2
-rw-r--r--drivers/acpi/acpica/nsparse.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c111
-rw-r--r--drivers/acpi/acpica/nsrepair.c598
-rw-r--r--drivers/acpi/acpica/nsrepair2.c567
-rw-r--r--drivers/acpi/acpica/nssearch.c2
-rw-r--r--drivers/acpi/acpica/nsutils.c59
-rw-r--r--drivers/acpi/acpica/nswalk.c202
-rw-r--r--drivers/acpi/acpica/nsxfeval.c96
-rw-r--r--drivers/acpi/acpica/nsxfname.c12
-rw-r--r--drivers/acpi/acpica/nsxfobj.c16
-rw-r--r--drivers/acpi/acpica/psargs.c4
-rw-r--r--drivers/acpi/acpica/psloop.c34
-rw-r--r--drivers/acpi/acpica/psopcode.c2
-rw-r--r--drivers/acpi/acpica/psparse.c10
-rw-r--r--drivers/acpi/acpica/psscope.c2
-rw-r--r--drivers/acpi/acpica/pstree.c2
-rw-r--r--drivers/acpi/acpica/psutils.c2
-rw-r--r--drivers/acpi/acpica/pswalk.c2
-rw-r--r--drivers/acpi/acpica/psxface.c9
-rw-r--r--drivers/acpi/acpica/rsaddr.c2
-rw-r--r--drivers/acpi/acpica/rscalc.c2
-rw-r--r--drivers/acpi/acpica/rscreate.c4
-rw-r--r--drivers/acpi/acpica/rsdump.c2
-rw-r--r--drivers/acpi/acpica/rsinfo.c2
-rw-r--r--drivers/acpi/acpica/rsio.c2
-rw-r--r--drivers/acpi/acpica/rsirq.c2
-rw-r--r--drivers/acpi/acpica/rslist.c2
-rw-r--r--drivers/acpi/acpica/rsmemory.c2
-rw-r--r--drivers/acpi/acpica/rsmisc.c2
-rw-r--r--drivers/acpi/acpica/rsutils.c2
-rw-r--r--drivers/acpi/acpica/rsxface.c4
-rw-r--r--drivers/acpi/acpica/tbfadt.c2
-rw-r--r--drivers/acpi/acpica/tbfind.c2
-rw-r--r--drivers/acpi/acpica/tbinstal.c2
-rw-r--r--drivers/acpi/acpica/tbutils.c2
-rw-r--r--drivers/acpi/acpica/tbxface.c2
-rw-r--r--drivers/acpi/acpica/tbxfroot.c2
-rw-r--r--drivers/acpi/acpica/utalloc.c2
-rw-r--r--drivers/acpi/acpica/utcopy.c29
-rw-r--r--drivers/acpi/acpica/utdebug.c5
-rw-r--r--drivers/acpi/acpica/utdelete.c2
-rw-r--r--drivers/acpi/acpica/uteval.c4
-rw-r--r--drivers/acpi/acpica/utglobal.c4
-rw-r--r--drivers/acpi/acpica/utids.c2
-rw-r--r--drivers/acpi/acpica/utinit.c2
-rw-r--r--drivers/acpi/acpica/utlock.c2
-rw-r--r--drivers/acpi/acpica/utmath.c27
-rw-r--r--drivers/acpi/acpica/utmisc.c58
-rw-r--r--drivers/acpi/acpica/utmutex.c18
-rw-r--r--drivers/acpi/acpica/utobject.c31
-rw-r--r--drivers/acpi/acpica/utresrc.c2
-rw-r--r--drivers/acpi/acpica/utstate.c2
-rw-r--r--drivers/acpi/acpica/utxface.c2
-rw-r--r--drivers/acpi/battery.c99
-rw-r--r--drivers/acpi/blacklist.c14
-rw-r--r--drivers/acpi/bus.c178
-rw-r--r--drivers/acpi/button.c23
-rw-r--r--drivers/acpi/container.c5
-rw-r--r--drivers/acpi/debug.c85
-rw-r--r--drivers/acpi/dock.c276
-rw-r--r--drivers/acpi/ec.c229
-rw-r--r--drivers/acpi/event.c1
-rw-r--r--drivers/acpi/fan.c2
-rw-r--r--drivers/acpi/glue.c7
-rw-r--r--drivers/acpi/hest.c139
-rw-r--r--drivers/acpi/internal.h5
-rw-r--r--drivers/acpi/numa.c41
-rw-r--r--drivers/acpi/osl.c29
-rw-r--r--drivers/acpi/pci_bind.c14
-rw-r--r--drivers/acpi/pci_irq.c1
-rw-r--r--drivers/acpi/pci_link.c3
-rw-r--r--drivers/acpi/pci_root.c88
-rw-r--r--drivers/acpi/pci_slot.c9
-rw-r--r--drivers/acpi/power.c3
-rw-r--r--drivers/acpi/power_meter.c37
-rw-r--r--drivers/acpi/proc.c2
-rw-r--r--drivers/acpi/processor_core.c1140
-rw-r--r--drivers/acpi/processor_driver.c979
-rw-r--r--drivers/acpi/processor_idle.c114
-rw-r--r--drivers/acpi/processor_perflib.c72
-rw-r--r--drivers/acpi/processor_thermal.c3
-rw-r--r--drivers/acpi/processor_throttling.c28
-rw-r--r--drivers/acpi/sbs.c9
-rw-r--r--drivers/acpi/sbshc.c5
-rw-r--r--drivers/acpi/scan.c118
-rw-r--r--drivers/acpi/sleep.c119
-rw-r--r--drivers/acpi/system.c7
-rw-r--r--drivers/acpi/tables.c4
-rw-r--r--drivers/acpi/thermal.c44
-rw-r--r--drivers/acpi/utils.c62
-rw-r--r--drivers/acpi/video.c154
-rw-r--r--drivers/acpi/video_detect.c16
-rw-r--r--drivers/acpi/wakeup.c84
179 files changed, 4985 insertions, 2782 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 7702118509a0..a8d8998dd5c5 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -19,6 +19,7 @@ obj-y += acpi.o \
19 19
20# All the builtin files are in the "acpi." module_param namespace. 20# All the builtin files are in the "acpi." module_param namespace.
21acpi-y += osl.o utils.o reboot.o 21acpi-y += osl.o utils.o reboot.o
22acpi-y += hest.o
22 23
23# sleep related files 24# sleep related files
24acpi-y += wakeup.o 25acpi-y += wakeup.o
@@ -31,6 +32,7 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o
31# 32#
32acpi-y += bus.o glue.o 33acpi-y += bus.o glue.o
33acpi-y += scan.o 34acpi-y += scan.o
35acpi-y += processor_core.o
34acpi-y += ec.o 36acpi-y += ec.o
35acpi-$(CONFIG_ACPI_DOCK) += dock.o 37acpi-$(CONFIG_ACPI_DOCK) += dock.o
36acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 38acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
@@ -59,7 +61,7 @@ obj-$(CONFIG_ACPI_SBS) += sbs.o
59obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o 61obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o
60 62
61# processor has its own "processor." module_param namespace 63# processor has its own "processor." module_param namespace
62processor-y := processor_core.o processor_throttling.o 64processor-y := processor_driver.o processor_throttling.o
63processor-y += processor_idle.o processor_thermal.o 65processor-y += processor_idle.o processor_thermal.o
64processor-$(CONFIG_CPU_FREQ) += processor_perflib.o 66processor-$(CONFIG_CPU_FREQ) += processor_perflib.o
65 67
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index b6ed60b57b0d..56205a0b85df 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/types.h> 30#include <linux/types.h>
30#ifdef CONFIG_ACPI_PROCFS_POWER 31#ifdef CONFIG_ACPI_PROCFS_POWER
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 28ccdbc05ac8..d98571385656 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/memory_hotplug.h> 32#include <linux/memory_hotplug.h>
33#include <linux/slab.h>
33#include <acpi/acpi_drivers.h> 34#include <acpi/acpi_drivers.h>
34 35
35#define ACPI_MEMORY_DEVICE_CLASS "memory" 36#define ACPI_MEMORY_DEVICE_CLASS "memory"
@@ -537,7 +538,7 @@ static int __init acpi_memory_device_init(void)
537 538
538 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 539 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
539 ACPI_UINT32_MAX, 540 ACPI_UINT32_MAX,
540 acpi_memory_register_notify_handler, 541 acpi_memory_register_notify_handler, NULL,
541 NULL, NULL); 542 NULL, NULL);
542 543
543 if (ACPI_FAILURE(status)) { 544 if (ACPI_FAILURE(status)) {
@@ -561,7 +562,7 @@ static void __exit acpi_memory_device_exit(void)
561 */ 562 */
562 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 563 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
563 ACPI_UINT32_MAX, 564 ACPI_UINT32_MAX,
564 acpi_memory_deregister_notify_handler, 565 acpi_memory_deregister_notify_handler, NULL,
565 NULL, NULL); 566 NULL, NULL);
566 567
567 if (ACPI_FAILURE(status)) 568 if (ACPI_FAILURE(status))
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 0d2cdb86158b..62122134693b 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -27,10 +27,11 @@
27#include <linux/freezer.h> 27#include <linux/freezer.h>
28#include <linux/cpu.h> 28#include <linux/cpu.h>
29#include <linux/clockchips.h> 29#include <linux/clockchips.h>
30#include <linux/slab.h>
30#include <acpi/acpi_bus.h> 31#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h> 32#include <acpi/acpi_drivers.h>
32 33
33#define ACPI_PROCESSOR_AGGREGATOR_CLASS "processor_aggregator" 34#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad"
34#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" 35#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
35#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80 36#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
36static DEFINE_MUTEX(isolated_cpus_lock); 37static DEFINE_MUTEX(isolated_cpus_lock);
@@ -100,7 +101,8 @@ static void round_robin_cpu(unsigned int tsk_index)
100 struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits); 101 struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
101 cpumask_var_t tmp; 102 cpumask_var_t tmp;
102 int cpu; 103 int cpu;
103 unsigned long min_weight = -1, preferred_cpu; 104 unsigned long min_weight = -1;
105 unsigned long uninitialized_var(preferred_cpu);
104 106
105 if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) 107 if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
106 return; 108 return;
@@ -207,7 +209,7 @@ static int power_saving_thread(void *data)
207 * the mechanism only works when all CPUs have RT task running, 209 * the mechanism only works when all CPUs have RT task running,
208 * as if one CPU hasn't RT task, RT task from other CPUs will 210 * as if one CPU hasn't RT task, RT task from other CPUs will
209 * borrow CPU time from this CPU and cause RT task use > 95% 211 * borrow CPU time from this CPU and cause RT task use > 95%
210 * CPU time. To make 'avoid staration' work, takes a nap here. 212 * CPU time. To make 'avoid starvation' work, takes a nap here.
211 */ 213 */
212 if (do_sleep) 214 if (do_sleep)
213 schedule_timeout_killable(HZ * idle_pct / 100); 215 schedule_timeout_killable(HZ * idle_pct / 100);
@@ -221,14 +223,18 @@ static struct task_struct *ps_tsks[NR_CPUS];
221static unsigned int ps_tsk_num; 223static unsigned int ps_tsk_num;
222static int create_power_saving_task(void) 224static int create_power_saving_task(void)
223{ 225{
226 int rc = -ENOMEM;
227
224 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, 228 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread,
225 (void *)(unsigned long)ps_tsk_num, 229 (void *)(unsigned long)ps_tsk_num,
226 "power_saving/%d", ps_tsk_num); 230 "power_saving/%d", ps_tsk_num);
227 if (ps_tsks[ps_tsk_num]) { 231 rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0;
232 if (!rc)
228 ps_tsk_num++; 233 ps_tsk_num++;
229 return 0; 234 else
230 } 235 ps_tsks[ps_tsk_num] = NULL;
231 return -EINVAL; 236
237 return rc;
232} 238}
233 239
234static void destroy_power_saving_task(void) 240static void destroy_power_saving_task(void)
@@ -236,6 +242,7 @@ static void destroy_power_saving_task(void)
236 if (ps_tsk_num > 0) { 242 if (ps_tsk_num > 0) {
237 ps_tsk_num--; 243 ps_tsk_num--;
238 kthread_stop(ps_tsks[ps_tsk_num]); 244 kthread_stop(ps_tsks[ps_tsk_num]);
245 ps_tsks[ps_tsk_num] = NULL;
239 } 246 }
240} 247}
241 248
@@ -252,7 +259,7 @@ static void set_power_saving_task_num(unsigned int num)
252 } 259 }
253} 260}
254 261
255static int acpi_pad_idle_cpus(unsigned int num_cpus) 262static void acpi_pad_idle_cpus(unsigned int num_cpus)
256{ 263{
257 get_online_cpus(); 264 get_online_cpus();
258 265
@@ -260,7 +267,6 @@ static int acpi_pad_idle_cpus(unsigned int num_cpus)
260 set_power_saving_task_num(num_cpus); 267 set_power_saving_task_num(num_cpus);
261 268
262 put_online_cpus(); 269 put_online_cpus();
263 return 0;
264} 270}
265 271
266static uint32_t acpi_pad_idle_cpus_num(void) 272static uint32_t acpi_pad_idle_cpus_num(void)
@@ -368,19 +374,21 @@ static void acpi_pad_remove_sysfs(struct acpi_device *device)
368static int acpi_pad_pur(acpi_handle handle, int *num_cpus) 374static int acpi_pad_pur(acpi_handle handle, int *num_cpus)
369{ 375{
370 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 376 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
371 acpi_status status;
372 union acpi_object *package; 377 union acpi_object *package;
373 int rev, num, ret = -EINVAL; 378 int rev, num, ret = -EINVAL;
374 379
375 status = acpi_evaluate_object(handle, "_PUR", NULL, &buffer); 380 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PUR", NULL, &buffer)))
376 if (ACPI_FAILURE(status)) 381 return -EINVAL;
382
383 if (!buffer.length || !buffer.pointer)
377 return -EINVAL; 384 return -EINVAL;
385
378 package = buffer.pointer; 386 package = buffer.pointer;
379 if (package->type != ACPI_TYPE_PACKAGE || package->package.count != 2) 387 if (package->type != ACPI_TYPE_PACKAGE || package->package.count != 2)
380 goto out; 388 goto out;
381 rev = package->package.elements[0].integer.value; 389 rev = package->package.elements[0].integer.value;
382 num = package->package.elements[1].integer.value; 390 num = package->package.elements[1].integer.value;
383 if (rev != 1) 391 if (rev != 1 || num < 0)
384 goto out; 392 goto out;
385 *num_cpus = num; 393 *num_cpus = num;
386 ret = 0; 394 ret = 0;
@@ -409,7 +417,7 @@ static void acpi_pad_ost(acpi_handle handle, int stat,
409 417
410static void acpi_pad_handle_notify(acpi_handle handle) 418static void acpi_pad_handle_notify(acpi_handle handle)
411{ 419{
412 int num_cpus, ret; 420 int num_cpus;
413 uint32_t idle_cpus; 421 uint32_t idle_cpus;
414 422
415 mutex_lock(&isolated_cpus_lock); 423 mutex_lock(&isolated_cpus_lock);
@@ -417,12 +425,9 @@ static void acpi_pad_handle_notify(acpi_handle handle)
417 mutex_unlock(&isolated_cpus_lock); 425 mutex_unlock(&isolated_cpus_lock);
418 return; 426 return;
419 } 427 }
420 ret = acpi_pad_idle_cpus(num_cpus); 428 acpi_pad_idle_cpus(num_cpus);
421 idle_cpus = acpi_pad_idle_cpus_num(); 429 idle_cpus = acpi_pad_idle_cpus_num();
422 if (!ret) 430 acpi_pad_ost(handle, 0, idle_cpus);
423 acpi_pad_ost(handle, 0, idle_cpus);
424 else
425 acpi_pad_ost(handle, 1, 0);
426 mutex_unlock(&isolated_cpus_lock); 431 mutex_unlock(&isolated_cpus_lock);
427} 432}
428 433
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index e7973bc16846..7423052ece5a 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -28,7 +28,7 @@ acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o
28acpi-y += nsaccess.o nsload.o nssearch.o nsxfeval.o \ 28acpi-y += nsaccess.o nsload.o nssearch.o nsxfeval.o \
29 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \ 29 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
30 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \ 30 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
31 nsparse.o nspredef.o nsrepair.o 31 nsparse.o nspredef.o nsrepair.o nsrepair2.o
32 32
33acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o 33acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
34 34
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
index 3b20786cbb0d..3e50c74ed4a1 100644
--- a/drivers/acpi/acpica/accommon.h
+++ b/drivers/acpi/acpica/accommon.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
index a4471e3d3853..33181ad350d5 100644
--- a/drivers/acpi/acpica/acconfig.h
+++ b/drivers/acpi/acpica/acconfig.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index a4fb001d96f1..48faf3eba9fb 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 6291904be01e..894a0ff2a946 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 0bba148a2c61..3e6ba99e4053 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -76,12 +76,9 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node *node,
76 * evgpe - GPE handling and dispatch 76 * evgpe - GPE handling and dispatch
77 */ 77 */
78acpi_status 78acpi_status
79acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info, 79acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info);
80 u8 type);
81 80
82acpi_status 81acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info);
83acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
84 u8 write_to_hardware);
85 82
86acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info); 83acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
87 84
@@ -122,9 +119,6 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info,
122u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list); 119u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list);
123 120
124acpi_status 121acpi_status
125acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type);
126
127acpi_status
128acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info); 122acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info);
129 123
130acpi_status acpi_ev_gpe_initialize(void); 124acpi_status acpi_ev_gpe_initialize(void);
@@ -139,8 +133,7 @@ acpi_status acpi_ev_initialize_op_regions(void);
139acpi_status 133acpi_status
140acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, 134acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
141 u32 function, 135 u32 function,
142 u32 region_offset, 136 u32 region_offset, u32 bit_width, u64 *value);
143 u32 bit_width, acpi_integer * value);
144 137
145acpi_status 138acpi_status
146acpi_ev_attach_region(union acpi_operand_object *handler_obj, 139acpi_ev_attach_region(union acpi_operand_object *handler_obj,
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 29ba66d5a790..f8dd8f250ac4 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 36192f142fbb..5900f135dc6d 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index 5db9f2916f7c..6df3f8428168 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -129,18 +129,17 @@ acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc,
129 129
130acpi_status 130acpi_status
131acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, 131acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
132 acpi_integer mask, 132 u64 mask,
133 acpi_integer field_value, 133 u64 field_value, u32 field_datum_byte_offset);
134 u32 field_datum_byte_offset);
135 134
136void 135void
137acpi_ex_get_buffer_datum(acpi_integer * datum, 136acpi_ex_get_buffer_datum(u64 *datum,
138 void *buffer, 137 void *buffer,
139 u32 buffer_length, 138 u32 buffer_length,
140 u32 byte_granularity, u32 buffer_offset); 139 u32 byte_granularity, u32 buffer_offset);
141 140
142void 141void
143acpi_ex_set_buffer_datum(acpi_integer merged_datum, 142acpi_ex_set_buffer_datum(u64 merged_datum,
144 void *buffer, 143 void *buffer,
145 u32 buffer_length, 144 u32 buffer_length,
146 u32 byte_granularity, u32 buffer_offset); 145 u32 byte_granularity, u32 buffer_offset);
@@ -168,8 +167,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
168 167
169acpi_status 168acpi_status
170acpi_ex_access_region(union acpi_operand_object *obj_desc, 169acpi_ex_access_region(union acpi_operand_object *obj_desc,
171 u32 field_datum_byte_offset, 170 u32 field_datum_byte_offset, u64 *value, u32 read_write);
172 acpi_integer * value, u32 read_write);
173 171
174/* 172/*
175 * exmisc - misc support routines 173 * exmisc - misc support routines
@@ -193,16 +191,14 @@ acpi_ex_do_concatenate(union acpi_operand_object *obj_desc,
193 191
194acpi_status 192acpi_status
195acpi_ex_do_logical_numeric_op(u16 opcode, 193acpi_ex_do_logical_numeric_op(u16 opcode,
196 acpi_integer integer0, 194 u64 integer0, u64 integer1, u8 *logical_result);
197 acpi_integer integer1, u8 * logical_result);
198 195
199acpi_status 196acpi_status
200acpi_ex_do_logical_op(u16 opcode, 197acpi_ex_do_logical_op(u16 opcode,
201 union acpi_operand_object *operand0, 198 union acpi_operand_object *operand0,
202 union acpi_operand_object *operand1, u8 * logical_result); 199 union acpi_operand_object *operand1, u8 *logical_result);
203 200
204acpi_integer 201u64 acpi_ex_do_math_op(u16 opcode, u64 operand0, u64 operand1);
205acpi_ex_do_math_op(u16 opcode, acpi_integer operand0, acpi_integer operand1);
206 202
207acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state); 203acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state);
208 204
@@ -278,7 +274,7 @@ acpi_status
278acpi_ex_system_do_notify_op(union acpi_operand_object *value, 274acpi_ex_system_do_notify_op(union acpi_operand_object *value,
279 union acpi_operand_object *obj_desc); 275 union acpi_operand_object *obj_desc);
280 276
281acpi_status acpi_ex_system_do_suspend(acpi_integer time); 277acpi_status acpi_ex_system_do_suspend(u64 time);
282 278
283acpi_status acpi_ex_system_do_stall(u32 time); 279acpi_status acpi_ex_system_do_stall(u32 time);
284 280
@@ -461,9 +457,9 @@ void acpi_ex_acquire_global_lock(u32 rule);
461 457
462void acpi_ex_release_global_lock(u32 rule); 458void acpi_ex_release_global_lock(u32 rule);
463 459
464void acpi_ex_eisa_id_to_string(char *dest, acpi_integer compressed_id); 460void acpi_ex_eisa_id_to_string(char *dest, u64 compressed_id);
465 461
466void acpi_ex_integer_to_string(char *dest, acpi_integer value); 462void acpi_ex_integer_to_string(char *dest, u64 value);
467 463
468/* 464/*
469 * exregion - default op_region handlers 465 * exregion - default op_region handlers
@@ -472,7 +468,7 @@ acpi_status
472acpi_ex_system_memory_space_handler(u32 function, 468acpi_ex_system_memory_space_handler(u32 function,
473 acpi_physical_address address, 469 acpi_physical_address address,
474 u32 bit_width, 470 u32 bit_width,
475 acpi_integer * value, 471 u64 *value,
476 void *handler_context, 472 void *handler_context,
477 void *region_context); 473 void *region_context);
478 474
@@ -480,35 +476,35 @@ acpi_status
480acpi_ex_system_io_space_handler(u32 function, 476acpi_ex_system_io_space_handler(u32 function,
481 acpi_physical_address address, 477 acpi_physical_address address,
482 u32 bit_width, 478 u32 bit_width,
483 acpi_integer * value, 479 u64 *value,
484 void *handler_context, void *region_context); 480 void *handler_context, void *region_context);
485 481
486acpi_status 482acpi_status
487acpi_ex_pci_config_space_handler(u32 function, 483acpi_ex_pci_config_space_handler(u32 function,
488 acpi_physical_address address, 484 acpi_physical_address address,
489 u32 bit_width, 485 u32 bit_width,
490 acpi_integer * value, 486 u64 *value,
491 void *handler_context, void *region_context); 487 void *handler_context, void *region_context);
492 488
493acpi_status 489acpi_status
494acpi_ex_cmos_space_handler(u32 function, 490acpi_ex_cmos_space_handler(u32 function,
495 acpi_physical_address address, 491 acpi_physical_address address,
496 u32 bit_width, 492 u32 bit_width,
497 acpi_integer * value, 493 u64 *value,
498 void *handler_context, void *region_context); 494 void *handler_context, void *region_context);
499 495
500acpi_status 496acpi_status
501acpi_ex_pci_bar_space_handler(u32 function, 497acpi_ex_pci_bar_space_handler(u32 function,
502 acpi_physical_address address, 498 acpi_physical_address address,
503 u32 bit_width, 499 u32 bit_width,
504 acpi_integer * value, 500 u64 *value,
505 void *handler_context, void *region_context); 501 void *handler_context, void *region_context);
506 502
507acpi_status 503acpi_status
508acpi_ex_embedded_controller_space_handler(u32 function, 504acpi_ex_embedded_controller_space_handler(u32 function,
509 acpi_physical_address address, 505 acpi_physical_address address,
510 u32 bit_width, 506 u32 bit_width,
511 acpi_integer * value, 507 u64 *value,
512 void *handler_context, 508 void *handler_context,
513 void *region_context); 509 void *region_context);
514 510
@@ -516,14 +512,14 @@ acpi_status
516acpi_ex_sm_bus_space_handler(u32 function, 512acpi_ex_sm_bus_space_handler(u32 function,
517 acpi_physical_address address, 513 acpi_physical_address address,
518 u32 bit_width, 514 u32 bit_width,
519 acpi_integer * value, 515 u64 *value,
520 void *handler_context, void *region_context); 516 void *handler_context, void *region_context);
521 517
522acpi_status 518acpi_status
523acpi_ex_data_table_space_handler(u32 function, 519acpi_ex_data_table_space_handler(u32 function,
524 acpi_physical_address address, 520 acpi_physical_address address,
525 u32 bit_width, 521 u32 bit_width,
526 acpi_integer * value, 522 u64 *value,
527 void *handler_context, void *region_context); 523 void *handler_context, void *region_context);
528 524
529#endif /* __INTERP_H__ */ 525#endif /* __INTERP_H__ */
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 81e64f478679..24b8faa5c395 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -374,6 +374,7 @@ union acpi_predefined_info {
374struct acpi_predefined_data { 374struct acpi_predefined_data {
375 char *pathname; 375 char *pathname;
376 const union acpi_predefined_info *predefined; 376 const union acpi_predefined_info *predefined;
377 union acpi_operand_object *parent_package;
377 u32 flags; 378 u32 flags;
378 u8 node_flags; 379 u8 node_flags;
379}; 380};
@@ -426,6 +427,8 @@ struct acpi_gpe_event_info {
426 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */ 427 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
427 u8 flags; /* Misc info about this GPE */ 428 u8 flags; /* Misc info about this GPE */
428 u8 gpe_number; /* This GPE */ 429 u8 gpe_number; /* This GPE */
430 u8 runtime_count;
431 u8 wakeup_count;
429}; 432};
430 433
431/* Information about a GPE register pair, one per each status/enable pair in an array */ 434/* Information about a GPE register pair, one per each status/enable pair in an array */
@@ -649,8 +652,7 @@ struct acpi_opcode_info {
649}; 652};
650 653
651union acpi_parse_value { 654union acpi_parse_value {
652 acpi_integer integer; /* Integer constant (Up to 64 bits) */ 655 u64 integer; /* Integer constant (Up to 64 bits) */
653 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
654 u32 size; /* bytelist or field size */ 656 u32 size; /* bytelist or field size */
655 char *string; /* NULL terminated string */ 657 char *string; /* NULL terminated string */
656 u8 *buffer; /* buffer or string */ 658 u8 *buffer; /* buffer or string */
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 3acd9c6760ea..9894929a2abb 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -272,8 +272,8 @@
272 * MASK_BITS_ABOVE creates a mask starting AT the position and above 272 * MASK_BITS_ABOVE creates a mask starting AT the position and above
273 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position 273 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
274 */ 274 */
275#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position)))) 275#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((u32) (position))))
276#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position))) 276#define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((u32) (position)))
277 277
278/* Bitfields within ACPI registers */ 278/* Bitfields within ACPI registers */
279 279
@@ -341,6 +341,7 @@
341#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e); 341#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e);
342#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e); 342#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e);
343#define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist 343#define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist
344#define ACPI_INFO_PREDEFINED(plist) acpi_ut_predefined_info plist
344 345
345#else 346#else
346 347
@@ -349,6 +350,8 @@
349#define ACPI_ERROR_NAMESPACE(s, e) 350#define ACPI_ERROR_NAMESPACE(s, e)
350#define ACPI_ERROR_METHOD(s, n, p, e) 351#define ACPI_ERROR_METHOD(s, n, p, e)
351#define ACPI_WARN_PREDEFINED(plist) 352#define ACPI_WARN_PREDEFINED(plist)
353#define ACPI_INFO_PREDEFINED(plist)
354
352#endif /* ACPI_NO_ERROR_MESSAGES */ 355#endif /* ACPI_NO_ERROR_MESSAGES */
353 356
354/* 357/*
@@ -411,16 +414,16 @@
411 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \ 414 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \
412 return (_s); }) 415 return (_s); })
413#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ 416#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
414 register acpi_integer _s = (s); \ 417 register u64 _s = (s); \
415 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ 418 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \
416 return (_s); }) 419 return (_s); })
417#define return_UINT8(s) ACPI_DO_WHILE0 ({ \ 420#define return_UINT8(s) ACPI_DO_WHILE0 ({ \
418 register u8 _s = (u8) (s); \ 421 register u8 _s = (u8) (s); \
419 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \ 422 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \
420 return (_s); }) 423 return (_s); })
421#define return_UINT32(s) ACPI_DO_WHILE0 ({ \ 424#define return_UINT32(s) ACPI_DO_WHILE0 ({ \
422 register u32 _s = (u32) (s); \ 425 register u32 _s = (u32) (s); \
423 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \ 426 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \
424 return (_s); }) 427 return (_s); })
425#else /* Use original less-safe macros */ 428#else /* Use original less-safe macros */
426 429
@@ -431,7 +434,7 @@
431 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \ 434 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \
432 return((s)); }) 435 return((s)); })
433#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ 436#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
434 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) (s)); \ 437 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) (s)); \
435 return((s)); }) 438 return((s)); })
436#define return_UINT8(s) return_VALUE(s) 439#define return_UINT8(s) return_VALUE(s)
437#define return_UINT32(s) return_VALUE(s) 440#define return_UINT32(s) return_VALUE(s)
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 09a2764c734b..258159cfcdfa 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -104,7 +104,8 @@ acpi_ns_walk_namespace(acpi_object_type type,
104 acpi_handle start_object, 104 acpi_handle start_object,
105 u32 max_depth, 105 u32 max_depth,
106 u32 flags, 106 u32 flags,
107 acpi_walk_callback user_function, 107 acpi_walk_callback pre_order_visit,
108 acpi_walk_callback post_order_visit,
108 void *context, void **return_value); 109 void *context, void **return_value);
109 110
110struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node 111struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
@@ -272,7 +273,8 @@ acpi_ns_get_attached_data(struct acpi_namespace_node *node,
272 acpi_object_handler handler, void **data); 273 acpi_object_handler handler, void **data);
273 274
274/* 275/*
275 * nsrepair - return object repair for predefined methods/objects 276 * nsrepair - General return object repair for all
277 * predefined methods/objects
276 */ 278 */
277acpi_status 279acpi_status
278acpi_ns_repair_object(struct acpi_predefined_data *data, 280acpi_ns_repair_object(struct acpi_predefined_data *data,
@@ -284,6 +286,27 @@ acpi_status
284acpi_ns_repair_package_list(struct acpi_predefined_data *data, 286acpi_ns_repair_package_list(struct acpi_predefined_data *data,
285 union acpi_operand_object **obj_desc_ptr); 287 union acpi_operand_object **obj_desc_ptr);
286 288
289acpi_status
290acpi_ns_repair_null_element(struct acpi_predefined_data *data,
291 u32 expected_btypes,
292 u32 package_index,
293 union acpi_operand_object **return_object_ptr);
294
295void
296acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
297 u8 package_type,
298 union acpi_operand_object *obj_desc);
299
300/*
301 * nsrepair2 - Return object repair for specific
302 * predefined methods/objects
303 */
304acpi_status
305acpi_ns_complex_repairs(struct acpi_predefined_data *data,
306 struct acpi_namespace_node *node,
307 acpi_status validate_status,
308 union acpi_operand_object **return_object_ptr);
309
287/* 310/*
288 * nssearch - Namespace searching and entry 311 * nssearch - Namespace searching and entry
289 */ 312 */
@@ -342,9 +365,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
342 const char *internal_name, 365 const char *internal_name,
343 u32 * converted_name_length, char **converted_name); 366 u32 * converted_name_length, char **converted_name);
344 367
345struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle); 368struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle);
346
347acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node);
348 369
349void acpi_ns_terminate(void); 370void acpi_ns_terminate(void);
350 371
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index b39d682a2140..cde18ea82656 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -111,7 +111,7 @@ ACPI_OBJECT_COMMON_HEADER};
111 111
112struct acpi_object_integer { 112struct acpi_object_integer {
113 ACPI_OBJECT_COMMON_HEADER u8 fill[3]; /* Prevent warning on some compilers */ 113 ACPI_OBJECT_COMMON_HEADER u8 fill[3]; /* Prevent warning on some compilers */
114 acpi_integer value; 114 u64 value;
115}; 115};
116 116
117/* 117/*
@@ -180,7 +180,11 @@ struct acpi_object_method {
180 u8 sync_level; 180 u8 sync_level;
181 union acpi_operand_object *mutex; 181 union acpi_operand_object *mutex;
182 u8 *aml_start; 182 u8 *aml_start;
183 ACPI_INTERNAL_METHOD implementation; 183 union {
184 ACPI_INTERNAL_METHOD implementation;
185 union acpi_operand_object *handler;
186 } extra;
187
184 u32 aml_length; 188 u32 aml_length;
185 u8 thread_count; 189 u8 thread_count;
186 acpi_owner_id owner_id; 190 acpi_owner_id owner_id;
@@ -283,8 +287,10 @@ struct acpi_object_buffer_field {
283 287
284struct acpi_object_notify_handler { 288struct acpi_object_notify_handler {
285 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Parent device */ 289 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Parent device */
290 u32 handler_type;
286 acpi_notify_handler handler; 291 acpi_notify_handler handler;
287 void *context; 292 void *context;
293 struct acpi_object_notify_handler *next;
288}; 294};
289 295
290struct acpi_object_addr_handler { 296struct acpi_object_addr_handler {
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index dfdf63327885..8c15ff43f42b 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
index 22881e8ce229..d0bb0fd3e57a 100644
--- a/drivers/acpi/acpica/acparser.h
+++ b/drivers/acpi/acpica/acparser.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 57bdaf6ffab1..97116082cb6c 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
index eef5bd7a59fa..528bcbaf4ce7 100644
--- a/drivers/acpi/acpica/acresrc.h
+++ b/drivers/acpi/acpica/acresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 7980a26bad35..161bc0e3d70a 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 01c76b8ea7ba..8ff3b741df28 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 863a264b829e..35df755251ce 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -134,7 +134,7 @@ char *acpi_ut_get_region_name(u8 space_id);
134 134
135char *acpi_ut_get_event_name(u32 event_id); 135char *acpi_ut_get_event_name(u32 event_id);
136 136
137char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position); 137char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);
138 138
139u8 acpi_ut_valid_object_type(acpi_object_type type); 139u8 acpi_ut_valid_object_type(acpi_object_type type);
140 140
@@ -279,8 +279,7 @@ acpi_ut_status_exit(u32 line_number,
279void 279void
280acpi_ut_value_exit(u32 line_number, 280acpi_ut_value_exit(u32 line_number,
281 const char *function_name, 281 const char *function_name,
282 const char *module_name, 282 const char *module_name, u32 component_id, u64 value);
283 u32 component_id, acpi_integer value);
284 283
285void 284void
286acpi_ut_ptr_exit(u32 line_number, 285acpi_ut_ptr_exit(u32 line_number,
@@ -324,7 +323,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
324acpi_status 323acpi_status
325acpi_ut_evaluate_numeric_object(char *object_name, 324acpi_ut_evaluate_numeric_object(char *object_name,
326 struct acpi_namespace_node *device_node, 325 struct acpi_namespace_node *device_node,
327 acpi_integer *value); 326 u64 *value);
328 327
329acpi_status 328acpi_status
330acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 *status_flags); 329acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 *status_flags);
@@ -386,6 +385,8 @@ u8 acpi_ut_valid_internal_object(void *object);
386 385
387union acpi_operand_object *acpi_ut_create_package_object(u32 count); 386union acpi_operand_object *acpi_ut_create_package_object(u32 count);
388 387
388union acpi_operand_object *acpi_ut_create_integer_object(u64 value);
389
389union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size); 390union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size);
390 391
391union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size); 392union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size);
@@ -435,14 +436,12 @@ void acpi_ut_delete_generic_state(union acpi_generic_state *state);
435 * utmath 436 * utmath
436 */ 437 */
437acpi_status 438acpi_status
438acpi_ut_divide(acpi_integer in_dividend, 439acpi_ut_divide(u64 in_dividend,
439 acpi_integer in_divisor, 440 u64 in_divisor, u64 *out_quotient, u64 *out_remainder);
440 acpi_integer * out_quotient, acpi_integer * out_remainder);
441 441
442acpi_status 442acpi_status
443acpi_ut_short_divide(acpi_integer in_dividend, 443acpi_ut_short_divide(u64 in_dividend,
444 u32 divisor, 444 u32 divisor, u64 *out_quotient, u32 *out_remainder);
445 acpi_integer * out_quotient, u32 * out_remainder);
446 445
447/* 446/*
448 * utmisc 447 * utmisc
@@ -472,8 +471,7 @@ acpi_name acpi_ut_repair_name(char *name);
472 471
473u8 acpi_ut_valid_acpi_char(char character, u32 position); 472u8 acpi_ut_valid_acpi_char(char character, u32 position);
474 473
475acpi_status 474acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer);
476acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
477 475
478void ACPI_INTERNAL_VAR_XFACE 476void ACPI_INTERNAL_VAR_XFACE
479acpi_ut_predefined_warning(const char *module_name, 477acpi_ut_predefined_warning(const char *module_name,
@@ -481,6 +479,11 @@ acpi_ut_predefined_warning(const char *module_name,
481 char *pathname, 479 char *pathname,
482 u8 node_flags, const char *format, ...); 480 u8 node_flags, const char *format, ...);
483 481
482void ACPI_INTERNAL_VAR_XFACE
483acpi_ut_predefined_info(const char *module_name,
484 u32 line_number,
485 char *pathname, u8 node_flags, const char *format, ...);
486
484/* Values for Base above (16=Hex, 10=Decimal) */ 487/* Values for Base above (16=Hex, 10=Decimal) */
485 488
486#define ACPI_ANY_BASE 0 489#define ACPI_ANY_BASE 0
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index 4940249f2524..1f484ba228fc 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 7b070e42b7c5..0e5798fcbb19 100644
--- a/drivers/acpi/acpica/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index 54a225e56a64..bb13817e0c31 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -220,7 +220,7 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
220 union acpi_parse_object *arg) 220 union acpi_parse_object *arg)
221{ 221{
222 acpi_status status; 222 acpi_status status;
223 acpi_integer position; 223 u64 position;
224 224
225 ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info); 225 ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info);
226 226
@@ -240,8 +240,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
240 switch (arg->common.aml_opcode) { 240 switch (arg->common.aml_opcode) {
241 case AML_INT_RESERVEDFIELD_OP: 241 case AML_INT_RESERVEDFIELD_OP:
242 242
243 position = (acpi_integer) info->field_bit_position 243 position = (u64) info->field_bit_position
244 + (acpi_integer) arg->common.value.size; 244 + (u64) arg->common.value.size;
245 245
246 if (position > ACPI_UINT32_MAX) { 246 if (position > ACPI_UINT32_MAX) {
247 ACPI_ERROR((AE_INFO, 247 ACPI_ERROR((AE_INFO,
@@ -305,8 +305,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
305 305
306 /* Keep track of bit position for the next field */ 306 /* Keep track of bit position for the next field */
307 307
308 position = (acpi_integer) info->field_bit_position 308 position = (u64) info->field_bit_position
309 + (acpi_integer) arg->common.value.size; 309 + (u64) arg->common.value.size;
310 310
311 if (position > ACPI_UINT32_MAX) { 311 if (position > ACPI_UINT32_MAX) {
312 ACPI_ERROR((AE_INFO, 312 ACPI_ERROR((AE_INFO,
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index 3aae13f30c5e..abe140318a74 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -192,7 +192,7 @@ acpi_ds_initialize_objects(u32 table_index,
192 status = 192 status =
193 acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, 193 acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
194 ACPI_NS_WALK_UNLOCK, acpi_ds_init_one_object, 194 ACPI_NS_WALK_UNLOCK, acpi_ds_init_one_object,
195 &info, NULL); 195 NULL, &info, NULL);
196 if (ACPI_FAILURE(status)) { 196 if (ACPI_FAILURE(status)) {
197 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); 197 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
198 } 198 }
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 567a4899a018..721039233aa7 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -414,7 +414,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
414 /* Invoke an internal method if necessary */ 414 /* Invoke an internal method if necessary */
415 415
416 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 416 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
417 status = obj_desc->method.implementation(next_walk_state); 417 status = obj_desc->method.extra.implementation(next_walk_state);
418 if (status == AE_OK) { 418 if (status == AE_OK) {
419 status = AE_CTRL_TERMINATE; 419 status = AE_CTRL_TERMINATE;
420 } 420 }
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index 7d077bb2f525..cc343b959540 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -409,13 +409,11 @@ acpi_ds_method_data_get_value(u8 type,
409 /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ 409 /* If slack enabled, init the local_x/arg_x to an Integer of value zero */
410 410
411 if (acpi_gbl_enable_interpreter_slack) { 411 if (acpi_gbl_enable_interpreter_slack) {
412 object = 412 object = acpi_ut_create_integer_object((u64) 0);
413 acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
414 if (!object) { 413 if (!object) {
415 return_ACPI_STATUS(AE_NO_MEMORY); 414 return_ACPI_STATUS(AE_NO_MEMORY);
416 } 415 }
417 416
418 object->integer.value = 0;
419 node->object = object; 417 node->object = object;
420 } 418 }
421 419
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 507e1f0bbdfd..891e08bf560b 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -486,7 +486,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
486 * 486 *
487 * Note: technically, this is an error, from ACPI spec: "It is an error 487 * Note: technically, this is an error, from ACPI spec: "It is an error
488 * for NumElements to be less than the number of elements in the 488 * for NumElements to be less than the number of elements in the
489 * PackageList". However, we just print an error message and 489 * PackageList". However, we just print a message and
490 * no exception is returned. This provides Windows compatibility. Some 490 * no exception is returned. This provides Windows compatibility. Some
491 * BIOSs will alter the num_elements on the fly, creating this type 491 * BIOSs will alter the num_elements on the fly, creating this type
492 * of ill-formed package object. 492 * of ill-formed package object.
@@ -510,9 +510,9 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
510 arg = arg->common.next; 510 arg = arg->common.next;
511 } 511 }
512 512
513 ACPI_WARNING((AE_INFO, 513 ACPI_INFO((AE_INFO,
514 "Package List length (0x%X) larger than NumElements count (0x%X), truncated\n", 514 "Actual Package length (0x%X) is larger than NumElements field (0x%X), truncated\n",
515 i, element_count)); 515 i, element_count));
516 } else if (i < element_count) { 516 } else if (i < element_count) {
517 /* 517 /*
518 * Arg list (elements) was exhausted, but we did not reach num_elements count. 518 * Arg list (elements) was exhausted, but we did not reach num_elements count.
@@ -684,7 +684,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
684 684
685 case AML_ONES_OP: 685 case AML_ONES_OP:
686 686
687 obj_desc->integer.value = ACPI_INTEGER_MAX; 687 obj_desc->integer.value = ACPI_UINT64_MAX;
688 688
689 /* Truncate value if we are executing from a 32-bit ACPI table */ 689 /* Truncate value if we are executing from a 32-bit ACPI table */
690 690
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index b79978f7bc71..bf980cadb1e8 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index dfa104102926..306c62ab2e88 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index f0280856dc0e..6b76c486d784 100644
--- a/drivers/acpi/acpica/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 6de3a99d4cd4..140a9d002959 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -212,18 +212,19 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
212 case ACPI_TYPE_BUFFER: 212 case ACPI_TYPE_BUFFER:
213 213
214 /* 214 /*
215 * These types we will allow, but we will change the type. This 215 * These types we will allow, but we will change the type.
216 * enables some existing code of the form: 216 * This enables some existing code of the form:
217 * 217 *
218 * Name (DEB, 0) 218 * Name (DEB, 0)
219 * Scope (DEB) { ... } 219 * Scope (DEB) { ... }
220 * 220 *
221 * Note: silently change the type here. On the second pass, we will report 221 * Note: silently change the type here. On the second pass,
222 * a warning 222 * we will report a warning
223 */ 223 */
224 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 224 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
225 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", 225 "Type override - [%4.4s] had invalid type (%s) "
226 path, 226 "for Scope operator, changed to type ANY\n",
227 acpi_ut_get_node_name(node),
227 acpi_ut_get_type_name(node->type))); 228 acpi_ut_get_type_name(node->type)));
228 229
229 node->type = ACPI_TYPE_ANY; 230 node->type = ACPI_TYPE_ANY;
@@ -235,8 +236,10 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
235 /* All other types are an error */ 236 /* All other types are an error */
236 237
237 ACPI_ERROR((AE_INFO, 238 ACPI_ERROR((AE_INFO,
238 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)", 239 "Invalid type (%s) for target of "
239 acpi_ut_get_type_name(node->type), path)); 240 "Scope operator [%4.4s] (Cannot override)",
241 acpi_ut_get_type_name(node->type),
242 acpi_ut_get_node_name(node)));
240 243
241 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 244 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
242 } 245 }
@@ -639,26 +642,42 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
639 break; 642 break;
640 643
641 case AML_SCOPE_OP: 644 case AML_SCOPE_OP:
642 /* 645
643 * The Path is an object reference to an existing object. 646 /* Special case for Scope(\) -> refers to the Root node */
644 * Don't enter the name into the namespace, but look it up 647
645 * for use later. 648 if (op && (op->named.node == acpi_gbl_root_node)) {
646 */ 649 node = op->named.node;
647 status = 650
648 acpi_ns_lookup(walk_state->scope_info, buffer_ptr, 651 status =
649 object_type, ACPI_IMODE_EXECUTE, 652 acpi_ds_scope_stack_push(node, object_type,
650 ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 653 walk_state);
651 if (ACPI_FAILURE(status)) { 654 if (ACPI_FAILURE(status)) {
652#ifdef ACPI_ASL_COMPILER 655 return_ACPI_STATUS(status);
653 if (status == AE_NOT_FOUND) {
654 status = AE_OK;
655 } else {
656 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
657 } 656 }
657 } else {
658 /*
659 * The Path is an object reference to an existing object.
660 * Don't enter the name into the namespace, but look it up
661 * for use later.
662 */
663 status =
664 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
665 object_type, ACPI_IMODE_EXECUTE,
666 ACPI_NS_SEARCH_PARENT, walk_state,
667 &(node));
668 if (ACPI_FAILURE(status)) {
669#ifdef ACPI_ASL_COMPILER
670 if (status == AE_NOT_FOUND) {
671 status = AE_OK;
672 } else {
673 ACPI_ERROR_NAMESPACE(buffer_ptr,
674 status);
675 }
658#else 676#else
659 ACPI_ERROR_NAMESPACE(buffer_ptr, status); 677 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
660#endif 678#endif
661 return_ACPI_STATUS(status); 679 return_ACPI_STATUS(status);
680 }
662 } 681 }
663 682
664 /* 683 /*
@@ -681,15 +700,16 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
681 case ACPI_TYPE_BUFFER: 700 case ACPI_TYPE_BUFFER:
682 701
683 /* 702 /*
684 * These types we will allow, but we will change the type. This 703 * These types we will allow, but we will change the type.
685 * enables some existing code of the form: 704 * This enables some existing code of the form:
686 * 705 *
687 * Name (DEB, 0) 706 * Name (DEB, 0)
688 * Scope (DEB) { ... } 707 * Scope (DEB) { ... }
689 */ 708 */
690 ACPI_WARNING((AE_INFO, 709 ACPI_WARNING((AE_INFO,
691 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", 710 "Type override - [%4.4s] had invalid type (%s) "
692 buffer_ptr, 711 "for Scope operator, changed to type ANY\n",
712 acpi_ut_get_node_name(node),
693 acpi_ut_get_type_name(node->type))); 713 acpi_ut_get_type_name(node->type)));
694 714
695 node->type = ACPI_TYPE_ANY; 715 node->type = ACPI_TYPE_ANY;
@@ -701,9 +721,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
701 /* All other types are an error */ 721 /* All other types are an error */
702 722
703 ACPI_ERROR((AE_INFO, 723 ACPI_ERROR((AE_INFO,
704 "Invalid type (%s) for target of Scope operator [%4.4s]", 724 "Invalid type (%s) for target of "
725 "Scope operator [%4.4s] (Cannot override)",
705 acpi_ut_get_type_name(node->type), 726 acpi_ut_get_type_name(node->type),
706 buffer_ptr)); 727 acpi_ut_get_node_name(node)));
707 728
708 return (AE_AML_OPERAND_TYPE); 729 return (AE_AML_OPERAND_TYPE);
709 } 730 }
@@ -1031,9 +1052,22 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1031 } 1052 }
1032 1053
1033 /* 1054 /*
1034 * If we are executing a method, initialize the region 1055 * The op_region is not fully parsed at this time. The only valid
1056 * argument is the space_id. (We must save the address of the
1057 * AML of the address and length operands)
1058 *
1059 * If we have a valid region, initialize it. The namespace is
1060 * unlocked at this point.
1061 *
1062 * Need to unlock interpreter if it is locked (if we are running
1063 * a control method), in order to allow _REG methods to be run
1064 * during acpi_ev_initialize_region.
1035 */ 1065 */
1036 if (walk_state->method_node) { 1066 if (walk_state->method_node) {
1067 /*
1068 * Executing a method: initialize the region and unlock
1069 * the interpreter
1070 */
1037 status = 1071 status =
1038 acpi_ex_create_region(op->named.data, 1072 acpi_ex_create_region(op->named.data,
1039 op->named.length, 1073 op->named.length,
@@ -1042,21 +1076,17 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1042 if (ACPI_FAILURE(status)) { 1076 if (ACPI_FAILURE(status)) {
1043 return (status); 1077 return (status);
1044 } 1078 }
1045 }
1046 1079
1047 /* 1080 acpi_ex_exit_interpreter();
1048 * The op_region is not fully parsed at this time. Only valid 1081 }
1049 * argument is the space_id. (We must save the address of the
1050 * AML of the address and length operands)
1051 */
1052 1082
1053 /*
1054 * If we have a valid region, initialize it
1055 * Namespace is NOT locked at this point.
1056 */
1057 status = 1083 status =
1058 acpi_ev_initialize_region 1084 acpi_ev_initialize_region
1059 (acpi_ns_get_attached_object(node), FALSE); 1085 (acpi_ns_get_attached_object(node), FALSE);
1086 if (walk_state->method_node) {
1087 acpi_ex_enter_interpreter();
1088 }
1089
1060 if (ACPI_FAILURE(status)) { 1090 if (ACPI_FAILURE(status)) {
1061 /* 1091 /*
1062 * If AE_NOT_EXIST is returned, it is not fatal 1092 * If AE_NOT_EXIST is returned, it is not fatal
diff --git a/drivers/acpi/acpica/dswscope.c b/drivers/acpi/acpica/dswscope.c
index 908645e72f03..d1e701709dac 100644
--- a/drivers/acpi/acpica/dswscope.c
+++ b/drivers/acpi/acpica/dswscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
index e46c821cf572..050df8164165 100644
--- a/drivers/acpi/acpica/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index cd55c774e882..c1e6f472d435 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index afacf4416c73..78c55508aff5 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -54,54 +54,9 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
54 54
55/******************************************************************************* 55/*******************************************************************************
56 * 56 *
57 * FUNCTION: acpi_ev_set_gpe_type
58 *
59 * PARAMETERS: gpe_event_info - GPE to set
60 * Type - New type
61 *
62 * RETURN: Status
63 *
64 * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run)
65 *
66 ******************************************************************************/
67
68acpi_status
69acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type)
70{
71 acpi_status status;
72
73 ACPI_FUNCTION_TRACE(ev_set_gpe_type);
74
75 /* Validate type and update register enable masks */
76
77 switch (type) {
78 case ACPI_GPE_TYPE_WAKE:
79 case ACPI_GPE_TYPE_RUNTIME:
80 case ACPI_GPE_TYPE_WAKE_RUN:
81 break;
82
83 default:
84 return_ACPI_STATUS(AE_BAD_PARAMETER);
85 }
86
87 /* Disable the GPE if currently enabled */
88
89 status = acpi_ev_disable_gpe(gpe_event_info);
90
91 /* Clear the type bits and insert the new Type */
92
93 gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK;
94 gpe_event_info->flags |= type;
95 return_ACPI_STATUS(status);
96}
97
98/*******************************************************************************
99 *
100 * FUNCTION: acpi_ev_update_gpe_enable_masks 57 * FUNCTION: acpi_ev_update_gpe_enable_masks
101 * 58 *
102 * PARAMETERS: gpe_event_info - GPE to update 59 * PARAMETERS: gpe_event_info - GPE to update
103 * Type - What to do: ACPI_GPE_DISABLE or
104 * ACPI_GPE_ENABLE
105 * 60 *
106 * RETURN: Status 61 * RETURN: Status
107 * 62 *
@@ -110,8 +65,7 @@ acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type)
110 ******************************************************************************/ 65 ******************************************************************************/
111 66
112acpi_status 67acpi_status
113acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info, 68acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info)
114 u8 type)
115{ 69{
116 struct acpi_gpe_register_info *gpe_register_info; 70 struct acpi_gpe_register_info *gpe_register_info;
117 u8 register_bit; 71 u8 register_bit;
@@ -127,37 +81,14 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
127 (1 << 81 (1 <<
128 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number)); 82 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number));
129 83
130 /* 1) Disable case. Simply clear all enable bits */ 84 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, register_bit);
131 85 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
132 if (type == ACPI_GPE_DISABLE) {
133 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
134 register_bit);
135 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
136 return_ACPI_STATUS(AE_OK);
137 }
138
139 /* 2) Enable case. Set/Clear the appropriate enable bits */
140
141 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
142 case ACPI_GPE_TYPE_WAKE:
143 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
144 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
145 break;
146 86
147 case ACPI_GPE_TYPE_RUNTIME: 87 if (gpe_event_info->runtime_count)
148 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
149 register_bit);
150 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit); 88 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
151 break;
152 89
153 case ACPI_GPE_TYPE_WAKE_RUN: 90 if (gpe_event_info->wakeup_count)
154 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit); 91 ACPI_SET_BIT(gpe_register_info->enable_for_wake, register_bit);
155 ACPI_SET_BIT(gpe_register_info->enable_for_run, register_bit);
156 break;
157
158 default:
159 return_ACPI_STATUS(AE_BAD_PARAMETER);
160 }
161 92
162 return_ACPI_STATUS(AE_OK); 93 return_ACPI_STATUS(AE_OK);
163} 94}
@@ -167,8 +98,6 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
167 * FUNCTION: acpi_ev_enable_gpe 98 * FUNCTION: acpi_ev_enable_gpe
168 * 99 *
169 * PARAMETERS: gpe_event_info - GPE to enable 100 * PARAMETERS: gpe_event_info - GPE to enable
170 * write_to_hardware - Enable now, or just mark data structs
171 * (WAKE GPEs should be deferred)
172 * 101 *
173 * RETURN: Status 102 * RETURN: Status
174 * 103 *
@@ -176,9 +105,7 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
176 * 105 *
177 ******************************************************************************/ 106 ******************************************************************************/
178 107
179acpi_status 108acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
180acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
181 u8 write_to_hardware)
182{ 109{
183 acpi_status status; 110 acpi_status status;
184 111
@@ -186,50 +113,18 @@ acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
186 113
187 /* Make sure HW enable masks are updated */ 114 /* Make sure HW enable masks are updated */
188 115
189 status = 116 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
190 acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_ENABLE); 117 if (ACPI_FAILURE(status))
191 if (ACPI_FAILURE(status)) {
192 return_ACPI_STATUS(status); 118 return_ACPI_STATUS(status);
193 }
194
195 /* Mark wake-enabled or HW enable, or both */
196
197 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
198 case ACPI_GPE_TYPE_WAKE:
199
200 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
201 break;
202
203 case ACPI_GPE_TYPE_WAKE_RUN:
204
205 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
206
207 /*lint -fallthrough */
208
209 case ACPI_GPE_TYPE_RUNTIME:
210
211 ACPI_SET_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
212
213 if (write_to_hardware) {
214
215 /* Clear the GPE (of stale events), then enable it */
216
217 status = acpi_hw_clear_gpe(gpe_event_info);
218 if (ACPI_FAILURE(status)) {
219 return_ACPI_STATUS(status);
220 }
221
222 /* Enable the requested runtime GPE */
223
224 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
225 }
226 break;
227 119
228 default: 120 /* Clear the GPE (of stale events), then enable it */
229 return_ACPI_STATUS(AE_BAD_PARAMETER); 121 status = acpi_hw_clear_gpe(gpe_event_info);
230 } 122 if (ACPI_FAILURE(status))
123 return_ACPI_STATUS(status);
231 124
232 return_ACPI_STATUS(AE_OK); 125 /* Enable the requested GPE */
126 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
127 return_ACPI_STATUS(status);
233} 128}
234 129
235/******************************************************************************* 130/*******************************************************************************
@@ -252,34 +147,9 @@ acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
252 147
253 /* Make sure HW enable masks are updated */ 148 /* Make sure HW enable masks are updated */
254 149
255 status = 150 status = acpi_ev_update_gpe_enable_masks(gpe_event_info);
256 acpi_ev_update_gpe_enable_masks(gpe_event_info, ACPI_GPE_DISABLE); 151 if (ACPI_FAILURE(status))
257 if (ACPI_FAILURE(status)) {
258 return_ACPI_STATUS(status); 152 return_ACPI_STATUS(status);
259 }
260
261 /* Clear the appropriate enabled flags for this GPE */
262
263 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
264 case ACPI_GPE_TYPE_WAKE:
265 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
266 break;
267
268 case ACPI_GPE_TYPE_WAKE_RUN:
269 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
270
271 /* fallthrough */
272
273 case ACPI_GPE_TYPE_RUNTIME:
274
275 /* Disable the requested runtime GPE */
276
277 ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
278 break;
279
280 default:
281 break;
282 }
283 153
284 /* 154 /*
285 * Even if we don't know the GPE type, make sure that we always 155 * Even if we don't know the GPE type, make sure that we always
@@ -521,7 +391,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
521 391
522 /* Set the GPE flags for return to enabled state */ 392 /* Set the GPE flags for return to enabled state */
523 393
524 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE); 394 (void)acpi_ev_update_gpe_enable_masks(gpe_event_info);
525 395
526 /* 396 /*
527 * Take a snapshot of the GPE info for this level - we copy the info to 397 * Take a snapshot of the GPE info for this level - we copy the info to
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index a60aaa7635f3..fef721917eaf 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -258,7 +258,6 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
258 u32 gpe_number; 258 u32 gpe_number;
259 char name[ACPI_NAME_SIZE + 1]; 259 char name[ACPI_NAME_SIZE + 1];
260 u8 type; 260 u8 type;
261 acpi_status status;
262 261
263 ACPI_FUNCTION_TRACE(ev_save_method_info); 262 ACPI_FUNCTION_TRACE(ev_save_method_info);
264 263
@@ -325,26 +324,20 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
325 324
326 /* 325 /*
327 * Now we can add this information to the gpe_event_info block for use 326 * Now we can add this information to the gpe_event_info block for use
328 * during dispatch of this GPE. Default type is RUNTIME, although this may 327 * during dispatch of this GPE.
329 * change when the _PRW methods are executed later.
330 */ 328 */
331 gpe_event_info = 329 gpe_event_info =
332 &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 330 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
333 331
334 gpe_event_info->flags = (u8) 332 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD);
335 (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME);
336 333
337 gpe_event_info->dispatch.method_node = 334 gpe_event_info->dispatch.method_node =
338 (struct acpi_namespace_node *)obj_handle; 335 (struct acpi_namespace_node *)obj_handle;
339 336
340 /* Update enable mask, but don't enable the HW GPE as of yet */
341
342 status = acpi_ev_enable_gpe(gpe_event_info, FALSE);
343
344 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, 337 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
345 "Registered GPE method %s as GPE number 0x%.2X\n", 338 "Registered GPE method %s as GPE number 0x%.2X\n",
346 name, gpe_number)); 339 name, gpe_number));
347 return_ACPI_STATUS(status); 340 return_ACPI_STATUS(AE_OK);
348} 341}
349 342
350/******************************************************************************* 343/*******************************************************************************
@@ -454,20 +447,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
454 gpe_block-> 447 gpe_block->
455 block_base_number]; 448 block_base_number];
456 449
457 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ 450 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
458
459 gpe_event_info->flags &=
460 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
461
462 status =
463 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
464 if (ACPI_FAILURE(status)) {
465 goto cleanup;
466 }
467
468 status =
469 acpi_ev_update_gpe_enable_masks(gpe_event_info,
470 ACPI_GPE_DISABLE);
471 } 451 }
472 452
473 cleanup: 453 cleanup:
@@ -945,8 +925,8 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
945 925
946 status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device, 926 status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device,
947 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, 927 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
948 acpi_ev_save_method_info, gpe_block, 928 acpi_ev_save_method_info, NULL,
949 NULL); 929 gpe_block, NULL);
950 930
951 /* Return the new block */ 931 /* Return the new block */
952 932
@@ -989,7 +969,6 @@ acpi_status
989acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, 969acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
990 struct acpi_gpe_block_info *gpe_block) 970 struct acpi_gpe_block_info *gpe_block)
991{ 971{
992 acpi_status status;
993 struct acpi_gpe_event_info *gpe_event_info; 972 struct acpi_gpe_event_info *gpe_event_info;
994 struct acpi_gpe_walk_info gpe_info; 973 struct acpi_gpe_walk_info gpe_info;
995 u32 wake_gpe_count; 974 u32 wake_gpe_count;
@@ -1019,42 +998,50 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
1019 gpe_info.gpe_block = gpe_block; 998 gpe_info.gpe_block = gpe_block;
1020 gpe_info.gpe_device = gpe_device; 999 gpe_info.gpe_device = gpe_device;
1021 1000
1022 status = 1001 acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1023 acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1024 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, 1002 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
1025 acpi_ev_match_prw_and_gpe, &gpe_info, 1003 acpi_ev_match_prw_and_gpe, NULL,
1026 NULL); 1004 &gpe_info, NULL);
1027 } 1005 }
1028 1006
1029 /* 1007 /*
1030 * Enable all GPEs in this block that have these attributes: 1008 * Enable all GPEs that have a corresponding method and aren't
1031 * 1) are "runtime" or "run/wake" GPEs, and 1009 * capable of generating wakeups. Any other GPEs within this block
1032 * 2) have a corresponding _Lxx or _Exx method 1010 * must be enabled via the acpi_enable_gpe() interface.
1033 *
1034 * Any other GPEs within this block must be enabled via the
1035 * acpi_enable_gpe() external interface.
1036 */ 1011 */
1037 wake_gpe_count = 0; 1012 wake_gpe_count = 0;
1038 gpe_enabled_count = 0; 1013 gpe_enabled_count = 0;
1014 if (gpe_device == acpi_gbl_fadt_gpe_device)
1015 gpe_device = NULL;
1039 1016
1040 for (i = 0; i < gpe_block->register_count; i++) { 1017 for (i = 0; i < gpe_block->register_count; i++) {
1041 for (j = 0; j < 8; j++) { 1018 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
1019 acpi_status status;
1020 acpi_size gpe_index;
1021 int gpe_number;
1042 1022
1043 /* Get the info block for this particular GPE */ 1023 /* Get the info block for this particular GPE */
1024 gpe_index = (acpi_size)i * ACPI_GPE_REGISTER_WIDTH + j;
1025 gpe_event_info = &gpe_block->event_info[gpe_index];
1044 1026
1045 gpe_event_info = &gpe_block->event_info[((acpi_size) i * 1027 if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) {
1046 ACPI_GPE_REGISTER_WIDTH)
1047 + j];
1048
1049 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
1050 ACPI_GPE_DISPATCH_METHOD) &&
1051 (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) {
1052 gpe_enabled_count++;
1053 }
1054
1055 if (gpe_event_info->flags & ACPI_GPE_TYPE_WAKE) {
1056 wake_gpe_count++; 1028 wake_gpe_count++;
1029 if (acpi_gbl_leave_wake_gpes_disabled)
1030 continue;
1057 } 1031 }
1032
1033 if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD))
1034 continue;
1035
1036 gpe_number = gpe_index + gpe_block->block_base_number;
1037 status = acpi_enable_gpe(gpe_device, gpe_number,
1038 ACPI_GPE_TYPE_RUNTIME);
1039 if (ACPI_FAILURE(status))
1040 ACPI_ERROR((AE_INFO,
1041 "Failed to enable GPE %02X\n",
1042 gpe_number));
1043 else
1044 gpe_enabled_count++;
1058 } 1045 }
1059 } 1046 }
1060 1047
@@ -1062,15 +1049,7 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
1062 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 1049 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
1063 wake_gpe_count, gpe_enabled_count)); 1050 wake_gpe_count, gpe_enabled_count));
1064 1051
1065 /* Enable all valid runtime GPEs found above */ 1052 return_ACPI_STATUS(AE_OK);
1066
1067 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block, NULL);
1068 if (ACPI_FAILURE(status)) {
1069 ACPI_ERROR((AE_INFO, "Could not enable GPEs in GpeBlock %p",
1070 gpe_block));
1071 }
1072
1073 return_ACPI_STATUS(status);
1074} 1053}
1075 1054
1076/******************************************************************************* 1055/*******************************************************************************
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index ce224e1eaa89..9a3cb7045a32 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -259,9 +259,15 @@ static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
259 259
260 handler_obj = notify_info->notify.handler_obj; 260 handler_obj = notify_info->notify.handler_obj;
261 if (handler_obj) { 261 if (handler_obj) {
262 handler_obj->notify.handler(notify_info->notify.node, 262 struct acpi_object_notify_handler *notifier;
263 notify_info->notify.value, 263
264 handler_obj->notify.context); 264 notifier = &handler_obj->notify;
265 while (notifier) {
266 notifier->handler(notify_info->notify.node,
267 notify_info->notify.value,
268 notifier->context);
269 notifier = notifier->next;
270 }
265 } 271 }
266 272
267 /* All done with the info object */ 273 /* All done with the info object */
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 98c7f9c62653..98fd210e87b2 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,10 @@
51ACPI_MODULE_NAME("evregion") 51ACPI_MODULE_NAME("evregion")
52 52
53/* Local prototypes */ 53/* Local prototypes */
54static u8
55acpi_ev_has_default_handler(struct acpi_namespace_node *node,
56 acpi_adr_space_type space_id);
57
54static acpi_status 58static acpi_status
55acpi_ev_reg_run(acpi_handle obj_handle, 59acpi_ev_reg_run(acpi_handle obj_handle,
56 u32 level, void *context, void **return_value); 60 u32 level, void *context, void **return_value);
@@ -142,6 +146,50 @@ acpi_status acpi_ev_install_region_handlers(void)
142 146
143/******************************************************************************* 147/*******************************************************************************
144 * 148 *
149 * FUNCTION: acpi_ev_has_default_handler
150 *
151 * PARAMETERS: Node - Namespace node for the device
152 * space_id - The address space ID
153 *
154 * RETURN: TRUE if default handler is installed, FALSE otherwise
155 *
156 * DESCRIPTION: Check if the default handler is installed for the requested
157 * space ID.
158 *
159 ******************************************************************************/
160
161static u8
162acpi_ev_has_default_handler(struct acpi_namespace_node *node,
163 acpi_adr_space_type space_id)
164{
165 union acpi_operand_object *obj_desc;
166 union acpi_operand_object *handler_obj;
167
168 /* Must have an existing internal object */
169
170 obj_desc = acpi_ns_get_attached_object(node);
171 if (obj_desc) {
172 handler_obj = obj_desc->device.handler;
173
174 /* Walk the linked list of handlers for this object */
175
176 while (handler_obj) {
177 if (handler_obj->address_space.space_id == space_id) {
178 if (handler_obj->address_space.handler_flags &
179 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
180 return (TRUE);
181 }
182 }
183
184 handler_obj = handler_obj->address_space.next;
185 }
186 }
187
188 return (FALSE);
189}
190
191/*******************************************************************************
192 *
145 * FUNCTION: acpi_ev_initialize_op_regions 193 * FUNCTION: acpi_ev_initialize_op_regions
146 * 194 *
147 * PARAMETERS: None 195 * PARAMETERS: None
@@ -169,12 +217,18 @@ acpi_status acpi_ev_initialize_op_regions(void)
169 217
170 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { 218 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
171 /* 219 /*
172 * TBD: Make sure handler is the DEFAULT handler, otherwise 220 * Make sure the installed handler is the DEFAULT handler. If not the
173 * _REG will have already been run. 221 * default, the _REG methods will have already been run (when the
222 * handler was installed)
174 */ 223 */
175 status = acpi_ev_execute_reg_methods(acpi_gbl_root_node, 224 if (acpi_ev_has_default_handler(acpi_gbl_root_node,
176 acpi_gbl_default_address_spaces 225 acpi_gbl_default_address_spaces
177 [i]); 226 [i])) {
227 status =
228 acpi_ev_execute_reg_methods(acpi_gbl_root_node,
229 acpi_gbl_default_address_spaces
230 [i]);
231 }
178 } 232 }
179 233
180 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 234 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
@@ -235,23 +289,20 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
235 * connection status 1 for connecting the handler, 0 for disconnecting 289 * connection status 1 for connecting the handler, 0 for disconnecting
236 * the handler (Passed as a parameter) 290 * the handler (Passed as a parameter)
237 */ 291 */
238 args[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 292 args[0] =
293 acpi_ut_create_integer_object((u64) region_obj->region.space_id);
239 if (!args[0]) { 294 if (!args[0]) {
240 status = AE_NO_MEMORY; 295 status = AE_NO_MEMORY;
241 goto cleanup1; 296 goto cleanup1;
242 } 297 }
243 298
244 args[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 299 args[1] = acpi_ut_create_integer_object((u64) function);
245 if (!args[1]) { 300 if (!args[1]) {
246 status = AE_NO_MEMORY; 301 status = AE_NO_MEMORY;
247 goto cleanup2; 302 goto cleanup2;
248 } 303 }
249 304
250 /* Setup the parameter objects */ 305 args[2] = NULL; /* Terminate list */
251
252 args[0]->integer.value = region_obj->region.space_id;
253 args[1]->integer.value = function;
254 args[2] = NULL;
255 306
256 /* Execute the method, no return value */ 307 /* Execute the method, no return value */
257 308
@@ -278,7 +329,7 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
278 * region_offset - Where in the region to read or write 329 * region_offset - Where in the region to read or write
279 * bit_width - Field width in bits (8, 16, 32, or 64) 330 * bit_width - Field width in bits (8, 16, 32, or 64)
280 * Value - Pointer to in or out value, must be 331 * Value - Pointer to in or out value, must be
281 * full 64-bit acpi_integer 332 * a full 64-bit integer
282 * 333 *
283 * RETURN: Status 334 * RETURN: Status
284 * 335 *
@@ -290,8 +341,7 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
290acpi_status 341acpi_status
291acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, 342acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
292 u32 function, 343 u32 function,
293 u32 region_offset, 344 u32 region_offset, u32 bit_width, u64 *value)
294 u32 bit_width, acpi_integer * value)
295{ 345{
296 acpi_status status; 346 acpi_status status;
297 acpi_adr_space_handler handler; 347 acpi_adr_space_handler handler;
@@ -667,7 +717,7 @@ acpi_ev_install_handler(acpi_handle obj_handle,
667 717
668 /* Convert and validate the device handle */ 718 /* Convert and validate the device handle */
669 719
670 node = acpi_ns_map_handle_to_node(obj_handle); 720 node = acpi_ns_validate_handle(obj_handle);
671 if (!node) { 721 if (!node) {
672 return (AE_BAD_PARAMETER); 722 return (AE_BAD_PARAMETER);
673 } 723 }
@@ -971,8 +1021,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
971 */ 1021 */
972 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, 1022 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
973 ACPI_NS_WALK_UNLOCK, 1023 ACPI_NS_WALK_UNLOCK,
974 acpi_ev_install_handler, handler_obj, 1024 acpi_ev_install_handler, NULL,
975 NULL); 1025 handler_obj, NULL);
976 1026
977 unlock_and_exit: 1027 unlock_and_exit:
978 return_ACPI_STATUS(status); 1028 return_ACPI_STATUS(status);
@@ -1008,7 +1058,7 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
1008 */ 1058 */
1009 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, 1059 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
1010 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, 1060 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
1011 &space_id, NULL); 1061 NULL, &space_id, NULL);
1012 1062
1013 return_ACPI_STATUS(status); 1063 return_ACPI_STATUS(status);
1014} 1064}
@@ -1036,7 +1086,7 @@ acpi_ev_reg_run(acpi_handle obj_handle,
1036 1086
1037 /* Convert and validate the device handle */ 1087 /* Convert and validate the device handle */
1038 1088
1039 node = acpi_ns_map_handle_to_node(obj_handle); 1089 node = acpi_ns_validate_handle(obj_handle);
1040 if (!node) { 1090 if (!node) {
1041 return (AE_BAD_PARAMETER); 1091 return (AE_BAD_PARAMETER);
1042 } 1092 }
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index cf29c4953028..2e3b0334072f 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -168,7 +168,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
168 void *handler_context, void **region_context) 168 void *handler_context, void **region_context)
169{ 169{
170 acpi_status status = AE_OK; 170 acpi_status status = AE_OK;
171 acpi_integer pci_value; 171 u64 pci_value;
172 struct acpi_pci_id *pci_id = *region_context; 172 struct acpi_pci_id *pci_id = *region_context;
173 union acpi_operand_object *handler_obj; 173 union acpi_operand_object *handler_obj;
174 struct acpi_namespace_node *parent_node; 174 struct acpi_namespace_node *parent_node;
@@ -575,6 +575,21 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
575 handler_obj = obj_desc->thermal_zone.handler; 575 handler_obj = obj_desc->thermal_zone.handler;
576 break; 576 break;
577 577
578 case ACPI_TYPE_METHOD:
579 /*
580 * If we are executing module level code, the original
581 * Node's object was replaced by this Method object and we
582 * saved the handler in the method object.
583 *
584 * See acpi_ns_exec_module_code
585 */
586 if (obj_desc->method.
587 flags & AOPOBJ_MODULE_LEVEL) {
588 handler_obj =
589 obj_desc->method.extra.handler;
590 }
591 break;
592
578 default: 593 default:
579 /* Ignore other objects */ 594 /* Ignore other objects */
580 break; 595 break;
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index 567b356c85af..8dfbaa96e422 100644
--- a/drivers/acpi/acpica/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 10b8543dd466..b40757955f9b 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -218,6 +218,72 @@ ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler)
218 218
219/******************************************************************************* 219/*******************************************************************************
220 * 220 *
221 * FUNCTION: acpi_populate_handler_object
222 *
223 * PARAMETERS: handler_obj - Handler object to populate
224 * handler_type - The type of handler:
225 * ACPI_SYSTEM_NOTIFY: system_handler (00-7f)
226 * ACPI_DEVICE_NOTIFY: driver_handler (80-ff)
227 * ACPI_ALL_NOTIFY: both system and device
228 * handler - Address of the handler
229 * context - Value passed to the handler on each GPE
230 * next - Address of a handler object to link to
231 *
232 * RETURN: None
233 *
234 * DESCRIPTION: Populate a handler object.
235 *
236 ******************************************************************************/
237static void
238acpi_populate_handler_object(struct acpi_object_notify_handler *handler_obj,
239 u32 handler_type,
240 acpi_notify_handler handler, void *context,
241 struct acpi_object_notify_handler *next)
242{
243 handler_obj->handler_type = handler_type;
244 handler_obj->handler = handler;
245 handler_obj->context = context;
246 handler_obj->next = next;
247}
248
249/*******************************************************************************
250 *
251 * FUNCTION: acpi_add_handler_object
252 *
253 * PARAMETERS: parent_obj - Parent of the new object
254 * handler - Address of the handler
255 * context - Value passed to the handler on each GPE
256 *
257 * RETURN: Status
258 *
259 * DESCRIPTION: Create a new handler object and populate it.
260 *
261 ******************************************************************************/
262static acpi_status
263acpi_add_handler_object(struct acpi_object_notify_handler *parent_obj,
264 acpi_notify_handler handler, void *context)
265{
266 struct acpi_object_notify_handler *handler_obj;
267
268 /* The parent must not be a defice notify handler object. */
269 if (parent_obj->handler_type & ACPI_DEVICE_NOTIFY)
270 return AE_BAD_PARAMETER;
271
272 handler_obj = ACPI_ALLOCATE_ZEROED(sizeof(*handler_obj));
273 if (!handler_obj)
274 return AE_NO_MEMORY;
275
276 acpi_populate_handler_object(handler_obj,
277 ACPI_SYSTEM_NOTIFY,
278 handler, context,
279 parent_obj->next);
280 parent_obj->next = handler_obj;
281
282 return AE_OK;
283}
284
285/*******************************************************************************
286 *
221 * FUNCTION: acpi_install_notify_handler 287 * FUNCTION: acpi_install_notify_handler
222 * 288 *
223 * PARAMETERS: Device - The device for which notifies will be handled 289 * PARAMETERS: Device - The device for which notifies will be handled
@@ -259,7 +325,7 @@ acpi_install_notify_handler(acpi_handle device,
259 325
260 /* Convert and validate the device handle */ 326 /* Convert and validate the device handle */
261 327
262 node = acpi_ns_map_handle_to_node(device); 328 node = acpi_ns_validate_handle(device);
263 if (!node) { 329 if (!node) {
264 status = AE_BAD_PARAMETER; 330 status = AE_BAD_PARAMETER;
265 goto unlock_and_exit; 331 goto unlock_and_exit;
@@ -316,15 +382,32 @@ acpi_install_notify_handler(acpi_handle device,
316 obj_desc = acpi_ns_get_attached_object(node); 382 obj_desc = acpi_ns_get_attached_object(node);
317 if (obj_desc) { 383 if (obj_desc) {
318 384
319 /* Object exists - make sure there's no handler */ 385 /* Object exists. */
320 386
321 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 387 /* For a device notify, make sure there's no handler. */
322 obj_desc->common_notify.system_notify) || 388 if ((handler_type & ACPI_DEVICE_NOTIFY) &&
323 ((handler_type & ACPI_DEVICE_NOTIFY) && 389 obj_desc->common_notify.device_notify) {
324 obj_desc->common_notify.device_notify)) {
325 status = AE_ALREADY_EXISTS; 390 status = AE_ALREADY_EXISTS;
326 goto unlock_and_exit; 391 goto unlock_and_exit;
327 } 392 }
393
394 /* System notifies may have more handlers installed. */
395 notify_obj = obj_desc->common_notify.system_notify;
396
397 if ((handler_type & ACPI_SYSTEM_NOTIFY) && notify_obj) {
398 struct acpi_object_notify_handler *parent_obj;
399
400 if (handler_type & ACPI_DEVICE_NOTIFY) {
401 status = AE_ALREADY_EXISTS;
402 goto unlock_and_exit;
403 }
404
405 parent_obj = &notify_obj->notify;
406 status = acpi_add_handler_object(parent_obj,
407 handler,
408 context);
409 goto unlock_and_exit;
410 }
328 } else { 411 } else {
329 /* Create a new object */ 412 /* Create a new object */
330 413
@@ -356,9 +439,10 @@ acpi_install_notify_handler(acpi_handle device,
356 goto unlock_and_exit; 439 goto unlock_and_exit;
357 } 440 }
358 441
359 notify_obj->notify.node = node; 442 acpi_populate_handler_object(&notify_obj->notify,
360 notify_obj->notify.handler = handler; 443 handler_type,
361 notify_obj->notify.context = context; 444 handler, context,
445 NULL);
362 446
363 if (handler_type & ACPI_SYSTEM_NOTIFY) { 447 if (handler_type & ACPI_SYSTEM_NOTIFY) {
364 obj_desc->common_notify.system_notify = notify_obj; 448 obj_desc->common_notify.system_notify = notify_obj;
@@ -418,6 +502,10 @@ acpi_remove_notify_handler(acpi_handle device,
418 goto exit; 502 goto exit;
419 } 503 }
420 504
505
506 /* Make sure all deferred tasks are completed */
507 acpi_os_wait_events_complete(NULL);
508
421 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 509 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
422 if (ACPI_FAILURE(status)) { 510 if (ACPI_FAILURE(status)) {
423 goto exit; 511 goto exit;
@@ -425,7 +513,7 @@ acpi_remove_notify_handler(acpi_handle device,
425 513
426 /* Convert and validate the device handle */ 514 /* Convert and validate the device handle */
427 515
428 node = acpi_ns_map_handle_to_node(device); 516 node = acpi_ns_validate_handle(device);
429 if (!node) { 517 if (!node) {
430 status = AE_BAD_PARAMETER; 518 status = AE_BAD_PARAMETER;
431 goto unlock_and_exit; 519 goto unlock_and_exit;
@@ -445,15 +533,6 @@ acpi_remove_notify_handler(acpi_handle device,
445 goto unlock_and_exit; 533 goto unlock_and_exit;
446 } 534 }
447 535
448 /* Make sure all deferred tasks are completed */
449
450 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
451 acpi_os_wait_events_complete(NULL);
452 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
453 if (ACPI_FAILURE(status)) {
454 goto exit;
455 }
456
457 if (handler_type & ACPI_SYSTEM_NOTIFY) { 536 if (handler_type & ACPI_SYSTEM_NOTIFY) {
458 acpi_gbl_system_notify.node = NULL; 537 acpi_gbl_system_notify.node = NULL;
459 acpi_gbl_system_notify.handler = NULL; 538 acpi_gbl_system_notify.handler = NULL;
@@ -488,28 +567,60 @@ acpi_remove_notify_handler(acpi_handle device,
488 /* Object exists - make sure there's an existing handler */ 567 /* Object exists - make sure there's an existing handler */
489 568
490 if (handler_type & ACPI_SYSTEM_NOTIFY) { 569 if (handler_type & ACPI_SYSTEM_NOTIFY) {
570 struct acpi_object_notify_handler *handler_obj;
571 struct acpi_object_notify_handler *parent_obj;
572
491 notify_obj = obj_desc->common_notify.system_notify; 573 notify_obj = obj_desc->common_notify.system_notify;
492 if (!notify_obj) { 574 if (!notify_obj) {
493 status = AE_NOT_EXIST; 575 status = AE_NOT_EXIST;
494 goto unlock_and_exit; 576 goto unlock_and_exit;
495 } 577 }
496 578
497 if (notify_obj->notify.handler != handler) { 579 handler_obj = &notify_obj->notify;
580 parent_obj = NULL;
581 while (handler_obj->handler != handler) {
582 if (handler_obj->next) {
583 parent_obj = handler_obj;
584 handler_obj = handler_obj->next;
585 } else {
586 break;
587 }
588 }
589
590 if (handler_obj->handler != handler) {
498 status = AE_BAD_PARAMETER; 591 status = AE_BAD_PARAMETER;
499 goto unlock_and_exit; 592 goto unlock_and_exit;
500 } 593 }
501 /* Make sure all deferred tasks are completed */
502 594
503 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 595 /*
504 acpi_os_wait_events_complete(NULL); 596 * Remove the handler. There are three possible cases.
505 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 597 * First, we may need to remove a non-embedded object.
506 if (ACPI_FAILURE(status)) { 598 * Second, we may need to remove the embedded object's
507 goto exit; 599 * handler data, while non-embedded objects exist.
600 * Finally, we may need to remove the embedded object
601 * entirely along with its container.
602 */
603 if (parent_obj) {
604 /* Non-embedded object is being removed. */
605 parent_obj->next = handler_obj->next;
606 ACPI_FREE(handler_obj);
607 } else if (notify_obj->notify.next) {
608 /*
609 * The handler matches the embedded object, but
610 * there are more handler objects in the list.
611 * Replace the embedded object's data with the
612 * first next object's data and remove that
613 * object.
614 */
615 parent_obj = &notify_obj->notify;
616 handler_obj = notify_obj->notify.next;
617 *parent_obj = *handler_obj;
618 ACPI_FREE(handler_obj);
619 } else {
620 /* No more handler objects in the list. */
621 obj_desc->common_notify.system_notify = NULL;
622 acpi_ut_remove_reference(notify_obj);
508 } 623 }
509
510 /* Remove the handler */
511 obj_desc->common_notify.system_notify = NULL;
512 acpi_ut_remove_reference(notify_obj);
513 } 624 }
514 625
515 if (handler_type & ACPI_DEVICE_NOTIFY) { 626 if (handler_type & ACPI_DEVICE_NOTIFY) {
@@ -523,14 +634,6 @@ acpi_remove_notify_handler(acpi_handle device,
523 status = AE_BAD_PARAMETER; 634 status = AE_BAD_PARAMETER;
524 goto unlock_and_exit; 635 goto unlock_and_exit;
525 } 636 }
526 /* Make sure all deferred tasks are completed */
527
528 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
529 acpi_os_wait_events_complete(NULL);
530 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
531 if (ACPI_FAILURE(status)) {
532 goto exit;
533 }
534 637
535 /* Remove the handler */ 638 /* Remove the handler */
536 obj_desc->common_notify.device_notify = NULL; 639 obj_desc->common_notify.device_notify = NULL;
@@ -617,13 +720,6 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
617 handler->context = context; 720 handler->context = context;
618 handler->method_node = gpe_event_info->dispatch.method_node; 721 handler->method_node = gpe_event_info->dispatch.method_node;
619 722
620 /* Disable the GPE before installing the handler */
621
622 status = acpi_ev_disable_gpe(gpe_event_info);
623 if (ACPI_FAILURE(status)) {
624 goto unlock_and_exit;
625 }
626
627 /* Install the handler */ 723 /* Install the handler */
628 724
629 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 725 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
@@ -707,13 +803,6 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
707 goto unlock_and_exit; 803 goto unlock_and_exit;
708 } 804 }
709 805
710 /* Disable the GPE before removing the handler */
711
712 status = acpi_ev_disable_gpe(gpe_event_info);
713 if (ACPI_FAILURE(status)) {
714 goto unlock_and_exit;
715 }
716
717 /* Make sure all deferred tasks are completed */ 806 /* Make sure all deferred tasks are completed */
718 807
719 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 808 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 4721f58fe42c..5ff32c78ea2d 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -201,23 +201,27 @@ ACPI_EXPORT_SYMBOL(acpi_enable_event)
201 201
202/******************************************************************************* 202/*******************************************************************************
203 * 203 *
204 * FUNCTION: acpi_set_gpe_type 204 * FUNCTION: acpi_set_gpe
205 * 205 *
206 * PARAMETERS: gpe_device - Parent GPE Device 206 * PARAMETERS: gpe_device - Parent GPE Device
207 * gpe_number - GPE level within the GPE block 207 * gpe_number - GPE level within the GPE block
208 * Type - New GPE type 208 * action - Enable or disable
209 * Called from ISR or not
209 * 210 *
210 * RETURN: Status 211 * RETURN: Status
211 * 212 *
212 * DESCRIPTION: Set the type of an individual GPE 213 * DESCRIPTION: Enable or disable an ACPI event (general purpose)
213 * 214 *
214 ******************************************************************************/ 215 ******************************************************************************/
215acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type) 216acpi_status acpi_set_gpe(acpi_handle gpe_device, u32 gpe_number, u8 action)
216{ 217{
217 acpi_status status = AE_OK; 218 acpi_status status = AE_OK;
219 acpi_cpu_flags flags;
218 struct acpi_gpe_event_info *gpe_event_info; 220 struct acpi_gpe_event_info *gpe_event_info;
219 221
220 ACPI_FUNCTION_TRACE(acpi_set_gpe_type); 222 ACPI_FUNCTION_TRACE(acpi_set_gpe);
223
224 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
221 225
222 /* Ensure that we have a valid GPE number */ 226 /* Ensure that we have a valid GPE number */
223 227
@@ -227,19 +231,29 @@ acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
227 goto unlock_and_exit; 231 goto unlock_and_exit;
228 } 232 }
229 233
230 if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) { 234 /* Perform the action */
231 return_ACPI_STATUS(AE_OK); 235
232 } 236 switch (action) {
237 case ACPI_GPE_ENABLE:
238 status = acpi_ev_enable_gpe(gpe_event_info);
239 break;
233 240
234 /* Set the new type (will disable GPE if currently enabled) */ 241 case ACPI_GPE_DISABLE:
242 status = acpi_ev_disable_gpe(gpe_event_info);
243 break;
235 244
236 status = acpi_ev_set_gpe_type(gpe_event_info, type); 245 default:
246 ACPI_ERROR((AE_INFO, "Invalid action\n"));
247 status = AE_BAD_PARAMETER;
248 break;
249 }
237 250
238 unlock_and_exit: 251 unlock_and_exit:
252 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
239 return_ACPI_STATUS(status); 253 return_ACPI_STATUS(status);
240} 254}
241 255
242ACPI_EXPORT_SYMBOL(acpi_set_gpe_type) 256ACPI_EXPORT_SYMBOL(acpi_set_gpe)
243 257
244/******************************************************************************* 258/*******************************************************************************
245 * 259 *
@@ -247,15 +261,14 @@ ACPI_EXPORT_SYMBOL(acpi_set_gpe_type)
247 * 261 *
248 * PARAMETERS: gpe_device - Parent GPE Device 262 * PARAMETERS: gpe_device - Parent GPE Device
249 * gpe_number - GPE level within the GPE block 263 * gpe_number - GPE level within the GPE block
250 * Flags - Just enable, or also wake enable? 264 * type - Purpose the GPE will be used for
251 * Called from ISR or not
252 * 265 *
253 * RETURN: Status 266 * RETURN: Status
254 * 267 *
255 * DESCRIPTION: Enable an ACPI event (general purpose) 268 * DESCRIPTION: Take a reference to a GPE and enable it if necessary
256 * 269 *
257 ******************************************************************************/ 270 ******************************************************************************/
258acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) 271acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 type)
259{ 272{
260 acpi_status status = AE_OK; 273 acpi_status status = AE_OK;
261 acpi_cpu_flags flags; 274 acpi_cpu_flags flags;
@@ -263,6 +276,9 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
263 276
264 ACPI_FUNCTION_TRACE(acpi_enable_gpe); 277 ACPI_FUNCTION_TRACE(acpi_enable_gpe);
265 278
279 if (type & ~ACPI_GPE_TYPE_WAKE_RUN)
280 return_ACPI_STATUS(AE_BAD_PARAMETER);
281
266 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 282 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
267 283
268 /* Ensure that we have a valid GPE number */ 284 /* Ensure that we have a valid GPE number */
@@ -273,15 +289,32 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
273 goto unlock_and_exit; 289 goto unlock_and_exit;
274 } 290 }
275 291
276 /* Perform the enable */ 292 if (type & ACPI_GPE_TYPE_RUNTIME) {
293 if (++gpe_event_info->runtime_count == 1) {
294 status = acpi_ev_enable_gpe(gpe_event_info);
295 if (ACPI_FAILURE(status))
296 gpe_event_info->runtime_count--;
297 }
298 }
299
300 if (type & ACPI_GPE_TYPE_WAKE) {
301 if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) {
302 status = AE_BAD_PARAMETER;
303 goto unlock_and_exit;
304 }
277 305
278 status = acpi_ev_enable_gpe(gpe_event_info, TRUE); 306 /*
307 * Wake-up GPEs are only enabled right prior to putting the
308 * system into a sleep state.
309 */
310 if (++gpe_event_info->wakeup_count == 1)
311 acpi_ev_update_gpe_enable_masks(gpe_event_info);
312 }
279 313
280 unlock_and_exit: 314unlock_and_exit:
281 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 315 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
282 return_ACPI_STATUS(status); 316 return_ACPI_STATUS(status);
283} 317}
284
285ACPI_EXPORT_SYMBOL(acpi_enable_gpe) 318ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
286 319
287/******************************************************************************* 320/*******************************************************************************
@@ -290,15 +323,14 @@ ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
290 * 323 *
291 * PARAMETERS: gpe_device - Parent GPE Device 324 * PARAMETERS: gpe_device - Parent GPE Device
292 * gpe_number - GPE level within the GPE block 325 * gpe_number - GPE level within the GPE block
293 * Flags - Just disable, or also wake disable? 326 * type - Purpose the GPE won't be used for any more
294 * Called from ISR or not
295 * 327 *
296 * RETURN: Status 328 * RETURN: Status
297 * 329 *
298 * DESCRIPTION: Disable an ACPI event (general purpose) 330 * DESCRIPTION: Release a reference to a GPE and disable it if necessary
299 * 331 *
300 ******************************************************************************/ 332 ******************************************************************************/
301acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number) 333acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u8 type)
302{ 334{
303 acpi_status status = AE_OK; 335 acpi_status status = AE_OK;
304 acpi_cpu_flags flags; 336 acpi_cpu_flags flags;
@@ -306,6 +338,9 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
306 338
307 ACPI_FUNCTION_TRACE(acpi_disable_gpe); 339 ACPI_FUNCTION_TRACE(acpi_disable_gpe);
308 340
341 if (type & ~ACPI_GPE_TYPE_WAKE_RUN)
342 return_ACPI_STATUS(AE_BAD_PARAMETER);
343
309 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 344 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
310 /* Ensure that we have a valid GPE number */ 345 /* Ensure that we have a valid GPE number */
311 346
@@ -315,13 +350,24 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
315 goto unlock_and_exit; 350 goto unlock_and_exit;
316 } 351 }
317 352
318 status = acpi_ev_disable_gpe(gpe_event_info); 353 if ((type & ACPI_GPE_TYPE_RUNTIME) && gpe_event_info->runtime_count) {
354 if (--gpe_event_info->runtime_count == 0)
355 status = acpi_ev_disable_gpe(gpe_event_info);
356 }
357
358 if ((type & ACPI_GPE_TYPE_WAKE) && gpe_event_info->wakeup_count) {
359 /*
360 * Wake-up GPEs are not enabled after leaving system sleep
361 * states, so we don't need to disable them here.
362 */
363 if (--gpe_event_info->wakeup_count == 0)
364 acpi_ev_update_gpe_enable_masks(gpe_event_info);
365 }
319 366
320unlock_and_exit: 367unlock_and_exit:
321 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 368 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
322 return_ACPI_STATUS(status); 369 return_ACPI_STATUS(status);
323} 370}
324
325ACPI_EXPORT_SYMBOL(acpi_disable_gpe) 371ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
326 372
327/******************************************************************************* 373/*******************************************************************************
@@ -610,7 +656,7 @@ acpi_install_gpe_block(acpi_handle gpe_device,
610 return (status); 656 return (status);
611 } 657 }
612 658
613 node = acpi_ns_map_handle_to_node(gpe_device); 659 node = acpi_ns_validate_handle(gpe_device);
614 if (!node) { 660 if (!node) {
615 status = AE_BAD_PARAMETER; 661 status = AE_BAD_PARAMETER;
616 goto unlock_and_exit; 662 goto unlock_and_exit;
@@ -698,7 +744,7 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
698 return (status); 744 return (status);
699 } 745 }
700 746
701 node = acpi_ns_map_handle_to_node(gpe_device); 747 node = acpi_ns_validate_handle(gpe_device);
702 if (!node) { 748 if (!node) {
703 status = AE_BAD_PARAMETER; 749 status = AE_BAD_PARAMETER;
704 goto unlock_and_exit; 750 goto unlock_and_exit;
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index 7c3d2d356ffb..541cbc1544d5 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -89,7 +89,7 @@ acpi_install_address_space_handler(acpi_handle device,
89 89
90 /* Convert and validate the device handle */ 90 /* Convert and validate the device handle */
91 91
92 node = acpi_ns_map_handle_to_node(device); 92 node = acpi_ns_validate_handle(device);
93 if (!node) { 93 if (!node) {
94 status = AE_BAD_PARAMETER; 94 status = AE_BAD_PARAMETER;
95 goto unlock_and_exit; 95 goto unlock_and_exit;
@@ -155,7 +155,7 @@ acpi_remove_address_space_handler(acpi_handle device,
155 155
156 /* Convert and validate the device handle */ 156 /* Convert and validate the device handle */
157 157
158 node = acpi_ns_map_handle_to_node(device); 158 node = acpi_ns_validate_handle(device);
159 if (!node || 159 if (!node ||
160 ((node->type != ACPI_TYPE_DEVICE) && 160 ((node->type != ACPI_TYPE_DEVICE) &&
161 (node->type != ACPI_TYPE_PROCESSOR) && 161 (node->type != ACPI_TYPE_PROCESSOR) &&
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 24afef81af39..7e8b3bedc376 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -170,14 +170,12 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
170 170
171 /* Table not found, return an Integer=0 and AE_OK */ 171 /* Table not found, return an Integer=0 and AE_OK */
172 172
173 ddb_handle = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 173 ddb_handle = acpi_ut_create_integer_object((u64) 0);
174 if (!ddb_handle) { 174 if (!ddb_handle) {
175 return_ACPI_STATUS(AE_NO_MEMORY); 175 return_ACPI_STATUS(AE_NO_MEMORY);
176 } 176 }
177 177
178 ddb_handle->integer.value = 0;
179 *return_desc = ddb_handle; 178 *return_desc = ddb_handle;
180
181 return_ACPI_STATUS(AE_OK); 179 return_ACPI_STATUS(AE_OK);
182 } 180 }
183 181
@@ -286,7 +284,7 @@ static acpi_status
286acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer) 284acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
287{ 285{
288 acpi_status status; 286 acpi_status status;
289 acpi_integer value; 287 u64 value;
290 u32 region_offset = 0; 288 u32 region_offset = 0;
291 u32 i; 289 u32 i;
292 290
@@ -492,7 +490,11 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
492 490
493 status = acpi_tb_add_table(&table_desc, &table_index); 491 status = acpi_tb_add_table(&table_desc, &table_index);
494 if (ACPI_FAILURE(status)) { 492 if (ACPI_FAILURE(status)) {
495 goto cleanup; 493
494 /* Delete allocated table buffer */
495
496 acpi_tb_delete_table(&table_desc);
497 return_ACPI_STATUS(status);
496 } 498 }
497 499
498 /* 500 /*
@@ -535,13 +537,6 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
535 acpi_gbl_table_handler_context); 537 acpi_gbl_table_handler_context);
536 } 538 }
537 539
538 cleanup:
539 if (ACPI_FAILURE(status)) {
540
541 /* Delete allocated table buffer */
542
543 acpi_tb_delete_table(&table_desc);
544 }
545 return_ACPI_STATUS(status); 540 return_ACPI_STATUS(status);
546} 541}
547 542
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 37d0d39e60a6..bda7aed0404b 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,8 +51,7 @@ ACPI_MODULE_NAME("exconvrt")
51 51
52/* Local prototypes */ 52/* Local prototypes */
53static u32 53static u32
54acpi_ex_convert_to_ascii(acpi_integer integer, 54acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
55 u16 base, u8 * string, u8 max_length);
56 55
57/******************************************************************************* 56/*******************************************************************************
58 * 57 *
@@ -75,7 +74,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
75{ 74{
76 union acpi_operand_object *return_desc; 75 union acpi_operand_object *return_desc;
77 u8 *pointer; 76 u8 *pointer;
78 acpi_integer result; 77 u64 result;
79 u32 i; 78 u32 i;
80 u32 count; 79 u32 count;
81 acpi_status status; 80 acpi_status status;
@@ -155,7 +154,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
155 * Little endian is used, meaning that the first byte of the buffer 154 * Little endian is used, meaning that the first byte of the buffer
156 * is the LSB of the integer 155 * is the LSB of the integer
157 */ 156 */
158 result |= (((acpi_integer) pointer[i]) << (i * 8)); 157 result |= (((u64) pointer[i]) << (i * 8));
159 } 158 }
160 break; 159 break;
161 160
@@ -167,7 +166,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
167 166
168 /* Create a new integer */ 167 /* Create a new integer */
169 168
170 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 169 return_desc = acpi_ut_create_integer_object(result);
171 if (!return_desc) { 170 if (!return_desc) {
172 return_ACPI_STATUS(AE_NO_MEMORY); 171 return_ACPI_STATUS(AE_NO_MEMORY);
173 } 172 }
@@ -177,7 +176,6 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
177 176
178 /* Save the Result */ 177 /* Save the Result */
179 178
180 return_desc->integer.value = result;
181 acpi_ex_truncate_for32bit_table(return_desc); 179 acpi_ex_truncate_for32bit_table(return_desc);
182 *result_desc = return_desc; 180 *result_desc = return_desc;
183 return_ACPI_STATUS(AE_OK); 181 return_ACPI_STATUS(AE_OK);
@@ -286,10 +284,9 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
286 ******************************************************************************/ 284 ******************************************************************************/
287 285
288static u32 286static u32
289acpi_ex_convert_to_ascii(acpi_integer integer, 287acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
290 u16 base, u8 * string, u8 data_width)
291{ 288{
292 acpi_integer digit; 289 u64 digit;
293 u32 i; 290 u32 i;
294 u32 j; 291 u32 j;
295 u32 k = 0; 292 u32 k = 0;
@@ -532,10 +529,9 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
532 * (separated by commas or spaces) 529 * (separated by commas or spaces)
533 */ 530 */
534 for (i = 0; i < obj_desc->buffer.length; i++) { 531 for (i = 0; i < obj_desc->buffer.length; i++) {
535 new_buf += acpi_ex_convert_to_ascii((acpi_integer) 532 new_buf += acpi_ex_convert_to_ascii((u64) obj_desc->
536 obj_desc->buffer. 533 buffer.pointer[i],
537 pointer[i], base, 534 base, new_buf, 1);
538 new_buf, 1);
539 *new_buf++ = separator; /* each separated by a comma or space */ 535 *new_buf++ = separator; /* each separated by a comma or space */
540 } 536 }
541 537
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index 02b25d233d99..0aa57d938698 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index de3446372ddc..d39d438ba1e3 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index 0b33d6c887b9..6c79fecbee42 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -130,7 +130,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
130 /* Call the region handler for the read */ 130 /* Call the region handler for the read */
131 131
132 status = acpi_ex_access_region(obj_desc, 0, 132 status = acpi_ex_access_region(obj_desc, 0,
133 ACPI_CAST_PTR(acpi_integer, 133 ACPI_CAST_PTR(u64,
134 buffer_desc-> 134 buffer_desc->
135 buffer.pointer), 135 buffer.pointer),
136 function); 136 function);
@@ -141,7 +141,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
141 /* 141 /*
142 * Allocate a buffer for the contents of the field. 142 * Allocate a buffer for the contents of the field.
143 * 143 *
144 * If the field is larger than the size of an acpi_integer, create 144 * If the field is larger than the current integer width, create
145 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows 145 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
146 * the use of arithmetic operators on the returned value if the 146 * the use of arithmetic operators on the returned value if the
147 * field size is equal or smaller than an Integer. 147 * field size is equal or smaller than an Integer.
@@ -162,13 +162,12 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
162 } else { 162 } else {
163 /* Field will fit within an Integer (normal case) */ 163 /* Field will fit within an Integer (normal case) */
164 164
165 buffer_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 165 buffer_desc = acpi_ut_create_integer_object((u64) 0);
166 if (!buffer_desc) { 166 if (!buffer_desc) {
167 return_ACPI_STATUS(AE_NO_MEMORY); 167 return_ACPI_STATUS(AE_NO_MEMORY);
168 } 168 }
169 169
170 length = acpi_gbl_integer_byte_width; 170 length = acpi_gbl_integer_byte_width;
171 buffer_desc->integer.value = 0;
172 buffer = &buffer_desc->integer.value; 171 buffer = &buffer_desc->integer.value;
173 } 172 }
174 173
@@ -307,8 +306,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
307 * same buffer) 306 * same buffer)
308 */ 307 */
309 status = acpi_ex_access_region(obj_desc, 0, 308 status = acpi_ex_access_region(obj_desc, 0,
310 (acpi_integer *) buffer, 309 (u64 *) buffer, function);
311 function);
312 acpi_ex_release_global_lock(obj_desc->common_field.field_flags); 310 acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
313 311
314 *result_desc = buffer_desc; 312 *result_desc = buffer_desc;
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index d7b3b418fb45..f68a216168be 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -55,11 +55,10 @@ ACPI_MODULE_NAME("exfldio")
55static acpi_status 55static acpi_status
56acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, 56acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
57 u32 field_datum_byte_offset, 57 u32 field_datum_byte_offset,
58 acpi_integer * value, u32 read_write); 58 u64 *value, u32 read_write);
59 59
60static u8 60static u8
61acpi_ex_register_overflow(union acpi_operand_object *obj_desc, 61acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value);
62 acpi_integer value);
63 62
64static acpi_status 63static acpi_status
65acpi_ex_setup_region(union acpi_operand_object *obj_desc, 64acpi_ex_setup_region(union acpi_operand_object *obj_desc,
@@ -212,7 +211,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
212 * field_datum_byte_offset - Byte offset of this datum within the 211 * field_datum_byte_offset - Byte offset of this datum within the
213 * parent field 212 * parent field
214 * Value - Where to store value (must at least 213 * Value - Where to store value (must at least
215 * the size of acpi_integer) 214 * 64 bits)
216 * Function - Read or Write flag plus other region- 215 * Function - Read or Write flag plus other region-
217 * dependent flags 216 * dependent flags
218 * 217 *
@@ -224,8 +223,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
224 223
225acpi_status 224acpi_status
226acpi_ex_access_region(union acpi_operand_object *obj_desc, 225acpi_ex_access_region(union acpi_operand_object *obj_desc,
227 u32 field_datum_byte_offset, 226 u32 field_datum_byte_offset, u64 *value, u32 function)
228 acpi_integer * value, u32 function)
229{ 227{
230 acpi_status status; 228 acpi_status status;
231 union acpi_operand_object *rgn_desc; 229 union acpi_operand_object *rgn_desc;
@@ -317,8 +315,7 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
317 ******************************************************************************/ 315 ******************************************************************************/
318 316
319static u8 317static u8
320acpi_ex_register_overflow(union acpi_operand_object *obj_desc, 318acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
321 acpi_integer value)
322{ 319{
323 320
324 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) { 321 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
@@ -329,7 +326,7 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
329 return (FALSE); 326 return (FALSE);
330 } 327 }
331 328
332 if (value >= ((acpi_integer) 1 << obj_desc->common_field.bit_length)) { 329 if (value >= ((u64) 1 << obj_desc->common_field.bit_length)) {
333 /* 330 /*
334 * The Value is larger than the maximum value that can fit into 331 * The Value is larger than the maximum value that can fit into
335 * the register. 332 * the register.
@@ -362,11 +359,10 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
362 359
363static acpi_status 360static acpi_status
364acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, 361acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
365 u32 field_datum_byte_offset, 362 u32 field_datum_byte_offset, u64 *value, u32 read_write)
366 acpi_integer * value, u32 read_write)
367{ 363{
368 acpi_status status; 364 acpi_status status;
369 acpi_integer local_value; 365 u64 local_value;
370 366
371 ACPI_FUNCTION_TRACE_U32(ex_field_datum_io, field_datum_byte_offset); 367 ACPI_FUNCTION_TRACE_U32(ex_field_datum_io, field_datum_byte_offset);
372 368
@@ -439,8 +435,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
439 * the register 435 * the register
440 */ 436 */
441 if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj, 437 if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj,
442 (acpi_integer) obj_desc-> 438 (u64) obj_desc->bank_field.
443 bank_field.value)) { 439 value)) {
444 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); 440 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
445 } 441 }
446 442
@@ -481,8 +477,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
481 * the register 477 * the register
482 */ 478 */
483 if (acpi_ex_register_overflow(obj_desc->index_field.index_obj, 479 if (acpi_ex_register_overflow(obj_desc->index_field.index_obj,
484 (acpi_integer) obj_desc-> 480 (u64) obj_desc->index_field.
485 index_field.value)) { 481 value)) {
486 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT); 482 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
487 } 483 }
488 484
@@ -512,7 +508,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
512 status = 508 status =
513 acpi_ex_extract_from_field(obj_desc->index_field. 509 acpi_ex_extract_from_field(obj_desc->index_field.
514 data_obj, value, 510 data_obj, value,
515 sizeof(acpi_integer)); 511 sizeof(u64));
516 } else { 512 } else {
517 /* Write the datum to the data_register */ 513 /* Write the datum to the data_register */
518 514
@@ -523,7 +519,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
523 status = 519 status =
524 acpi_ex_insert_into_field(obj_desc->index_field. 520 acpi_ex_insert_into_field(obj_desc->index_field.
525 data_obj, value, 521 data_obj, value,
526 sizeof(acpi_integer)); 522 sizeof(u64));
527 } 523 }
528 break; 524 break;
529 525
@@ -571,13 +567,12 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
571 567
572acpi_status 568acpi_status
573acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, 569acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
574 acpi_integer mask, 570 u64 mask,
575 acpi_integer field_value, 571 u64 field_value, u32 field_datum_byte_offset)
576 u32 field_datum_byte_offset)
577{ 572{
578 acpi_status status = AE_OK; 573 acpi_status status = AE_OK;
579 acpi_integer merged_value; 574 u64 merged_value;
580 acpi_integer current_value; 575 u64 current_value;
581 576
582 ACPI_FUNCTION_TRACE_U32(ex_write_with_update_rule, mask); 577 ACPI_FUNCTION_TRACE_U32(ex_write_with_update_rule, mask);
583 578
@@ -587,7 +582,7 @@ acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
587 582
588 /* If the mask is all ones, we don't need to worry about the update rule */ 583 /* If the mask is all ones, we don't need to worry about the update rule */
589 584
590 if (mask != ACPI_INTEGER_MAX) { 585 if (mask != ACPI_UINT64_MAX) {
591 586
592 /* Decode the update rule */ 587 /* Decode the update rule */
593 588
@@ -678,8 +673,8 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
678 void *buffer, u32 buffer_length) 673 void *buffer, u32 buffer_length)
679{ 674{
680 acpi_status status; 675 acpi_status status;
681 acpi_integer raw_datum; 676 u64 raw_datum;
682 acpi_integer merged_datum; 677 u64 merged_datum;
683 u32 field_offset = 0; 678 u32 field_offset = 0;
684 u32 buffer_offset = 0; 679 u32 buffer_offset = 0;
685 u32 buffer_tail_bits; 680 u32 buffer_tail_bits;
@@ -804,10 +799,10 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
804 void *buffer, u32 buffer_length) 799 void *buffer, u32 buffer_length)
805{ 800{
806 acpi_status status; 801 acpi_status status;
807 acpi_integer mask; 802 u64 mask;
808 acpi_integer width_mask; 803 u64 width_mask;
809 acpi_integer merged_datum; 804 u64 merged_datum;
810 acpi_integer raw_datum = 0; 805 u64 raw_datum = 0;
811 u32 field_offset = 0; 806 u32 field_offset = 0;
812 u32 buffer_offset = 0; 807 u32 buffer_offset = 0;
813 u32 buffer_tail_bits; 808 u32 buffer_tail_bits;
@@ -855,7 +850,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
855 * shift operator 850 * shift operator
856 */ 851 */
857 if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) { 852 if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) {
858 width_mask = ACPI_INTEGER_MAX; 853 width_mask = ACPI_UINT64_MAX;
859 } else { 854 } else {
860 width_mask = 855 width_mask =
861 ACPI_MASK_BITS_ABOVE(obj_desc->common_field. 856 ACPI_MASK_BITS_ABOVE(obj_desc->common_field.
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 998eac329937..c5bb1eeed2df 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -409,8 +409,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
409 * 409 *
410 ******************************************************************************/ 410 ******************************************************************************/
411 411
412acpi_integer 412u64 acpi_ex_do_math_op(u16 opcode, u64 integer0, u64 integer1)
413acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
414{ 413{
415 414
416 ACPI_FUNCTION_ENTRY(); 415 ACPI_FUNCTION_ENTRY();
@@ -498,8 +497,7 @@ acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
498 497
499acpi_status 498acpi_status
500acpi_ex_do_logical_numeric_op(u16 opcode, 499acpi_ex_do_logical_numeric_op(u16 opcode,
501 acpi_integer integer0, 500 u64 integer0, u64 integer1, u8 *logical_result)
502 acpi_integer integer1, u8 * logical_result)
503{ 501{
504 acpi_status status = AE_OK; 502 acpi_status status = AE_OK;
505 u8 local_result = FALSE; 503 u8 local_result = FALSE;
@@ -564,8 +562,8 @@ acpi_ex_do_logical_op(u16 opcode,
564 union acpi_operand_object *operand1, u8 * logical_result) 562 union acpi_operand_object *operand1, u8 * logical_result)
565{ 563{
566 union acpi_operand_object *local_operand1 = operand1; 564 union acpi_operand_object *local_operand1 = operand1;
567 acpi_integer integer0; 565 u64 integer0;
568 acpi_integer integer1; 566 u64 integer1;
569 u32 length0; 567 u32 length0;
570 u32 length1; 568 u32 length1;
571 acpi_status status = AE_OK; 569 acpi_status status = AE_OK;
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index 2f0114202b05..7116bc86494d 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -375,6 +375,14 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
375 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); 375 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
376 } 376 }
377 377
378 /* Must have a valid thread. */
379 if (!walk_state->thread) {
380 ACPI_ERROR((AE_INFO,
381 "Cannot release Mutex [%4.4s], null thread info",
382 acpi_ut_get_node_name(obj_desc->mutex.node)));
383 return_ACPI_STATUS(AE_AML_INTERNAL);
384 }
385
378 /* 386 /*
379 * The Mutex is owned, but this thread must be the owner. 387 * The Mutex is owned, but this thread must be the owner.
380 * Special case for Global Lock, any thread can release 388 * Special case for Global Lock, any thread can release
@@ -392,15 +400,6 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
392 return_ACPI_STATUS(AE_AML_NOT_OWNER); 400 return_ACPI_STATUS(AE_AML_NOT_OWNER);
393 } 401 }
394 402
395 /* Must have a valid thread ID */
396
397 if (!walk_state->thread) {
398 ACPI_ERROR((AE_INFO,
399 "Cannot release Mutex [%4.4s], null thread info",
400 acpi_ut_get_node_name(obj_desc->mutex.node)));
401 return_ACPI_STATUS(AE_AML_INTERNAL);
402 }
403
404 /* 403 /*
405 * The sync level of the mutex must be equal to the current sync level. In 404 * The sync level of the mutex must be equal to the current sync level. In
406 * other words, the current level means that at least one mutex at that 405 * other words, the current level means that at least one mutex at that
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c
index ffdae122d94a..679f308c5a89 100644
--- a/drivers/acpi/acpica/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index 9635d21e568d..99adbab5acbf 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -100,12 +100,12 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
100 100
101 /* Create a return object of type Integer */ 101 /* Create a return object of type Integer */
102 102
103 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 103 return_desc =
104 acpi_ut_create_integer_object(acpi_os_get_timer());
104 if (!return_desc) { 105 if (!return_desc) {
105 status = AE_NO_MEMORY; 106 status = AE_NO_MEMORY;
106 goto cleanup; 107 goto cleanup;
107 } 108 }
108 return_desc->integer.value = acpi_os_get_timer();
109 break; 109 break;
110 110
111 default: /* Unknown opcode */ 111 default: /* Unknown opcode */
@@ -261,8 +261,8 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
261 union acpi_operand_object *return_desc2 = NULL; 261 union acpi_operand_object *return_desc2 = NULL;
262 u32 temp32; 262 u32 temp32;
263 u32 i; 263 u32 i;
264 acpi_integer power_of_ten; 264 u64 power_of_ten;
265 acpi_integer digit; 265 u64 digit;
266 266
267 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_1R, 267 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_1T_1R,
268 acpi_ps_get_opcode_name(walk_state->opcode)); 268 acpi_ps_get_opcode_name(walk_state->opcode));
@@ -362,7 +362,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
362 /* Sum the digit into the result with the current power of 10 */ 362 /* Sum the digit into the result with the current power of 10 */
363 363
364 return_desc->integer.value += 364 return_desc->integer.value +=
365 (((acpi_integer) temp32) * power_of_ten); 365 (((u64) temp32) * power_of_ten);
366 366
367 /* Shift to next BCD digit */ 367 /* Shift to next BCD digit */
368 368
@@ -392,7 +392,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
392 * remainder from above 392 * remainder from above
393 */ 393 */
394 return_desc->integer.value |= 394 return_desc->integer.value |=
395 (((acpi_integer) temp32) << ACPI_MUL_4(i)); 395 (((u64) temp32) << ACPI_MUL_4(i));
396 } 396 }
397 397
398 /* Overflow if there is any data left in Digit */ 398 /* Overflow if there is any data left in Digit */
@@ -439,7 +439,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
439 439
440 /* The object exists in the namespace, return TRUE */ 440 /* The object exists in the namespace, return TRUE */
441 441
442 return_desc->integer.value = ACPI_INTEGER_MAX; 442 return_desc->integer.value = ACPI_UINT64_MAX;
443 goto cleanup; 443 goto cleanup;
444 444
445 default: 445 default:
@@ -589,7 +589,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
589 union acpi_operand_object *return_desc = NULL; 589 union acpi_operand_object *return_desc = NULL;
590 acpi_status status = AE_OK; 590 acpi_status status = AE_OK;
591 u32 type; 591 u32 type;
592 acpi_integer value; 592 u64 value;
593 593
594 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_1R, 594 ACPI_FUNCTION_TRACE_STR(ex_opcode_1A_0T_1R,
595 acpi_ps_get_opcode_name(walk_state->opcode)); 595 acpi_ps_get_opcode_name(walk_state->opcode));
@@ -599,7 +599,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
599 switch (walk_state->opcode) { 599 switch (walk_state->opcode) {
600 case AML_LNOT_OP: /* LNot (Operand) */ 600 case AML_LNOT_OP: /* LNot (Operand) */
601 601
602 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 602 return_desc = acpi_ut_create_integer_object((u64) 0);
603 if (!return_desc) { 603 if (!return_desc) {
604 status = AE_NO_MEMORY; 604 status = AE_NO_MEMORY;
605 goto cleanup; 605 goto cleanup;
@@ -610,7 +610,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
610 * return_desc->Integer.Value is initially == 0 (FALSE) from above. 610 * return_desc->Integer.Value is initially == 0 (FALSE) from above.
611 */ 611 */
612 if (!operand[0]->integer.value) { 612 if (!operand[0]->integer.value) {
613 return_desc->integer.value = ACPI_INTEGER_MAX; 613 return_desc->integer.value = ACPI_UINT64_MAX;
614 } 614 }
615 break; 615 break;
616 616
@@ -702,13 +702,11 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
702 702
703 /* Allocate a descriptor to hold the type. */ 703 /* Allocate a descriptor to hold the type. */
704 704
705 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 705 return_desc = acpi_ut_create_integer_object((u64) type);
706 if (!return_desc) { 706 if (!return_desc) {
707 status = AE_NO_MEMORY; 707 status = AE_NO_MEMORY;
708 goto cleanup; 708 goto cleanup;
709 } 709 }
710
711 return_desc->integer.value = type;
712 break; 710 break;
713 711
714 case AML_SIZE_OF_OP: /* size_of (source_object) */ 712 case AML_SIZE_OF_OP: /* size_of (source_object) */
@@ -777,13 +775,11 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
777 * Now that we have the size of the object, create a result 775 * Now that we have the size of the object, create a result
778 * object to hold the value 776 * object to hold the value
779 */ 777 */
780 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 778 return_desc = acpi_ut_create_integer_object(value);
781 if (!return_desc) { 779 if (!return_desc) {
782 status = AE_NO_MEMORY; 780 status = AE_NO_MEMORY;
783 goto cleanup; 781 goto cleanup;
784 } 782 }
785
786 return_desc->integer.value = value;
787 break; 783 break;
788 784
789 case AML_REF_OF_OP: /* ref_of (source_object) */ 785 case AML_REF_OF_OP: /* ref_of (source_object) */
@@ -946,24 +942,24 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
946 * NOTE: index into a buffer is NOT a pointer to a 942 * NOTE: index into a buffer is NOT a pointer to a
947 * sub-buffer of the main buffer, it is only a pointer to a 943 * sub-buffer of the main buffer, it is only a pointer to a
948 * single element (byte) of the buffer! 944 * single element (byte) of the buffer!
945 *
946 * Since we are returning the value of the buffer at the
947 * indexed location, we don't need to add an additional
948 * reference to the buffer itself.
949 */ 949 */
950 return_desc = 950 return_desc =
951 acpi_ut_create_internal_object 951 acpi_ut_create_integer_object((u64)
952 (ACPI_TYPE_INTEGER); 952 temp_desc->
953 buffer.
954 pointer
955 [operand
956 [0]->
957 reference.
958 value]);
953 if (!return_desc) { 959 if (!return_desc) {
954 status = AE_NO_MEMORY; 960 status = AE_NO_MEMORY;
955 goto cleanup; 961 goto cleanup;
956 } 962 }
957
958 /*
959 * Since we are returning the value of the buffer at the
960 * indexed location, we don't need to add an additional
961 * reference to the buffer itself.
962 */
963 return_desc->integer.value =
964 temp_desc->buffer.
965 pointer[operand[0]->reference.
966 value];
967 break; 963 break;
968 964
969 case ACPI_TYPE_PACKAGE: 965 case ACPI_TYPE_PACKAGE:
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index 85d95c92dfd3..22841bbbe63c 100644
--- a/drivers/acpi/acpica/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -282,7 +282,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
282{ 282{
283 union acpi_operand_object **operand = &walk_state->operands[0]; 283 union acpi_operand_object **operand = &walk_state->operands[0];
284 union acpi_operand_object *return_desc = NULL; 284 union acpi_operand_object *return_desc = NULL;
285 acpi_integer index; 285 u64 index;
286 acpi_status status = AE_OK; 286 acpi_status status = AE_OK;
287 acpi_size length; 287 acpi_size length;
288 288
@@ -584,7 +584,7 @@ acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state)
584 * Default is FALSE (zero) 584 * Default is FALSE (zero)
585 */ 585 */
586 if (logical_result) { 586 if (logical_result) {
587 return_desc->integer.value = ACPI_INTEGER_MAX; 587 return_desc->integer.value = ACPI_UINT64_MAX;
588 } 588 }
589 589
590 cleanup: 590 cleanup:
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 253f9e122584..8bb1012ef44e 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -148,7 +148,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
148 union acpi_operand_object *return_desc = NULL; 148 union acpi_operand_object *return_desc = NULL;
149 char *buffer = NULL; 149 char *buffer = NULL;
150 acpi_status status = AE_OK; 150 acpi_status status = AE_OK;
151 acpi_integer index; 151 u64 index;
152 acpi_size length; 152 acpi_size length;
153 153
154 ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_1T_1R, 154 ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_1T_1R,
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index ae43f7670a6c..f256b6a25f2e 100644
--- a/drivers/acpi/acpica/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -218,7 +218,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
218 union acpi_operand_object **operand = &walk_state->operands[0]; 218 union acpi_operand_object **operand = &walk_state->operands[0];
219 union acpi_operand_object *return_desc = NULL; 219 union acpi_operand_object *return_desc = NULL;
220 acpi_status status = AE_OK; 220 acpi_status status = AE_OK;
221 acpi_integer index; 221 u64 index;
222 union acpi_operand_object *this_element; 222 union acpi_operand_object *this_element;
223 223
224 ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R, 224 ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R,
@@ -253,18 +253,15 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
253 } 253 }
254 254
255 /* Create an integer for the return value */ 255 /* Create an integer for the return value */
256 /* Default return value is ACPI_UINT64_MAX if no match found */
256 257
257 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 258 return_desc = acpi_ut_create_integer_object(ACPI_UINT64_MAX);
258 if (!return_desc) { 259 if (!return_desc) {
259 status = AE_NO_MEMORY; 260 status = AE_NO_MEMORY;
260 goto cleanup; 261 goto cleanup;
261 262
262 } 263 }
263 264
264 /* Default return value if no match found */
265
266 return_desc->integer.value = ACPI_INTEGER_MAX;
267
268 /* 265 /*
269 * Examine each element until a match is found. Both match conditions 266 * Examine each element until a match is found. Both match conditions
270 * must be satisfied for a match to occur. Within the loop, 267 * must be satisfied for a match to occur. Within the loop,
@@ -273,7 +270,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
273 * 270 *
274 * Upon finding a match, the loop will terminate via "break" at 271 * Upon finding a match, the loop will terminate via "break" at
275 * the bottom. If it terminates "normally", match_value will be 272 * the bottom. If it terminates "normally", match_value will be
276 * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no 273 * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
277 * match was found. 274 * match was found.
278 */ 275 */
279 for (; index < operand[0]->package.count; index++) { 276 for (; index < operand[0]->package.count; index++) {
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index 52fec07064f0..2fbfe51fb141 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -468,6 +468,23 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
468 468
469 acpi_ut_add_reference(obj_desc->field.region_obj); 469 acpi_ut_add_reference(obj_desc->field.region_obj);
470 470
471 /* allow full data read from EC address space */
472 if (obj_desc->field.region_obj->region.space_id ==
473 ACPI_ADR_SPACE_EC) {
474 if (obj_desc->common_field.bit_length > 8) {
475 unsigned width =
476 ACPI_ROUND_BITS_UP_TO_BYTES(
477 obj_desc->common_field.bit_length);
478 // access_bit_width is u8, don't overflow it
479 if (width > 8)
480 width = 8;
481 obj_desc->common_field.access_byte_width =
482 width;
483 obj_desc->common_field.access_bit_width =
484 8 * width;
485 }
486 }
487
471 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 488 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
472 "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", 489 "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
473 obj_desc->field.start_field_bit_offset, 490 obj_desc->field.start_field_bit_offset,
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 2bd83ac57c3a..486b2e5661b6 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,7 @@ acpi_status
70acpi_ex_system_memory_space_handler(u32 function, 70acpi_ex_system_memory_space_handler(u32 function,
71 acpi_physical_address address, 71 acpi_physical_address address,
72 u32 bit_width, 72 u32 bit_width,
73 acpi_integer * value, 73 u64 *value,
74 void *handler_context, void *region_context) 74 void *handler_context, void *region_context)
75{ 75{
76 acpi_status status = AE_OK; 76 acpi_status status = AE_OK;
@@ -115,8 +115,7 @@ acpi_ex_system_memory_space_handler(u32 function,
115 * Hardware does not support non-aligned data transfers, we must verify 115 * Hardware does not support non-aligned data transfers, we must verify
116 * the request. 116 * the request.
117 */ 117 */
118 (void)acpi_ut_short_divide((acpi_integer) address, length, NULL, 118 (void)acpi_ut_short_divide((u64) address, length, NULL, &remainder);
119 &remainder);
120 if (remainder != 0) { 119 if (remainder != 0) {
121 return_ACPI_STATUS(AE_AML_ALIGNMENT); 120 return_ACPI_STATUS(AE_AML_ALIGNMENT);
122 } 121 }
@@ -128,10 +127,9 @@ acpi_ex_system_memory_space_handler(u32 function,
128 * 2) Address beyond the current mapping? 127 * 2) Address beyond the current mapping?
129 */ 128 */
130 if ((address < mem_info->mapped_physical_address) || 129 if ((address < mem_info->mapped_physical_address) ||
131 (((acpi_integer) address + length) > ((acpi_integer) 130 (((u64) address + length) > ((u64)
132 mem_info-> 131 mem_info->mapped_physical_address +
133 mapped_physical_address + 132 mem_info->mapped_length))) {
134 mem_info->mapped_length))) {
135 /* 133 /*
136 * The request cannot be resolved by the current memory mapping; 134 * The request cannot be resolved by the current memory mapping;
137 * Delete the existing mapping and create a new one. 135 * Delete the existing mapping and create a new one.
@@ -193,8 +191,7 @@ acpi_ex_system_memory_space_handler(u32 function,
193 * access 191 * access
194 */ 192 */
195 logical_addr_ptr = mem_info->mapped_logical_address + 193 logical_addr_ptr = mem_info->mapped_logical_address +
196 ((acpi_integer) address - 194 ((u64) address - (u64) mem_info->mapped_physical_address);
197 (acpi_integer) mem_info->mapped_physical_address);
198 195
199 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 196 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
200 "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", 197 "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n",
@@ -215,19 +212,19 @@ acpi_ex_system_memory_space_handler(u32 function,
215 *value = 0; 212 *value = 0;
216 switch (bit_width) { 213 switch (bit_width) {
217 case 8: 214 case 8:
218 *value = (acpi_integer) ACPI_GET8(logical_addr_ptr); 215 *value = (u64) ACPI_GET8(logical_addr_ptr);
219 break; 216 break;
220 217
221 case 16: 218 case 16:
222 *value = (acpi_integer) ACPI_GET16(logical_addr_ptr); 219 *value = (u64) ACPI_GET16(logical_addr_ptr);
223 break; 220 break;
224 221
225 case 32: 222 case 32:
226 *value = (acpi_integer) ACPI_GET32(logical_addr_ptr); 223 *value = (u64) ACPI_GET32(logical_addr_ptr);
227 break; 224 break;
228 225
229 case 64: 226 case 64:
230 *value = (acpi_integer) ACPI_GET64(logical_addr_ptr); 227 *value = (u64) ACPI_GET64(logical_addr_ptr);
231 break; 228 break;
232 229
233 default: 230 default:
@@ -291,7 +288,7 @@ acpi_status
291acpi_ex_system_io_space_handler(u32 function, 288acpi_ex_system_io_space_handler(u32 function,
292 acpi_physical_address address, 289 acpi_physical_address address,
293 u32 bit_width, 290 u32 bit_width,
294 acpi_integer * value, 291 u64 *value,
295 void *handler_context, void *region_context) 292 void *handler_context, void *region_context)
296{ 293{
297 acpi_status status = AE_OK; 294 acpi_status status = AE_OK;
@@ -350,7 +347,7 @@ acpi_status
350acpi_ex_pci_config_space_handler(u32 function, 347acpi_ex_pci_config_space_handler(u32 function,
351 acpi_physical_address address, 348 acpi_physical_address address,
352 u32 bit_width, 349 u32 bit_width,
353 acpi_integer * value, 350 u64 *value,
354 void *handler_context, void *region_context) 351 void *handler_context, void *region_context)
355{ 352{
356 acpi_status status = AE_OK; 353 acpi_status status = AE_OK;
@@ -425,7 +422,7 @@ acpi_status
425acpi_ex_cmos_space_handler(u32 function, 422acpi_ex_cmos_space_handler(u32 function,
426 acpi_physical_address address, 423 acpi_physical_address address,
427 u32 bit_width, 424 u32 bit_width,
428 acpi_integer * value, 425 u64 *value,
429 void *handler_context, void *region_context) 426 void *handler_context, void *region_context)
430{ 427{
431 acpi_status status = AE_OK; 428 acpi_status status = AE_OK;
@@ -457,7 +454,7 @@ acpi_status
457acpi_ex_pci_bar_space_handler(u32 function, 454acpi_ex_pci_bar_space_handler(u32 function,
458 acpi_physical_address address, 455 acpi_physical_address address,
459 u32 bit_width, 456 u32 bit_width,
460 acpi_integer * value, 457 u64 *value,
461 void *handler_context, void *region_context) 458 void *handler_context, void *region_context)
462{ 459{
463 acpi_status status = AE_OK; 460 acpi_status status = AE_OK;
@@ -489,7 +486,7 @@ acpi_status
489acpi_ex_data_table_space_handler(u32 function, 486acpi_ex_data_table_space_handler(u32 function,
490 acpi_physical_address address, 487 acpi_physical_address address,
491 u32 bit_width, 488 u32 bit_width,
492 acpi_integer * value, 489 u64 *value,
493 void *handler_context, void *region_context) 490 void *handler_context, void *region_context)
494{ 491{
495 ACPI_FUNCTION_TRACE(ex_data_table_space_handler); 492 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 607958ff467c..fdc1b27999ef 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index c93b54ce7f78..fdd6a7079b97 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index 5c729a9e9131..c5ecd615f145 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 6efd07a4f779..702b9ecfd44b 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index 608e838d537e..d4af684620ca 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c
index 257706e7734f..e972b667b09b 100644
--- a/drivers/acpi/acpica/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c
index 3d00b9357233..e11b6cb42a57 100644
--- a/drivers/acpi/acpica/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -193,7 +193,7 @@ acpi_status acpi_ex_system_do_stall(u32 how_long)
193 * 193 *
194 ******************************************************************************/ 194 ******************************************************************************/
195 195
196acpi_status acpi_ex_system_do_suspend(acpi_integer how_long) 196acpi_status acpi_ex_system_do_suspend(u64 how_long)
197{ 197{
198 ACPI_FUNCTION_ENTRY(); 198 ACPI_FUNCTION_ENTRY();
199 199
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 7d41f99f7052..74c24d517f81 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,7 @@
67ACPI_MODULE_NAME("exutils") 67ACPI_MODULE_NAME("exutils")
68 68
69/* Local prototypes */ 69/* Local prototypes */
70static u32 acpi_ex_digits_needed(acpi_integer value, u32 base); 70static u32 acpi_ex_digits_needed(u64 value, u32 base);
71 71
72#ifndef ACPI_NO_METHOD_EXECUTION 72#ifndef ACPI_NO_METHOD_EXECUTION
73/******************************************************************************* 73/*******************************************************************************
@@ -230,7 +230,7 @@ void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
230 * We are running a method that exists in a 32-bit ACPI table. 230 * We are running a method that exists in a 32-bit ACPI table.
231 * Truncate the value to 32 bits by zeroing out the upper 32-bit field 231 * Truncate the value to 32 bits by zeroing out the upper 32-bit field
232 */ 232 */
233 obj_desc->integer.value &= (acpi_integer) ACPI_UINT32_MAX; 233 obj_desc->integer.value &= (u64) ACPI_UINT32_MAX;
234 } 234 }
235} 235}
236 236
@@ -327,14 +327,14 @@ void acpi_ex_release_global_lock(u32 field_flags)
327 * 327 *
328 ******************************************************************************/ 328 ******************************************************************************/
329 329
330static u32 acpi_ex_digits_needed(acpi_integer value, u32 base) 330static u32 acpi_ex_digits_needed(u64 value, u32 base)
331{ 331{
332 u32 num_digits; 332 u32 num_digits;
333 acpi_integer current_value; 333 u64 current_value;
334 334
335 ACPI_FUNCTION_TRACE(ex_digits_needed); 335 ACPI_FUNCTION_TRACE(ex_digits_needed);
336 336
337 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 337 /* u64 is unsigned, so we don't worry about a '-' prefix */
338 338
339 if (value == 0) { 339 if (value == 0) {
340 return_UINT32(1); 340 return_UINT32(1);
@@ -370,7 +370,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
370 * 370 *
371 ******************************************************************************/ 371 ******************************************************************************/
372 372
373void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id) 373void acpi_ex_eisa_id_to_string(char *out_string, u64 compressed_id)
374{ 374{
375 u32 swapped_id; 375 u32 swapped_id;
376 376
@@ -394,10 +394,10 @@ void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id)
394 (char)(0x40 + (((unsigned long)swapped_id >> 26) & 0x1F)); 394 (char)(0x40 + (((unsigned long)swapped_id >> 26) & 0x1F));
395 out_string[1] = (char)(0x40 + ((swapped_id >> 21) & 0x1F)); 395 out_string[1] = (char)(0x40 + ((swapped_id >> 21) & 0x1F));
396 out_string[2] = (char)(0x40 + ((swapped_id >> 16) & 0x1F)); 396 out_string[2] = (char)(0x40 + ((swapped_id >> 16) & 0x1F));
397 out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 12); 397 out_string[3] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 12);
398 out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 8); 398 out_string[4] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 8);
399 out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 4); 399 out_string[5] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 4);
400 out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 0); 400 out_string[6] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 0);
401 out_string[7] = 0; 401 out_string[7] = 0;
402} 402}
403 403
@@ -418,7 +418,7 @@ void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id)
418 * 418 *
419 ******************************************************************************/ 419 ******************************************************************************/
420 420
421void acpi_ex_integer_to_string(char *out_string, acpi_integer value) 421void acpi_ex_integer_to_string(char *out_string, u64 value)
422{ 422{
423 u32 count; 423 u32 count;
424 u32 digits_needed; 424 u32 digits_needed;
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 9af361a191e7..679a112a7d26 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index c28c41b3180b..bd72319a38f0 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -224,7 +224,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
224 224
225 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address); 225 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
226 if (ACPI_FAILURE(status)) { 226 if (ACPI_FAILURE(status)) {
227 goto unlock_and_exit; 227 return (status);
228 } 228 }
229 229
230 if (register_bit & in_byte) { 230 if (register_bit & in_byte) {
@@ -234,9 +234,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
234 /* Set return value */ 234 /* Set return value */
235 235
236 (*event_status) = local_event_status; 236 (*event_status) = local_event_status;
237 237 return (AE_OK);
238 unlock_and_exit:
239 return (status);
240} 238}
241 239
242/****************************************************************************** 240/******************************************************************************
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 15c9ed2be853..ec7fc227b33f 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -7,7 +7,7 @@
7 ******************************************************************************/ 7 ******************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 10 * Copyright (C) 2000 - 2010, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index cc22f9a585b0..5e6d4dbb8024 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index 6b282e85d039..1ef8e0bb250b 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -140,7 +140,7 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
140{ 140{
141 acpi_status status; 141 acpi_status status;
142 u32 delta_ticks; 142 u32 delta_ticks;
143 acpi_integer quotient; 143 u64 quotient;
144 144
145 ACPI_FUNCTION_TRACE(acpi_get_timer_duration); 145 ACPI_FUNCTION_TRACE(acpi_get_timer_duration);
146 146
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
index ec33f270c5b7..e26c17d4b716 100644
--- a/drivers/acpi/acpica/hwvalid.c
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2009, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 647c7b6e6756..50cc3be77724 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index 9c3cdbe2d82a..aa2b80132d0a 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -165,7 +165,7 @@ acpi_status acpi_ns_root_initialize(void)
165 165
166 obj_desc->method.method_flags = 166 obj_desc->method.method_flags =
167 AML_METHOD_INTERNAL_ONLY; 167 AML_METHOD_INTERNAL_ONLY;
168 obj_desc->method.implementation = 168 obj_desc->method.extra.implementation =
169 acpi_ut_osi_implementation; 169 acpi_ut_osi_implementation;
170#endif 170#endif
171 break; 171 break;
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 8a58a1b85aa0..982269c1fa48 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 2bad613db73a..0689d36638d9 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -180,7 +180,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
180 return (AE_OK); 180 return (AE_OK);
181 } 181 }
182 182
183 this_node = acpi_ns_map_handle_to_node(obj_handle); 183 this_node = acpi_ns_validate_handle(obj_handle);
184 if (!this_node) { 184 if (!this_node) {
185 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n", 185 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n",
186 obj_handle)); 186 obj_handle));
@@ -634,8 +634,8 @@ acpi_ns_dump_objects(acpi_object_type type,
634 (void)acpi_ns_walk_namespace(type, start_handle, max_depth, 634 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
635 ACPI_NS_WALK_NO_UNLOCK | 635 ACPI_NS_WALK_NO_UNLOCK |
636 ACPI_NS_WALK_TEMP_NODES, 636 ACPI_NS_WALK_TEMP_NODES,
637 acpi_ns_dump_one_object, (void *)&info, 637 acpi_ns_dump_one_object, NULL,
638 NULL); 638 (void *)&info, NULL);
639} 639}
640#endif /* ACPI_FUTURE_USAGE */ 640#endif /* ACPI_FUTURE_USAGE */
641 641
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 0fe87f1aef16..d2a97921e249 100644
--- a/drivers/acpi/acpica/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -131,7 +131,8 @@ void acpi_ns_dump_root_devices(void)
131 131
132 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, sys_bus_handle, 132 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, sys_bus_handle,
133 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, 133 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
134 acpi_ns_dump_one_device, NULL, NULL); 134 acpi_ns_dump_one_device, NULL, NULL,
135 NULL);
135} 136}
136 137
137#endif 138#endif
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 846d1132feb1..f52829cc294b 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -366,50 +366,88 @@ static void
366acpi_ns_exec_module_code(union acpi_operand_object *method_obj, 366acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
367 struct acpi_evaluate_info *info) 367 struct acpi_evaluate_info *info)
368{ 368{
369 union acpi_operand_object *root_obj; 369 union acpi_operand_object *parent_obj;
370 struct acpi_namespace_node *parent_node;
371 acpi_object_type type;
370 acpi_status status; 372 acpi_status status;
371 373
372 ACPI_FUNCTION_TRACE(ns_exec_module_code); 374 ACPI_FUNCTION_TRACE(ns_exec_module_code);
373 375
376 /*
377 * Get the parent node. We cheat by using the next_object field
378 * of the method object descriptor.
379 */
380 parent_node = ACPI_CAST_PTR(struct acpi_namespace_node,
381 method_obj->method.next_object);
382 type = acpi_ns_get_type(parent_node);
383
384 /*
385 * Get the region handler and save it in the method object. We may need
386 * this if an operation region declaration causes a _REG method to be run.
387 *
388 * We can't do this in acpi_ps_link_module_code because
389 * acpi_gbl_root_node->Object is NULL at PASS1.
390 */
391 if ((type == ACPI_TYPE_DEVICE) && parent_node->object) {
392 method_obj->method.extra.handler =
393 parent_node->object->device.handler;
394 }
395
396 /* Must clear next_object (acpi_ns_attach_object needs the field) */
397
398 method_obj->method.next_object = NULL;
399
374 /* Initialize the evaluation information block */ 400 /* Initialize the evaluation information block */
375 401
376 ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info)); 402 ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info));
377 info->prefix_node = acpi_gbl_root_node; 403 info->prefix_node = parent_node;
378 404
379 /* 405 /*
380 * Get the currently attached root object. Add a reference, because the 406 * Get the currently attached parent object. Add a reference, because the
381 * ref count will be decreased when the method object is installed to 407 * ref count will be decreased when the method object is installed to
382 * the root node. 408 * the parent node.
383 */ 409 */
384 root_obj = acpi_ns_get_attached_object(acpi_gbl_root_node); 410 parent_obj = acpi_ns_get_attached_object(parent_node);
385 acpi_ut_add_reference(root_obj); 411 if (parent_obj) {
412 acpi_ut_add_reference(parent_obj);
413 }
386 414
387 /* Install the method (module-level code) in the root node */ 415 /* Install the method (module-level code) in the parent node */
388 416
389 status = acpi_ns_attach_object(acpi_gbl_root_node, method_obj, 417 status = acpi_ns_attach_object(parent_node, method_obj,
390 ACPI_TYPE_METHOD); 418 ACPI_TYPE_METHOD);
391 if (ACPI_FAILURE(status)) { 419 if (ACPI_FAILURE(status)) {
392 goto exit; 420 goto exit;
393 } 421 }
394 422
395 /* Execute the root node as a control method */ 423 /* Execute the parent node as a control method */
396 424
397 status = acpi_ns_evaluate(info); 425 status = acpi_ns_evaluate(info);
398 426
399 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Executed module-level code at %p\n", 427 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Executed module-level code at %p\n",
400 method_obj->method.aml_start)); 428 method_obj->method.aml_start));
401 429
430 /* Delete a possible implicit return value (in slack mode) */
431
432 if (info->return_object) {
433 acpi_ut_remove_reference(info->return_object);
434 }
435
402 /* Detach the temporary method object */ 436 /* Detach the temporary method object */
403 437
404 acpi_ns_detach_object(acpi_gbl_root_node); 438 acpi_ns_detach_object(parent_node);
405 439
406 /* Restore the original root object */ 440 /* Restore the original parent object */
407 441
408 status = 442 if (parent_obj) {
409 acpi_ns_attach_object(acpi_gbl_root_node, root_obj, 443 status = acpi_ns_attach_object(parent_node, parent_obj, type);
410 ACPI_TYPE_DEVICE); 444 } else {
445 parent_node->type = (u8)type;
446 }
411 447
412 exit: 448 exit:
413 acpi_ut_remove_reference(root_obj); 449 if (parent_obj) {
450 acpi_ut_remove_reference(parent_obj);
451 }
414 return_VOID; 452 return_VOID;
415} 453}
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 1d5b360eb25b..9bd6f050f299 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -96,7 +96,7 @@ acpi_status acpi_ns_initialize_objects(void)
96 /* Walk entire namespace from the supplied root */ 96 /* Walk entire namespace from the supplied root */
97 97
98 status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 98 status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
99 ACPI_UINT32_MAX, acpi_ns_init_one_object, 99 ACPI_UINT32_MAX, acpi_ns_init_one_object, NULL,
100 &info, NULL); 100 &info, NULL);
101 if (ACPI_FAILURE(status)) { 101 if (ACPI_FAILURE(status)) {
102 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); 102 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
@@ -156,7 +156,8 @@ acpi_status acpi_ns_initialize_devices(void)
156 156
157 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 157 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
158 ACPI_UINT32_MAX, FALSE, 158 ACPI_UINT32_MAX, FALSE,
159 acpi_ns_find_ini_methods, &info, NULL); 159 acpi_ns_find_ini_methods, NULL, &info,
160 NULL);
160 if (ACPI_FAILURE(status)) { 161 if (ACPI_FAILURE(status)) {
161 goto error_exit; 162 goto error_exit;
162 } 163 }
@@ -189,7 +190,8 @@ acpi_status acpi_ns_initialize_devices(void)
189 190
190 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 191 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
191 ACPI_UINT32_MAX, FALSE, 192 ACPI_UINT32_MAX, FALSE,
192 acpi_ns_init_one_device, &info, NULL); 193 acpi_ns_init_one_device, NULL, &info,
194 NULL);
193 195
194 ACPI_FREE(info.evaluate_info); 196 ACPI_FREE(info.evaluate_info);
195 if (ACPI_FAILURE(status)) { 197 if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index a7234e60e985..df18be94fefe 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index af8e6bcee07e..959372451635 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -232,7 +232,7 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle,
232 232
233 ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle); 233 ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle);
234 234
235 node = acpi_ns_map_handle_to_node(target_handle); 235 node = acpi_ns_validate_handle(target_handle);
236 if (!node) { 236 if (!node) {
237 return_ACPI_STATUS(AE_BAD_PARAMETER); 237 return_ACPI_STATUS(AE_BAD_PARAMETER);
238 } 238 }
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index 60f3af08d28c..41a9213dd5af 100644
--- a/drivers/acpi/acpica/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 662a4bd5b621..27cda52c76bc 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index f8427afeebdf..7096bcda0c72 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -216,23 +216,39 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
216 data->pathname = pathname; 216 data->pathname = pathname;
217 217
218 /* 218 /*
219 * Check that the type of the return object is what is expected for 219 * Check that the type of the main return object is what is expected
220 * this predefined name 220 * for this predefined name
221 */ 221 */
222 status = acpi_ns_check_object_type(data, return_object_ptr, 222 status = acpi_ns_check_object_type(data, return_object_ptr,
223 predefined->info.expected_btypes, 223 predefined->info.expected_btypes,
224 ACPI_NOT_PACKAGE_ELEMENT); 224 ACPI_NOT_PACKAGE_ELEMENT);
225 if (ACPI_FAILURE(status)) { 225 if (ACPI_FAILURE(status)) {
226 goto check_validation_status; 226 goto exit;
227 } 227 }
228 228
229 /* For returned Package objects, check the type of all sub-objects */ 229 /*
230 230 * For returned Package objects, check the type of all sub-objects.
231 if (return_object->common.type == ACPI_TYPE_PACKAGE) { 231 * Note: Package may have been newly created by call above.
232 */
233 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) {
234 data->parent_package = *return_object_ptr;
232 status = acpi_ns_check_package(data, return_object_ptr); 235 status = acpi_ns_check_package(data, return_object_ptr);
236 if (ACPI_FAILURE(status)) {
237 goto exit;
238 }
233 } 239 }
234 240
235check_validation_status: 241 /*
242 * The return object was OK, or it was successfully repaired above.
243 * Now make some additional checks such as verifying that package
244 * objects are sorted correctly (if required) or buffer objects have
245 * the correct data width (bytes vs. dwords). These repairs are
246 * performed on a per-name basis, i.e., the code is specific to
247 * particular predefined names.
248 */
249 status = acpi_ns_complex_repairs(data, node, status, return_object_ptr);
250
251exit:
236 /* 252 /*
237 * If the object validation failed or if we successfully repaired one 253 * If the object validation failed or if we successfully repaired one
238 * or more objects, mark the parent node to suppress further warning 254 * or more objects, mark the parent node to suppress further warning
@@ -421,6 +437,13 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
421 data->pathname, package->ret_info.type, 437 data->pathname, package->ret_info.type,
422 return_object->package.count)); 438 return_object->package.count));
423 439
440 /*
441 * For variable-length Packages, we can safely remove all embedded
442 * and trailing NULL package elements
443 */
444 acpi_ns_remove_null_elements(data, package->ret_info.type,
445 return_object);
446
424 /* Extract package count and elements array */ 447 /* Extract package count and elements array */
425 448
426 elements = return_object->package.elements; 449 elements = return_object->package.elements;
@@ -455,11 +478,11 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
455 if (count < expected_count) { 478 if (count < expected_count) {
456 goto package_too_small; 479 goto package_too_small;
457 } else if (count > expected_count) { 480 } else if (count > expected_count) {
458 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, 481 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
459 data->node_flags, 482 "%s: Return Package is larger than needed - "
460 "Return Package is larger than needed - " 483 "found %u, expected %u\n",
461 "found %u, expected %u", count, 484 data->pathname, count,
462 expected_count)); 485 expected_count));
463 } 486 }
464 487
465 /* Validate all elements of the returned package */ 488 /* Validate all elements of the returned package */
@@ -601,7 +624,8 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
601 * there is only one entry). We may be able to repair this by 624 * there is only one entry). We may be able to repair this by
602 * wrapping the returned Package with a new outer Package. 625 * wrapping the returned Package with a new outer Package.
603 */ 626 */
604 if ((*elements)->common.type != ACPI_TYPE_PACKAGE) { 627 if (*elements
628 && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) {
605 629
606 /* Create the new outer package and populate it */ 630 /* Create the new outer package and populate it */
607 631
@@ -677,11 +701,17 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
677 u32 i; 701 u32 i;
678 u32 j; 702 u32 j;
679 703
680 /* Validate each sub-Package in the parent Package */ 704 /*
681 705 * Validate each sub-Package in the parent Package
706 *
707 * NOTE: assumes list of sub-packages contains no NULL elements.
708 * Any NULL elements should have been removed by earlier call
709 * to acpi_ns_remove_null_elements.
710 */
682 for (i = 0; i < count; i++) { 711 for (i = 0; i < count; i++) {
683 sub_package = *elements; 712 sub_package = *elements;
684 sub_elements = sub_package->package.elements; 713 sub_elements = sub_package->package.elements;
714 data->parent_package = sub_package;
685 715
686 /* Each sub-object must be of type Package */ 716 /* Each sub-object must be of type Package */
687 717
@@ -693,6 +723,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
693 723
694 /* Examine the different types of expected sub-packages */ 724 /* Examine the different types of expected sub-packages */
695 725
726 data->parent_package = sub_package;
696 switch (package->ret_info.type) { 727 switch (package->ret_info.type) {
697 case ACPI_PTYPE2: 728 case ACPI_PTYPE2:
698 case ACPI_PTYPE2_PKG_COUNT: 729 case ACPI_PTYPE2_PKG_COUNT:
@@ -772,7 +803,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
772 803
773 /* 804 /*
774 * First element is the (Integer) count of elements, including 805 * First element is the (Integer) count of elements, including
775 * the count field. 806 * the count field (the ACPI name is num_elements)
776 */ 807 */
777 status = acpi_ns_check_object_type(data, sub_elements, 808 status = acpi_ns_check_object_type(data, sub_elements,
778 ACPI_RTYPE_INTEGER, 809 ACPI_RTYPE_INTEGER,
@@ -794,6 +825,16 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
794 expected_count = package->ret_info.count1; 825 expected_count = package->ret_info.count1;
795 goto package_too_small; 826 goto package_too_small;
796 } 827 }
828 if (expected_count == 0) {
829 /*
830 * Either the num_entries element was originally zero or it was
831 * a NULL element and repaired to an Integer of value zero.
832 * In either case, repair it by setting num_entries to be the
833 * actual size of the subpackage.
834 */
835 expected_count = sub_package->package.count;
836 (*sub_elements)->integer.value = expected_count;
837 }
797 838
798 /* Check the type of each sub-package element */ 839 /* Check the type of each sub-package element */
799 840
@@ -917,10 +958,18 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
917 char type_buffer[48]; /* Room for 5 types */ 958 char type_buffer[48]; /* Room for 5 types */
918 959
919 /* 960 /*
920 * If we get a NULL return_object here, it is a NULL package element, 961 * If we get a NULL return_object here, it is a NULL package element.
921 * and this is always an error. 962 * Since all extraneous NULL package elements were removed earlier by a
963 * call to acpi_ns_remove_null_elements, this is an unexpected NULL element.
964 * We will attempt to repair it.
922 */ 965 */
923 if (!return_object) { 966 if (!return_object) {
967 status = acpi_ns_repair_null_element(data, expected_btypes,
968 package_index,
969 return_object_ptr);
970 if (ACPI_SUCCESS(status)) {
971 return (AE_OK); /* Repair was successful */
972 }
924 goto type_error_exit; 973 goto type_error_exit;
925 } 974 }
926 975
@@ -972,27 +1021,25 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
972 1021
973 /* Is the object one of the expected types? */ 1022 /* Is the object one of the expected types? */
974 1023
975 if (!(return_btype & expected_btypes)) { 1024 if (return_btype & expected_btypes) {
976 1025
977 /* Type mismatch -- attempt repair of the returned object */ 1026 /* For reference objects, check that the reference type is correct */
978 1027
979 status = acpi_ns_repair_object(data, expected_btypes, 1028 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
980 package_index, 1029 status = acpi_ns_check_reference(data, return_object);
981 return_object_ptr);
982 if (ACPI_SUCCESS(status)) {
983 return (AE_OK); /* Repair was successful */
984 } 1030 }
985 goto type_error_exit; 1031
1032 return (status);
986 } 1033 }
987 1034
988 /* For reference objects, check that the reference type is correct */ 1035 /* Type mismatch -- attempt repair of the returned object */
989 1036
990 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { 1037 status = acpi_ns_repair_object(data, expected_btypes,
991 status = acpi_ns_check_reference(data, return_object); 1038 package_index, return_object_ptr);
1039 if (ACPI_SUCCESS(status)) {
1040 return (AE_OK); /* Repair was successful */
992 } 1041 }
993 1042
994 return (status);
995
996 type_error_exit: 1043 type_error_exit:
997 1044
998 /* Create a string with all expected types for this predefined object */ 1045 /* Create a string with all expected types for this predefined object */
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index db2b2a99c3a8..d4be37751be4 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,7 @@
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "acnamesp.h" 46#include "acnamesp.h"
47#include "acinterp.h"
47#include "acpredef.h" 48#include "acpredef.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
@@ -51,6 +52,52 @@ ACPI_MODULE_NAME("nsrepair")
51 52
52/******************************************************************************* 53/*******************************************************************************
53 * 54 *
55 * This module attempts to repair or convert objects returned by the
56 * predefined methods to an object type that is expected, as per the ACPI
57 * specification. The need for this code is dictated by the many machines that
58 * return incorrect types for the standard predefined methods. Performing these
59 * conversions here, in one place, eliminates the need for individual ACPI
60 * device drivers to do the same. Note: Most of these conversions are different
61 * than the internal object conversion routines used for implicit object
62 * conversion.
63 *
64 * The following conversions can be performed as necessary:
65 *
66 * Integer -> String
67 * Integer -> Buffer
68 * String -> Integer
69 * String -> Buffer
70 * Buffer -> Integer
71 * Buffer -> String
72 * Buffer -> Package of Integers
73 * Package -> Package of one Package
74 *
75 * Additional possible repairs:
76 *
77 * Optional/unnecessary NULL package elements removed
78 * Required package elements that are NULL replaced by Integer/String/Buffer
79 * Incorrect standalone package wrapped with required outer package
80 *
81 ******************************************************************************/
82/* Local prototypes */
83static acpi_status
84acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
85 union acpi_operand_object **return_object);
86
87static acpi_status
88acpi_ns_convert_to_string(union acpi_operand_object *original_object,
89 union acpi_operand_object **return_object);
90
91static acpi_status
92acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
93 union acpi_operand_object **return_object);
94
95static acpi_status
96acpi_ns_convert_to_package(union acpi_operand_object *original_object,
97 union acpi_operand_object **return_object);
98
99/*******************************************************************************
100 *
54 * FUNCTION: acpi_ns_repair_object 101 * FUNCTION: acpi_ns_repair_object
55 * 102 *
56 * PARAMETERS: Data - Pointer to validation data structure 103 * PARAMETERS: Data - Pointer to validation data structure
@@ -67,6 +114,7 @@ ACPI_MODULE_NAME("nsrepair")
67 * not expected. 114 * not expected.
68 * 115 *
69 ******************************************************************************/ 116 ******************************************************************************/
117
70acpi_status 118acpi_status
71acpi_ns_repair_object(struct acpi_predefined_data *data, 119acpi_ns_repair_object(struct acpi_predefined_data *data,
72 u32 expected_btypes, 120 u32 expected_btypes,
@@ -75,26 +123,206 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
75{ 123{
76 union acpi_operand_object *return_object = *return_object_ptr; 124 union acpi_operand_object *return_object = *return_object_ptr;
77 union acpi_operand_object *new_object; 125 union acpi_operand_object *new_object;
78 acpi_size length; 126 acpi_status status;
127
128 ACPI_FUNCTION_NAME(ns_repair_object);
129
130 /*
131 * At this point, we know that the type of the returned object was not
132 * one of the expected types for this predefined name. Attempt to
133 * repair the object by converting it to one of the expected object
134 * types for this predefined name.
135 */
136 if (expected_btypes & ACPI_RTYPE_INTEGER) {
137 status = acpi_ns_convert_to_integer(return_object, &new_object);
138 if (ACPI_SUCCESS(status)) {
139 goto object_repaired;
140 }
141 }
142 if (expected_btypes & ACPI_RTYPE_STRING) {
143 status = acpi_ns_convert_to_string(return_object, &new_object);
144 if (ACPI_SUCCESS(status)) {
145 goto object_repaired;
146 }
147 }
148 if (expected_btypes & ACPI_RTYPE_BUFFER) {
149 status = acpi_ns_convert_to_buffer(return_object, &new_object);
150 if (ACPI_SUCCESS(status)) {
151 goto object_repaired;
152 }
153 }
154 if (expected_btypes & ACPI_RTYPE_PACKAGE) {
155 status = acpi_ns_convert_to_package(return_object, &new_object);
156 if (ACPI_SUCCESS(status)) {
157 goto object_repaired;
158 }
159 }
160
161 /* We cannot repair this object */
162
163 return (AE_AML_OPERAND_TYPE);
164
165 object_repaired:
166
167 /* Object was successfully repaired */
168
169 /*
170 * If the original object is a package element, we need to:
171 * 1. Set the reference count of the new object to match the
172 * reference count of the old object.
173 * 2. Decrement the reference count of the original object.
174 */
175 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
176 new_object->common.reference_count =
177 return_object->common.reference_count;
178
179 if (return_object->common.reference_count > 1) {
180 return_object->common.reference_count--;
181 }
182
183 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
184 "%s: Converted %s to expected %s at index %u\n",
185 data->pathname,
186 acpi_ut_get_object_type_name(return_object),
187 acpi_ut_get_object_type_name(new_object),
188 package_index));
189 } else {
190 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
191 "%s: Converted %s to expected %s\n",
192 data->pathname,
193 acpi_ut_get_object_type_name(return_object),
194 acpi_ut_get_object_type_name(new_object)));
195 }
196
197 /* Delete old object, install the new return object */
198
199 acpi_ut_remove_reference(return_object);
200 *return_object_ptr = new_object;
201 data->flags |= ACPI_OBJECT_REPAIRED;
202 return (AE_OK);
203}
204
205/*******************************************************************************
206 *
207 * FUNCTION: acpi_ns_convert_to_integer
208 *
209 * PARAMETERS: original_object - Object to be converted
210 * return_object - Where the new converted object is returned
211 *
212 * RETURN: Status. AE_OK if conversion was successful.
213 *
214 * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
215 *
216 ******************************************************************************/
217
218static acpi_status
219acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
220 union acpi_operand_object **return_object)
221{
222 union acpi_operand_object *new_object;
223 acpi_status status;
224 u64 value = 0;
225 u32 i;
226
227 switch (original_object->common.type) {
228 case ACPI_TYPE_STRING:
229
230 /* String-to-Integer conversion */
231
232 status = acpi_ut_strtoul64(original_object->string.pointer,
233 ACPI_ANY_BASE, &value);
234 if (ACPI_FAILURE(status)) {
235 return (status);
236 }
237 break;
79 238
80 switch (return_object->common.type) {
81 case ACPI_TYPE_BUFFER: 239 case ACPI_TYPE_BUFFER:
82 240
83 /* Does the method/object legally return a string? */ 241 /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
84 242
85 if (!(expected_btypes & ACPI_RTYPE_STRING)) { 243 if (original_object->buffer.length > 8) {
86 return (AE_AML_OPERAND_TYPE); 244 return (AE_AML_OPERAND_TYPE);
87 } 245 }
88 246
247 /* Extract each buffer byte to create the integer */
248
249 for (i = 0; i < original_object->buffer.length; i++) {
250 value |=
251 ((u64) original_object->buffer.
252 pointer[i] << (i * 8));
253 }
254 break;
255
256 default:
257 return (AE_AML_OPERAND_TYPE);
258 }
259
260 new_object = acpi_ut_create_integer_object(value);
261 if (!new_object) {
262 return (AE_NO_MEMORY);
263 }
264
265 *return_object = new_object;
266 return (AE_OK);
267}
268
269/*******************************************************************************
270 *
271 * FUNCTION: acpi_ns_convert_to_string
272 *
273 * PARAMETERS: original_object - Object to be converted
274 * return_object - Where the new converted object is returned
275 *
276 * RETURN: Status. AE_OK if conversion was successful.
277 *
278 * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
279 *
280 ******************************************************************************/
281
282static acpi_status
283acpi_ns_convert_to_string(union acpi_operand_object *original_object,
284 union acpi_operand_object **return_object)
285{
286 union acpi_operand_object *new_object;
287 acpi_size length;
288 acpi_status status;
289
290 switch (original_object->common.type) {
291 case ACPI_TYPE_INTEGER:
292 /*
293 * Integer-to-String conversion. Commonly, convert
294 * an integer of value 0 to a NULL string. The last element of
295 * _BIF and _BIX packages occasionally need this fix.
296 */
297 if (original_object->integer.value == 0) {
298
299 /* Allocate a new NULL string object */
300
301 new_object = acpi_ut_create_string_object(0);
302 if (!new_object) {
303 return (AE_NO_MEMORY);
304 }
305 } else {
306 status =
307 acpi_ex_convert_to_string(original_object,
308 &new_object,
309 ACPI_IMPLICIT_CONVERT_HEX);
310 if (ACPI_FAILURE(status)) {
311 return (status);
312 }
313 }
314 break;
315
316 case ACPI_TYPE_BUFFER:
89 /* 317 /*
90 * Have a Buffer, expected a String, convert. Use a to_string 318 * Buffer-to-String conversion. Use a to_string
91 * conversion, no transform performed on the buffer data. The best 319 * conversion, no transform performed on the buffer data. The best
92 * example of this is the _BIF method, where the string data from 320 * example of this is the _BIF method, where the string data from
93 * the battery is often (incorrectly) returned as buffer object(s). 321 * the battery is often (incorrectly) returned as buffer object(s).
94 */ 322 */
95 length = 0; 323 length = 0;
96 while ((length < return_object->buffer.length) && 324 while ((length < original_object->buffer.length) &&
97 (return_object->buffer.pointer[length])) { 325 (original_object->buffer.pointer[length])) {
98 length++; 326 length++;
99 } 327 }
100 328
@@ -110,44 +338,343 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
110 * terminated at Length+1. 338 * terminated at Length+1.
111 */ 339 */
112 ACPI_MEMCPY(new_object->string.pointer, 340 ACPI_MEMCPY(new_object->string.pointer,
113 return_object->buffer.pointer, length); 341 original_object->buffer.pointer, length);
342 break;
343
344 default:
345 return (AE_AML_OPERAND_TYPE);
346 }
347
348 *return_object = new_object;
349 return (AE_OK);
350}
351
352/*******************************************************************************
353 *
354 * FUNCTION: acpi_ns_convert_to_buffer
355 *
356 * PARAMETERS: original_object - Object to be converted
357 * return_object - Where the new converted object is returned
358 *
359 * RETURN: Status. AE_OK if conversion was successful.
360 *
361 * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
362 *
363 ******************************************************************************/
114 364
365static acpi_status
366acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
367 union acpi_operand_object **return_object)
368{
369 union acpi_operand_object *new_object;
370 acpi_status status;
371 union acpi_operand_object **elements;
372 u32 *dword_buffer;
373 u32 count;
374 u32 i;
375
376 switch (original_object->common.type) {
377 case ACPI_TYPE_INTEGER:
115 /* 378 /*
116 * If the original object is a package element, we need to: 379 * Integer-to-Buffer conversion.
117 * 1. Set the reference count of the new object to match the 380 * Convert the Integer to a packed-byte buffer. _MAT and other
118 * reference count of the old object. 381 * objects need this sometimes, if a read has been performed on a
119 * 2. Decrement the reference count of the original object. 382 * Field object that is less than or equal to the global integer
383 * size (32 or 64 bits).
120 */ 384 */
121 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { 385 status =
122 new_object->common.reference_count = 386 acpi_ex_convert_to_buffer(original_object, &new_object);
123 return_object->common.reference_count; 387 if (ACPI_FAILURE(status)) {
388 return (status);
389 }
390 break;
391
392 case ACPI_TYPE_STRING:
124 393
125 if (return_object->common.reference_count > 1) { 394 /* String-to-Buffer conversion. Simple data copy */
126 return_object->common.reference_count--; 395
396 new_object =
397 acpi_ut_create_buffer_object(original_object->string.
398 length);
399 if (!new_object) {
400 return (AE_NO_MEMORY);
401 }
402
403 ACPI_MEMCPY(new_object->buffer.pointer,
404 original_object->string.pointer,
405 original_object->string.length);
406 break;
407
408 case ACPI_TYPE_PACKAGE:
409 /*
410 * This case is often seen for predefined names that must return a
411 * Buffer object with multiple DWORD integers within. For example,
412 * _FDE and _GTM. The Package can be converted to a Buffer.
413 */
414
415 /* All elements of the Package must be integers */
416
417 elements = original_object->package.elements;
418 count = original_object->package.count;
419
420 for (i = 0; i < count; i++) {
421 if ((!*elements) ||
422 ((*elements)->common.type != ACPI_TYPE_INTEGER)) {
423 return (AE_AML_OPERAND_TYPE);
127 } 424 }
425 elements++;
426 }
128 427
129 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, 428 /* Create the new buffer object to replace the Package */
130 data->node_flags, 429
131 "Converted Buffer to expected String at index %u", 430 new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count));
132 package_index)); 431 if (!new_object) {
133 } else { 432 return (AE_NO_MEMORY);
134 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
135 data->node_flags,
136 "Converted Buffer to expected String"));
137 } 433 }
138 434
139 /* Delete old object, install the new return object */ 435 /* Copy the package elements (integers) to the buffer as DWORDs */
140 436
141 acpi_ut_remove_reference(return_object); 437 elements = original_object->package.elements;
142 *return_object_ptr = new_object; 438 dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer);
143 data->flags |= ACPI_OBJECT_REPAIRED; 439
144 return (AE_OK); 440 for (i = 0; i < count; i++) {
441 *dword_buffer = (u32) (*elements)->integer.value;
442 dword_buffer++;
443 elements++;
444 }
445 break;
145 446
146 default: 447 default:
448 return (AE_AML_OPERAND_TYPE);
449 }
450
451 *return_object = new_object;
452 return (AE_OK);
453}
454
455/*******************************************************************************
456 *
457 * FUNCTION: acpi_ns_convert_to_package
458 *
459 * PARAMETERS: original_object - Object to be converted
460 * return_object - Where the new converted object is returned
461 *
462 * RETURN: Status. AE_OK if conversion was successful.
463 *
464 * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of
465 * the buffer is converted to a single integer package element.
466 *
467 ******************************************************************************/
468
469static acpi_status
470acpi_ns_convert_to_package(union acpi_operand_object *original_object,
471 union acpi_operand_object **return_object)
472{
473 union acpi_operand_object *new_object;
474 union acpi_operand_object **elements;
475 u32 length;
476 u8 *buffer;
477
478 switch (original_object->common.type) {
479 case ACPI_TYPE_BUFFER:
480
481 /* Buffer-to-Package conversion */
482
483 length = original_object->buffer.length;
484 new_object = acpi_ut_create_package_object(length);
485 if (!new_object) {
486 return (AE_NO_MEMORY);
487 }
488
489 /* Convert each buffer byte to an integer package element */
490
491 elements = new_object->package.elements;
492 buffer = original_object->buffer.pointer;
493
494 while (length--) {
495 *elements =
496 acpi_ut_create_integer_object((u64) *buffer);
497 if (!*elements) {
498 acpi_ut_remove_reference(new_object);
499 return (AE_NO_MEMORY);
500 }
501 elements++;
502 buffer++;
503 }
147 break; 504 break;
505
506 default:
507 return (AE_AML_OPERAND_TYPE);
148 } 508 }
149 509
150 return (AE_AML_OPERAND_TYPE); 510 *return_object = new_object;
511 return (AE_OK);
512}
513
514/*******************************************************************************
515 *
516 * FUNCTION: acpi_ns_repair_null_element
517 *
518 * PARAMETERS: Data - Pointer to validation data structure
519 * expected_btypes - Object types expected
520 * package_index - Index of object within parent package (if
521 * applicable - ACPI_NOT_PACKAGE_ELEMENT
522 * otherwise)
523 * return_object_ptr - Pointer to the object returned from the
524 * evaluation of a method or object
525 *
526 * RETURN: Status. AE_OK if repair was successful.
527 *
528 * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
529 *
530 ******************************************************************************/
531
532acpi_status
533acpi_ns_repair_null_element(struct acpi_predefined_data *data,
534 u32 expected_btypes,
535 u32 package_index,
536 union acpi_operand_object **return_object_ptr)
537{
538 union acpi_operand_object *return_object = *return_object_ptr;
539 union acpi_operand_object *new_object;
540
541 ACPI_FUNCTION_NAME(ns_repair_null_element);
542
543 /* No repair needed if return object is non-NULL */
544
545 if (return_object) {
546 return (AE_OK);
547 }
548
549 /*
550 * Attempt to repair a NULL element of a Package object. This applies to
551 * predefined names that return a fixed-length package and each element
552 * is required. It does not apply to variable-length packages where NULL
553 * elements are allowed, especially at the end of the package.
554 */
555 if (expected_btypes & ACPI_RTYPE_INTEGER) {
556
557 /* Need an Integer - create a zero-value integer */
558
559 new_object = acpi_ut_create_integer_object(0);
560 } else if (expected_btypes & ACPI_RTYPE_STRING) {
561
562 /* Need a String - create a NULL string */
563
564 new_object = acpi_ut_create_string_object(0);
565 } else if (expected_btypes & ACPI_RTYPE_BUFFER) {
566
567 /* Need a Buffer - create a zero-length buffer */
568
569 new_object = acpi_ut_create_buffer_object(0);
570 } else {
571 /* Error for all other expected types */
572
573 return (AE_AML_OPERAND_TYPE);
574 }
575
576 if (!new_object) {
577 return (AE_NO_MEMORY);
578 }
579
580 /* Set the reference count according to the parent Package object */
581
582 new_object->common.reference_count =
583 data->parent_package->common.reference_count;
584
585 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
586 "%s: Converted NULL package element to expected %s at index %u\n",
587 data->pathname,
588 acpi_ut_get_object_type_name(new_object),
589 package_index));
590
591 *return_object_ptr = new_object;
592 data->flags |= ACPI_OBJECT_REPAIRED;
593 return (AE_OK);
594}
595
596/******************************************************************************
597 *
598 * FUNCTION: acpi_ns_remove_null_elements
599 *
600 * PARAMETERS: Data - Pointer to validation data structure
601 * package_type - An acpi_return_package_types value
602 * obj_desc - A Package object
603 *
604 * RETURN: None.
605 *
606 * DESCRIPTION: Remove all NULL package elements from packages that contain
607 * a variable number of sub-packages. For these types of
608 * packages, NULL elements can be safely removed.
609 *
610 *****************************************************************************/
611
612void
613acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
614 u8 package_type,
615 union acpi_operand_object *obj_desc)
616{
617 union acpi_operand_object **source;
618 union acpi_operand_object **dest;
619 u32 count;
620 u32 new_count;
621 u32 i;
622
623 ACPI_FUNCTION_NAME(ns_remove_null_elements);
624
625 /*
626 * PTYPE1 packages contain no subpackages.
627 * PTYPE2 packages contain a variable number of sub-packages. We can
628 * safely remove all NULL elements from the PTYPE2 packages.
629 */
630 switch (package_type) {
631 case ACPI_PTYPE1_FIXED:
632 case ACPI_PTYPE1_VAR:
633 case ACPI_PTYPE1_OPTION:
634 return;
635
636 case ACPI_PTYPE2:
637 case ACPI_PTYPE2_COUNT:
638 case ACPI_PTYPE2_PKG_COUNT:
639 case ACPI_PTYPE2_FIXED:
640 case ACPI_PTYPE2_MIN:
641 case ACPI_PTYPE2_REV_FIXED:
642 break;
643
644 default:
645 return;
646 }
647
648 count = obj_desc->package.count;
649 new_count = count;
650
651 source = obj_desc->package.elements;
652 dest = source;
653
654 /* Examine all elements of the package object, remove nulls */
655
656 for (i = 0; i < count; i++) {
657 if (!*source) {
658 new_count--;
659 } else {
660 *dest = *source;
661 dest++;
662 }
663 source++;
664 }
665
666 /* Update parent package if any null elements were removed */
667
668 if (new_count < count) {
669 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
670 "%s: Found and removed %u NULL elements\n",
671 data->pathname, (count - new_count)));
672
673 /* NULL terminate list and update the package count */
674
675 *dest = NULL;
676 obj_desc->package.count = new_count;
677 }
151} 678}
152 679
153/******************************************************************************* 680/*******************************************************************************
@@ -180,6 +707,8 @@ acpi_ns_repair_package_list(struct acpi_predefined_data *data,
180{ 707{
181 union acpi_operand_object *pkg_obj_desc; 708 union acpi_operand_object *pkg_obj_desc;
182 709
710 ACPI_FUNCTION_NAME(ns_repair_package_list);
711
183 /* 712 /*
184 * Create the new outer package and populate it. The new package will 713 * Create the new outer package and populate it. The new package will
185 * have a single element, the lone subpackage. 714 * have a single element, the lone subpackage.
@@ -196,8 +725,9 @@ acpi_ns_repair_package_list(struct acpi_predefined_data *data,
196 *obj_desc_ptr = pkg_obj_desc; 725 *obj_desc_ptr = pkg_obj_desc;
197 data->flags |= ACPI_OBJECT_REPAIRED; 726 data->flags |= ACPI_OBJECT_REPAIRED;
198 727
199 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 728 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
200 "Incorrectly formed Package, attempting repair")); 729 "%s: Repaired incorrectly formed Package\n",
730 data->pathname));
201 731
202 return (AE_OK); 732 return (AE_OK);
203} 733}
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
new file mode 100644
index 000000000000..61bd0f6755d2
--- /dev/null
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -0,0 +1,567 @@
1/******************************************************************************
2 *
3 * Module Name: nsrepair2 - Repair for objects returned by specific
4 * predefined methods
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "acnamesp.h"
48
49#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsrepair2")
51
52/*
53 * Information structure and handler for ACPI predefined names that can
54 * be repaired on a per-name basis.
55 */
56typedef
57acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data,
58 union acpi_operand_object **return_object_ptr);
59
60typedef struct acpi_repair_info {
61 char name[ACPI_NAME_SIZE];
62 acpi_repair_function repair_function;
63
64} acpi_repair_info;
65
66/* Local prototypes */
67
68static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct
69 acpi_namespace_node
70 *node);
71
72static acpi_status
73acpi_ns_repair_ALR(struct acpi_predefined_data *data,
74 union acpi_operand_object **return_object_ptr);
75
76static acpi_status
77acpi_ns_repair_FDE(struct acpi_predefined_data *data,
78 union acpi_operand_object **return_object_ptr);
79
80static acpi_status
81acpi_ns_repair_PSS(struct acpi_predefined_data *data,
82 union acpi_operand_object **return_object_ptr);
83
84static acpi_status
85acpi_ns_repair_TSS(struct acpi_predefined_data *data,
86 union acpi_operand_object **return_object_ptr);
87
88static acpi_status
89acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
90 union acpi_operand_object *return_object,
91 u32 expected_count,
92 u32 sort_index,
93 u8 sort_direction, char *sort_key_name);
94
95static void
96acpi_ns_sort_list(union acpi_operand_object **elements,
97 u32 count, u32 index, u8 sort_direction);
98
99/* Values for sort_direction above */
100
101#define ACPI_SORT_ASCENDING 0
102#define ACPI_SORT_DESCENDING 1
103
104/*
105 * This table contains the names of the predefined methods for which we can
106 * perform more complex repairs.
107 *
108 * As necessary:
109 *
110 * _ALR: Sort the list ascending by ambient_illuminance
111 * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs
112 * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
113 * _PSS: Sort the list descending by Power
114 * _TSS: Sort the list descending by Power
115 */
116static const struct acpi_repair_info acpi_ns_repairable_names[] = {
117 {"_ALR", acpi_ns_repair_ALR},
118 {"_FDE", acpi_ns_repair_FDE},
119 {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */
120 {"_PSS", acpi_ns_repair_PSS},
121 {"_TSS", acpi_ns_repair_TSS},
122 {{0, 0, 0, 0}, NULL} /* Table terminator */
123};
124
125#define ACPI_FDE_FIELD_COUNT 5
126#define ACPI_FDE_BYTE_BUFFER_SIZE 5
127#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (u32))
128
129/******************************************************************************
130 *
131 * FUNCTION: acpi_ns_complex_repairs
132 *
133 * PARAMETERS: Data - Pointer to validation data structure
134 * Node - Namespace node for the method/object
135 * validate_status - Original status of earlier validation
136 * return_object_ptr - Pointer to the object returned from the
137 * evaluation of a method or object
138 *
139 * RETURN: Status. AE_OK if repair was successful. If name is not
140 * matched, validate_status is returned.
141 *
142 * DESCRIPTION: Attempt to repair/convert a return object of a type that was
143 * not expected.
144 *
145 *****************************************************************************/
146
147acpi_status
148acpi_ns_complex_repairs(struct acpi_predefined_data *data,
149 struct acpi_namespace_node *node,
150 acpi_status validate_status,
151 union acpi_operand_object **return_object_ptr)
152{
153 const struct acpi_repair_info *predefined;
154 acpi_status status;
155
156 /* Check if this name is in the list of repairable names */
157
158 predefined = acpi_ns_match_repairable_name(node);
159 if (!predefined) {
160 return (validate_status);
161 }
162
163 status = predefined->repair_function(data, return_object_ptr);
164 return (status);
165}
166
167/******************************************************************************
168 *
169 * FUNCTION: acpi_ns_match_repairable_name
170 *
171 * PARAMETERS: Node - Namespace node for the method/object
172 *
173 * RETURN: Pointer to entry in repair table. NULL indicates not found.
174 *
175 * DESCRIPTION: Check an object name against the repairable object list.
176 *
177 *****************************************************************************/
178
179static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct
180 acpi_namespace_node
181 *node)
182{
183 const struct acpi_repair_info *this_name;
184
185 /* Search info table for a repairable predefined method/object name */
186
187 this_name = acpi_ns_repairable_names;
188 while (this_name->repair_function) {
189 if (ACPI_COMPARE_NAME(node->name.ascii, this_name->name)) {
190 return (this_name);
191 }
192 this_name++;
193 }
194
195 return (NULL); /* Not found */
196}
197
198/******************************************************************************
199 *
200 * FUNCTION: acpi_ns_repair_ALR
201 *
202 * PARAMETERS: Data - Pointer to validation data structure
203 * return_object_ptr - Pointer to the object returned from the
204 * evaluation of a method or object
205 *
206 * RETURN: Status. AE_OK if object is OK or was repaired successfully
207 *
208 * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list
209 * ascending by the ambient illuminance values.
210 *
211 *****************************************************************************/
212
213static acpi_status
214acpi_ns_repair_ALR(struct acpi_predefined_data *data,
215 union acpi_operand_object **return_object_ptr)
216{
217 union acpi_operand_object *return_object = *return_object_ptr;
218 acpi_status status;
219
220 status = acpi_ns_check_sorted_list(data, return_object, 2, 1,
221 ACPI_SORT_ASCENDING,
222 "AmbientIlluminance");
223
224 return (status);
225}
226
227/******************************************************************************
228 *
229 * FUNCTION: acpi_ns_repair_FDE
230 *
231 * PARAMETERS: Data - Pointer to validation data structure
232 * return_object_ptr - Pointer to the object returned from the
233 * evaluation of a method or object
234 *
235 * RETURN: Status. AE_OK if object is OK or was repaired successfully
236 *
237 * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return
238 * value is a Buffer of 5 DWORDs. This function repairs a common
239 * problem where the return value is a Buffer of BYTEs, not
240 * DWORDs.
241 *
242 *****************************************************************************/
243
244static acpi_status
245acpi_ns_repair_FDE(struct acpi_predefined_data *data,
246 union acpi_operand_object **return_object_ptr)
247{
248 union acpi_operand_object *return_object = *return_object_ptr;
249 union acpi_operand_object *buffer_object;
250 u8 *byte_buffer;
251 u32 *dword_buffer;
252 u32 i;
253
254 ACPI_FUNCTION_NAME(ns_repair_FDE);
255
256 switch (return_object->common.type) {
257 case ACPI_TYPE_BUFFER:
258
259 /* This is the expected type. Length should be (at least) 5 DWORDs */
260
261 if (return_object->buffer.length >= ACPI_FDE_DWORD_BUFFER_SIZE) {
262 return (AE_OK);
263 }
264
265 /* We can only repair if we have exactly 5 BYTEs */
266
267 if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) {
268 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
269 data->node_flags,
270 "Incorrect return buffer length %u, expected %u",
271 return_object->buffer.length,
272 ACPI_FDE_DWORD_BUFFER_SIZE));
273
274 return (AE_AML_OPERAND_TYPE);
275 }
276
277 /* Create the new (larger) buffer object */
278
279 buffer_object =
280 acpi_ut_create_buffer_object(ACPI_FDE_DWORD_BUFFER_SIZE);
281 if (!buffer_object) {
282 return (AE_NO_MEMORY);
283 }
284
285 /* Expand each byte to a DWORD */
286
287 byte_buffer = return_object->buffer.pointer;
288 dword_buffer =
289 ACPI_CAST_PTR(u32, buffer_object->buffer.pointer);
290
291 for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) {
292 *dword_buffer = (u32) *byte_buffer;
293 dword_buffer++;
294 byte_buffer++;
295 }
296
297 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
298 "%s Expanded Byte Buffer to expected DWord Buffer\n",
299 data->pathname));
300 break;
301
302 default:
303 return (AE_AML_OPERAND_TYPE);
304 }
305
306 /* Delete the original return object, return the new buffer object */
307
308 acpi_ut_remove_reference(return_object);
309 *return_object_ptr = buffer_object;
310
311 data->flags |= ACPI_OBJECT_REPAIRED;
312 return (AE_OK);
313}
314
315/******************************************************************************
316 *
317 * FUNCTION: acpi_ns_repair_TSS
318 *
319 * PARAMETERS: Data - Pointer to validation data structure
320 * return_object_ptr - Pointer to the object returned from the
321 * evaluation of a method or object
322 *
323 * RETURN: Status. AE_OK if object is OK or was repaired successfully
324 *
325 * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list
326 * descending by the power dissipation values.
327 *
328 *****************************************************************************/
329
330static acpi_status
331acpi_ns_repair_TSS(struct acpi_predefined_data *data,
332 union acpi_operand_object **return_object_ptr)
333{
334 union acpi_operand_object *return_object = *return_object_ptr;
335 acpi_status status;
336
337 status = acpi_ns_check_sorted_list(data, return_object, 5, 1,
338 ACPI_SORT_DESCENDING,
339 "PowerDissipation");
340
341 return (status);
342}
343
344/******************************************************************************
345 *
346 * FUNCTION: acpi_ns_repair_PSS
347 *
348 * PARAMETERS: Data - Pointer to validation data structure
349 * return_object_ptr - Pointer to the object returned from the
350 * evaluation of a method or object
351 *
352 * RETURN: Status. AE_OK if object is OK or was repaired successfully
353 *
354 * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list
355 * by the CPU frequencies. Check that the power dissipation values
356 * are all proportional to CPU frequency (i.e., sorting by
357 * frequency should be the same as sorting by power.)
358 *
359 *****************************************************************************/
360
361static acpi_status
362acpi_ns_repair_PSS(struct acpi_predefined_data *data,
363 union acpi_operand_object **return_object_ptr)
364{
365 union acpi_operand_object *return_object = *return_object_ptr;
366 union acpi_operand_object **outer_elements;
367 u32 outer_element_count;
368 union acpi_operand_object **elements;
369 union acpi_operand_object *obj_desc;
370 u32 previous_value;
371 acpi_status status;
372 u32 i;
373
374 /*
375 * Entries (sub-packages) in the _PSS Package must be sorted by power
376 * dissipation, in descending order. If it appears that the list is
377 * incorrectly sorted, sort it. We sort by cpu_frequency, since this
378 * should be proportional to the power.
379 */
380 status = acpi_ns_check_sorted_list(data, return_object, 6, 0,
381 ACPI_SORT_DESCENDING,
382 "CpuFrequency");
383 if (ACPI_FAILURE(status)) {
384 return (status);
385 }
386
387 /*
388 * We now know the list is correctly sorted by CPU frequency. Check if
389 * the power dissipation values are proportional.
390 */
391 previous_value = ACPI_UINT32_MAX;
392 outer_elements = return_object->package.elements;
393 outer_element_count = return_object->package.count;
394
395 for (i = 0; i < outer_element_count; i++) {
396 elements = (*outer_elements)->package.elements;
397 obj_desc = elements[1]; /* Index1 = power_dissipation */
398
399 if ((u32) obj_desc->integer.value > previous_value) {
400 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
401 data->node_flags,
402 "SubPackage[%u,%u] - suspicious power dissipation values",
403 i - 1, i));
404 }
405
406 previous_value = (u32) obj_desc->integer.value;
407 outer_elements++;
408 }
409
410 return (AE_OK);
411}
412
413/******************************************************************************
414 *
415 * FUNCTION: acpi_ns_check_sorted_list
416 *
417 * PARAMETERS: Data - Pointer to validation data structure
418 * return_object - Pointer to the top-level returned object
419 * expected_count - Minimum length of each sub-package
420 * sort_index - Sub-package entry to sort on
421 * sort_direction - Ascending or descending
422 * sort_key_name - Name of the sort_index field
423 *
424 * RETURN: Status. AE_OK if the list is valid and is sorted correctly or
425 * has been repaired by sorting the list.
426 *
427 * DESCRIPTION: Check if the package list is valid and sorted correctly by the
428 * sort_index. If not, then sort the list.
429 *
430 *****************************************************************************/
431
432static acpi_status
433acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
434 union acpi_operand_object *return_object,
435 u32 expected_count,
436 u32 sort_index,
437 u8 sort_direction, char *sort_key_name)
438{
439 u32 outer_element_count;
440 union acpi_operand_object **outer_elements;
441 union acpi_operand_object **elements;
442 union acpi_operand_object *obj_desc;
443 u32 i;
444 u32 previous_value;
445
446 ACPI_FUNCTION_NAME(ns_check_sorted_list);
447
448 /* The top-level object must be a package */
449
450 if (return_object->common.type != ACPI_TYPE_PACKAGE) {
451 return (AE_AML_OPERAND_TYPE);
452 }
453
454 /*
455 * NOTE: assumes list of sub-packages contains no NULL elements.
456 * Any NULL elements should have been removed by earlier call
457 * to acpi_ns_remove_null_elements.
458 */
459 outer_elements = return_object->package.elements;
460 outer_element_count = return_object->package.count;
461 if (!outer_element_count) {
462 return (AE_AML_PACKAGE_LIMIT);
463 }
464
465 previous_value = 0;
466 if (sort_direction == ACPI_SORT_DESCENDING) {
467 previous_value = ACPI_UINT32_MAX;
468 }
469
470 /* Examine each subpackage */
471
472 for (i = 0; i < outer_element_count; i++) {
473
474 /* Each element of the top-level package must also be a package */
475
476 if ((*outer_elements)->common.type != ACPI_TYPE_PACKAGE) {
477 return (AE_AML_OPERAND_TYPE);
478 }
479
480 /* Each sub-package must have the minimum length */
481
482 if ((*outer_elements)->package.count < expected_count) {
483 return (AE_AML_PACKAGE_LIMIT);
484 }
485
486 elements = (*outer_elements)->package.elements;
487 obj_desc = elements[sort_index];
488
489 if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
490 return (AE_AML_OPERAND_TYPE);
491 }
492
493 /*
494 * The list must be sorted in the specified order. If we detect a
495 * discrepancy, sort the entire list.
496 */
497 if (((sort_direction == ACPI_SORT_ASCENDING) &&
498 (obj_desc->integer.value < previous_value)) ||
499 ((sort_direction == ACPI_SORT_DESCENDING) &&
500 (obj_desc->integer.value > previous_value))) {
501 acpi_ns_sort_list(return_object->package.elements,
502 outer_element_count, sort_index,
503 sort_direction);
504
505 data->flags |= ACPI_OBJECT_REPAIRED;
506
507 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
508 "%s: Repaired unsorted list - now sorted by %s\n",
509 data->pathname, sort_key_name));
510 return (AE_OK);
511 }
512
513 previous_value = (u32) obj_desc->integer.value;
514 outer_elements++;
515 }
516
517 return (AE_OK);
518}
519
520/******************************************************************************
521 *
522 * FUNCTION: acpi_ns_sort_list
523 *
524 * PARAMETERS: Elements - Package object element list
525 * Count - Element count for above
526 * Index - Sort by which package element
527 * sort_direction - Ascending or Descending sort
528 *
529 * RETURN: None
530 *
531 * DESCRIPTION: Sort the objects that are in a package element list.
532 *
533 * NOTE: Assumes that all NULL elements have been removed from the package,
534 * and that all elements have been verified to be of type Integer.
535 *
536 *****************************************************************************/
537
538static void
539acpi_ns_sort_list(union acpi_operand_object **elements,
540 u32 count, u32 index, u8 sort_direction)
541{
542 union acpi_operand_object *obj_desc1;
543 union acpi_operand_object *obj_desc2;
544 union acpi_operand_object *temp_obj;
545 u32 i;
546 u32 j;
547
548 /* Simple bubble sort */
549
550 for (i = 1; i < count; i++) {
551 for (j = (count - 1); j >= i; j--) {
552 obj_desc1 = elements[j - 1]->package.elements[index];
553 obj_desc2 = elements[j]->package.elements[index];
554
555 if (((sort_direction == ACPI_SORT_ASCENDING) &&
556 (obj_desc1->integer.value >
557 obj_desc2->integer.value))
558 || ((sort_direction == ACPI_SORT_DESCENDING)
559 && (obj_desc1->integer.value <
560 obj_desc2->integer.value))) {
561 temp_obj = elements[j - 1];
562 elements[j - 1] = elements[j];
563 elements[j] = temp_obj;
564 }
565 }
566 }
567}
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index 7e865639a928..08f8b3f5ccaa 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index ea55ab4f9849..24d05a87a2a3 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -671,24 +671,25 @@ acpi_ns_externalize_name(u32 internal_name_length,
671 671
672/******************************************************************************* 672/*******************************************************************************
673 * 673 *
674 * FUNCTION: acpi_ns_map_handle_to_node 674 * FUNCTION: acpi_ns_validate_handle
675 * 675 *
676 * PARAMETERS: Handle - Handle to be converted to an Node 676 * PARAMETERS: Handle - Handle to be validated and typecast to a
677 * namespace node.
677 * 678 *
678 * RETURN: A Name table entry pointer 679 * RETURN: A pointer to a namespace node
679 * 680 *
680 * DESCRIPTION: Convert a namespace handle to a real Node 681 * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
682 * cases for the root node.
681 * 683 *
682 * Note: Real integer handles would allow for more verification 684 * NOTE: Real integer handles would allow for more verification
683 * and keep all pointers within this subsystem - however this introduces 685 * and keep all pointers within this subsystem - however this introduces
684 * more (and perhaps unnecessary) overhead. 686 * more overhead and has not been necessary to this point. Drivers
685 * 687 * holding handles are typically notified before a node becomes invalid
686 * The current implemenation is basically a placeholder until such time comes 688 * due to a table unload.
687 * that it is needed.
688 * 689 *
689 ******************************************************************************/ 690 ******************************************************************************/
690 691
691struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle) 692struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle)
692{ 693{
693 694
694 ACPI_FUNCTION_ENTRY(); 695 ACPI_FUNCTION_ENTRY();
@@ -710,42 +711,6 @@ struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
710 711
711/******************************************************************************* 712/*******************************************************************************
712 * 713 *
713 * FUNCTION: acpi_ns_convert_entry_to_handle
714 *
715 * PARAMETERS: Node - Node to be converted to a Handle
716 *
717 * RETURN: A user handle
718 *
719 * DESCRIPTION: Convert a real Node to a namespace handle
720 *
721 ******************************************************************************/
722
723acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node)
724{
725
726 /*
727 * Simple implementation for now;
728 */
729 return ((acpi_handle) node);
730
731/* Example future implementation ---------------------
732
733 if (!Node)
734 {
735 return (NULL);
736 }
737
738 if (Node == acpi_gbl_root_node)
739 {
740 return (ACPI_ROOT_OBJECT);
741 }
742
743 return ((acpi_handle) Node);
744------------------------------------------------------*/
745}
746
747/*******************************************************************************
748 *
749 * FUNCTION: acpi_ns_terminate 714 * FUNCTION: acpi_ns_terminate
750 * 715 *
751 * PARAMETERS: none 716 * PARAMETERS: none
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 35539df5c75d..00e79fb26029 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -165,24 +165,27 @@ struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type,
165 * max_depth - Depth to which search is to reach 165 * max_depth - Depth to which search is to reach
166 * Flags - Whether to unlock the NS before invoking 166 * Flags - Whether to unlock the NS before invoking
167 * the callback routine 167 * the callback routine
168 * user_function - Called when an object of "Type" is found 168 * pre_order_visit - Called during tree pre-order visit
169 * Context - Passed to user function 169 * when an object of "Type" is found
170 * return_value - from the user_function if terminated early. 170 * post_order_visit - Called during tree post-order visit
171 * Otherwise, returns NULL. 171 * when an object of "Type" is found
172 * Context - Passed to user function(s) above
173 * return_value - from the user_function if terminated
174 * early. Otherwise, returns NULL.
172 * RETURNS: Status 175 * RETURNS: Status
173 * 176 *
174 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, 177 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
175 * starting (and ending) at the node specified by start_handle. 178 * starting (and ending) at the node specified by start_handle.
176 * The user_function is called whenever a node that matches 179 * The callback function is called whenever a node that matches
177 * the type parameter is found. If the user function returns 180 * the type parameter is found. If the callback function returns
178 * a non-zero value, the search is terminated immediately and 181 * a non-zero value, the search is terminated immediately and
179 * this value is returned to the caller. 182 * this value is returned to the caller.
180 * 183 *
181 * The point of this procedure is to provide a generic namespace 184 * The point of this procedure is to provide a generic namespace
182 * walk routine that can be called from multiple places to 185 * walk routine that can be called from multiple places to
183 * provide multiple services; the User Function can be tailored 186 * provide multiple services; the callback function(s) can be
184 * to each task, whether it is a print function, a compare 187 * tailored to each task, whether it is a print function,
185 * function, etc. 188 * a compare function, etc.
186 * 189 *
187 ******************************************************************************/ 190 ******************************************************************************/
188 191
@@ -191,7 +194,8 @@ acpi_ns_walk_namespace(acpi_object_type type,
191 acpi_handle start_node, 194 acpi_handle start_node,
192 u32 max_depth, 195 u32 max_depth,
193 u32 flags, 196 u32 flags,
194 acpi_walk_callback user_function, 197 acpi_walk_callback pre_order_visit,
198 acpi_walk_callback post_order_visit,
195 void *context, void **return_value) 199 void *context, void **return_value)
196{ 200{
197 acpi_status status; 201 acpi_status status;
@@ -200,6 +204,7 @@ acpi_ns_walk_namespace(acpi_object_type type,
200 struct acpi_namespace_node *parent_node; 204 struct acpi_namespace_node *parent_node;
201 acpi_object_type child_type; 205 acpi_object_type child_type;
202 u32 level; 206 u32 level;
207 u8 node_previously_visited = FALSE;
203 208
204 ACPI_FUNCTION_TRACE(ns_walk_namespace); 209 ACPI_FUNCTION_TRACE(ns_walk_namespace);
205 210
@@ -212,7 +217,7 @@ acpi_ns_walk_namespace(acpi_object_type type,
212 /* Null child means "get first node" */ 217 /* Null child means "get first node" */
213 218
214 parent_node = start_node; 219 parent_node = start_node;
215 child_node = NULL; 220 child_node = acpi_ns_get_next_node(parent_node, NULL);
216 child_type = ACPI_TYPE_ANY; 221 child_type = ACPI_TYPE_ANY;
217 level = 1; 222 level = 1;
218 223
@@ -221,102 +226,129 @@ acpi_ns_walk_namespace(acpi_object_type type,
221 * started. When Level is zero, the loop is done because we have 226 * started. When Level is zero, the loop is done because we have
222 * bubbled up to (and passed) the original parent handle (start_entry) 227 * bubbled up to (and passed) the original parent handle (start_entry)
223 */ 228 */
224 while (level > 0) { 229 while (level > 0 && child_node) {
230 status = AE_OK;
225 231
226 /* Get the next node in this scope. Null if not found */ 232 /* Found next child, get the type if we are not searching for ANY */
227 233
228 status = AE_OK; 234 if (type != ACPI_TYPE_ANY) {
229 child_node = acpi_ns_get_next_node(parent_node, child_node); 235 child_type = child_node->type;
230 if (child_node) { 236 }
231 237
232 /* Found next child, get the type if we are not searching for ANY */ 238 /*
239 * Ignore all temporary namespace nodes (created during control
240 * method execution) unless told otherwise. These temporary nodes
241 * can cause a race condition because they can be deleted during
242 * the execution of the user function (if the namespace is
243 * unlocked before invocation of the user function.) Only the
244 * debugger namespace dump will examine the temporary nodes.
245 */
246 if ((child_node->flags & ANOBJ_TEMPORARY) &&
247 !(flags & ACPI_NS_WALK_TEMP_NODES)) {
248 status = AE_CTRL_DEPTH;
249 }
233 250
234 if (type != ACPI_TYPE_ANY) { 251 /* Type must match requested type */
235 child_type = child_node->type;
236 }
237 252
253 else if (child_type == type) {
238 /* 254 /*
239 * Ignore all temporary namespace nodes (created during control 255 * Found a matching node, invoke the user callback function.
240 * method execution) unless told otherwise. These temporary nodes 256 * Unlock the namespace if flag is set.
241 * can cause a race condition because they can be deleted during
242 * the execution of the user function (if the namespace is
243 * unlocked before invocation of the user function.) Only the
244 * debugger namespace dump will examine the temporary nodes.
245 */ 257 */
246 if ((child_node->flags & ANOBJ_TEMPORARY) && 258 if (flags & ACPI_NS_WALK_UNLOCK) {
247 !(flags & ACPI_NS_WALK_TEMP_NODES)) { 259 mutex_status =
248 status = AE_CTRL_DEPTH; 260 acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
261 if (ACPI_FAILURE(mutex_status)) {
262 return_ACPI_STATUS(mutex_status);
263 }
249 } 264 }
250 265
251 /* Type must match requested type */ 266 /*
252 267 * Invoke the user function, either pre-order or post-order
253 else if (child_type == type) { 268 * or both.
254 /* 269 */
255 * Found a matching node, invoke the user callback function. 270 if (!node_previously_visited) {
256 * Unlock the namespace if flag is set. 271 if (pre_order_visit) {
257 */ 272 status =
258 if (flags & ACPI_NS_WALK_UNLOCK) { 273 pre_order_visit(child_node, level,
259 mutex_status = 274 context,
260 acpi_ut_release_mutex 275 return_value);
261 (ACPI_MTX_NAMESPACE);
262 if (ACPI_FAILURE(mutex_status)) {
263 return_ACPI_STATUS
264 (mutex_status);
265 }
266 } 276 }
277 } else {
278 if (post_order_visit) {
279 status =
280 post_order_visit(child_node, level,
281 context,
282 return_value);
283 }
284 }
267 285
268 status = 286 if (flags & ACPI_NS_WALK_UNLOCK) {
269 user_function(child_node, level, context, 287 mutex_status =
270 return_value); 288 acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
271 289 if (ACPI_FAILURE(mutex_status)) {
272 if (flags & ACPI_NS_WALK_UNLOCK) { 290 return_ACPI_STATUS(mutex_status);
273 mutex_status =
274 acpi_ut_acquire_mutex
275 (ACPI_MTX_NAMESPACE);
276 if (ACPI_FAILURE(mutex_status)) {
277 return_ACPI_STATUS
278 (mutex_status);
279 }
280 } 291 }
292 }
281 293
282 switch (status) { 294 switch (status) {
283 case AE_OK: 295 case AE_OK:
284 case AE_CTRL_DEPTH: 296 case AE_CTRL_DEPTH:
285 297
286 /* Just keep going */ 298 /* Just keep going */
287 break; 299 break;
288 300
289 case AE_CTRL_TERMINATE: 301 case AE_CTRL_TERMINATE:
290 302
291 /* Exit now, with OK status */ 303 /* Exit now, with OK status */
292 304
293 return_ACPI_STATUS(AE_OK); 305 return_ACPI_STATUS(AE_OK);
294 306
295 default: 307 default:
296 308
297 /* All others are valid exceptions */ 309 /* All others are valid exceptions */
298 310
299 return_ACPI_STATUS(status); 311 return_ACPI_STATUS(status);
300 } 312 }
313 }
314
315 /*
316 * Depth first search: Attempt to go down another level in the
317 * namespace if we are allowed to. Don't go any further if we have
318 * reached the caller specified maximum depth or if the user
319 * function has specified that the maximum depth has been reached.
320 */
321 if (!node_previously_visited &&
322 (level < max_depth) && (status != AE_CTRL_DEPTH)) {
323 if (child_node->child) {
324
325 /* There is at least one child of this node, visit it */
326
327 level++;
328 parent_node = child_node;
329 child_node =
330 acpi_ns_get_next_node(parent_node, NULL);
331 continue;
301 } 332 }
333 }
302 334
303 /* 335 /* No more children, re-visit this node */
304 * Depth first search: Attempt to go down another level in the
305 * namespace if we are allowed to. Don't go any further if we have
306 * reached the caller specified maximum depth or if the user
307 * function has specified that the maximum depth has been reached.
308 */
309 if ((level < max_depth) && (status != AE_CTRL_DEPTH)) {
310 if (child_node->child) {
311 336
312 /* There is at least one child of this node, visit it */ 337 if (!node_previously_visited) {
338 node_previously_visited = TRUE;
339 continue;
340 }
313 341
314 level++; 342 /* No more children, visit peers */
315 parent_node = child_node; 343
316 child_node = NULL; 344 child_node = acpi_ns_get_next_node(parent_node, child_node);
317 } 345 if (child_node) {
318 } 346 node_previously_visited = FALSE;
319 } else { 347 }
348
349 /* No peers, re-visit parent */
350
351 else {
320 /* 352 /*
321 * No more children of this node (acpi_ns_get_next_node failed), go 353 * No more children of this node (acpi_ns_get_next_node failed), go
322 * back upwards in the namespace tree to the node's parent. 354 * back upwards in the namespace tree to the node's parent.
@@ -324,6 +356,8 @@ acpi_ns_walk_namespace(acpi_object_type type,
324 level--; 356 level--;
325 child_node = parent_node; 357 child_node = parent_node;
326 parent_node = acpi_ns_get_parent_node(parent_node); 358 parent_node = acpi_ns_get_parent_node(parent_node);
359
360 node_previously_visited = TRUE;
327 } 361 }
328 } 362 }
329 363
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index 4929dbdbc8f0..ebef8a7fd707 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -190,7 +190,7 @@ acpi_evaluate_object(acpi_handle handle,
190 190
191 /* Convert and validate the device handle */ 191 /* Convert and validate the device handle */
192 192
193 info->prefix_node = acpi_ns_map_handle_to_node(handle); 193 info->prefix_node = acpi_ns_validate_handle(handle);
194 if (!info->prefix_node) { 194 if (!info->prefix_node) {
195 status = AE_BAD_PARAMETER; 195 status = AE_BAD_PARAMETER;
196 goto cleanup; 196 goto cleanup;
@@ -433,8 +433,11 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
433 * PARAMETERS: Type - acpi_object_type to search for 433 * PARAMETERS: Type - acpi_object_type to search for
434 * start_object - Handle in namespace where search begins 434 * start_object - Handle in namespace where search begins
435 * max_depth - Depth to which search is to reach 435 * max_depth - Depth to which search is to reach
436 * user_function - Called when an object of "Type" is found 436 * pre_order_visit - Called during tree pre-order visit
437 * Context - Passed to user function 437 * when an object of "Type" is found
438 * post_order_visit - Called during tree post-order visit
439 * when an object of "Type" is found
440 * Context - Passed to user function(s) above
438 * return_value - Location where return value of 441 * return_value - Location where return value of
439 * user_function is put if terminated early 442 * user_function is put if terminated early
440 * 443 *
@@ -443,16 +446,16 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
443 * 446 *
444 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, 447 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
445 * starting (and ending) at the object specified by start_handle. 448 * starting (and ending) at the object specified by start_handle.
446 * The user_function is called whenever an object that matches 449 * The callback function is called whenever an object that matches
447 * the type parameter is found. If the user function returns 450 * the type parameter is found. If the callback function returns
448 * a non-zero value, the search is terminated immediately and this 451 * a non-zero value, the search is terminated immediately and this
449 * value is returned to the caller. 452 * value is returned to the caller.
450 * 453 *
451 * The point of this procedure is to provide a generic namespace 454 * The point of this procedure is to provide a generic namespace
452 * walk routine that can be called from multiple places to 455 * walk routine that can be called from multiple places to
453 * provide multiple services; the User Function can be tailored 456 * provide multiple services; the callback function(s) can be
454 * to each task, whether it is a print function, a compare 457 * tailored to each task, whether it is a print function,
455 * function, etc. 458 * a compare function, etc.
456 * 459 *
457 ******************************************************************************/ 460 ******************************************************************************/
458 461
@@ -460,7 +463,8 @@ acpi_status
460acpi_walk_namespace(acpi_object_type type, 463acpi_walk_namespace(acpi_object_type type,
461 acpi_handle start_object, 464 acpi_handle start_object,
462 u32 max_depth, 465 u32 max_depth,
463 acpi_walk_callback user_function, 466 acpi_walk_callback pre_order_visit,
467 acpi_walk_callback post_order_visit,
464 void *context, void **return_value) 468 void *context, void **return_value)
465{ 469{
466 acpi_status status; 470 acpi_status status;
@@ -469,7 +473,8 @@ acpi_walk_namespace(acpi_object_type type,
469 473
470 /* Parameter validation */ 474 /* Parameter validation */
471 475
472 if ((type > ACPI_TYPE_LOCAL_MAX) || (!max_depth) || (!user_function)) { 476 if ((type > ACPI_TYPE_LOCAL_MAX) ||
477 (!max_depth) || (!pre_order_visit && !post_order_visit)) {
473 return_ACPI_STATUS(AE_BAD_PARAMETER); 478 return_ACPI_STATUS(AE_BAD_PARAMETER);
474 } 479 }
475 480
@@ -501,8 +506,9 @@ acpi_walk_namespace(acpi_object_type type,
501 } 506 }
502 507
503 status = acpi_ns_walk_namespace(type, start_object, max_depth, 508 status = acpi_ns_walk_namespace(type, start_object, max_depth,
504 ACPI_NS_WALK_UNLOCK, user_function, 509 ACPI_NS_WALK_UNLOCK, pre_order_visit,
505 context, return_value); 510 post_order_visit, context,
511 return_value);
506 512
507 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 513 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
508 514
@@ -546,7 +552,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
546 return (status); 552 return (status);
547 } 553 }
548 554
549 node = acpi_ns_map_handle_to_node(obj_handle); 555 node = acpi_ns_validate_handle(obj_handle);
550 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 556 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
551 if (ACPI_FAILURE(status)) { 557 if (ACPI_FAILURE(status)) {
552 return (status); 558 return (status);
@@ -556,25 +562,20 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
556 return (AE_BAD_PARAMETER); 562 return (AE_BAD_PARAMETER);
557 } 563 }
558 564
559 /* Run _STA to determine if device is present */ 565 /*
560 566 * First, filter based on the device HID and CID.
561 status = acpi_ut_execute_STA(node, &flags); 567 *
562 if (ACPI_FAILURE(status)) { 568 * 01/2010: For this case where a specific HID is requested, we don't
563 return (AE_CTRL_DEPTH); 569 * want to run _STA until we have an actual HID match. Thus, we will
564 } 570 * not unnecessarily execute _STA on devices for which the caller
565 571 * doesn't care about. Previously, _STA was executed unconditionally
566 if (!(flags & ACPI_STA_DEVICE_PRESENT) && 572 * on all devices found here.
567 !(flags & ACPI_STA_DEVICE_FUNCTIONING)) { 573 *
568 /* 574 * A side-effect of this change is that now we will continue to search
569 * Don't examine the children of the device only when the 575 * for a matching HID even under device trees where the parent device
570 * device is neither present nor functional. See ACPI spec, 576 * would have returned a _STA that indicates it is not present or
571 * description of _STA for more information. 577 * not functioning (thus aborting the search on that branch).
572 */ 578 */
573 return (AE_CTRL_DEPTH);
574 }
575
576 /* Filter based on device HID & CID */
577
578 if (info->hid != NULL) { 579 if (info->hid != NULL) {
579 status = acpi_ut_execute_HID(node, &hid); 580 status = acpi_ut_execute_HID(node, &hid);
580 if (status == AE_NOT_FOUND) { 581 if (status == AE_NOT_FOUND) {
@@ -614,6 +615,25 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
614 } 615 }
615 } 616 }
616 617
618 /* Run _STA to determine if device is present */
619
620 status = acpi_ut_execute_STA(node, &flags);
621 if (ACPI_FAILURE(status)) {
622 return (AE_CTRL_DEPTH);
623 }
624
625 if (!(flags & ACPI_STA_DEVICE_PRESENT) &&
626 !(flags & ACPI_STA_DEVICE_FUNCTIONING)) {
627 /*
628 * Don't examine the children of the device only when the
629 * device is neither present nor functional. See ACPI spec,
630 * description of _STA for more information.
631 */
632 return (AE_CTRL_DEPTH);
633 }
634
635 /* We have a valid device, invoke the user function */
636
617 status = info->user_function(obj_handle, nesting_level, info->context, 637 status = info->user_function(obj_handle, nesting_level, info->context,
618 return_value); 638 return_value);
619 return (status); 639 return (status);
@@ -681,8 +701,8 @@ acpi_get_devices(const char *HID,
681 701
682 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 702 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
683 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, 703 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
684 acpi_ns_get_device_callback, &info, 704 acpi_ns_get_device_callback, NULL,
685 return_value); 705 &info, return_value);
686 706
687 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 707 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
688 return_ACPI_STATUS(status); 708 return_ACPI_STATUS(status);
@@ -723,7 +743,7 @@ acpi_attach_data(acpi_handle obj_handle,
723 743
724 /* Convert and validate the handle */ 744 /* Convert and validate the handle */
725 745
726 node = acpi_ns_map_handle_to_node(obj_handle); 746 node = acpi_ns_validate_handle(obj_handle);
727 if (!node) { 747 if (!node) {
728 status = AE_BAD_PARAMETER; 748 status = AE_BAD_PARAMETER;
729 goto unlock_and_exit; 749 goto unlock_and_exit;
@@ -769,7 +789,7 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
769 789
770 /* Convert and validate the handle */ 790 /* Convert and validate the handle */
771 791
772 node = acpi_ns_map_handle_to_node(obj_handle); 792 node = acpi_ns_validate_handle(obj_handle);
773 if (!node) { 793 if (!node) {
774 status = AE_BAD_PARAMETER; 794 status = AE_BAD_PARAMETER;
775 goto unlock_and_exit; 795 goto unlock_and_exit;
@@ -816,7 +836,7 @@ acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
816 836
817 /* Convert and validate the handle */ 837 /* Convert and validate the handle */
818 838
819 node = acpi_ns_map_handle_to_node(obj_handle); 839 node = acpi_ns_validate_handle(obj_handle);
820 if (!node) { 840 if (!node) {
821 status = AE_BAD_PARAMETER; 841 status = AE_BAD_PARAMETER;
822 goto unlock_and_exit; 842 goto unlock_and_exit;
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index ddc84af6336e..b01e45a415e3 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -93,7 +93,7 @@ acpi_get_handle(acpi_handle parent,
93 /* Convert a parent handle to a prefix node */ 93 /* Convert a parent handle to a prefix node */
94 94
95 if (parent) { 95 if (parent) {
96 prefix_node = acpi_ns_map_handle_to_node(parent); 96 prefix_node = acpi_ns_validate_handle(parent);
97 if (!prefix_node) { 97 if (!prefix_node) {
98 return (AE_BAD_PARAMETER); 98 return (AE_BAD_PARAMETER);
99 } 99 }
@@ -114,7 +114,7 @@ acpi_get_handle(acpi_handle parent,
114 114
115 if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) { 115 if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) {
116 *ret_handle = 116 *ret_handle =
117 acpi_ns_convert_entry_to_handle(acpi_gbl_root_node); 117 ACPI_CAST_PTR(acpi_handle, acpi_gbl_root_node);
118 return (AE_OK); 118 return (AE_OK);
119 } 119 }
120 } else if (!prefix_node) { 120 } else if (!prefix_node) {
@@ -129,7 +129,7 @@ acpi_get_handle(acpi_handle parent,
129 status = 129 status =
130 acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node); 130 acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
131 if (ACPI_SUCCESS(status)) { 131 if (ACPI_SUCCESS(status)) {
132 *ret_handle = acpi_ns_convert_entry_to_handle(node); 132 *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
133 } 133 }
134 134
135 return (status); 135 return (status);
@@ -186,7 +186,7 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
186 return (status); 186 return (status);
187 } 187 }
188 188
189 node = acpi_ns_map_handle_to_node(handle); 189 node = acpi_ns_validate_handle(handle);
190 if (!node) { 190 if (!node) {
191 status = AE_BAD_PARAMETER; 191 status = AE_BAD_PARAMETER;
192 goto unlock_and_exit; 192 goto unlock_and_exit;
@@ -291,7 +291,7 @@ acpi_get_object_info(acpi_handle handle,
291 goto cleanup; 291 goto cleanup;
292 } 292 }
293 293
294 node = acpi_ns_map_handle_to_node(handle); 294 node = acpi_ns_validate_handle(handle);
295 if (!node) { 295 if (!node) {
296 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 296 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
297 return (AE_BAD_PARAMETER); 297 return (AE_BAD_PARAMETER);
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 4071bad4458e..eafef24ea448 100644
--- a/drivers/acpi/acpica/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -79,7 +79,7 @@ acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id)
79 79
80 /* Convert and validate the handle */ 80 /* Convert and validate the handle */
81 81
82 node = acpi_ns_map_handle_to_node(handle); 82 node = acpi_ns_validate_handle(handle);
83 if (!node) { 83 if (!node) {
84 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 84 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
85 return (AE_BAD_PARAMETER); 85 return (AE_BAD_PARAMETER);
@@ -132,7 +132,7 @@ acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type)
132 132
133 /* Convert and validate the handle */ 133 /* Convert and validate the handle */
134 134
135 node = acpi_ns_map_handle_to_node(handle); 135 node = acpi_ns_validate_handle(handle);
136 if (!node) { 136 if (!node) {
137 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 137 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
138 return (AE_BAD_PARAMETER); 138 return (AE_BAD_PARAMETER);
@@ -182,7 +182,7 @@ acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
182 182
183 /* Convert and validate the handle */ 183 /* Convert and validate the handle */
184 184
185 node = acpi_ns_map_handle_to_node(handle); 185 node = acpi_ns_validate_handle(handle);
186 if (!node) { 186 if (!node) {
187 status = AE_BAD_PARAMETER; 187 status = AE_BAD_PARAMETER;
188 goto unlock_and_exit; 188 goto unlock_and_exit;
@@ -191,7 +191,7 @@ acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
191 /* Get the parent entry */ 191 /* Get the parent entry */
192 192
193 parent_node = acpi_ns_get_parent_node(node); 193 parent_node = acpi_ns_get_parent_node(node);
194 *ret_handle = acpi_ns_convert_entry_to_handle(parent_node); 194 *ret_handle = ACPI_CAST_PTR(acpi_handle, parent_node);
195 195
196 /* Return exception if parent is null */ 196 /* Return exception if parent is null */
197 197
@@ -251,7 +251,7 @@ acpi_get_next_object(acpi_object_type type,
251 251
252 /* Start search at the beginning of the specified scope */ 252 /* Start search at the beginning of the specified scope */
253 253
254 parent_node = acpi_ns_map_handle_to_node(parent); 254 parent_node = acpi_ns_validate_handle(parent);
255 if (!parent_node) { 255 if (!parent_node) {
256 status = AE_BAD_PARAMETER; 256 status = AE_BAD_PARAMETER;
257 goto unlock_and_exit; 257 goto unlock_and_exit;
@@ -260,7 +260,7 @@ acpi_get_next_object(acpi_object_type type,
260 /* Non-null handle, ignore the parent */ 260 /* Non-null handle, ignore the parent */
261 /* Convert and validate the handle */ 261 /* Convert and validate the handle */
262 262
263 child_node = acpi_ns_map_handle_to_node(child); 263 child_node = acpi_ns_validate_handle(child);
264 if (!child_node) { 264 if (!child_node) {
265 status = AE_BAD_PARAMETER; 265 status = AE_BAD_PARAMETER;
266 goto unlock_and_exit; 266 goto unlock_and_exit;
@@ -276,7 +276,7 @@ acpi_get_next_object(acpi_object_type type,
276 } 276 }
277 277
278 if (ret_handle) { 278 if (ret_handle) {
279 *ret_handle = acpi_ns_convert_entry_to_handle(node); 279 *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
280 } 280 }
281 281
282 unlock_and_exit: 282 unlock_and_exit:
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index b161f3544b51..00493e108a01 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -403,7 +403,7 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
403 /* Get 1 byte from the AML stream */ 403 /* Get 1 byte from the AML stream */
404 404
405 opcode = AML_BYTE_OP; 405 opcode = AML_BYTE_OP;
406 arg->common.value.integer = (acpi_integer) * aml; 406 arg->common.value.integer = (u64) *aml;
407 length = 1; 407 length = 1;
408 break; 408 break;
409 409
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index cd7995b3aed4..59aabaeab1d3 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -87,7 +87,8 @@ acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
87 union acpi_parse_object *op, acpi_status status); 87 union acpi_parse_object *op, acpi_status status);
88 88
89static void 89static void
90acpi_ps_link_module_code(u8 *aml_start, u32 aml_length, acpi_owner_id owner_id); 90acpi_ps_link_module_code(union acpi_parse_object *parent_op,
91 u8 *aml_start, u32 aml_length, acpi_owner_id owner_id);
91 92
92/******************************************************************************* 93/*******************************************************************************
93 * 94 *
@@ -479,11 +480,14 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
479 */ 480 */
480 if (walk_state->pass_number == 481 if (walk_state->pass_number ==
481 ACPI_IMODE_LOAD_PASS1) { 482 ACPI_IMODE_LOAD_PASS1) {
482 acpi_ps_link_module_code(aml_op_start, 483 acpi_ps_link_module_code(op->common.
483 walk_state-> 484 parent,
485 aml_op_start,
486 (u32)
487 (walk_state->
484 parser_state. 488 parser_state.
485 pkg_end - 489 pkg_end -
486 aml_op_start, 490 aml_op_start),
487 walk_state-> 491 walk_state->
488 owner_id); 492 owner_id);
489 } 493 }
@@ -598,7 +602,8 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
598 * 602 *
599 * FUNCTION: acpi_ps_link_module_code 603 * FUNCTION: acpi_ps_link_module_code
600 * 604 *
601 * PARAMETERS: aml_start - Pointer to the AML 605 * PARAMETERS: parent_op - Parent parser op
606 * aml_start - Pointer to the AML
602 * aml_length - Length of executable AML 607 * aml_length - Length of executable AML
603 * owner_id - owner_id of module level code 608 * owner_id - owner_id of module level code
604 * 609 *
@@ -611,11 +616,13 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
611 ******************************************************************************/ 616 ******************************************************************************/
612 617
613static void 618static void
614acpi_ps_link_module_code(u8 *aml_start, u32 aml_length, acpi_owner_id owner_id) 619acpi_ps_link_module_code(union acpi_parse_object *parent_op,
620 u8 *aml_start, u32 aml_length, acpi_owner_id owner_id)
615{ 621{
616 union acpi_operand_object *prev; 622 union acpi_operand_object *prev;
617 union acpi_operand_object *next; 623 union acpi_operand_object *next;
618 union acpi_operand_object *method_obj; 624 union acpi_operand_object *method_obj;
625 struct acpi_namespace_node *parent_node;
619 626
620 /* Get the tail of the list */ 627 /* Get the tail of the list */
621 628
@@ -639,11 +646,24 @@ acpi_ps_link_module_code(u8 *aml_start, u32 aml_length, acpi_owner_id owner_id)
639 return; 646 return;
640 } 647 }
641 648
649 if (parent_op->common.node) {
650 parent_node = parent_op->common.node;
651 } else {
652 parent_node = acpi_gbl_root_node;
653 }
654
642 method_obj->method.aml_start = aml_start; 655 method_obj->method.aml_start = aml_start;
643 method_obj->method.aml_length = aml_length; 656 method_obj->method.aml_length = aml_length;
644 method_obj->method.owner_id = owner_id; 657 method_obj->method.owner_id = owner_id;
645 method_obj->method.flags |= AOPOBJ_MODULE_LEVEL; 658 method_obj->method.flags |= AOPOBJ_MODULE_LEVEL;
646 659
660 /*
661 * Save the parent node in next_object. This is cheating, but we
662 * don't want to expand the method object.
663 */
664 method_obj->method.next_object =
665 ACPI_CAST_PTR(union acpi_operand_object, parent_node);
666
647 if (!prev) { 667 if (!prev) {
648 acpi_gbl_module_code_list = method_obj; 668 acpi_gbl_module_code_list = method_obj;
649 } else { 669 } else {
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c
index 3bc3a60194d6..2b0c3be2b1b8 100644
--- a/drivers/acpi/acpica/psopcode.c
+++ b/drivers/acpi/acpica/psopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c
index 70838e9b608c..8d81542194d4 100644
--- a/drivers/acpi/acpica/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -610,17 +610,13 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
610 implicit_return_obj) { 610 implicit_return_obj) {
611 previous_walk_state-> 611 previous_walk_state->
612 implicit_return_obj = 612 implicit_return_obj =
613 acpi_ut_create_internal_object 613 acpi_ut_create_integer_object
614 (ACPI_TYPE_INTEGER); 614 ((u64) 0);
615 if (!previous_walk_state-> 615 if (!previous_walk_state->
616 implicit_return_obj) { 616 implicit_return_obj) {
617 return_ACPI_STATUS 617 return_ACPI_STATUS
618 (AE_NO_MEMORY); 618 (AE_NO_MEMORY);
619 } 619 }
620
621 previous_walk_state->
622 implicit_return_obj->
623 integer.value = 0;
624 } 620 }
625 621
626 /* Restart the calling control method */ 622 /* Restart the calling control method */
diff --git a/drivers/acpi/acpica/psscope.c b/drivers/acpi/acpica/psscope.c
index 2feca5ca9581..40e2b279ea12 100644
--- a/drivers/acpi/acpica/psscope.c
+++ b/drivers/acpi/acpica/psscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c
index 4d3389118ec3..d4b970c3630b 100644
--- a/drivers/acpi/acpica/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c
index e636e078ad3d..fe29eee5adb1 100644
--- a/drivers/acpi/acpica/psutils.c
+++ b/drivers/acpi/acpica/psutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pswalk.c b/drivers/acpi/acpica/pswalk.c
index 78b8b791f2ae..8abb9629443d 100644
--- a/drivers/acpi/acpica/pswalk.c
+++ b/drivers/acpi/acpica/pswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index dd9731c29a79..6064dd4e94c2 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -287,7 +287,8 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
287 /* Invoke an internal method if necessary */ 287 /* Invoke an internal method if necessary */
288 288
289 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 289 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
290 status = info->obj_desc->method.implementation(walk_state); 290 status =
291 info->obj_desc->method.extra.implementation(walk_state);
291 info->return_object = walk_state->return_desc; 292 info->return_object = walk_state->return_desc;
292 293
293 /* Cleanup states */ 294 /* Cleanup states */
@@ -306,14 +307,12 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
306 */ 307 */
307 if (acpi_gbl_enable_interpreter_slack) { 308 if (acpi_gbl_enable_interpreter_slack) {
308 walk_state->implicit_return_obj = 309 walk_state->implicit_return_obj =
309 acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 310 acpi_ut_create_integer_object((u64) 0);
310 if (!walk_state->implicit_return_obj) { 311 if (!walk_state->implicit_return_obj) {
311 status = AE_NO_MEMORY; 312 status = AE_NO_MEMORY;
312 acpi_ds_delete_walk_state(walk_state); 313 acpi_ds_delete_walk_state(walk_state);
313 goto cleanup; 314 goto cleanup;
314 } 315 }
315
316 walk_state->implicit_return_obj->integer.value = 0;
317 } 316 }
318 317
319 /* Parse the AML */ 318 /* Parse the AML */
diff --git a/drivers/acpi/acpica/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index 1e437bfd8db5..226c806ae986 100644
--- a/drivers/acpi/acpica/rsaddr.c
+++ b/drivers/acpi/acpica/rsaddr.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 3c4dcc3d1069..d6ebf7ec622d 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index a3c23d686d5f..f2ee3b548609 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -182,7 +182,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
182 182
183 /* 183 /*
184 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a 184 * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
185 * package that in turn contains an acpi_integer Address, a u8 Pin, 185 * package that in turn contains an u64 Address, a u8 Pin,
186 * a Name, and a u8 source_index. 186 * a Name, and a u8 source_index.
187 */ 187 */
188 top_object_list = package_object->package.elements; 188 top_object_list = package_object->package.elements;
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 3f0ca5a12d34..f859b0386fe4 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index 77b25fdb459c..1fd868b964fd 100644
--- a/drivers/acpi/acpica/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsio.c b/drivers/acpi/acpica/rsio.c
index 35a49aa95609..33bff17c0bbc 100644
--- a/drivers/acpi/acpica/rsio.c
+++ b/drivers/acpi/acpica/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsirq.c b/drivers/acpi/acpica/rsirq.c
index 2e0256983aa6..545da40d7fa7 100644
--- a/drivers/acpi/acpica/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index 1b1dbc69f087..fd057c72d252 100644
--- a/drivers/acpi/acpica/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index ddc76cebdc92..887b8ba8c432 100644
--- a/drivers/acpi/acpica/rsmemory.c
+++ b/drivers/acpi/acpica/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index 5bc49a553284..07de352fa443 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index bc03d5966829..22cfcfbd9fff 100644
--- a/drivers/acpi/acpica/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index 395212bcd19b..9f6a6e7e1c8e 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -104,7 +104,7 @@ acpi_rs_validate_parameters(acpi_handle device_handle,
104 return_ACPI_STATUS(AE_BAD_PARAMETER); 104 return_ACPI_STATUS(AE_BAD_PARAMETER);
105 } 105 }
106 106
107 node = acpi_ns_map_handle_to_node(device_handle); 107 node = acpi_ns_validate_handle(device_handle);
108 if (!node) { 108 if (!node) {
109 return_ACPI_STATUS(AE_BAD_PARAMETER); 109 return_ACPI_STATUS(AE_BAD_PARAMETER);
110 } 110 }
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index c016335fb759..f43fbe0fc3fc 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 1054dfd49207..e252180ce61c 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 63e82329a9e8..7ec02b0f69e0 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 1f15497f00d1..02723a9fb10c 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index a88f02bd6c94..5217a6159a31 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index 85ea834199e2..dda6e8c497d3 100644
--- a/drivers/acpi/acpica/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 7580f6b3069e..3d706b8fd449 100644
--- a/drivers/acpi/acpica/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 0f0c64bf8ac9..97ec3621e71d 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -323,11 +323,11 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type,
323 * RETURN: Status 323 * RETURN: Status
324 * 324 *
325 * DESCRIPTION: This function is called to place a package object in a user 325 * DESCRIPTION: This function is called to place a package object in a user
326 * buffer. A package object by definition contains other objects. 326 * buffer. A package object by definition contains other objects.
327 * 327 *
328 * The buffer is assumed to have sufficient space for the object. 328 * The buffer is assumed to have sufficient space for the object.
329 * The caller must have verified the buffer length needed using the 329 * The caller must have verified the buffer length needed using
330 * acpi_ut_get_object_size function before calling this function. 330 * the acpi_ut_get_object_size function before calling this function.
331 * 331 *
332 ******************************************************************************/ 332 ******************************************************************************/
333 333
@@ -382,12 +382,12 @@ acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
382 * FUNCTION: acpi_ut_copy_iobject_to_eobject 382 * FUNCTION: acpi_ut_copy_iobject_to_eobject
383 * 383 *
384 * PARAMETERS: internal_object - The internal object to be converted 384 * PARAMETERS: internal_object - The internal object to be converted
385 * buffer_ptr - Where the object is returned 385 * ret_buffer - Where the object is returned
386 * 386 *
387 * RETURN: Status 387 * RETURN: Status
388 * 388 *
389 * DESCRIPTION: This function is called to build an API object to be returned to 389 * DESCRIPTION: This function is called to build an API object to be returned
390 * the caller. 390 * to the caller.
391 * 391 *
392 ******************************************************************************/ 392 ******************************************************************************/
393 393
@@ -626,7 +626,7 @@ acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
626 * PARAMETERS: external_object - The external object to be converted 626 * PARAMETERS: external_object - The external object to be converted
627 * internal_object - Where the internal object is returned 627 * internal_object - Where the internal object is returned
628 * 628 *
629 * RETURN: Status - the status of the call 629 * RETURN: Status
630 * 630 *
631 * DESCRIPTION: Converts an external object to an internal object. 631 * DESCRIPTION: Converts an external object to an internal object.
632 * 632 *
@@ -665,7 +665,7 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
665 * 665 *
666 * RETURN: Status 666 * RETURN: Status
667 * 667 *
668 * DESCRIPTION: Simple copy of one internal object to another. Reference count 668 * DESCRIPTION: Simple copy of one internal object to another. Reference count
669 * of the destination object is preserved. 669 * of the destination object is preserved.
670 * 670 *
671 ******************************************************************************/ 671 ******************************************************************************/
@@ -897,10 +897,11 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type,
897 * 897 *
898 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage 898 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
899 * 899 *
900 * PARAMETERS: *source_obj - Pointer to the source package object 900 * PARAMETERS: source_obj - Pointer to the source package object
901 * *dest_obj - Where the internal object is returned 901 * dest_obj - Where the internal object is returned
902 * walk_state - Current Walk state descriptor
902 * 903 *
903 * RETURN: Status - the status of the call 904 * RETURN: Status
904 * 905 *
905 * DESCRIPTION: This function is called to copy an internal package object 906 * DESCRIPTION: This function is called to copy an internal package object
906 * into another internal package object. 907 * into another internal package object.
@@ -953,9 +954,9 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
953 * 954 *
954 * FUNCTION: acpi_ut_copy_iobject_to_iobject 955 * FUNCTION: acpi_ut_copy_iobject_to_iobject
955 * 956 *
956 * PARAMETERS: walk_state - Current walk state 957 * PARAMETERS: source_desc - The internal object to be copied
957 * source_desc - The internal object to be copied
958 * dest_desc - Where the copied object is returned 958 * dest_desc - Where the copied object is returned
959 * walk_state - Current walk state
959 * 960 *
960 * RETURN: Status 961 * RETURN: Status
961 * 962 *
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 527d729f6815..983510640059 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -460,8 +460,7 @@ ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
460void 460void
461acpi_ut_value_exit(u32 line_number, 461acpi_ut_value_exit(u32 line_number,
462 const char *function_name, 462 const char *function_name,
463 const char *module_name, 463 const char *module_name, u32 component_id, u64 value)
464 u32 component_id, acpi_integer value)
465{ 464{
466 465
467 acpi_debug_print(ACPI_LV_FUNCTIONS, 466 acpi_debug_print(ACPI_LV_FUNCTIONS,
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index 96e26e70c63d..16b51c69606a 100644
--- a/drivers/acpi/acpica/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index 5d54e36ab453..7f5e734ce7f7 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -348,7 +348,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
348acpi_status 348acpi_status
349acpi_ut_evaluate_numeric_object(char *object_name, 349acpi_ut_evaluate_numeric_object(char *object_name,
350 struct acpi_namespace_node *device_node, 350 struct acpi_namespace_node *device_node,
351 acpi_integer *value) 351 u64 *value)
352{ 352{
353 union acpi_operand_object *obj_desc; 353 union acpi_operand_object *obj_desc;
354 acpi_status status; 354 acpi_status status;
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 3f2c68f4e959..eda3e656c4af 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -234,7 +234,7 @@ static const char acpi_gbl_hex_to_ascii[] = {
234 * 234 *
235 ******************************************************************************/ 235 ******************************************************************************/
236 236
237char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position) 237char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
238{ 238{
239 239
240 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]); 240 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
index 52eaae404554..1397fadd0d4b 100644
--- a/drivers/acpi/acpica/utids.c
+++ b/drivers/acpi/acpica/utids.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index 9d0919ebf7b0..a39c93dac719 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c
index 25e03120686d..b081cd46a15f 100644
--- a/drivers/acpi/acpica/utlock.c
+++ b/drivers/acpi/acpica/utlock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2009, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c
index c9f682d640ef..35059a14eb72 100644
--- a/drivers/acpi/acpica/utmath.c
+++ b/drivers/acpi/acpica/utmath.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -70,9 +70,8 @@ ACPI_MODULE_NAME("utmath")
70 * 70 *
71 ******************************************************************************/ 71 ******************************************************************************/
72acpi_status 72acpi_status
73acpi_ut_short_divide(acpi_integer dividend, 73acpi_ut_short_divide(u64 dividend,
74 u32 divisor, 74 u32 divisor, u64 *out_quotient, u32 *out_remainder)
75 acpi_integer * out_quotient, u32 * out_remainder)
76{ 75{
77 union uint64_overlay dividend_ovl; 76 union uint64_overlay dividend_ovl;
78 union uint64_overlay quotient; 77 union uint64_overlay quotient;
@@ -126,9 +125,8 @@ acpi_ut_short_divide(acpi_integer dividend,
126 ******************************************************************************/ 125 ******************************************************************************/
127 126
128acpi_status 127acpi_status
129acpi_ut_divide(acpi_integer in_dividend, 128acpi_ut_divide(u64 in_dividend,
130 acpi_integer in_divisor, 129 u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
131 acpi_integer * out_quotient, acpi_integer * out_remainder)
132{ 130{
133 union uint64_overlay dividend; 131 union uint64_overlay dividend;
134 union uint64_overlay divisor; 132 union uint64_overlay divisor;
@@ -199,9 +197,8 @@ acpi_ut_divide(acpi_integer in_dividend,
199 * The 64-bit remainder must be generated. 197 * The 64-bit remainder must be generated.
200 */ 198 */
201 partial1 = quotient.part.lo * divisor.part.hi; 199 partial1 = quotient.part.lo * divisor.part.hi;
202 partial2.full = 200 partial2.full = (u64) quotient.part.lo * divisor.part.lo;
203 (acpi_integer) quotient.part.lo * divisor.part.lo; 201 partial3.full = (u64) partial2.part.hi + partial1;
204 partial3.full = (acpi_integer) partial2.part.hi + partial1;
205 202
206 remainder.part.hi = partial3.part.lo; 203 remainder.part.hi = partial3.part.lo;
207 remainder.part.lo = partial2.part.lo; 204 remainder.part.lo = partial2.part.lo;
@@ -257,9 +254,8 @@ acpi_ut_divide(acpi_integer in_dividend,
257 * 254 *
258 ******************************************************************************/ 255 ******************************************************************************/
259acpi_status 256acpi_status
260acpi_ut_short_divide(acpi_integer in_dividend, 257acpi_ut_short_divide(u64 in_dividend,
261 u32 divisor, 258 u32 divisor, u64 *out_quotient, u32 *out_remainder)
262 acpi_integer * out_quotient, u32 * out_remainder)
263{ 259{
264 260
265 ACPI_FUNCTION_TRACE(ut_short_divide); 261 ACPI_FUNCTION_TRACE(ut_short_divide);
@@ -284,9 +280,8 @@ acpi_ut_short_divide(acpi_integer in_dividend,
284} 280}
285 281
286acpi_status 282acpi_status
287acpi_ut_divide(acpi_integer in_dividend, 283acpi_ut_divide(u64 in_dividend,
288 acpi_integer in_divisor, 284 u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
289 acpi_integer * out_quotient, acpi_integer * out_remainder)
290{ 285{
291 ACPI_FUNCTION_TRACE(ut_divide); 286 ACPI_FUNCTION_TRACE(ut_divide);
292 287
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 61f6315fce9f..32982e2ac384 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -724,13 +724,12 @@ acpi_name acpi_ut_repair_name(char *name)
724 * 724 *
725 ******************************************************************************/ 725 ******************************************************************************/
726 726
727acpi_status 727acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer)
728acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
729{ 728{
730 u32 this_digit = 0; 729 u32 this_digit = 0;
731 acpi_integer return_value = 0; 730 u64 return_value = 0;
732 acpi_integer quotient; 731 u64 quotient;
733 acpi_integer dividend; 732 u64 dividend;
734 u32 to_integer_op = (base == ACPI_ANY_BASE); 733 u32 to_integer_op = (base == ACPI_ANY_BASE);
735 u32 mode32 = (acpi_gbl_integer_byte_width == 4); 734 u32 mode32 = (acpi_gbl_integer_byte_width == 4);
736 u8 valid_digits = 0; 735 u8 valid_digits = 0;
@@ -844,9 +843,8 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
844 843
845 /* Divide the digit into the correct position */ 844 /* Divide the digit into the correct position */
846 845
847 (void) 846 (void)acpi_ut_short_divide((dividend - (u64) this_digit),
848 acpi_ut_short_divide((dividend - (acpi_integer) this_digit), 847 base, &quotient, NULL);
849 base, &quotient, NULL);
850 848
851 if (return_value > quotient) { 849 if (return_value > quotient) {
852 if (to_integer_op) { 850 if (to_integer_op) {
@@ -1161,3 +1159,45 @@ acpi_ut_predefined_warning(const char *module_name,
1161 ACPI_COMMON_MSG_SUFFIX; 1159 ACPI_COMMON_MSG_SUFFIX;
1162 va_end(args); 1160 va_end(args);
1163} 1161}
1162
1163/*******************************************************************************
1164 *
1165 * FUNCTION: acpi_ut_predefined_info
1166 *
1167 * PARAMETERS: module_name - Caller's module name (for error output)
1168 * line_number - Caller's line number (for error output)
1169 * Pathname - Full pathname to the node
1170 * node_flags - From Namespace node for the method/object
1171 * Format - Printf format string + additional args
1172 *
1173 * RETURN: None
1174 *
1175 * DESCRIPTION: Info messages for the predefined validation module. Messages
1176 * are only emitted the first time a problem with a particular
1177 * method/object is detected. This prevents a flood of
1178 * messages for methods that are repeatedly evaluated.
1179 *
1180 ******************************************************************************/
1181
1182void ACPI_INTERNAL_VAR_XFACE
1183acpi_ut_predefined_info(const char *module_name,
1184 u32 line_number,
1185 char *pathname, u8 node_flags, const char *format, ...)
1186{
1187 va_list args;
1188
1189 /*
1190 * Warning messages for this method/object will be disabled after the
1191 * first time a validation fails or an object is successfully repaired.
1192 */
1193 if (node_flags & ANOBJ_EVALUATED) {
1194 return;
1195 }
1196
1197 acpi_os_printf("ACPI Info for %s: ", pathname);
1198
1199 va_start(args, format);
1200 acpi_os_vprintf(format, args);
1201 ACPI_COMMON_MSG_SUFFIX;
1202 va_end(args);
1203}
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 80bb65154117..55d014ed6d55 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@ ACPI_MODULE_NAME("utmutex")
50/* Local prototypes */ 50/* Local prototypes */
51static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id); 51static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id);
52 52
53static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id); 53static void acpi_ut_delete_mutex(acpi_mutex_handle mutex_id);
54 54
55/******************************************************************************* 55/*******************************************************************************
56 * 56 *
@@ -114,7 +114,7 @@ void acpi_ut_mutex_terminate(void)
114 /* Delete each predefined mutex object */ 114 /* Delete each predefined mutex object */
115 115
116 for (i = 0; i < ACPI_NUM_MUTEX; i++) { 116 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
117 (void)acpi_ut_delete_mutex(i); 117 acpi_ut_delete_mutex(i);
118 } 118 }
119 119
120 /* Delete the spinlocks */ 120 /* Delete the spinlocks */
@@ -146,10 +146,6 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
146 146
147 ACPI_FUNCTION_TRACE_U32(ut_create_mutex, mutex_id); 147 ACPI_FUNCTION_TRACE_U32(ut_create_mutex, mutex_id);
148 148
149 if (mutex_id > ACPI_MAX_MUTEX) {
150 return_ACPI_STATUS(AE_BAD_PARAMETER);
151 }
152
153 if (!acpi_gbl_mutex_info[mutex_id].mutex) { 149 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
154 status = 150 status =
155 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex); 151 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex);
@@ -173,21 +169,15 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
173 * 169 *
174 ******************************************************************************/ 170 ******************************************************************************/
175 171
176static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) 172static void acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
177{ 173{
178 174
179 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id); 175 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id);
180 176
181 if (mutex_id > ACPI_MAX_MUTEX) {
182 return_ACPI_STATUS(AE_BAD_PARAMETER);
183 }
184
185 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex); 177 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
186 178
187 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 179 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
188 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 180 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
189
190 return_ACPI_STATUS(AE_OK);
191} 181}
192 182
193/******************************************************************************* 183/*******************************************************************************
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index 0207b625274a..3356f0cb0745 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -190,6 +190,35 @@ union acpi_operand_object *acpi_ut_create_package_object(u32 count)
190 190
191/******************************************************************************* 191/*******************************************************************************
192 * 192 *
193 * FUNCTION: acpi_ut_create_integer_object
194 *
195 * PARAMETERS: initial_value - Initial value for the integer
196 *
197 * RETURN: Pointer to a new Integer object, null on failure
198 *
199 * DESCRIPTION: Create an initialized integer object
200 *
201 ******************************************************************************/
202
203union acpi_operand_object *acpi_ut_create_integer_object(u64 initial_value)
204{
205 union acpi_operand_object *integer_desc;
206
207 ACPI_FUNCTION_TRACE(ut_create_integer_object);
208
209 /* Create and initialize a new integer object */
210
211 integer_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
212 if (!integer_desc) {
213 return_PTR(NULL);
214 }
215
216 integer_desc->integer.value = initial_value;
217 return_PTR(integer_desc);
218}
219
220/*******************************************************************************
221 *
193 * FUNCTION: acpi_ut_create_buffer_object 222 * FUNCTION: acpi_ut_create_buffer_object
194 * 223 *
195 * PARAMETERS: buffer_size - Size of buffer to be created 224 * PARAMETERS: buffer_size - Size of buffer to be created
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index 91b7c00236f4..7965919000b1 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c
index 0440c958f5a4..d35d109b8da2 100644
--- a/drivers/acpi/acpica/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index b1f5f680bc78..db9d8ca57987 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2008, Intel Corp. 8 * Copyright (C) 2000 - 2010, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 3f4602b8f287..3026e3fa83ef 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -32,6 +32,7 @@
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/async.h> 33#include <linux/async.h>
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/slab.h>
35 36
36#ifdef CONFIG_ACPI_PROCFS_POWER 37#ifdef CONFIG_ACPI_PROCFS_POWER
37#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
@@ -54,6 +55,7 @@
54#define ACPI_BATTERY_DEVICE_NAME "Battery" 55#define ACPI_BATTERY_DEVICE_NAME "Battery"
55#define ACPI_BATTERY_NOTIFY_STATUS 0x80 56#define ACPI_BATTERY_NOTIFY_STATUS 0x80
56#define ACPI_BATTERY_NOTIFY_INFO 0x81 57#define ACPI_BATTERY_NOTIFY_INFO 0x81
58#define ACPI_BATTERY_NOTIFY_THRESHOLD 0x82
57 59
58#define _COMPONENT ACPI_BATTERY_COMPONENT 60#define _COMPONENT ACPI_BATTERY_COMPONENT
59 61
@@ -88,10 +90,15 @@ static const struct acpi_device_id battery_device_ids[] = {
88 90
89MODULE_DEVICE_TABLE(acpi, battery_device_ids); 91MODULE_DEVICE_TABLE(acpi, battery_device_ids);
90 92
91/* For buggy DSDTs that report negative 16-bit values for either charging 93enum {
92 * or discharging current and/or report 0 as 65536 due to bad math. 94 ACPI_BATTERY_ALARM_PRESENT,
93 */ 95 ACPI_BATTERY_XINFO_PRESENT,
94#define QUIRK_SIGNED16_CURRENT 0x0001 96 /* For buggy DSDTs that report negative 16-bit values for either
97 * charging or discharging current and/or report 0 as 65536
98 * due to bad math.
99 */
100 ACPI_BATTERY_QUIRK_SIGNED16_CURRENT,
101};
95 102
96struct acpi_battery { 103struct acpi_battery {
97 struct mutex lock; 104 struct mutex lock;
@@ -109,6 +116,12 @@ struct acpi_battery {
109 int design_voltage; 116 int design_voltage;
110 int design_capacity_warning; 117 int design_capacity_warning;
111 int design_capacity_low; 118 int design_capacity_low;
119 int cycle_count;
120 int measurement_accuracy;
121 int max_sampling_time;
122 int min_sampling_time;
123 int max_averaging_interval;
124 int min_averaging_interval;
112 int capacity_granularity_1; 125 int capacity_granularity_1;
113 int capacity_granularity_2; 126 int capacity_granularity_2;
114 int alarm; 127 int alarm;
@@ -118,8 +131,7 @@ struct acpi_battery {
118 char oem_info[32]; 131 char oem_info[32];
119 int state; 132 int state;
120 int power_unit; 133 int power_unit;
121 u8 alarm_present; 134 unsigned long flags;
122 long quirks;
123}; 135};
124 136
125#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); 137#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat);
@@ -198,6 +210,9 @@ static int acpi_battery_get_property(struct power_supply *psy,
198 case POWER_SUPPLY_PROP_TECHNOLOGY: 210 case POWER_SUPPLY_PROP_TECHNOLOGY:
199 val->intval = acpi_battery_technology(battery); 211 val->intval = acpi_battery_technology(battery);
200 break; 212 break;
213 case POWER_SUPPLY_PROP_CYCLE_COUNT:
214 val->intval = battery->cycle_count;
215 break;
201 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 216 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
202 val->intval = battery->design_voltage * 1000; 217 val->intval = battery->design_voltage * 1000;
203 break; 218 break;
@@ -239,6 +254,7 @@ static enum power_supply_property charge_battery_props[] = {
239 POWER_SUPPLY_PROP_STATUS, 254 POWER_SUPPLY_PROP_STATUS,
240 POWER_SUPPLY_PROP_PRESENT, 255 POWER_SUPPLY_PROP_PRESENT,
241 POWER_SUPPLY_PROP_TECHNOLOGY, 256 POWER_SUPPLY_PROP_TECHNOLOGY,
257 POWER_SUPPLY_PROP_CYCLE_COUNT,
242 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 258 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
243 POWER_SUPPLY_PROP_VOLTAGE_NOW, 259 POWER_SUPPLY_PROP_VOLTAGE_NOW,
244 POWER_SUPPLY_PROP_CURRENT_NOW, 260 POWER_SUPPLY_PROP_CURRENT_NOW,
@@ -254,6 +270,7 @@ static enum power_supply_property energy_battery_props[] = {
254 POWER_SUPPLY_PROP_STATUS, 270 POWER_SUPPLY_PROP_STATUS,
255 POWER_SUPPLY_PROP_PRESENT, 271 POWER_SUPPLY_PROP_PRESENT,
256 POWER_SUPPLY_PROP_TECHNOLOGY, 272 POWER_SUPPLY_PROP_TECHNOLOGY,
273 POWER_SUPPLY_PROP_CYCLE_COUNT,
257 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 274 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
258 POWER_SUPPLY_PROP_VOLTAGE_NOW, 275 POWER_SUPPLY_PROP_VOLTAGE_NOW,
259 POWER_SUPPLY_PROP_CURRENT_NOW, 276 POWER_SUPPLY_PROP_CURRENT_NOW,
@@ -305,6 +322,28 @@ static struct acpi_offsets info_offsets[] = {
305 {offsetof(struct acpi_battery, oem_info), 1}, 322 {offsetof(struct acpi_battery, oem_info), 1},
306}; 323};
307 324
325static struct acpi_offsets extended_info_offsets[] = {
326 {offsetof(struct acpi_battery, power_unit), 0},
327 {offsetof(struct acpi_battery, design_capacity), 0},
328 {offsetof(struct acpi_battery, full_charge_capacity), 0},
329 {offsetof(struct acpi_battery, technology), 0},
330 {offsetof(struct acpi_battery, design_voltage), 0},
331 {offsetof(struct acpi_battery, design_capacity_warning), 0},
332 {offsetof(struct acpi_battery, design_capacity_low), 0},
333 {offsetof(struct acpi_battery, cycle_count), 0},
334 {offsetof(struct acpi_battery, measurement_accuracy), 0},
335 {offsetof(struct acpi_battery, max_sampling_time), 0},
336 {offsetof(struct acpi_battery, min_sampling_time), 0},
337 {offsetof(struct acpi_battery, max_averaging_interval), 0},
338 {offsetof(struct acpi_battery, min_averaging_interval), 0},
339 {offsetof(struct acpi_battery, capacity_granularity_1), 0},
340 {offsetof(struct acpi_battery, capacity_granularity_2), 0},
341 {offsetof(struct acpi_battery, model_number), 1},
342 {offsetof(struct acpi_battery, serial_number), 1},
343 {offsetof(struct acpi_battery, type), 1},
344 {offsetof(struct acpi_battery, oem_info), 1},
345};
346
308static int extract_package(struct acpi_battery *battery, 347static int extract_package(struct acpi_battery *battery,
309 union acpi_object *package, 348 union acpi_object *package,
310 struct acpi_offsets *offsets, int num) 349 struct acpi_offsets *offsets, int num)
@@ -324,8 +363,8 @@ static int extract_package(struct acpi_battery *battery,
324 strncpy(ptr, element->string.pointer, 32); 363 strncpy(ptr, element->string.pointer, 32);
325 else if (element->type == ACPI_TYPE_INTEGER) { 364 else if (element->type == ACPI_TYPE_INTEGER) {
326 strncpy(ptr, (u8 *)&element->integer.value, 365 strncpy(ptr, (u8 *)&element->integer.value,
327 sizeof(acpi_integer)); 366 sizeof(u64));
328 ptr[sizeof(acpi_integer)] = 0; 367 ptr[sizeof(u64)] = 0;
329 } else 368 } else
330 *ptr = 0; /* don't have value */ 369 *ptr = 0; /* don't have value */
331 } else { 370 } else {
@@ -350,22 +389,29 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
350{ 389{
351 int result = -EFAULT; 390 int result = -EFAULT;
352 acpi_status status = 0; 391 acpi_status status = 0;
392 char *name = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)?
393 "_BIX" : "_BIF";
394
353 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 395 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
354 396
355 if (!acpi_battery_present(battery)) 397 if (!acpi_battery_present(battery))
356 return 0; 398 return 0;
357 mutex_lock(&battery->lock); 399 mutex_lock(&battery->lock);
358 status = acpi_evaluate_object(battery->device->handle, "_BIF", 400 status = acpi_evaluate_object(battery->device->handle, name,
359 NULL, &buffer); 401 NULL, &buffer);
360 mutex_unlock(&battery->lock); 402 mutex_unlock(&battery->lock);
361 403
362 if (ACPI_FAILURE(status)) { 404 if (ACPI_FAILURE(status)) {
363 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); 405 ACPI_EXCEPTION((AE_INFO, status, "Evaluating %s", name));
364 return -ENODEV; 406 return -ENODEV;
365 } 407 }
366 408 if (test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags))
367 result = extract_package(battery, buffer.pointer, 409 result = extract_package(battery, buffer.pointer,
368 info_offsets, ARRAY_SIZE(info_offsets)); 410 extended_info_offsets,
411 ARRAY_SIZE(extended_info_offsets));
412 else
413 result = extract_package(battery, buffer.pointer,
414 info_offsets, ARRAY_SIZE(info_offsets));
369 kfree(buffer.pointer); 415 kfree(buffer.pointer);
370 return result; 416 return result;
371} 417}
@@ -399,7 +445,7 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
399 battery->update_time = jiffies; 445 battery->update_time = jiffies;
400 kfree(buffer.pointer); 446 kfree(buffer.pointer);
401 447
402 if ((battery->quirks & QUIRK_SIGNED16_CURRENT) && 448 if (test_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags) &&
403 battery->rate_now != -1) 449 battery->rate_now != -1)
404 battery->rate_now = abs((s16)battery->rate_now); 450 battery->rate_now = abs((s16)battery->rate_now);
405 451
@@ -412,7 +458,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery)
412 union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; 458 union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER };
413 struct acpi_object_list arg_list = { 1, &arg0 }; 459 struct acpi_object_list arg_list = { 1, &arg0 };
414 460
415 if (!acpi_battery_present(battery)|| !battery->alarm_present) 461 if (!acpi_battery_present(battery) ||
462 !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags))
416 return -ENODEV; 463 return -ENODEV;
417 464
418 arg0.integer.value = battery->alarm; 465 arg0.integer.value = battery->alarm;
@@ -437,10 +484,10 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery)
437 /* See if alarms are supported, and if so, set default */ 484 /* See if alarms are supported, and if so, set default */
438 status = acpi_get_handle(battery->device->handle, "_BTP", &handle); 485 status = acpi_get_handle(battery->device->handle, "_BTP", &handle);
439 if (ACPI_FAILURE(status)) { 486 if (ACPI_FAILURE(status)) {
440 battery->alarm_present = 0; 487 clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags);
441 return 0; 488 return 0;
442 } 489 }
443 battery->alarm_present = 1; 490 set_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags);
444 if (!battery->alarm) 491 if (!battery->alarm)
445 battery->alarm = battery->design_capacity_warning; 492 battery->alarm = battery->design_capacity_warning;
446 return acpi_battery_set_alarm(battery); 493 return acpi_battery_set_alarm(battery);
@@ -510,9 +557,8 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
510 557
511static void acpi_battery_quirks(struct acpi_battery *battery) 558static void acpi_battery_quirks(struct acpi_battery *battery)
512{ 559{
513 battery->quirks = 0;
514 if (dmi_name_in_vendors("Acer") && battery->power_unit) { 560 if (dmi_name_in_vendors("Acer") && battery->power_unit) {
515 battery->quirks |= QUIRK_SIGNED16_CURRENT; 561 set_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags);
516 } 562 }
517} 563}
518 564
@@ -522,13 +568,13 @@ static int acpi_battery_update(struct acpi_battery *battery)
522 result = acpi_battery_get_status(battery); 568 result = acpi_battery_get_status(battery);
523 if (result) 569 if (result)
524 return result; 570 return result;
525#ifdef CONFIG_ACPI_SYSFS_POWER
526 if (!acpi_battery_present(battery)) { 571 if (!acpi_battery_present(battery)) {
572#ifdef CONFIG_ACPI_SYSFS_POWER
527 sysfs_remove_battery(battery); 573 sysfs_remove_battery(battery);
574#endif
528 battery->update_time = 0; 575 battery->update_time = 0;
529 return 0; 576 return 0;
530 } 577 }
531#endif
532 if (!battery->update_time || 578 if (!battery->update_time ||
533 old_present != acpi_battery_present(battery)) { 579 old_present != acpi_battery_present(battery)) {
534 result = acpi_battery_get_info(battery); 580 result = acpi_battery_get_info(battery);
@@ -590,6 +636,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
590 seq_printf(seq, "design capacity low: %d %sh\n", 636 seq_printf(seq, "design capacity low: %d %sh\n",
591 battery->design_capacity_low, 637 battery->design_capacity_low,
592 acpi_battery_units(battery)); 638 acpi_battery_units(battery));
639 seq_printf(seq, "cycle count: %i\n", battery->cycle_count);
593 seq_printf(seq, "capacity granularity 1: %d %sh\n", 640 seq_printf(seq, "capacity granularity 1: %d %sh\n",
594 battery->capacity_granularity_1, 641 battery->capacity_granularity_1,
595 acpi_battery_units(battery)); 642 acpi_battery_units(battery));
@@ -831,9 +878,9 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
831 dev_name(&device->dev), event, 878 dev_name(&device->dev), event,
832 acpi_battery_present(battery)); 879 acpi_battery_present(battery));
833#ifdef CONFIG_ACPI_SYSFS_POWER 880#ifdef CONFIG_ACPI_SYSFS_POWER
834 /* acpi_batter_update could remove power_supply object */ 881 /* acpi_battery_update could remove power_supply object */
835 if (battery->bat.dev) 882 if (battery->bat.dev)
836 kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); 883 power_supply_changed(&battery->bat);
837#endif 884#endif
838} 885}
839 886
@@ -841,6 +888,7 @@ static int acpi_battery_add(struct acpi_device *device)
841{ 888{
842 int result = 0; 889 int result = 0;
843 struct acpi_battery *battery = NULL; 890 struct acpi_battery *battery = NULL;
891 acpi_handle handle;
844 if (!device) 892 if (!device)
845 return -EINVAL; 893 return -EINVAL;
846 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); 894 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
@@ -851,6 +899,9 @@ static int acpi_battery_add(struct acpi_device *device)
851 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); 899 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
852 device->driver_data = battery; 900 device->driver_data = battery;
853 mutex_init(&battery->lock); 901 mutex_init(&battery->lock);
902 if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle,
903 "_BIX", &handle)))
904 set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
854 acpi_battery_update(battery); 905 acpi_battery_update(battery);
855#ifdef CONFIG_ACPI_PROCFS_POWER 906#ifdef CONFIG_ACPI_PROCFS_POWER
856 result = acpi_battery_add_fs(device); 907 result = acpi_battery_add_fs(device);
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 23e5a0519af5..2815df66f6f7 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -185,6 +185,12 @@ static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
185 acpi_osi_setup("!Windows 2006"); 185 acpi_osi_setup("!Windows 2006");
186 return 0; 186 return 0;
187} 187}
188static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
189{
190 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
191 acpi_osi_setup("!Windows 2009");
192 return 0;
193}
188 194
189static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { 195static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
190 { 196 {
@@ -211,6 +217,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
211 DMI_MATCH(DMI_PRODUCT_NAME, "Sony VGN-SR290J"), 217 DMI_MATCH(DMI_PRODUCT_NAME, "Sony VGN-SR290J"),
212 }, 218 },
213 }, 219 },
220 {
221 .callback = dmi_disable_osi_win7,
222 .ident = "ASUS K50IJ",
223 .matches = {
224 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
225 DMI_MATCH(DMI_PRODUCT_NAME, "K50IJ"),
226 },
227 },
214 228
215 /* 229 /*
216 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. 230 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 741191524353..743576bf1bd7 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -32,6 +32,7 @@
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
34#include <linux/acpi.h> 34#include <linux/acpi.h>
35#include <linux/slab.h>
35#ifdef CONFIG_X86 36#ifdef CONFIG_X86
36#include <asm/mpspec.h> 37#include <asm/mpspec.h>
37#endif 38#endif
@@ -190,16 +191,16 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
190 * Get the device's power state either directly (via _PSC) or 191 * Get the device's power state either directly (via _PSC) or
191 * indirectly (via power resources). 192 * indirectly (via power resources).
192 */ 193 */
193 if (device->power.flags.explicit_get) { 194 if (device->power.flags.power_resources) {
195 result = acpi_power_get_inferred_state(device);
196 if (result)
197 return result;
198 } else if (device->power.flags.explicit_get) {
194 status = acpi_evaluate_integer(device->handle, "_PSC", 199 status = acpi_evaluate_integer(device->handle, "_PSC",
195 NULL, &psc); 200 NULL, &psc);
196 if (ACPI_FAILURE(status)) 201 if (ACPI_FAILURE(status))
197 return -ENODEV; 202 return -ENODEV;
198 device->power.state = (int)psc; 203 device->power.state = (int)psc;
199 } else if (device->power.flags.power_resources) {
200 result = acpi_power_get_inferred_state(device);
201 if (result)
202 return result;
203 } 204 }
204 205
205 *state = device->power.state; 206 *state = device->power.state;
@@ -344,6 +345,167 @@ bool acpi_bus_can_wakeup(acpi_handle handle)
344 345
345EXPORT_SYMBOL(acpi_bus_can_wakeup); 346EXPORT_SYMBOL(acpi_bus_can_wakeup);
346 347
348static void acpi_print_osc_error(acpi_handle handle,
349 struct acpi_osc_context *context, char *error)
350{
351 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER};
352 int i;
353
354 if (ACPI_FAILURE(acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer)))
355 printk(KERN_DEBUG "%s\n", error);
356 else {
357 printk(KERN_DEBUG "%s:%s\n", (char *)buffer.pointer, error);
358 kfree(buffer.pointer);
359 }
360 printk(KERN_DEBUG"_OSC request data:");
361 for (i = 0; i < context->cap.length; i += sizeof(u32))
362 printk("%x ", *((u32 *)(context->cap.pointer + i)));
363 printk("\n");
364}
365
366static u8 hex_val(unsigned char c)
367{
368 return isdigit(c) ? c - '0' : toupper(c) - 'A' + 10;
369}
370
371static acpi_status acpi_str_to_uuid(char *str, u8 *uuid)
372{
373 int i;
374 static int opc_map_to_uuid[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
375 24, 26, 28, 30, 32, 34};
376
377 if (strlen(str) != 36)
378 return AE_BAD_PARAMETER;
379 for (i = 0; i < 36; i++) {
380 if (i == 8 || i == 13 || i == 18 || i == 23) {
381 if (str[i] != '-')
382 return AE_BAD_PARAMETER;
383 } else if (!isxdigit(str[i]))
384 return AE_BAD_PARAMETER;
385 }
386 for (i = 0; i < 16; i++) {
387 uuid[i] = hex_val(str[opc_map_to_uuid[i]]) << 4;
388 uuid[i] |= hex_val(str[opc_map_to_uuid[i] + 1]);
389 }
390 return AE_OK;
391}
392
393acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
394{
395 acpi_status status;
396 struct acpi_object_list input;
397 union acpi_object in_params[4];
398 union acpi_object *out_obj;
399 u8 uuid[16];
400 u32 errors;
401 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
402
403 if (!context)
404 return AE_ERROR;
405 if (ACPI_FAILURE(acpi_str_to_uuid(context->uuid_str, uuid)))
406 return AE_ERROR;
407 context->ret.length = ACPI_ALLOCATE_BUFFER;
408 context->ret.pointer = NULL;
409
410 /* Setting up input parameters */
411 input.count = 4;
412 input.pointer = in_params;
413 in_params[0].type = ACPI_TYPE_BUFFER;
414 in_params[0].buffer.length = 16;
415 in_params[0].buffer.pointer = uuid;
416 in_params[1].type = ACPI_TYPE_INTEGER;
417 in_params[1].integer.value = context->rev;
418 in_params[2].type = ACPI_TYPE_INTEGER;
419 in_params[2].integer.value = context->cap.length/sizeof(u32);
420 in_params[3].type = ACPI_TYPE_BUFFER;
421 in_params[3].buffer.length = context->cap.length;
422 in_params[3].buffer.pointer = context->cap.pointer;
423
424 status = acpi_evaluate_object(handle, "_OSC", &input, &output);
425 if (ACPI_FAILURE(status))
426 return status;
427
428 if (!output.length)
429 return AE_NULL_OBJECT;
430
431 out_obj = output.pointer;
432 if (out_obj->type != ACPI_TYPE_BUFFER
433 || out_obj->buffer.length != context->cap.length) {
434 acpi_print_osc_error(handle, context,
435 "_OSC evaluation returned wrong type");
436 status = AE_TYPE;
437 goto out_kfree;
438 }
439 /* Need to ignore the bit0 in result code */
440 errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
441 if (errors) {
442 if (errors & OSC_REQUEST_ERROR)
443 acpi_print_osc_error(handle, context,
444 "_OSC request failed");
445 if (errors & OSC_INVALID_UUID_ERROR)
446 acpi_print_osc_error(handle, context,
447 "_OSC invalid UUID");
448 if (errors & OSC_INVALID_REVISION_ERROR)
449 acpi_print_osc_error(handle, context,
450 "_OSC invalid revision");
451 if (errors & OSC_CAPABILITIES_MASK_ERROR) {
452 if (((u32 *)context->cap.pointer)[OSC_QUERY_TYPE]
453 & OSC_QUERY_ENABLE)
454 goto out_success;
455 status = AE_SUPPORT;
456 goto out_kfree;
457 }
458 status = AE_ERROR;
459 goto out_kfree;
460 }
461out_success:
462 context->ret.length = out_obj->buffer.length;
463 context->ret.pointer = kmalloc(context->ret.length, GFP_KERNEL);
464 if (!context->ret.pointer) {
465 status = AE_NO_MEMORY;
466 goto out_kfree;
467 }
468 memcpy(context->ret.pointer, out_obj->buffer.pointer,
469 context->ret.length);
470 status = AE_OK;
471
472out_kfree:
473 kfree(output.pointer);
474 if (status != AE_OK)
475 context->ret.pointer = NULL;
476 return status;
477}
478EXPORT_SYMBOL(acpi_run_osc);
479
480static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
481static void acpi_bus_osc_support(void)
482{
483 u32 capbuf[2];
484 struct acpi_osc_context context = {
485 .uuid_str = sb_uuid_str,
486 .rev = 1,
487 .cap.length = 8,
488 .cap.pointer = capbuf,
489 };
490 acpi_handle handle;
491
492 capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
493 capbuf[OSC_SUPPORT_TYPE] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */
494#if defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) ||\
495 defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
496 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PAD_SUPPORT;
497#endif
498
499#if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE)
500 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT;
501#endif
502 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
503 return;
504 if (ACPI_SUCCESS(acpi_run_osc(handle, &context)))
505 kfree(context.ret.pointer);
506 /* do we need to check the returned cap? Sounds no */
507}
508
347/* -------------------------------------------------------------------------- 509/* --------------------------------------------------------------------------
348 Event Management 510 Event Management
349 -------------------------------------------------------------------------- */ 511 -------------------------------------------------------------------------- */
@@ -365,7 +527,7 @@ int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id,
365 if (!event_is_open) 527 if (!event_is_open)
366 return 0; 528 return 0;
367 529
368 event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC); 530 event = kzalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
369 if (!event) 531 if (!event)
370 return -ENOMEM; 532 return -ENOMEM;
371 533
@@ -734,12 +896,16 @@ static int __init acpi_bus_init(void)
734 status = acpi_ec_ecdt_probe(); 896 status = acpi_ec_ecdt_probe();
735 /* Ignore result. Not having an ECDT is not fatal. */ 897 /* Ignore result. Not having an ECDT is not fatal. */
736 898
899 acpi_bus_osc_support();
900
737 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); 901 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
738 if (ACPI_FAILURE(status)) { 902 if (ACPI_FAILURE(status)) {
739 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n"); 903 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
740 goto error1; 904 goto error1;
741 } 905 }
742 906
907 acpi_early_processor_set_pdc();
908
743 /* 909 /*
744 * Maybe EC region is required at bus_scan/acpi_get_devices. So it 910 * Maybe EC region is required at bus_scan/acpi_get_devices. So it
745 * is necessary to enable it as early as possible. 911 * is necessary to enable it as early as possible.
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 0c9c6a9a002c..fd51c4ab4829 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -30,6 +30,7 @@
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/slab.h>
33#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
34#include <acpi/acpi_drivers.h> 35#include <acpi/acpi_drivers.h>
35 36
@@ -282,6 +283,13 @@ static int acpi_lid_send_state(struct acpi_device *device)
282 if (ret == NOTIFY_DONE) 283 if (ret == NOTIFY_DONE)
283 ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, 284 ret = blocking_notifier_call_chain(&acpi_lid_notifier, state,
284 device); 285 device);
286 if (ret == NOTIFY_DONE || ret == NOTIFY_OK) {
287 /*
288 * It is also regarded as success if the notifier_chain
289 * returns NOTIFY_OK or NOTIFY_DONE.
290 */
291 ret = 0;
292 }
285 return ret; 293 return ret;
286} 294}
287 295
@@ -415,11 +423,10 @@ static int acpi_button_add(struct acpi_device *device)
415 423
416 if (device->wakeup.flags.valid) { 424 if (device->wakeup.flags.valid) {
417 /* Button's GPE is run-wake GPE */ 425 /* Button's GPE is run-wake GPE */
418 acpi_set_gpe_type(device->wakeup.gpe_device,
419 device->wakeup.gpe_number,
420 ACPI_GPE_TYPE_WAKE_RUN);
421 acpi_enable_gpe(device->wakeup.gpe_device, 426 acpi_enable_gpe(device->wakeup.gpe_device,
422 device->wakeup.gpe_number); 427 device->wakeup.gpe_number,
428 ACPI_GPE_TYPE_WAKE_RUN);
429 device->wakeup.run_wake_count++;
423 device->wakeup.state.enabled = 1; 430 device->wakeup.state.enabled = 1;
424 } 431 }
425 432
@@ -439,6 +446,14 @@ static int acpi_button_remove(struct acpi_device *device, int type)
439{ 446{
440 struct acpi_button *button = acpi_driver_data(device); 447 struct acpi_button *button = acpi_driver_data(device);
441 448
449 if (device->wakeup.flags.valid) {
450 acpi_disable_gpe(device->wakeup.gpe_device,
451 device->wakeup.gpe_number,
452 ACPI_GPE_TYPE_WAKE_RUN);
453 device->wakeup.run_wake_count--;
454 device->wakeup.state.enabled = 0;
455 }
456
442 acpi_button_remove_fs(device); 457 acpi_button_remove_fs(device);
443 input_unregister_device(button->input); 458 input_unregister_device(button->input);
444 kfree(button); 459 kfree(button);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 642bb305cb65..45cd03b4630e 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -29,6 +29,7 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/slab.h>
32#include <linux/types.h> 33#include <linux/types.h>
33#include <linux/acpi.h> 34#include <linux/acpi.h>
34#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
@@ -258,7 +259,7 @@ static int __init acpi_container_init(void)
258 acpi_walk_namespace(ACPI_TYPE_DEVICE, 259 acpi_walk_namespace(ACPI_TYPE_DEVICE,
259 ACPI_ROOT_OBJECT, 260 ACPI_ROOT_OBJECT,
260 ACPI_UINT32_MAX, 261 ACPI_UINT32_MAX,
261 container_walk_namespace_cb, &action, NULL); 262 container_walk_namespace_cb, NULL, &action, NULL);
262 263
263 return (0); 264 return (0);
264} 265}
@@ -271,7 +272,7 @@ static void __exit acpi_container_exit(void)
271 acpi_walk_namespace(ACPI_TYPE_DEVICE, 272 acpi_walk_namespace(ACPI_TYPE_DEVICE,
272 ACPI_ROOT_OBJECT, 273 ACPI_ROOT_OBJECT,
273 ACPI_UINT32_MAX, 274 ACPI_UINT32_MAX,
274 container_walk_namespace_cb, &action, NULL); 275 container_walk_namespace_cb, NULL, &action, NULL);
275 276
276 acpi_bus_unregister_driver(&acpi_container_driver); 277 acpi_bus_unregister_driver(&acpi_container_driver);
277 278
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index 8a690c3b8e23..146135e7a6a1 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -8,6 +8,8 @@
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/moduleparam.h> 10#include <linux/moduleparam.h>
11#include <linux/debugfs.h>
12#include <linux/slab.h>
11#include <asm/uaccess.h> 13#include <asm/uaccess.h>
12#include <acpi/acpi_drivers.h> 14#include <acpi/acpi_drivers.h>
13 15
@@ -196,6 +198,80 @@ module_param_call(trace_state, param_set_trace_state, param_get_trace_state,
196 NULL, 0644); 198 NULL, 0644);
197 199
198/* -------------------------------------------------------------------------- 200/* --------------------------------------------------------------------------
201 DebugFS Interface
202 -------------------------------------------------------------------------- */
203
204static ssize_t cm_write(struct file *file, const char __user *user_buf,
205 size_t count, loff_t *ppos)
206{
207 static char *buf;
208 static int uncopied_bytes;
209 struct acpi_table_header table;
210 acpi_status status;
211
212 if (!(*ppos)) {
213 /* parse the table header to get the table length */
214 if (count <= sizeof(struct acpi_table_header))
215 return -EINVAL;
216 if (copy_from_user(&table, user_buf,
217 sizeof(struct acpi_table_header)))
218 return -EFAULT;
219 uncopied_bytes = table.length;
220 buf = kzalloc(uncopied_bytes, GFP_KERNEL);
221 if (!buf)
222 return -ENOMEM;
223 }
224
225 if (uncopied_bytes < count) {
226 kfree(buf);
227 return -EINVAL;
228 }
229
230 if (copy_from_user(buf + (*ppos), user_buf, count)) {
231 kfree(buf);
232 return -EFAULT;
233 }
234
235 uncopied_bytes -= count;
236 *ppos += count;
237
238 if (!uncopied_bytes) {
239 status = acpi_install_method(buf);
240 kfree(buf);
241 if (ACPI_FAILURE(status))
242 return -EINVAL;
243 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
244 }
245
246 return count;
247}
248
249static const struct file_operations cm_fops = {
250 .write = cm_write,
251};
252
253static int acpi_debugfs_init(void)
254{
255 struct dentry *acpi_dir, *cm_dentry;
256
257 acpi_dir = debugfs_create_dir("acpi", NULL);
258 if (!acpi_dir)
259 goto err;
260
261 cm_dentry = debugfs_create_file("custom_method", S_IWUGO,
262 acpi_dir, NULL, &cm_fops);
263 if (!cm_dentry)
264 goto err;
265
266 return 0;
267
268err:
269 if (acpi_dir)
270 debugfs_remove(acpi_dir);
271 return -EINVAL;
272}
273
274/* --------------------------------------------------------------------------
199 FS Interface (/proc) 275 FS Interface (/proc)
200 -------------------------------------------------------------------------- */ 276 -------------------------------------------------------------------------- */
201#ifdef CONFIG_ACPI_PROCFS 277#ifdef CONFIG_ACPI_PROCFS
@@ -286,7 +362,7 @@ static const struct file_operations acpi_system_debug_proc_fops = {
286}; 362};
287#endif 363#endif
288 364
289int __init acpi_debug_init(void) 365int __init acpi_procfs_init(void)
290{ 366{
291#ifdef CONFIG_ACPI_PROCFS 367#ifdef CONFIG_ACPI_PROCFS
292 struct proc_dir_entry *entry; 368 struct proc_dir_entry *entry;
@@ -321,3 +397,10 @@ int __init acpi_debug_init(void)
321 return 0; 397 return 0;
322#endif 398#endif
323} 399}
400
401int __init acpi_debug_init(void)
402{
403 acpi_debugfs_init();
404 acpi_procfs_init();
405 return 0;
406}
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 7338b6a3e049..3fe29e992be8 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/types.h> 29#include <linux/types.h>
29#include <linux/notifier.h> 30#include <linux/notifier.h>
@@ -50,7 +51,6 @@ MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
50 " before undocking"); 51 " before undocking");
51 52
52static struct atomic_notifier_head dock_notifier_list; 53static struct atomic_notifier_head dock_notifier_list;
53static char dock_device_name[] = "dock";
54 54
55static const struct acpi_device_id dock_device_ids[] = { 55static const struct acpi_device_id dock_device_ids[] = {
56 {"LNXDOCK", 0}, 56 {"LNXDOCK", 0},
@@ -93,40 +93,30 @@ struct dock_dependent_device {
93 * Dock Dependent device functions * 93 * Dock Dependent device functions *
94 *****************************************************************************/ 94 *****************************************************************************/
95/** 95/**
96 * alloc_dock_dependent_device - allocate and init a dependent device 96 * add_dock_dependent_device - associate a device with the dock station
97 * @handle: the acpi_handle of the dependent device 97 * @ds: The dock station
98 * @handle: handle of the dependent device
98 * 99 *
99 * Allocate memory for a dependent device structure for a device referenced 100 * Add the dependent device to the dock's dependent device list.
100 * by the acpi handle
101 */ 101 */
102static struct dock_dependent_device * 102static int
103alloc_dock_dependent_device(acpi_handle handle) 103add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
104{ 104{
105 struct dock_dependent_device *dd; 105 struct dock_dependent_device *dd;
106 106
107 dd = kzalloc(sizeof(*dd), GFP_KERNEL); 107 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
108 if (dd) { 108 if (!dd)
109 dd->handle = handle; 109 return -ENOMEM;
110 INIT_LIST_HEAD(&dd->list); 110
111 INIT_LIST_HEAD(&dd->hotplug_list); 111 dd->handle = handle;
112 } 112 INIT_LIST_HEAD(&dd->list);
113 return dd; 113 INIT_LIST_HEAD(&dd->hotplug_list);
114}
115 114
116/**
117 * add_dock_dependent_device - associate a device with the dock station
118 * @ds: The dock station
119 * @dd: The dependent device
120 *
121 * Add the dependent device to the dock's dependent device list.
122 */
123static void
124add_dock_dependent_device(struct dock_station *ds,
125 struct dock_dependent_device *dd)
126{
127 spin_lock(&ds->dd_lock); 115 spin_lock(&ds->dd_lock);
128 list_add_tail(&dd->list, &ds->dependent_devices); 116 list_add_tail(&dd->list, &ds->dependent_devices);
129 spin_unlock(&ds->dd_lock); 117 spin_unlock(&ds->dd_lock);
118
119 return 0;
130} 120}
131 121
132/** 122/**
@@ -249,6 +239,7 @@ static int is_battery(acpi_handle handle)
249static int is_ejectable_bay(acpi_handle handle) 239static int is_ejectable_bay(acpi_handle handle)
250{ 240{
251 acpi_handle phandle; 241 acpi_handle phandle;
242
252 if (!is_ejectable(handle)) 243 if (!is_ejectable(handle))
253 return 0; 244 return 0;
254 if (is_battery(handle) || is_ata(handle)) 245 if (is_battery(handle) || is_ata(handle))
@@ -275,14 +266,13 @@ int is_dock_device(acpi_handle handle)
275 266
276 if (is_dock(handle)) 267 if (is_dock(handle))
277 return 1; 268 return 1;
278 list_for_each_entry(dock_station, &dock_stations, sibling) { 269
270 list_for_each_entry(dock_station, &dock_stations, sibling)
279 if (find_dock_dependent_device(dock_station, handle)) 271 if (find_dock_dependent_device(dock_station, handle))
280 return 1; 272 return 1;
281 }
282 273
283 return 0; 274 return 0;
284} 275}
285
286EXPORT_SYMBOL_GPL(is_dock_device); 276EXPORT_SYMBOL_GPL(is_dock_device);
287 277
288/** 278/**
@@ -305,8 +295,6 @@ static int dock_present(struct dock_station *ds)
305 return 0; 295 return 0;
306} 296}
307 297
308
309
310/** 298/**
311 * dock_create_acpi_device - add new devices to acpi 299 * dock_create_acpi_device - add new devices to acpi
312 * @handle - handle of the device to add 300 * @handle - handle of the device to add
@@ -320,7 +308,7 @@ static int dock_present(struct dock_station *ds)
320 */ 308 */
321static struct acpi_device * dock_create_acpi_device(acpi_handle handle) 309static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
322{ 310{
323 struct acpi_device *device = NULL; 311 struct acpi_device *device;
324 struct acpi_device *parent_device; 312 struct acpi_device *parent_device;
325 acpi_handle parent; 313 acpi_handle parent;
326 int ret; 314 int ret;
@@ -337,8 +325,7 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
337 ret = acpi_bus_add(&device, parent_device, handle, 325 ret = acpi_bus_add(&device, parent_device, handle,
338 ACPI_BUS_TYPE_DEVICE); 326 ACPI_BUS_TYPE_DEVICE);
339 if (ret) { 327 if (ret) {
340 pr_debug("error adding bus, %x\n", 328 pr_debug("error adding bus, %x\n", -ret);
341 -ret);
342 return NULL; 329 return NULL;
343 } 330 }
344 } 331 }
@@ -364,7 +351,6 @@ static void dock_remove_acpi_device(acpi_handle handle)
364 } 351 }
365} 352}
366 353
367
368/** 354/**
369 * hotplug_dock_devices - insert or remove devices on the dock station 355 * hotplug_dock_devices - insert or remove devices on the dock station
370 * @ds: the dock station 356 * @ds: the dock station
@@ -384,10 +370,9 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
384 /* 370 /*
385 * First call driver specific hotplug functions 371 * First call driver specific hotplug functions
386 */ 372 */
387 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) { 373 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list)
388 if (dd->ops && dd->ops->handler) 374 if (dd->ops && dd->ops->handler)
389 dd->ops->handler(dd->handle, event, dd->context); 375 dd->ops->handler(dd->handle, event, dd->context);
390 }
391 376
392 /* 377 /*
393 * Now make sure that an acpi_device is created for each 378 * Now make sure that an acpi_device is created for each
@@ -426,6 +411,7 @@ static void dock_event(struct dock_station *ds, u32 event, int num)
426 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) 411 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list)
427 if (dd->ops && dd->ops->uevent) 412 if (dd->ops && dd->ops->uevent)
428 dd->ops->uevent(dd->handle, event, dd->context); 413 dd->ops->uevent(dd->handle, event, dd->context);
414
429 if (num != DOCK_EVENT) 415 if (num != DOCK_EVENT)
430 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); 416 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
431} 417}
@@ -456,8 +442,8 @@ static void eject_dock(struct dock_station *ds)
456 arg.type = ACPI_TYPE_INTEGER; 442 arg.type = ACPI_TYPE_INTEGER;
457 arg.integer.value = 1; 443 arg.integer.value = 1;
458 444
459 if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", 445 status = acpi_evaluate_object(ds->handle, "_EJ0", &arg_list, NULL);
460 &arg_list, NULL))) 446 if (ACPI_FAILURE(status))
461 pr_debug("Failed to evaluate _EJ0!\n"); 447 pr_debug("Failed to evaluate _EJ0!\n");
462} 448}
463 449
@@ -577,7 +563,6 @@ int register_dock_notifier(struct notifier_block *nb)
577 563
578 return atomic_notifier_chain_register(&dock_notifier_list, nb); 564 return atomic_notifier_chain_register(&dock_notifier_list, nb);
579} 565}
580
581EXPORT_SYMBOL_GPL(register_dock_notifier); 566EXPORT_SYMBOL_GPL(register_dock_notifier);
582 567
583/** 568/**
@@ -591,7 +576,6 @@ void unregister_dock_notifier(struct notifier_block *nb)
591 576
592 atomic_notifier_chain_unregister(&dock_notifier_list, nb); 577 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
593} 578}
594
595EXPORT_SYMBOL_GPL(unregister_dock_notifier); 579EXPORT_SYMBOL_GPL(unregister_dock_notifier);
596 580
597/** 581/**
@@ -622,7 +606,7 @@ register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops,
622 list_for_each_entry(dock_station, &dock_stations, sibling) { 606 list_for_each_entry(dock_station, &dock_stations, sibling) {
623 /* 607 /*
624 * An ATA bay can be in a dock and itself can be ejected 608 * An ATA bay can be in a dock and itself can be ejected
625 * seperately, so there are two 'dock stations' which need the 609 * separately, so there are two 'dock stations' which need the
626 * ops 610 * ops
627 */ 611 */
628 dd = find_dock_dependent_device(dock_station, handle); 612 dd = find_dock_dependent_device(dock_station, handle);
@@ -636,7 +620,6 @@ register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops,
636 620
637 return ret; 621 return ret;
638} 622}
639
640EXPORT_SYMBOL_GPL(register_hotplug_dock_device); 623EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
641 624
642/** 625/**
@@ -657,7 +640,6 @@ void unregister_hotplug_dock_device(acpi_handle handle)
657 dock_del_hotplug_device(dock_station, dd); 640 dock_del_hotplug_device(dock_station, dd);
658 } 641 }
659} 642}
660
661EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); 643EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
662 644
663/** 645/**
@@ -772,7 +754,7 @@ struct dock_data {
772 754
773static void acpi_dock_deferred_cb(void *context) 755static void acpi_dock_deferred_cb(void *context)
774{ 756{
775 struct dock_data *data = (struct dock_data *)context; 757 struct dock_data *data = context;
776 758
777 dock_notify(data->handle, data->event, data->ds); 759 dock_notify(data->handle, data->event, data->ds);
778 kfree(data); 760 kfree(data);
@@ -782,23 +764,22 @@ static int acpi_dock_notifier_call(struct notifier_block *this,
782 unsigned long event, void *data) 764 unsigned long event, void *data)
783{ 765{
784 struct dock_station *dock_station; 766 struct dock_station *dock_station;
785 acpi_handle handle = (acpi_handle)data; 767 acpi_handle handle = data;
786 768
787 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK 769 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
788 && event != ACPI_NOTIFY_EJECT_REQUEST) 770 && event != ACPI_NOTIFY_EJECT_REQUEST)
789 return 0; 771 return 0;
790 list_for_each_entry(dock_station, &dock_stations, sibling) { 772 list_for_each_entry(dock_station, &dock_stations, sibling) {
791 if (dock_station->handle == handle) { 773 if (dock_station->handle == handle) {
792 struct dock_data *dock_data; 774 struct dock_data *dd;
793 775
794 dock_data = kmalloc(sizeof(*dock_data), GFP_KERNEL); 776 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
795 if (!dock_data) 777 if (!dd)
796 return 0; 778 return 0;
797 dock_data->handle = handle; 779 dd->handle = handle;
798 dock_data->event = event; 780 dd->event = event;
799 dock_data->ds = dock_station; 781 dd->ds = dock_station;
800 acpi_os_hotplug_execute(acpi_dock_deferred_cb, 782 acpi_os_hotplug_execute(acpi_dock_deferred_cb, dd);
801 dock_data);
802 return 0 ; 783 return 0 ;
803 } 784 }
804 } 785 }
@@ -826,7 +807,6 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
826 acpi_status status; 807 acpi_status status;
827 acpi_handle tmp, parent; 808 acpi_handle tmp, parent;
828 struct dock_station *ds = context; 809 struct dock_station *ds = context;
829 struct dock_dependent_device *dd;
830 810
831 status = acpi_bus_get_ejd(handle, &tmp); 811 status = acpi_bus_get_ejd(handle, &tmp);
832 if (ACPI_FAILURE(status)) { 812 if (ACPI_FAILURE(status)) {
@@ -840,11 +820,9 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
840 goto fdd_out; 820 goto fdd_out;
841 } 821 }
842 822
843 if (tmp == ds->handle) { 823 if (tmp == ds->handle)
844 dd = alloc_dock_dependent_device(handle); 824 add_dock_dependent_device(ds, handle);
845 if (dd) 825
846 add_dock_dependent_device(ds, dd);
847 }
848fdd_out: 826fdd_out:
849 return AE_OK; 827 return AE_OK;
850} 828}
@@ -857,8 +835,7 @@ static ssize_t show_docked(struct device *dev,
857{ 835{
858 struct acpi_device *tmp; 836 struct acpi_device *tmp;
859 837
860 struct dock_station *dock_station = *((struct dock_station **) 838 struct dock_station *dock_station = dev->platform_data;
861 dev->platform_data);
862 839
863 if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp))) 840 if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp)))
864 return snprintf(buf, PAGE_SIZE, "1\n"); 841 return snprintf(buf, PAGE_SIZE, "1\n");
@@ -872,8 +849,7 @@ static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
872static ssize_t show_flags(struct device *dev, 849static ssize_t show_flags(struct device *dev,
873 struct device_attribute *attr, char *buf) 850 struct device_attribute *attr, char *buf)
874{ 851{
875 struct dock_station *dock_station = *((struct dock_station **) 852 struct dock_station *dock_station = dev->platform_data;
876 dev->platform_data);
877 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); 853 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
878 854
879} 855}
@@ -886,8 +862,7 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
886 const char *buf, size_t count) 862 const char *buf, size_t count)
887{ 863{
888 int ret; 864 int ret;
889 struct dock_station *dock_station = *((struct dock_station **) 865 struct dock_station *dock_station = dev->platform_data;
890 dev->platform_data);
891 866
892 if (!count) 867 if (!count)
893 return -EINVAL; 868 return -EINVAL;
@@ -905,8 +880,7 @@ static ssize_t show_dock_uid(struct device *dev,
905 struct device_attribute *attr, char *buf) 880 struct device_attribute *attr, char *buf)
906{ 881{
907 unsigned long long lbuf; 882 unsigned long long lbuf;
908 struct dock_station *dock_station = *((struct dock_station **) 883 struct dock_station *dock_station = dev->platform_data;
909 dev->platform_data);
910 acpi_status status = acpi_evaluate_integer(dock_station->handle, 884 acpi_status status = acpi_evaluate_integer(dock_station->handle,
911 "_UID", NULL, &lbuf); 885 "_UID", NULL, &lbuf);
912 if (ACPI_FAILURE(status)) 886 if (ACPI_FAILURE(status))
@@ -919,8 +893,7 @@ static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
919static ssize_t show_dock_type(struct device *dev, 893static ssize_t show_dock_type(struct device *dev,
920 struct device_attribute *attr, char *buf) 894 struct device_attribute *attr, char *buf)
921{ 895{
922 struct dock_station *dock_station = *((struct dock_station **) 896 struct dock_station *dock_station = dev->platform_data;
923 dev->platform_data);
924 char *type; 897 char *type;
925 898
926 if (dock_station->flags & DOCK_IS_DOCK) 899 if (dock_station->flags & DOCK_IS_DOCK)
@@ -936,6 +909,19 @@ static ssize_t show_dock_type(struct device *dev,
936} 909}
937static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL); 910static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
938 911
912static struct attribute *dock_attributes[] = {
913 &dev_attr_docked.attr,
914 &dev_attr_flags.attr,
915 &dev_attr_undock.attr,
916 &dev_attr_uid.attr,
917 &dev_attr_type.attr,
918 NULL
919};
920
921static struct attribute_group dock_attribute_group = {
922 .attrs = dock_attributes
923};
924
939/** 925/**
940 * dock_add - add a new dock station 926 * dock_add - add a new dock station
941 * @handle: the dock station handle 927 * @handle: the dock station handle
@@ -945,39 +931,31 @@ static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
945 */ 931 */
946static int dock_add(acpi_handle handle) 932static int dock_add(acpi_handle handle)
947{ 933{
948 int ret; 934 int ret, id;
949 struct dock_dependent_device *dd; 935 struct dock_station ds, *dock_station;
950 struct dock_station *dock_station; 936 struct platform_device *dd;
951 struct platform_device *dock_device; 937
938 id = dock_station_count;
939 memset(&ds, 0, sizeof(ds));
940 dd = platform_device_register_data(NULL, "dock", id, &ds, sizeof(ds));
941 if (IS_ERR(dd))
942 return PTR_ERR(dd);
943
944 dock_station = dd->dev.platform_data;
952 945
953 /* allocate & initialize the dock_station private data */
954 dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL);
955 if (!dock_station)
956 return -ENOMEM;
957 dock_station->handle = handle; 946 dock_station->handle = handle;
947 dock_station->dock_device = dd;
958 dock_station->last_dock_time = jiffies - HZ; 948 dock_station->last_dock_time = jiffies - HZ;
959 INIT_LIST_HEAD(&dock_station->dependent_devices); 949
960 INIT_LIST_HEAD(&dock_station->hotplug_devices);
961 INIT_LIST_HEAD(&dock_station->sibling);
962 spin_lock_init(&dock_station->dd_lock);
963 mutex_init(&dock_station->hp_lock); 950 mutex_init(&dock_station->hp_lock);
951 spin_lock_init(&dock_station->dd_lock);
952 INIT_LIST_HEAD(&dock_station->sibling);
953 INIT_LIST_HEAD(&dock_station->hotplug_devices);
964 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); 954 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
965 955 INIT_LIST_HEAD(&dock_station->dependent_devices);
966 /* initialize platform device stuff */
967 dock_station->dock_device =
968 platform_device_register_simple(dock_device_name,
969 dock_station_count, NULL, 0);
970 dock_device = dock_station->dock_device;
971 if (IS_ERR(dock_device)) {
972 kfree(dock_station);
973 dock_station = NULL;
974 return PTR_ERR(dock_device);
975 }
976 platform_device_add_data(dock_device, &dock_station,
977 sizeof(struct dock_station *));
978 956
979 /* we want the dock device to send uevents */ 957 /* we want the dock device to send uevents */
980 dev_set_uevent_suppress(&dock_device->dev, 0); 958 dev_set_uevent_suppress(&dd->dev, 0);
981 959
982 if (is_dock(handle)) 960 if (is_dock(handle))
983 dock_station->flags |= DOCK_IS_DOCK; 961 dock_station->flags |= DOCK_IS_DOCK;
@@ -986,106 +964,53 @@ static int dock_add(acpi_handle handle)
986 if (is_battery(handle)) 964 if (is_battery(handle))
987 dock_station->flags |= DOCK_IS_BAT; 965 dock_station->flags |= DOCK_IS_BAT;
988 966
989 ret = device_create_file(&dock_device->dev, &dev_attr_docked); 967 ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
990 if (ret) {
991 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
992 platform_device_unregister(dock_device);
993 kfree(dock_station);
994 dock_station = NULL;
995 return ret;
996 }
997 ret = device_create_file(&dock_device->dev, &dev_attr_undock);
998 if (ret) {
999 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1000 device_remove_file(&dock_device->dev, &dev_attr_docked);
1001 platform_device_unregister(dock_device);
1002 kfree(dock_station);
1003 dock_station = NULL;
1004 return ret;
1005 }
1006 ret = device_create_file(&dock_device->dev, &dev_attr_uid);
1007 if (ret) {
1008 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1009 device_remove_file(&dock_device->dev, &dev_attr_docked);
1010 device_remove_file(&dock_device->dev, &dev_attr_undock);
1011 platform_device_unregister(dock_device);
1012 kfree(dock_station);
1013 dock_station = NULL;
1014 return ret;
1015 }
1016 ret = device_create_file(&dock_device->dev, &dev_attr_flags);
1017 if (ret) {
1018 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1019 device_remove_file(&dock_device->dev, &dev_attr_docked);
1020 device_remove_file(&dock_device->dev, &dev_attr_undock);
1021 device_remove_file(&dock_device->dev, &dev_attr_uid);
1022 platform_device_unregister(dock_device);
1023 kfree(dock_station);
1024 dock_station = NULL;
1025 return ret;
1026 }
1027 ret = device_create_file(&dock_device->dev, &dev_attr_type);
1028 if (ret) 968 if (ret)
1029 printk(KERN_ERR"Error %d adding sysfs file\n", ret); 969 goto err_unregister;
1030 970
1031 /* Find dependent devices */ 971 /* Find dependent devices */
1032 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 972 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1033 ACPI_UINT32_MAX, find_dock_devices, dock_station, 973 ACPI_UINT32_MAX, find_dock_devices, NULL,
1034 NULL); 974 dock_station, NULL);
1035 975
1036 /* add the dock station as a device dependent on itself */ 976 /* add the dock station as a device dependent on itself */
1037 dd = alloc_dock_dependent_device(handle); 977 ret = add_dock_dependent_device(dock_station, handle);
1038 if (!dd) { 978 if (ret)
1039 kfree(dock_station); 979 goto err_rmgroup;
1040 dock_station = NULL;
1041 ret = -ENOMEM;
1042 goto dock_add_err_unregister;
1043 }
1044 add_dock_dependent_device(dock_station, dd);
1045 980
1046 dock_station_count++; 981 dock_station_count++;
1047 list_add(&dock_station->sibling, &dock_stations); 982 list_add(&dock_station->sibling, &dock_stations);
1048 return 0; 983 return 0;
1049 984
1050dock_add_err_unregister: 985err_rmgroup:
1051 device_remove_file(&dock_device->dev, &dev_attr_type); 986 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
1052 device_remove_file(&dock_device->dev, &dev_attr_docked); 987err_unregister:
1053 device_remove_file(&dock_device->dev, &dev_attr_undock); 988 platform_device_unregister(dd);
1054 device_remove_file(&dock_device->dev, &dev_attr_uid); 989 printk(KERN_ERR "%s encountered error %d\n", __func__, ret);
1055 device_remove_file(&dock_device->dev, &dev_attr_flags);
1056 platform_device_unregister(dock_device);
1057 kfree(dock_station);
1058 dock_station = NULL;
1059 return ret; 990 return ret;
1060} 991}
1061 992
1062/** 993/**
1063 * dock_remove - free up resources related to the dock station 994 * dock_remove - free up resources related to the dock station
1064 */ 995 */
1065static int dock_remove(struct dock_station *dock_station) 996static int dock_remove(struct dock_station *ds)
1066{ 997{
1067 struct dock_dependent_device *dd, *tmp; 998 struct dock_dependent_device *dd, *tmp;
1068 struct platform_device *dock_device = dock_station->dock_device; 999 struct platform_device *dock_device = ds->dock_device;
1069 1000
1070 if (!dock_station_count) 1001 if (!dock_station_count)
1071 return 0; 1002 return 0;
1072 1003
1073 /* remove dependent devices */ 1004 /* remove dependent devices */
1074 list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices, 1005 list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, list)
1075 list) 1006 kfree(dd);
1076 kfree(dd); 1007
1008 list_del(&ds->sibling);
1077 1009
1078 /* cleanup sysfs */ 1010 /* cleanup sysfs */
1079 device_remove_file(&dock_device->dev, &dev_attr_type); 1011 sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group);
1080 device_remove_file(&dock_device->dev, &dev_attr_docked);
1081 device_remove_file(&dock_device->dev, &dev_attr_undock);
1082 device_remove_file(&dock_device->dev, &dev_attr_uid);
1083 device_remove_file(&dock_device->dev, &dev_attr_flags);
1084 platform_device_unregister(dock_device); 1012 platform_device_unregister(dock_device);
1085 1013
1086 /* free dock station memory */
1087 kfree(dock_station);
1088 dock_station = NULL;
1089 return 0; 1014 return 0;
1090} 1015}
1091 1016
@@ -1101,14 +1026,10 @@ static int dock_remove(struct dock_station *dock_station)
1101static acpi_status 1026static acpi_status
1102find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) 1027find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
1103{ 1028{
1104 acpi_status status = AE_OK; 1029 if (is_dock(handle))
1030 dock_add(handle);
1105 1031
1106 if (is_dock(handle)) { 1032 return AE_OK;
1107 if (dock_add(handle) >= 0) {
1108 status = AE_CTRL_TERMINATE;
1109 }
1110 }
1111 return status;
1112} 1033}
1113 1034
1114static acpi_status 1035static acpi_status
@@ -1127,11 +1048,11 @@ static int __init dock_init(void)
1127 1048
1128 /* look for a dock station */ 1049 /* look for a dock station */
1129 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1050 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1130 ACPI_UINT32_MAX, find_dock, NULL, NULL); 1051 ACPI_UINT32_MAX, find_dock, NULL, NULL, NULL);
1131 1052
1132 /* look for bay */ 1053 /* look for bay */
1133 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1054 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1134 ACPI_UINT32_MAX, find_bay, NULL, NULL); 1055 ACPI_UINT32_MAX, find_bay, NULL, NULL, NULL);
1135 if (!dock_station_count) { 1056 if (!dock_station_count) {
1136 printk(KERN_INFO PREFIX "No dock devices found.\n"); 1057 printk(KERN_INFO PREFIX "No dock devices found.\n");
1137 return 0; 1058 return 0;
@@ -1145,8 +1066,7 @@ static int __init dock_init(void)
1145 1066
1146static void __exit dock_exit(void) 1067static void __exit dock_exit(void)
1147{ 1068{
1148 struct dock_station *dock_station; 1069 struct dock_station *tmp, *dock_station;
1149 struct dock_station *tmp;
1150 1070
1151 unregister_acpi_bus_notifier(&dock_acpi_notifier); 1071 unregister_acpi_bus_notifier(&dock_acpi_notifier);
1152 list_for_each_entry_safe(dock_station, tmp, &dock_stations, sibling) 1072 list_for_each_entry_safe(dock_station, tmp, &dock_stations, sibling)
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index baef28c1e630..f2234db85da0 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -39,6 +39,7 @@
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/list.h> 40#include <linux/list.h>
41#include <linux/spinlock.h> 41#include <linux/spinlock.h>
42#include <linux/slab.h>
42#include <asm/io.h> 43#include <asm/io.h>
43#include <acpi/acpi_bus.h> 44#include <acpi/acpi_bus.h>
44#include <acpi/acpi_drivers.h> 45#include <acpi/acpi_drivers.h>
@@ -76,8 +77,9 @@ enum ec_command {
76enum { 77enum {
77 EC_FLAGS_QUERY_PENDING, /* Query is pending */ 78 EC_FLAGS_QUERY_PENDING, /* Query is pending */
78 EC_FLAGS_GPE_STORM, /* GPE storm detected */ 79 EC_FLAGS_GPE_STORM, /* GPE storm detected */
79 EC_FLAGS_HANDLERS_INSTALLED /* Handlers for GPE and 80 EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and
80 * OpReg are installed */ 81 * OpReg are installed */
82 EC_FLAGS_FROZEN, /* Transactions are suspended */
81}; 83};
82 84
83/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 85/* If we find an EC via the ECDT, we need to keep a ptr to its context */
@@ -201,14 +203,13 @@ unlock:
201 spin_unlock_irqrestore(&ec->curr_lock, flags); 203 spin_unlock_irqrestore(&ec->curr_lock, flags);
202} 204}
203 205
204static void acpi_ec_gpe_query(void *ec_cxt); 206static int acpi_ec_sync_query(struct acpi_ec *ec);
205 207
206static int ec_check_sci(struct acpi_ec *ec, u8 state) 208static int ec_check_sci_sync(struct acpi_ec *ec, u8 state)
207{ 209{
208 if (state & ACPI_EC_FLAG_SCI) { 210 if (state & ACPI_EC_FLAG_SCI) {
209 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) 211 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
210 return acpi_os_execute(OSL_EC_BURST_HANDLER, 212 return acpi_ec_sync_query(ec);
211 acpi_ec_gpe_query, ec);
212 } 213 }
213 return 0; 214 return 0;
214} 215}
@@ -249,11 +250,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
249{ 250{
250 unsigned long tmp; 251 unsigned long tmp;
251 int ret = 0; 252 int ret = 0;
252 pr_debug(PREFIX "transaction start\n");
253 /* disable GPE during transaction if storm is detected */
254 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
255 acpi_disable_gpe(NULL, ec->gpe);
256 }
257 if (EC_FLAGS_MSI) 253 if (EC_FLAGS_MSI)
258 udelay(ACPI_EC_MSI_UDELAY); 254 udelay(ACPI_EC_MSI_UDELAY);
259 /* start transaction */ 255 /* start transaction */
@@ -265,20 +261,9 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
265 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 261 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
266 spin_unlock_irqrestore(&ec->curr_lock, tmp); 262 spin_unlock_irqrestore(&ec->curr_lock, tmp);
267 ret = ec_poll(ec); 263 ret = ec_poll(ec);
268 pr_debug(PREFIX "transaction end\n");
269 spin_lock_irqsave(&ec->curr_lock, tmp); 264 spin_lock_irqsave(&ec->curr_lock, tmp);
270 ec->curr = NULL; 265 ec->curr = NULL;
271 spin_unlock_irqrestore(&ec->curr_lock, tmp); 266 spin_unlock_irqrestore(&ec->curr_lock, tmp);
272 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
273 /* check if we received SCI during transaction */
274 ec_check_sci(ec, acpi_ec_read_status(ec));
275 /* it is safe to enable GPE outside of transaction */
276 acpi_enable_gpe(NULL, ec->gpe);
277 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) {
278 pr_info(PREFIX "GPE storm detected, "
279 "transactions will use polling mode\n");
280 set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
281 }
282 return ret; 267 return ret;
283} 268}
284 269
@@ -308,6 +293,10 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
308 if (t->rdata) 293 if (t->rdata)
309 memset(t->rdata, 0, t->rlen); 294 memset(t->rdata, 0, t->rlen);
310 mutex_lock(&ec->lock); 295 mutex_lock(&ec->lock);
296 if (test_bit(EC_FLAGS_FROZEN, &ec->flags)) {
297 status = -EINVAL;
298 goto unlock;
299 }
311 if (ec->global_lock) { 300 if (ec->global_lock) {
312 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 301 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
313 if (ACPI_FAILURE(status)) { 302 if (ACPI_FAILURE(status)) {
@@ -321,7 +310,34 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
321 status = -ETIME; 310 status = -ETIME;
322 goto end; 311 goto end;
323 } 312 }
313 pr_debug(PREFIX "transaction start\n");
314 /* disable GPE during transaction if storm is detected */
315 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
316 /*
317 * It has to be disabled at the hardware level regardless of the
318 * GPE reference counting, so that it doesn't trigger.
319 */
320 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE);
321 }
322
324 status = acpi_ec_transaction_unlocked(ec, t); 323 status = acpi_ec_transaction_unlocked(ec, t);
324
325 /* check if we received SCI during transaction */
326 ec_check_sci_sync(ec, acpi_ec_read_status(ec));
327 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
328 msleep(1);
329 /*
330 * It is safe to enable the GPE outside of the transaction. Use
331 * acpi_set_gpe() for that, since we used it to disable the GPE
332 * above.
333 */
334 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE);
335 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) {
336 pr_info(PREFIX "GPE storm detected, "
337 "transactions will use polling mode\n");
338 set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
339 }
340 pr_debug(PREFIX "transaction end\n");
325end: 341end:
326 if (ec->global_lock) 342 if (ec->global_lock)
327 acpi_release_global_lock(glk); 343 acpi_release_global_lock(glk);
@@ -443,7 +459,33 @@ int ec_transaction(u8 command,
443 459
444EXPORT_SYMBOL(ec_transaction); 460EXPORT_SYMBOL(ec_transaction);
445 461
446static int acpi_ec_query(struct acpi_ec *ec, u8 * data) 462void acpi_ec_suspend_transactions(void)
463{
464 struct acpi_ec *ec = first_ec;
465
466 if (!ec)
467 return;
468
469 mutex_lock(&ec->lock);
470 /* Prevent transactions from being carried out */
471 set_bit(EC_FLAGS_FROZEN, &ec->flags);
472 mutex_unlock(&ec->lock);
473}
474
475void acpi_ec_resume_transactions(void)
476{
477 struct acpi_ec *ec = first_ec;
478
479 if (!ec)
480 return;
481
482 mutex_lock(&ec->lock);
483 /* Allow transactions to be carried out again */
484 clear_bit(EC_FLAGS_FROZEN, &ec->flags);
485 mutex_unlock(&ec->lock);
486}
487
488static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data)
447{ 489{
448 int result; 490 int result;
449 u8 d; 491 u8 d;
@@ -452,20 +494,16 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
452 .wlen = 0, .rlen = 1}; 494 .wlen = 0, .rlen = 1};
453 if (!ec || !data) 495 if (!ec || !data)
454 return -EINVAL; 496 return -EINVAL;
455
456 /* 497 /*
457 * Query the EC to find out which _Qxx method we need to evaluate. 498 * Query the EC to find out which _Qxx method we need to evaluate.
458 * Note that successful completion of the query causes the ACPI_EC_SCI 499 * Note that successful completion of the query causes the ACPI_EC_SCI
459 * bit to be cleared (and thus clearing the interrupt source). 500 * bit to be cleared (and thus clearing the interrupt source).
460 */ 501 */
461 502 result = acpi_ec_transaction_unlocked(ec, &t);
462 result = acpi_ec_transaction(ec, &t);
463 if (result) 503 if (result)
464 return result; 504 return result;
465
466 if (!d) 505 if (!d)
467 return -ENODATA; 506 return -ENODATA;
468
469 *data = d; 507 *data = d;
470 return 0; 508 return 0;
471} 509}
@@ -509,43 +547,79 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
509 547
510EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler); 548EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
511 549
512static void acpi_ec_gpe_query(void *ec_cxt) 550static void acpi_ec_run(void *cxt)
513{ 551{
514 struct acpi_ec *ec = ec_cxt; 552 struct acpi_ec_query_handler *handler = cxt;
515 u8 value = 0; 553 if (!handler)
516 struct acpi_ec_query_handler *handler, copy;
517
518 if (!ec || acpi_ec_query(ec, &value))
519 return; 554 return;
520 mutex_lock(&ec->lock); 555 pr_debug(PREFIX "start query execution\n");
556 if (handler->func)
557 handler->func(handler->data);
558 else if (handler->handle)
559 acpi_evaluate_object(handler->handle, NULL, NULL, NULL);
560 pr_debug(PREFIX "stop query execution\n");
561 kfree(handler);
562}
563
564static int acpi_ec_sync_query(struct acpi_ec *ec)
565{
566 u8 value = 0;
567 int status;
568 struct acpi_ec_query_handler *handler, *copy;
569 if ((status = acpi_ec_query_unlocked(ec, &value)))
570 return status;
521 list_for_each_entry(handler, &ec->list, node) { 571 list_for_each_entry(handler, &ec->list, node) {
522 if (value == handler->query_bit) { 572 if (value == handler->query_bit) {
523 /* have custom handler for this bit */ 573 /* have custom handler for this bit */
524 memcpy(&copy, handler, sizeof(copy)); 574 copy = kmalloc(sizeof(*handler), GFP_KERNEL);
525 mutex_unlock(&ec->lock); 575 if (!copy)
526 if (copy.func) { 576 return -ENOMEM;
527 copy.func(copy.data); 577 memcpy(copy, handler, sizeof(*copy));
528 } else if (copy.handle) { 578 pr_debug(PREFIX "push query execution (0x%2x) on queue\n", value);
529 acpi_evaluate_object(copy.handle, NULL, NULL, NULL); 579 return acpi_os_execute((copy->func) ?
530 } 580 OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER,
531 return; 581 acpi_ec_run, copy);
532 } 582 }
533 } 583 }
584 return 0;
585}
586
587static void acpi_ec_gpe_query(void *ec_cxt)
588{
589 struct acpi_ec *ec = ec_cxt;
590 if (!ec)
591 return;
592 mutex_lock(&ec->lock);
593 acpi_ec_sync_query(ec);
534 mutex_unlock(&ec->lock); 594 mutex_unlock(&ec->lock);
535} 595}
536 596
597static void acpi_ec_gpe_query(void *ec_cxt);
598
599static int ec_check_sci(struct acpi_ec *ec, u8 state)
600{
601 if (state & ACPI_EC_FLAG_SCI) {
602 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) {
603 pr_debug(PREFIX "push gpe query to the queue\n");
604 return acpi_os_execute(OSL_NOTIFY_HANDLER,
605 acpi_ec_gpe_query, ec);
606 }
607 }
608 return 0;
609}
610
537static u32 acpi_ec_gpe_handler(void *data) 611static u32 acpi_ec_gpe_handler(void *data)
538{ 612{
539 struct acpi_ec *ec = data; 613 struct acpi_ec *ec = data;
540 u8 status;
541 614
542 pr_debug(PREFIX "~~~> interrupt\n"); 615 pr_debug(PREFIX "~~~> interrupt\n");
543 status = acpi_ec_read_status(ec);
544 616
545 advance_transaction(ec, status); 617 advance_transaction(ec, acpi_ec_read_status(ec));
546 if (ec_transaction_done(ec) && (status & ACPI_EC_FLAG_IBF) == 0) 618 if (ec_transaction_done(ec) &&
619 (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) {
547 wake_up(&ec->wait); 620 wake_up(&ec->wait);
548 ec_check_sci(ec, status); 621 ec_check_sci(ec, acpi_ec_read_status(ec));
622 }
549 return ACPI_INTERRUPT_HANDLED; 623 return ACPI_INTERRUPT_HANDLED;
550} 624}
551 625
@@ -555,12 +629,12 @@ static u32 acpi_ec_gpe_handler(void *data)
555 629
556static acpi_status 630static acpi_status
557acpi_ec_space_handler(u32 function, acpi_physical_address address, 631acpi_ec_space_handler(u32 function, acpi_physical_address address,
558 u32 bits, acpi_integer *value, 632 u32 bits, u64 *value64,
559 void *handler_context, void *region_context) 633 void *handler_context, void *region_context)
560{ 634{
561 struct acpi_ec *ec = handler_context; 635 struct acpi_ec *ec = handler_context;
562 int result = 0, i; 636 int result = 0, i, bytes = bits / 8;
563 u8 temp = 0; 637 u8 *value = (u8 *)value64;
564 638
565 if ((address > 0xFF) || !value || !handler_context) 639 if ((address > 0xFF) || !value || !handler_context)
566 return AE_BAD_PARAMETER; 640 return AE_BAD_PARAMETER;
@@ -568,32 +642,15 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
568 if (function != ACPI_READ && function != ACPI_WRITE) 642 if (function != ACPI_READ && function != ACPI_WRITE)
569 return AE_BAD_PARAMETER; 643 return AE_BAD_PARAMETER;
570 644
571 if (bits != 8 && acpi_strict) 645 if (EC_FLAGS_MSI || bits > 8)
572 return AE_BAD_PARAMETER;
573
574 if (EC_FLAGS_MSI)
575 acpi_ec_burst_enable(ec); 646 acpi_ec_burst_enable(ec);
576 647
577 if (function == ACPI_READ) { 648 for (i = 0; i < bytes; ++i, ++address, ++value)
578 result = acpi_ec_read(ec, address, &temp); 649 result = (function == ACPI_READ) ?
579 *value = temp; 650 acpi_ec_read(ec, address, value) :
580 } else { 651 acpi_ec_write(ec, address, *value);
581 temp = 0xff & (*value);
582 result = acpi_ec_write(ec, address, temp);
583 }
584
585 for (i = 8; unlikely(bits - i > 0); i += 8) {
586 ++address;
587 if (function == ACPI_READ) {
588 result = acpi_ec_read(ec, address, &temp);
589 (*value) |= ((acpi_integer)temp) << i;
590 } else {
591 temp = 0xff & ((*value) >> i);
592 result = acpi_ec_write(ec, address, temp);
593 }
594 }
595 652
596 if (EC_FLAGS_MSI) 653 if (EC_FLAGS_MSI || bits > 8)
597 acpi_ec_burst_disable(ec); 654 acpi_ec_burst_disable(ec);
598 655
599 switch (result) { 656 switch (result) {
@@ -754,8 +811,8 @@ static int ec_install_handlers(struct acpi_ec *ec)
754 &acpi_ec_gpe_handler, ec); 811 &acpi_ec_gpe_handler, ec);
755 if (ACPI_FAILURE(status)) 812 if (ACPI_FAILURE(status))
756 return -ENODEV; 813 return -ENODEV;
757 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME); 814
758 acpi_enable_gpe(NULL, ec->gpe); 815 acpi_enable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
759 status = acpi_install_address_space_handler(ec->handle, 816 status = acpi_install_address_space_handler(ec->handle,
760 ACPI_ADR_SPACE_EC, 817 ACPI_ADR_SPACE_EC,
761 &acpi_ec_space_handler, 818 &acpi_ec_space_handler,
@@ -772,6 +829,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
772 } else { 829 } else {
773 acpi_remove_gpe_handler(NULL, ec->gpe, 830 acpi_remove_gpe_handler(NULL, ec->gpe,
774 &acpi_ec_gpe_handler); 831 &acpi_ec_gpe_handler);
832 acpi_disable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
775 return -ENODEV; 833 return -ENODEV;
776 } 834 }
777 } 835 }
@@ -782,6 +840,7 @@ static int ec_install_handlers(struct acpi_ec *ec)
782 840
783static void ec_remove_handlers(struct acpi_ec *ec) 841static void ec_remove_handlers(struct acpi_ec *ec)
784{ 842{
843 acpi_disable_gpe(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
785 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, 844 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
786 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) 845 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
787 pr_err(PREFIX "failed to remove space handler\n"); 846 pr_err(PREFIX "failed to remove space handler\n");
@@ -820,7 +879,7 @@ static int acpi_ec_add(struct acpi_device *device)
820 879
821 /* Find and register all query methods */ 880 /* Find and register all query methods */
822 acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1, 881 acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1,
823 acpi_ec_register_query_methods, ec, NULL); 882 acpi_ec_register_query_methods, NULL, ec, NULL);
824 883
825 if (!first_ec) 884 if (!first_ec)
826 first_ec = ec; 885 first_ec = ec;
@@ -916,6 +975,7 @@ static int ec_validate_ecdt(const struct dmi_system_id *id)
916/* MSI EC needs special treatment, enable it */ 975/* MSI EC needs special treatment, enable it */
917static int ec_flag_msi(const struct dmi_system_id *id) 976static int ec_flag_msi(const struct dmi_system_id *id)
918{ 977{
978 printk(KERN_DEBUG PREFIX "Detected MSI hardware, enabling workarounds.\n");
919 EC_FLAGS_MSI = 1; 979 EC_FLAGS_MSI = 1;
920 EC_FLAGS_VALIDATE_ECDT = 1; 980 EC_FLAGS_VALIDATE_ECDT = 1;
921 return 0; 981 return 0;
@@ -928,8 +988,13 @@ static struct dmi_system_id __initdata ec_dmi_table[] = {
928 DMI_MATCH(DMI_BOARD_NAME, "JFL92") }, NULL}, 988 DMI_MATCH(DMI_BOARD_NAME, "JFL92") }, NULL},
929 { 989 {
930 ec_flag_msi, "MSI hardware", { 990 ec_flag_msi, "MSI hardware", {
931 DMI_MATCH(DMI_BIOS_VENDOR, "Micro-Star"), 991 DMI_MATCH(DMI_BIOS_VENDOR, "Micro-Star")}, NULL},
932 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-Star") }, NULL}, 992 {
993 ec_flag_msi, "MSI hardware", {
994 DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star")}, NULL},
995 {
996 ec_flag_msi, "MSI hardware", {
997 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-Star")}, NULL},
933 { 998 {
934 ec_validate_ecdt, "ASUS hardware", { 999 ec_validate_ecdt, "ASUS hardware", {
935 DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL}, 1000 DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL},
@@ -1017,16 +1082,16 @@ error:
1017static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state) 1082static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
1018{ 1083{
1019 struct acpi_ec *ec = acpi_driver_data(device); 1084 struct acpi_ec *ec = acpi_driver_data(device);
1020 /* Stop using GPE */ 1085 /* Stop using the GPE, but keep it reference counted. */
1021 acpi_disable_gpe(NULL, ec->gpe); 1086 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_DISABLE);
1022 return 0; 1087 return 0;
1023} 1088}
1024 1089
1025static int acpi_ec_resume(struct acpi_device *device) 1090static int acpi_ec_resume(struct acpi_device *device)
1026{ 1091{
1027 struct acpi_ec *ec = acpi_driver_data(device); 1092 struct acpi_ec *ec = acpi_driver_data(device);
1028 /* Enable use of GPE back */ 1093 /* Enable the GPE again, but don't reference count it once more. */
1029 acpi_enable_gpe(NULL, ec->gpe); 1094 acpi_set_gpe(NULL, ec->gpe, ACPI_GPE_ENABLE);
1030 return 0; 1095 return 0;
1031} 1096}
1032 1097
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index c511071bfd79..d439314a75d8 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -10,6 +10,7 @@
10#include <linux/proc_fs.h> 10#include <linux/proc_fs.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/poll.h> 12#include <linux/poll.h>
13#include <linux/gfp.h>
13#include <acpi/acpi_drivers.h> 14#include <acpi/acpi_drivers.h>
14#include <net/netlink.h> 15#include <net/netlink.h>
15#include <net/genetlink.h> 16#include <net/genetlink.h>
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index f419849a0d3f..acf2ab249842 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -267,7 +267,7 @@ static int acpi_fan_add(struct acpi_device *device)
267 goto end; 267 goto end;
268 } 268 }
269 269
270 dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id); 270 dev_dbg(&device->dev, "registered as cooling_device%d\n", cdev->id);
271 271
272 device->driver_data = cdev; 272 device->driver_data = cdev;
273 result = sysfs_create_link(&device->dev.kobj, 273 result = sysfs_create_link(&device->dev.kobj,
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index c6645f26224b..4af6301601e7 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -9,6 +9,7 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/list.h> 10#include <linux/list.h>
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/slab.h>
12#include <linux/rwsem.h> 13#include <linux/rwsem.h>
13#include <linux/acpi.h> 14#include <linux/acpi.h>
14 15
@@ -87,7 +88,7 @@ static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
87/* Get device's handler per its address under its parent */ 88/* Get device's handler per its address under its parent */
88struct acpi_find_child { 89struct acpi_find_child {
89 acpi_handle handle; 90 acpi_handle handle;
90 acpi_integer address; 91 u64 address;
91}; 92};
92 93
93static acpi_status 94static acpi_status
@@ -106,14 +107,14 @@ do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
106 return AE_OK; 107 return AE_OK;
107} 108}
108 109
109acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address) 110acpi_handle acpi_get_child(acpi_handle parent, u64 address)
110{ 111{
111 struct acpi_find_child find = { NULL, address }; 112 struct acpi_find_child find = { NULL, address };
112 113
113 if (!parent) 114 if (!parent)
114 return NULL; 115 return NULL;
115 acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 116 acpi_walk_namespace(ACPI_TYPE_DEVICE, parent,
116 1, do_acpi_find_child, &find, NULL); 117 1, do_acpi_find_child, NULL, &find, NULL);
117 return find.handle; 118 return find.handle;
118} 119}
119 120
diff --git a/drivers/acpi/hest.c b/drivers/acpi/hest.c
new file mode 100644
index 000000000000..1c527a192872
--- /dev/null
+++ b/drivers/acpi/hest.c
@@ -0,0 +1,139 @@
1#include <linux/acpi.h>
2#include <linux/pci.h>
3
4#define PREFIX "ACPI: "
5
6static inline unsigned long parse_acpi_hest_ia_machine_check(struct acpi_hest_ia_machine_check *p)
7{
8 return sizeof(*p) +
9 (sizeof(struct acpi_hest_ia_error_bank) * p->num_hardware_banks);
10}
11
12static inline unsigned long parse_acpi_hest_ia_corrected(struct acpi_hest_ia_corrected *p)
13{
14 return sizeof(*p) +
15 (sizeof(struct acpi_hest_ia_error_bank) * p->num_hardware_banks);
16}
17
18static inline unsigned long parse_acpi_hest_ia_nmi(struct acpi_hest_ia_nmi *p)
19{
20 return sizeof(*p);
21}
22
23static inline unsigned long parse_acpi_hest_generic(struct acpi_hest_generic *p)
24{
25 return sizeof(*p);
26}
27
28static inline unsigned int hest_match_pci(struct acpi_hest_aer_common *p, struct pci_dev *pci)
29{
30 return (0 == pci_domain_nr(pci->bus) &&
31 p->bus == pci->bus->number &&
32 p->device == PCI_SLOT(pci->devfn) &&
33 p->function == PCI_FUNC(pci->devfn));
34}
35
36static unsigned long parse_acpi_hest_aer(void *hdr, int type, struct pci_dev *pci, int *firmware_first)
37{
38 struct acpi_hest_aer_common *p = hdr + sizeof(struct acpi_hest_header);
39 unsigned long rc=0;
40 u8 pcie_type = 0;
41 u8 bridge = 0;
42 switch (type) {
43 case ACPI_HEST_TYPE_AER_ROOT_PORT:
44 rc = sizeof(struct acpi_hest_aer_root);
45 pcie_type = PCI_EXP_TYPE_ROOT_PORT;
46 break;
47 case ACPI_HEST_TYPE_AER_ENDPOINT:
48 rc = sizeof(struct acpi_hest_aer);
49 pcie_type = PCI_EXP_TYPE_ENDPOINT;
50 break;
51 case ACPI_HEST_TYPE_AER_BRIDGE:
52 rc = sizeof(struct acpi_hest_aer_bridge);
53 if ((pci->class >> 16) == PCI_BASE_CLASS_BRIDGE)
54 bridge = 1;
55 break;
56 }
57
58 if (p->flags & ACPI_HEST_GLOBAL) {
59 if ((pci->is_pcie && (pci->pcie_type == pcie_type)) || bridge)
60 *firmware_first = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
61 }
62 else
63 if (hest_match_pci(p, pci))
64 *firmware_first = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
65 return rc;
66}
67
68static int acpi_hest_firmware_first(struct acpi_table_header *stdheader, struct pci_dev *pci)
69{
70 struct acpi_table_hest *hest = (struct acpi_table_hest *)stdheader;
71 void *p = (void *)hest + sizeof(*hest); /* defined by the ACPI 4.0 spec */
72 struct acpi_hest_header *hdr = p;
73
74 int i;
75 int firmware_first = 0;
76 static unsigned char printed_unused = 0;
77 static unsigned char printed_reserved = 0;
78
79 for (i=0, hdr=p; p < (((void *)hest) + hest->header.length) && i < hest->error_source_count; i++) {
80 switch (hdr->type) {
81 case ACPI_HEST_TYPE_IA32_CHECK:
82 p += parse_acpi_hest_ia_machine_check(p);
83 break;
84 case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK:
85 p += parse_acpi_hest_ia_corrected(p);
86 break;
87 case ACPI_HEST_TYPE_IA32_NMI:
88 p += parse_acpi_hest_ia_nmi(p);
89 break;
90 /* These three should never appear */
91 case ACPI_HEST_TYPE_NOT_USED3:
92 case ACPI_HEST_TYPE_NOT_USED4:
93 case ACPI_HEST_TYPE_NOT_USED5:
94 if (!printed_unused) {
95 printk(KERN_DEBUG PREFIX
96 "HEST Error Source list contains an obsolete type (%d).\n", hdr->type);
97 printed_unused = 1;
98 }
99 break;
100 case ACPI_HEST_TYPE_AER_ROOT_PORT:
101 case ACPI_HEST_TYPE_AER_ENDPOINT:
102 case ACPI_HEST_TYPE_AER_BRIDGE:
103 p += parse_acpi_hest_aer(p, hdr->type, pci, &firmware_first);
104 break;
105 case ACPI_HEST_TYPE_GENERIC_ERROR:
106 p += parse_acpi_hest_generic(p);
107 break;
108 /* These should never appear either */
109 case ACPI_HEST_TYPE_RESERVED:
110 default:
111 if (!printed_reserved) {
112 printk(KERN_DEBUG PREFIX
113 "HEST Error Source list contains a reserved type (%d).\n", hdr->type);
114 printed_reserved = 1;
115 }
116 break;
117 }
118 }
119 return firmware_first;
120}
121
122int acpi_hest_firmware_first_pci(struct pci_dev *pci)
123{
124 acpi_status status = AE_NOT_FOUND;
125 struct acpi_table_header *hest = NULL;
126
127 if (acpi_disabled)
128 return 0;
129
130 status = acpi_get_table(ACPI_SIG_HEST, 1, &hest);
131
132 if (ACPI_SUCCESS(status)) {
133 if (acpi_hest_firmware_first(hest, pci)) {
134 return 1;
135 }
136 }
137 return 0;
138}
139EXPORT_SYMBOL_GPL(acpi_hest_firmware_first_pci);
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 074cf8682d52..e28411367239 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -36,13 +36,12 @@ static inline int acpi_debug_init(void) { return 0; }
36int acpi_power_init(void); 36int acpi_power_init(void);
37int acpi_device_sleep_wake(struct acpi_device *dev, 37int acpi_device_sleep_wake(struct acpi_device *dev,
38 int enable, int sleep_state, int dev_state); 38 int enable, int sleep_state, int dev_state);
39int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state);
40int acpi_disable_wakeup_device_power(struct acpi_device *dev);
41int acpi_power_get_inferred_state(struct acpi_device *device); 39int acpi_power_get_inferred_state(struct acpi_device *device);
42int acpi_power_transition(struct acpi_device *device, int state); 40int acpi_power_transition(struct acpi_device *device, int state);
43extern int acpi_power_nocheck; 41extern int acpi_power_nocheck;
44 42
45int acpi_wakeup_device_init(void); 43int acpi_wakeup_device_init(void);
44void acpi_early_processor_set_pdc(void);
46 45
47/* -------------------------------------------------------------------------- 46/* --------------------------------------------------------------------------
48 Embedded Controller 47 Embedded Controller
@@ -50,6 +49,8 @@ int acpi_wakeup_device_init(void);
50int acpi_ec_init(void); 49int acpi_ec_init(void);
51int acpi_ec_ecdt_probe(void); 50int acpi_ec_ecdt_probe(void);
52int acpi_boot_ec_enable(void); 51int acpi_boot_ec_enable(void);
52void acpi_ec_suspend_transactions(void);
53void acpi_ec_resume_transactions(void);
53 54
54/*-------------------------------------------------------------------------- 55/*--------------------------------------------------------------------------
55 Suspend/Resume 56 Suspend/Resume
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 202dd0c976a3..b0337d314604 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -28,6 +28,7 @@
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <linux/numa.h>
31#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
32 33
33#define PREFIX "ACPI: " 34#define PREFIX "ACPI: "
@@ -40,14 +41,14 @@ static nodemask_t nodes_found_map = NODE_MASK_NONE;
40 41
41/* maps to convert between proximity domain and logical node ID */ 42/* maps to convert between proximity domain and logical node ID */
42static int pxm_to_node_map[MAX_PXM_DOMAINS] 43static int pxm_to_node_map[MAX_PXM_DOMAINS]
43 = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL }; 44 = { [0 ... MAX_PXM_DOMAINS - 1] = NUMA_NO_NODE };
44static int node_to_pxm_map[MAX_NUMNODES] 45static int node_to_pxm_map[MAX_NUMNODES]
45 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; 46 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
46 47
47int pxm_to_node(int pxm) 48int pxm_to_node(int pxm)
48{ 49{
49 if (pxm < 0) 50 if (pxm < 0)
50 return NID_INVAL; 51 return NUMA_NO_NODE;
51 return pxm_to_node_map[pxm]; 52 return pxm_to_node_map[pxm];
52} 53}
53 54
@@ -60,17 +61,19 @@ int node_to_pxm(int node)
60 61
61void __acpi_map_pxm_to_node(int pxm, int node) 62void __acpi_map_pxm_to_node(int pxm, int node)
62{ 63{
63 pxm_to_node_map[pxm] = node; 64 if (pxm_to_node_map[pxm] == NUMA_NO_NODE || node < pxm_to_node_map[pxm])
64 node_to_pxm_map[node] = pxm; 65 pxm_to_node_map[pxm] = node;
66 if (node_to_pxm_map[node] == PXM_INVAL || pxm < node_to_pxm_map[node])
67 node_to_pxm_map[node] = pxm;
65} 68}
66 69
67int acpi_map_pxm_to_node(int pxm) 70int acpi_map_pxm_to_node(int pxm)
68{ 71{
69 int node = pxm_to_node_map[pxm]; 72 int node = pxm_to_node_map[pxm];
70 73
71 if (node < 0){ 74 if (node < 0) {
72 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES) 75 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES)
73 return NID_INVAL; 76 return NUMA_NO_NODE;
74 node = first_unset_node(nodes_found_map); 77 node = first_unset_node(nodes_found_map);
75 __acpi_map_pxm_to_node(pxm, node); 78 __acpi_map_pxm_to_node(pxm, node);
76 node_set(node, nodes_found_map); 79 node_set(node, nodes_found_map);
@@ -79,16 +82,6 @@ int acpi_map_pxm_to_node(int pxm)
79 return node; 82 return node;
80} 83}
81 84
82#if 0
83void __cpuinit acpi_unmap_pxm_to_node(int node)
84{
85 int pxm = node_to_pxm_map[node];
86 pxm_to_node_map[pxm] = NID_INVAL;
87 node_to_pxm_map[node] = PXM_INVAL;
88 node_clear(node, nodes_found_map);
89}
90#endif /* 0 */
91
92static void __init 85static void __init
93acpi_table_print_srat_entry(struct acpi_subtable_header *header) 86acpi_table_print_srat_entry(struct acpi_subtable_header *header)
94{ 87{
@@ -283,22 +276,24 @@ acpi_table_parse_srat(enum acpi_srat_type id,
283 276
284int __init acpi_numa_init(void) 277int __init acpi_numa_init(void)
285{ 278{
279 int ret = 0;
280
286 /* SRAT: Static Resource Affinity Table */ 281 /* SRAT: Static Resource Affinity Table */
287 if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) { 282 if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
288 acpi_table_parse_srat(ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY, 283 acpi_table_parse_srat(ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY,
289 acpi_parse_x2apic_affinity, NR_CPUS); 284 acpi_parse_x2apic_affinity, nr_cpu_ids);
290 acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY, 285 acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY,
291 acpi_parse_processor_affinity, NR_CPUS); 286 acpi_parse_processor_affinity, nr_cpu_ids);
292 acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY, 287 ret = acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
293 acpi_parse_memory_affinity, 288 acpi_parse_memory_affinity,
294 NR_NODE_MEMBLKS); 289 NR_NODE_MEMBLKS);
295 } 290 }
296 291
297 /* SLIT: System Locality Information Table */ 292 /* SLIT: System Locality Information Table */
298 acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit); 293 acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);
299 294
300 acpi_numa_arch_fixup(); 295 acpi_numa_arch_fixup();
301 return 0; 296 return ret;
302} 297}
303 298
304int acpi_get_pxm(acpi_handle h) 299int acpi_get_pxm(acpi_handle h)
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 7c1c59ea9ec6..7594f65800cf 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -436,7 +436,7 @@ acpi_status acpi_os_remove_interrupt_handler(u32 irq, acpi_osd_handler handler)
436 * Running in interpreter thread context, safe to sleep 436 * Running in interpreter thread context, safe to sleep
437 */ 437 */
438 438
439void acpi_os_sleep(acpi_integer ms) 439void acpi_os_sleep(u64 ms)
440{ 440{
441 schedule_timeout_interruptible(msecs_to_jiffies(ms)); 441 schedule_timeout_interruptible(msecs_to_jiffies(ms));
442} 442}
@@ -603,7 +603,7 @@ acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
603 603
604acpi_status 604acpi_status
605acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, 605acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
606 acpi_integer value, u32 width) 606 u64 value, u32 width)
607{ 607{
608 int result, size; 608 int result, size;
609 609
@@ -758,7 +758,14 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
758 queue = hp ? kacpi_hotplug_wq : 758 queue = hp ? kacpi_hotplug_wq :
759 (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq); 759 (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq);
760 dpc->wait = hp ? 1 : 0; 760 dpc->wait = hp ? 1 : 0;
761 INIT_WORK(&dpc->work, acpi_os_execute_deferred); 761
762 if (queue == kacpi_hotplug_wq)
763 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
764 else if (queue == kacpi_notify_wq)
765 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
766 else
767 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
768
762 ret = queue_work(queue, &dpc->work); 769 ret = queue_work(queue, &dpc->work);
763 770
764 if (!ret) { 771 if (!ret) {
@@ -1118,7 +1125,7 @@ __setup("acpi_enforce_resources=", acpi_enforce_resources_setup);
1118 1125
1119/* Check for resource conflicts between ACPI OperationRegions and native 1126/* Check for resource conflicts between ACPI OperationRegions and native
1120 * drivers */ 1127 * drivers */
1121int acpi_check_resource_conflict(struct resource *res) 1128int acpi_check_resource_conflict(const struct resource *res)
1122{ 1129{
1123 struct acpi_res_list *res_list_elem; 1130 struct acpi_res_list *res_list_elem;
1124 int ioport; 1131 int ioport;
@@ -1151,16 +1158,10 @@ int acpi_check_resource_conflict(struct resource *res)
1151 1158
1152 if (clash) { 1159 if (clash) {
1153 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { 1160 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) {
1154 printk("%sACPI: %s resource %s [0x%llx-0x%llx]" 1161 printk(KERN_WARNING "ACPI: resource %s %pR"
1155 " conflicts with ACPI region %s" 1162 " conflicts with ACPI region %s %pR\n",
1156 " [0x%llx-0x%llx]\n", 1163 res->name, res, res_list_elem->name,
1157 acpi_enforce_resources == ENFORCE_RESOURCES_LAX 1164 res_list_elem);
1158 ? KERN_WARNING : KERN_ERR,
1159 ioport ? "I/O" : "Memory", res->name,
1160 (long long) res->start, (long long) res->end,
1161 res_list_elem->name,
1162 (long long) res_list_elem->start,
1163 (long long) res_list_elem->end);
1164 if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX) 1165 if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX)
1165 printk(KERN_NOTICE "ACPI: This conflict may" 1166 printk(KERN_NOTICE "ACPI: This conflict may"
1166 " cause random problems and system" 1167 " cause random problems and system"
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index a5a77b78a723..2ef04098cc1d 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -26,7 +26,9 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/pci-acpi.h>
29#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <linux/pm_runtime.h>
30#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h> 33#include <acpi/acpi_drivers.h>
32 34
@@ -38,7 +40,13 @@ static int acpi_pci_unbind(struct acpi_device *device)
38 struct pci_dev *dev; 40 struct pci_dev *dev;
39 41
40 dev = acpi_get_pci_dev(device->handle); 42 dev = acpi_get_pci_dev(device->handle);
41 if (!dev || !dev->subordinate) 43 if (!dev)
44 goto out;
45
46 device_set_run_wake(&dev->dev, false);
47 pci_acpi_remove_pm_notifier(device);
48
49 if (!dev->subordinate)
42 goto out; 50 goto out;
43 51
44 acpi_pci_irq_del_prt(dev->subordinate); 52 acpi_pci_irq_del_prt(dev->subordinate);
@@ -62,6 +70,10 @@ static int acpi_pci_bind(struct acpi_device *device)
62 if (!dev) 70 if (!dev)
63 return 0; 71 return 0;
64 72
73 pci_acpi_add_pm_notifier(device, dev);
74 if (device->wakeup.flags.run_wake)
75 device_set_run_wake(&dev->dev, true);
76
65 /* 77 /*
66 * Install the 'bind' function to facilitate callbacks for 78 * Install the 'bind' function to facilitate callbacks for
67 * children of the P2P bridge. 79 * children of the P2P bridge.
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 843699ed93f2..b0a71ecee682 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -37,6 +37,7 @@
37#include <linux/pm.h> 37#include <linux/pm.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/acpi.h> 39#include <linux/acpi.h>
40#include <linux/slab.h>
40#include <acpi/acpi_bus.h> 41#include <acpi/acpi_bus.h>
41#include <acpi/acpi_drivers.h> 42#include <acpi/acpi_drivers.h>
42 43
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 394ae89409c2..8d47a5846aeb 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -39,6 +39,7 @@
39#include <linux/pm.h> 39#include <linux/pm.h>
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/mutex.h> 41#include <linux/mutex.h>
42#include <linux/slab.h>
42 43
43#include <acpi/acpi_bus.h> 44#include <acpi/acpi_bus.h>
44#include <acpi/acpi_drivers.h> 45#include <acpi/acpi_drivers.h>
@@ -56,7 +57,7 @@ ACPI_MODULE_NAME("pci_link");
56static int acpi_pci_link_add(struct acpi_device *device); 57static int acpi_pci_link_add(struct acpi_device *device);
57static int acpi_pci_link_remove(struct acpi_device *device, int type); 58static int acpi_pci_link_remove(struct acpi_device *device, int type);
58 59
59static struct acpi_device_id link_device_ids[] = { 60static const struct acpi_device_id link_device_ids[] = {
60 {"PNP0C0F", 0}, 61 {"PNP0C0F", 0},
61 {"", 0}, 62 {"", 0},
62}; 63};
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 1af808171d46..aefce33f2a09 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -30,9 +30,11 @@
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/pm.h> 32#include <linux/pm.h>
33#include <linux/pm_runtime.h>
33#include <linux/pci.h> 34#include <linux/pci.h>
34#include <linux/pci-acpi.h> 35#include <linux/pci-acpi.h>
35#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/slab.h>
36#include <acpi/acpi_bus.h> 38#include <acpi/acpi_bus.h>
37#include <acpi/acpi_drivers.h> 39#include <acpi/acpi_drivers.h>
38 40
@@ -46,7 +48,7 @@ static int acpi_pci_root_add(struct acpi_device *device);
46static int acpi_pci_root_remove(struct acpi_device *device, int type); 48static int acpi_pci_root_remove(struct acpi_device *device, int type);
47static int acpi_pci_root_start(struct acpi_device *device); 49static int acpi_pci_root_start(struct acpi_device *device);
48 50
49static struct acpi_device_id root_device_ids[] = { 51static const struct acpi_device_id root_device_ids[] = {
50 {"PNP0A03", 0}, 52 {"PNP0A03", 0},
51 {"", 0}, 53 {"", 0},
52}; 54};
@@ -202,72 +204,24 @@ static void acpi_pci_bridge_scan(struct acpi_device *device)
202 } 204 }
203} 205}
204 206
205static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 207static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
206 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
207 208
208static acpi_status acpi_pci_run_osc(acpi_handle handle, 209static acpi_status acpi_pci_run_osc(acpi_handle handle,
209 const u32 *capbuf, u32 *retval) 210 const u32 *capbuf, u32 *retval)
210{ 211{
212 struct acpi_osc_context context = {
213 .uuid_str = pci_osc_uuid_str,
214 .rev = 1,
215 .cap.length = 12,
216 .cap.pointer = (void *)capbuf,
217 };
211 acpi_status status; 218 acpi_status status;
212 struct acpi_object_list input;
213 union acpi_object in_params[4];
214 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
215 union acpi_object *out_obj;
216 u32 errors;
217
218 /* Setting up input parameters */
219 input.count = 4;
220 input.pointer = in_params;
221 in_params[0].type = ACPI_TYPE_BUFFER;
222 in_params[0].buffer.length = 16;
223 in_params[0].buffer.pointer = OSC_UUID;
224 in_params[1].type = ACPI_TYPE_INTEGER;
225 in_params[1].integer.value = 1;
226 in_params[2].type = ACPI_TYPE_INTEGER;
227 in_params[2].integer.value = 3;
228 in_params[3].type = ACPI_TYPE_BUFFER;
229 in_params[3].buffer.length = 12;
230 in_params[3].buffer.pointer = (u8 *)capbuf;
231
232 status = acpi_evaluate_object(handle, "_OSC", &input, &output);
233 if (ACPI_FAILURE(status))
234 return status;
235
236 if (!output.length)
237 return AE_NULL_OBJECT;
238 219
239 out_obj = output.pointer; 220 status = acpi_run_osc(handle, &context);
240 if (out_obj->type != ACPI_TYPE_BUFFER) { 221 if (ACPI_SUCCESS(status)) {
241 printk(KERN_DEBUG "_OSC evaluation returned wrong type\n"); 222 *retval = *((u32 *)(context.ret.pointer + 8));
242 status = AE_TYPE; 223 kfree(context.ret.pointer);
243 goto out_kfree;
244 }
245 /* Need to ignore the bit0 in result code */
246 errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
247 if (errors) {
248 if (errors & OSC_REQUEST_ERROR)
249 printk(KERN_DEBUG "_OSC request failed\n");
250 if (errors & OSC_INVALID_UUID_ERROR)
251 printk(KERN_DEBUG "_OSC invalid UUID\n");
252 if (errors & OSC_INVALID_REVISION_ERROR)
253 printk(KERN_DEBUG "_OSC invalid revision\n");
254 if (errors & OSC_CAPABILITIES_MASK_ERROR) {
255 if (capbuf[OSC_QUERY_TYPE] & OSC_QUERY_ENABLE)
256 goto out_success;
257 printk(KERN_DEBUG
258 "Firmware did not grant requested _OSC control\n");
259 status = AE_SUPPORT;
260 goto out_kfree;
261 }
262 status = AE_ERROR;
263 goto out_kfree;
264 } 224 }
265out_success:
266 *retval = *((u32 *)(out_obj->buffer.pointer + 8));
267 status = AE_OK;
268
269out_kfree:
270 kfree(output.pointer);
271 return status; 225 return status;
272} 226}
273 227
@@ -277,10 +231,10 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root, u32 flags)
277 u32 support_set, result, capbuf[3]; 231 u32 support_set, result, capbuf[3];
278 232
279 /* do _OSC query for all possible controls */ 233 /* do _OSC query for all possible controls */
280 support_set = root->osc_support_set | (flags & OSC_SUPPORT_MASKS); 234 support_set = root->osc_support_set | (flags & OSC_PCI_SUPPORT_MASKS);
281 capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; 235 capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
282 capbuf[OSC_SUPPORT_TYPE] = support_set; 236 capbuf[OSC_SUPPORT_TYPE] = support_set;
283 capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; 237 capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS;
284 238
285 status = acpi_pci_run_osc(root->device->handle, capbuf, &result); 239 status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
286 if (ACPI_SUCCESS(status)) { 240 if (ACPI_SUCCESS(status)) {
@@ -427,7 +381,7 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 flags)
427 if (ACPI_FAILURE(status)) 381 if (ACPI_FAILURE(status))
428 return status; 382 return status;
429 383
430 control_req = (flags & OSC_CONTROL_MASKS); 384 control_req = (flags & OSC_PCI_CONTROL_MASKS);
431 if (!control_req) 385 if (!control_req)
432 return AE_TYPE; 386 return AE_TYPE;
433 387
@@ -576,6 +530,10 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
576 if (flags != base_flags) 530 if (flags != base_flags)
577 acpi_pci_osc_support(root, flags); 531 acpi_pci_osc_support(root, flags);
578 532
533 pci_acpi_add_bus_pm_notifier(device, root->bus);
534 if (device->wakeup.flags.run_wake)
535 device_set_run_wake(root->bus->bridge, true);
536
579 return 0; 537 return 0;
580 538
581end: 539end:
@@ -597,6 +555,9 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
597{ 555{
598 struct acpi_pci_root *root = acpi_driver_data(device); 556 struct acpi_pci_root *root = acpi_driver_data(device);
599 557
558 device_set_run_wake(root->bus->bridge, false);
559 pci_acpi_remove_bus_pm_notifier(device);
560
600 kfree(root); 561 kfree(root);
601 return 0; 562 return 0;
602} 563}
@@ -606,6 +567,7 @@ static int __init acpi_pci_root_init(void)
606 if (acpi_pci_disabled) 567 if (acpi_pci_disabled)
607 return 0; 568 return 0;
608 569
570 pci_acpi_crs_quirks();
609 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) 571 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
610 return -ENODEV; 572 return -ENODEV;
611 573
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index 45da2bae36c8..07f7fea8a4e2 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h>
29#include <linux/types.h> 30#include <linux/types.h>
30#include <linux/pci.h> 31#include <linux/pci.h>
31#include <linux/acpi.h> 32#include <linux/acpi.h>
@@ -219,12 +220,12 @@ walk_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
219 220
220 dbg("p2p bridge walk, pci_bus = %x\n", dev->subordinate->number); 221 dbg("p2p bridge walk, pci_bus = %x\n", dev->subordinate->number);
221 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, 222 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
222 user_function, &child_context, NULL); 223 user_function, NULL, &child_context, NULL);
223 if (ACPI_FAILURE(status)) 224 if (ACPI_FAILURE(status))
224 goto out; 225 goto out;
225 226
226 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, 227 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
227 walk_p2p_bridge, &child_context, NULL); 228 walk_p2p_bridge, NULL, &child_context, NULL);
228out: 229out:
229 pci_dev_put(dev); 230 pci_dev_put(dev);
230 return AE_OK; 231 return AE_OK;
@@ -277,12 +278,12 @@ walk_root_bridge(acpi_handle handle, acpi_walk_callback user_function)
277 278
278 dbg("root bridge walk, pci_bus = %x\n", pci_bus->number); 279 dbg("root bridge walk, pci_bus = %x\n", pci_bus->number);
279 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, 280 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
280 user_function, &context, NULL); 281 user_function, NULL, &context, NULL);
281 if (ACPI_FAILURE(status)) 282 if (ACPI_FAILURE(status))
282 return status; 283 return status;
283 284
284 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, 285 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
285 walk_p2p_bridge, &context, NULL); 286 walk_p2p_bridge, NULL, &context, NULL);
286 if (ACPI_FAILURE(status)) 287 if (ACPI_FAILURE(status))
287 err("%s: walk_p2p_bridge failure - %d\n", __func__, status); 288 err("%s: walk_p2p_bridge failure - %d\n", __func__, status);
288 289
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 22b297916519..ddc76787b842 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -39,6 +39,7 @@
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/types.h> 41#include <linux/types.h>
42#include <linux/slab.h>
42#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
43#include <linux/seq_file.h> 44#include <linux/seq_file.h>
44#include <acpi/acpi_bus.h> 45#include <acpi/acpi_bus.h>
@@ -65,7 +66,7 @@ static int acpi_power_remove(struct acpi_device *device, int type);
65static int acpi_power_resume(struct acpi_device *device); 66static int acpi_power_resume(struct acpi_device *device);
66static int acpi_power_open_fs(struct inode *inode, struct file *file); 67static int acpi_power_open_fs(struct inode *inode, struct file *file);
67 68
68static struct acpi_device_id power_device_ids[] = { 69static const struct acpi_device_id power_device_ids[] = {
69 {ACPI_POWER_HID, 0}, 70 {ACPI_POWER_HID, 0},
70 {"", 0}, 71 {"", 0},
71}; 72};
diff --git a/drivers/acpi/power_meter.c b/drivers/acpi/power_meter.c
index 2ef7030a0c28..66f67293341e 100644
--- a/drivers/acpi/power_meter.c
+++ b/drivers/acpi/power_meter.c
@@ -25,6 +25,7 @@
25#include <linux/jiffies.h> 25#include <linux/jiffies.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/dmi.h> 27#include <linux/dmi.h>
28#include <linux/slab.h>
28#include <linux/kdev_t.h> 29#include <linux/kdev_t.h>
29#include <linux/sched.h> 30#include <linux/sched.h>
30#include <linux/time.h> 31#include <linux/time.h>
@@ -34,7 +35,7 @@
34#define ACPI_POWER_METER_NAME "power_meter" 35#define ACPI_POWER_METER_NAME "power_meter"
35ACPI_MODULE_NAME(ACPI_POWER_METER_NAME); 36ACPI_MODULE_NAME(ACPI_POWER_METER_NAME);
36#define ACPI_POWER_METER_DEVICE_NAME "Power Meter" 37#define ACPI_POWER_METER_DEVICE_NAME "Power Meter"
37#define ACPI_POWER_METER_CLASS "power_meter_resource" 38#define ACPI_POWER_METER_CLASS "pwr_meter_resource"
38 39
39#define NUM_SENSORS 17 40#define NUM_SENSORS 17
40 41
@@ -64,24 +65,24 @@ static int can_cap_in_hardware(void)
64 return force_cap_on || cap_in_hardware; 65 return force_cap_on || cap_in_hardware;
65} 66}
66 67
67static struct acpi_device_id power_meter_ids[] = { 68static const struct acpi_device_id power_meter_ids[] = {
68 {"ACPI000D", 0}, 69 {"ACPI000D", 0},
69 {"", 0}, 70 {"", 0},
70}; 71};
71MODULE_DEVICE_TABLE(acpi, power_meter_ids); 72MODULE_DEVICE_TABLE(acpi, power_meter_ids);
72 73
73struct acpi_power_meter_capabilities { 74struct acpi_power_meter_capabilities {
74 acpi_integer flags; 75 u64 flags;
75 acpi_integer units; 76 u64 units;
76 acpi_integer type; 77 u64 type;
77 acpi_integer accuracy; 78 u64 accuracy;
78 acpi_integer sampling_time; 79 u64 sampling_time;
79 acpi_integer min_avg_interval; 80 u64 min_avg_interval;
80 acpi_integer max_avg_interval; 81 u64 max_avg_interval;
81 acpi_integer hysteresis; 82 u64 hysteresis;
82 acpi_integer configurable_cap; 83 u64 configurable_cap;
83 acpi_integer min_cap; 84 u64 min_cap;
84 acpi_integer max_cap; 85 u64 max_cap;
85}; 86};
86 87
87struct acpi_power_meter_resource { 88struct acpi_power_meter_resource {
@@ -93,9 +94,9 @@ struct acpi_power_meter_resource {
93 acpi_string model_number; 94 acpi_string model_number;
94 acpi_string serial_number; 95 acpi_string serial_number;
95 acpi_string oem_info; 96 acpi_string oem_info;
96 acpi_integer power; 97 u64 power;
97 acpi_integer cap; 98 u64 cap;
98 acpi_integer avg_interval; 99 u64 avg_interval;
99 int sensors_valid; 100 int sensors_valid;
100 unsigned long sensors_last_updated; 101 unsigned long sensors_last_updated;
101 struct sensor_device_attribute sensors[NUM_SENSORS]; 102 struct sensor_device_attribute sensors[NUM_SENSORS];
@@ -402,7 +403,7 @@ static ssize_t show_val(struct device *dev,
402 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 403 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
403 struct acpi_device *acpi_dev = to_acpi_device(dev); 404 struct acpi_device *acpi_dev = to_acpi_device(dev);
404 struct acpi_power_meter_resource *resource = acpi_dev->driver_data; 405 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
405 acpi_integer val = 0; 406 u64 val = 0;
406 407
407 switch (attr->index) { 408 switch (attr->index) {
408 case 0: 409 case 0:
@@ -534,6 +535,7 @@ static void remove_domain_devices(struct acpi_power_meter_resource *resource)
534 535
535 kfree(resource->domain_devices); 536 kfree(resource->domain_devices);
536 kobject_put(resource->holders_dir); 537 kobject_put(resource->holders_dir);
538 resource->num_domain_devices = 0;
537} 539}
538 540
539static int read_domain_devices(struct acpi_power_meter_resource *resource) 541static int read_domain_devices(struct acpi_power_meter_resource *resource)
@@ -740,7 +742,6 @@ skip_unsafe_cap:
740 742
741 return res; 743 return res;
742error: 744error:
743 remove_domain_devices(resource);
744 remove_attrs(resource); 745 remove_attrs(resource);
745 return res; 746 return res;
746} 747}
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index d0d25e2e1ced..1ac678d2c51c 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -435,7 +435,7 @@ acpi_system_write_wakeup_device(struct file *file,
435 found_dev->wakeup.gpe_device)) { 435 found_dev->wakeup.gpe_device)) {
436 printk(KERN_WARNING 436 printk(KERN_WARNING
437 "ACPI: '%s' and '%s' have the same GPE, " 437 "ACPI: '%s' and '%s' have the same GPE, "
438 "can't disable/enable one seperately\n", 438 "can't disable/enable one separately\n",
439 dev->pnp.bus_id, found_dev->pnp.bus_id); 439 dev->pnp.bus_id, found_dev->pnp.bus_id);
440 dev->wakeup.state.enabled = 440 dev->wakeup.state.enabled =
441 found_dev->wakeup.state.enabled; 441 found_dev->wakeup.state.enabled;
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index ec742a4e5635..51284351418f 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -1,129 +1,24 @@
1/* 1/*
2 * acpi_processor.c - ACPI Processor Driver ($Revision: 71 $) 2 * Copyright (C) 2005 Intel Corporation
3 * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
3 * 4 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 5 * Alex Chiang <achiang@hp.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 6 * - Unified x86/ia64 implementations
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> 7 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 8 * - Added _PDC for platforms with Intel CPUs
8 * - Added processor hotplug support
9 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 * TBD:
28 * 1. Make # power states dynamic.
29 * 2. Support duty_cycle values that span bit 4.
30 * 3. Optimize by having scheduler determine business instead of
31 * having us try to calculate it here.
32 * 4. Need C1 timing -- must modify kernel (IRQ handler) to get this.
33 */ 9 */
34
35#include <linux/kernel.h>
36#include <linux/module.h>
37#include <linux/init.h>
38#include <linux/types.h>
39#include <linux/pci.h>
40#include <linux/pm.h>
41#include <linux/cpufreq.h>
42#include <linux/cpu.h>
43#include <linux/proc_fs.h>
44#include <linux/seq_file.h>
45#include <linux/dmi.h> 10#include <linux/dmi.h>
46#include <linux/moduleparam.h> 11#include <linux/slab.h>
47#include <linux/cpuidle.h>
48 12
49#include <asm/io.h>
50#include <asm/system.h>
51#include <asm/cpu.h>
52#include <asm/delay.h>
53#include <asm/uaccess.h>
54#include <asm/processor.h>
55#include <asm/smp.h>
56#include <asm/acpi.h>
57
58#include <acpi/acpi_bus.h>
59#include <acpi/acpi_drivers.h> 13#include <acpi/acpi_drivers.h>
60#include <acpi/processor.h> 14#include <acpi/processor.h>
61 15
62#define PREFIX "ACPI: " 16#include "internal.h"
63
64#define ACPI_PROCESSOR_CLASS "processor"
65#define ACPI_PROCESSOR_DEVICE_NAME "Processor"
66#define ACPI_PROCESSOR_FILE_INFO "info"
67#define ACPI_PROCESSOR_FILE_THROTTLING "throttling"
68#define ACPI_PROCESSOR_FILE_LIMIT "limit"
69#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
70#define ACPI_PROCESSOR_NOTIFY_POWER 0x81
71#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
72
73#define ACPI_PROCESSOR_LIMIT_USER 0
74#define ACPI_PROCESSOR_LIMIT_THERMAL 1
75 17
18#define PREFIX "ACPI: "
76#define _COMPONENT ACPI_PROCESSOR_COMPONENT 19#define _COMPONENT ACPI_PROCESSOR_COMPONENT
77ACPI_MODULE_NAME("processor_core"); 20ACPI_MODULE_NAME("processor_core");
78 21
79MODULE_AUTHOR("Paul Diefenbaugh");
80MODULE_DESCRIPTION("ACPI Processor Driver");
81MODULE_LICENSE("GPL");
82
83static int acpi_processor_add(struct acpi_device *device);
84static int acpi_processor_remove(struct acpi_device *device, int type);
85#ifdef CONFIG_ACPI_PROCFS
86static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
87#endif
88static void acpi_processor_notify(struct acpi_device *device, u32 event);
89static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
90static int acpi_processor_handle_eject(struct acpi_processor *pr);
91
92
93static const struct acpi_device_id processor_device_ids[] = {
94 {ACPI_PROCESSOR_OBJECT_HID, 0},
95 {"ACPI0007", 0},
96 {"", 0},
97};
98MODULE_DEVICE_TABLE(acpi, processor_device_ids);
99
100static struct acpi_driver acpi_processor_driver = {
101 .name = "processor",
102 .class = ACPI_PROCESSOR_CLASS,
103 .ids = processor_device_ids,
104 .ops = {
105 .add = acpi_processor_add,
106 .remove = acpi_processor_remove,
107 .suspend = acpi_processor_suspend,
108 .resume = acpi_processor_resume,
109 .notify = acpi_processor_notify,
110 },
111};
112
113#define INSTALL_NOTIFY_HANDLER 1
114#define UNINSTALL_NOTIFY_HANDLER 2
115#ifdef CONFIG_ACPI_PROCFS
116static const struct file_operations acpi_processor_info_fops = {
117 .owner = THIS_MODULE,
118 .open = acpi_processor_info_open_fs,
119 .read = seq_read,
120 .llseek = seq_lseek,
121 .release = single_release,
122};
123#endif
124
125DEFINE_PER_CPU(struct acpi_processor *, processors);
126struct acpi_processor_errata errata __read_mostly;
127static int set_no_mwait(const struct dmi_system_id *id) 22static int set_no_mwait(const struct dmi_system_id *id)
128{ 23{
129 printk(KERN_NOTICE PREFIX "%s detected - " 24 printk(KERN_NOTICE PREFIX "%s detected - "
@@ -148,296 +43,21 @@ static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
148 {}, 43 {},
149}; 44};
150 45
151/* -------------------------------------------------------------------------- 46#ifdef CONFIG_SMP
152 Errata Handling
153 -------------------------------------------------------------------------- */
154
155static int acpi_processor_errata_piix4(struct pci_dev *dev)
156{
157 u8 value1 = 0;
158 u8 value2 = 0;
159
160
161 if (!dev)
162 return -EINVAL;
163
164 /*
165 * Note that 'dev' references the PIIX4 ACPI Controller.
166 */
167
168 switch (dev->revision) {
169 case 0:
170 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n"));
171 break;
172 case 1:
173 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n"));
174 break;
175 case 2:
176 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n"));
177 break;
178 case 3:
179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n"));
180 break;
181 default:
182 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n"));
183 break;
184 }
185
186 switch (dev->revision) {
187
188 case 0: /* PIIX4 A-step */
189 case 1: /* PIIX4 B-step */
190 /*
191 * See specification changes #13 ("Manual Throttle Duty Cycle")
192 * and #14 ("Enabling and Disabling Manual Throttle"), plus
193 * erratum #5 ("STPCLK# Deassertion Time") from the January
194 * 2002 PIIX4 specification update. Applies to only older
195 * PIIX4 models.
196 */
197 errata.piix4.throttle = 1;
198
199 case 2: /* PIIX4E */
200 case 3: /* PIIX4M */
201 /*
202 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA
203 * Livelock") from the January 2002 PIIX4 specification update.
204 * Applies to all PIIX4 models.
205 */
206
207 /*
208 * BM-IDE
209 * ------
210 * Find the PIIX4 IDE Controller and get the Bus Master IDE
211 * Status register address. We'll use this later to read
212 * each IDE controller's DMA status to make sure we catch all
213 * DMA activity.
214 */
215 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
216 PCI_DEVICE_ID_INTEL_82371AB,
217 PCI_ANY_ID, PCI_ANY_ID, NULL);
218 if (dev) {
219 errata.piix4.bmisx = pci_resource_start(dev, 4);
220 pci_dev_put(dev);
221 }
222
223 /*
224 * Type-F DMA
225 * ----------
226 * Find the PIIX4 ISA Controller and read the Motherboard
227 * DMA controller's status to see if Type-F (Fast) DMA mode
228 * is enabled (bit 7) on either channel. Note that we'll
229 * disable C3 support if this is enabled, as some legacy
230 * devices won't operate well if fast DMA is disabled.
231 */
232 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
233 PCI_DEVICE_ID_INTEL_82371AB_0,
234 PCI_ANY_ID, PCI_ANY_ID, NULL);
235 if (dev) {
236 pci_read_config_byte(dev, 0x76, &value1);
237 pci_read_config_byte(dev, 0x77, &value2);
238 if ((value1 & 0x80) || (value2 & 0x80))
239 errata.piix4.fdma = 1;
240 pci_dev_put(dev);
241 }
242
243 break;
244 }
245
246 if (errata.piix4.bmisx)
247 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
248 "Bus master activity detection (BM-IDE) erratum enabled\n"));
249 if (errata.piix4.fdma)
250 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
251 "Type-F DMA livelock erratum (C3 disabled)\n"));
252
253 return 0;
254}
255
256static int acpi_processor_errata(struct acpi_processor *pr)
257{
258 int result = 0;
259 struct pci_dev *dev = NULL;
260
261
262 if (!pr)
263 return -EINVAL;
264
265 /*
266 * PIIX4
267 */
268 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
269 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
270 PCI_ANY_ID, NULL);
271 if (dev) {
272 result = acpi_processor_errata_piix4(dev);
273 pci_dev_put(dev);
274 }
275
276 return result;
277}
278
279/* --------------------------------------------------------------------------
280 Common ACPI processor functions
281 -------------------------------------------------------------------------- */
282
283/*
284 * _PDC is required for a BIOS-OS handshake for most of the newer
285 * ACPI processor features.
286 */
287static int acpi_processor_set_pdc(struct acpi_processor *pr)
288{
289 struct acpi_object_list *pdc_in = pr->pdc;
290 acpi_status status = AE_OK;
291
292
293 if (!pdc_in)
294 return status;
295 if (idle_nomwait) {
296 /*
297 * If mwait is disabled for CPU C-states, the C2C3_FFH access
298 * mode will be disabled in the parameter of _PDC object.
299 * Of course C1_FFH access mode will also be disabled.
300 */
301 union acpi_object *obj;
302 u32 *buffer = NULL;
303
304 obj = pdc_in->pointer;
305 buffer = (u32 *)(obj->buffer.pointer);
306 buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
307
308 }
309 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
310
311 if (ACPI_FAILURE(status))
312 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
313 "Could not evaluate _PDC, using legacy perf. control...\n"));
314
315 return status;
316}
317
318/* --------------------------------------------------------------------------
319 FS Interface (/proc)
320 -------------------------------------------------------------------------- */
321
322#ifdef CONFIG_ACPI_PROCFS
323static struct proc_dir_entry *acpi_processor_dir = NULL;
324
325static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
326{
327 struct acpi_processor *pr = seq->private;
328
329
330 if (!pr)
331 goto end;
332
333 seq_printf(seq, "processor id: %d\n"
334 "acpi id: %d\n"
335 "bus mastering control: %s\n"
336 "power management: %s\n"
337 "throttling control: %s\n"
338 "limit interface: %s\n",
339 pr->id,
340 pr->acpi_id,
341 pr->flags.bm_control ? "yes" : "no",
342 pr->flags.power ? "yes" : "no",
343 pr->flags.throttling ? "yes" : "no",
344 pr->flags.limit ? "yes" : "no");
345
346 end:
347 return 0;
348}
349
350static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
351{
352 return single_open(file, acpi_processor_info_seq_show,
353 PDE(inode)->data);
354}
355
356static int acpi_processor_add_fs(struct acpi_device *device)
357{
358 struct proc_dir_entry *entry = NULL;
359
360
361 if (!acpi_device_dir(device)) {
362 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
363 acpi_processor_dir);
364 if (!acpi_device_dir(device))
365 return -ENODEV;
366 }
367
368 /* 'info' [R] */
369 entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO,
370 S_IRUGO, acpi_device_dir(device),
371 &acpi_processor_info_fops,
372 acpi_driver_data(device));
373 if (!entry)
374 return -EIO;
375
376 /* 'throttling' [R/W] */
377 entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING,
378 S_IFREG | S_IRUGO | S_IWUSR,
379 acpi_device_dir(device),
380 &acpi_processor_throttling_fops,
381 acpi_driver_data(device));
382 if (!entry)
383 return -EIO;
384
385 /* 'limit' [R/W] */
386 entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT,
387 S_IFREG | S_IRUGO | S_IWUSR,
388 acpi_device_dir(device),
389 &acpi_processor_limit_fops,
390 acpi_driver_data(device));
391 if (!entry)
392 return -EIO;
393 return 0;
394}
395static int acpi_processor_remove_fs(struct acpi_device *device)
396{
397
398 if (acpi_device_dir(device)) {
399 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
400 acpi_device_dir(device));
401 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
402 acpi_device_dir(device));
403 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
404 acpi_device_dir(device));
405 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
406 acpi_device_dir(device) = NULL;
407 }
408
409 return 0;
410}
411#else
412static inline int acpi_processor_add_fs(struct acpi_device *device)
413{
414 return 0;
415}
416static inline int acpi_processor_remove_fs(struct acpi_device *device)
417{
418 return 0;
419}
420#endif
421
422/* Use the acpiid in MADT to map cpus in case of SMP */
423
424#ifndef CONFIG_SMP
425static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) { return -1; }
426#else
427
428static struct acpi_table_madt *madt;
429
430static int map_lapic_id(struct acpi_subtable_header *entry, 47static int map_lapic_id(struct acpi_subtable_header *entry,
431 u32 acpi_id, int *apic_id) 48 u32 acpi_id, int *apic_id)
432{ 49{
433 struct acpi_madt_local_apic *lapic = 50 struct acpi_madt_local_apic *lapic =
434 (struct acpi_madt_local_apic *)entry; 51 (struct acpi_madt_local_apic *)entry;
435 if ((lapic->lapic_flags & ACPI_MADT_ENABLED) && 52
436 lapic->processor_id == acpi_id) { 53 if (!(lapic->lapic_flags & ACPI_MADT_ENABLED))
437 *apic_id = lapic->id; 54 return 0;
438 return 1; 55
439 } 56 if (lapic->processor_id != acpi_id)
440 return 0; 57 return 0;
58
59 *apic_id = lapic->id;
60 return 1;
441} 61}
442 62
443static int map_x2apic_id(struct acpi_subtable_header *entry, 63static int map_x2apic_id(struct acpi_subtable_header *entry,
@@ -445,22 +65,16 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
445{ 65{
446 struct acpi_madt_local_x2apic *apic = 66 struct acpi_madt_local_x2apic *apic =
447 (struct acpi_madt_local_x2apic *)entry; 67 (struct acpi_madt_local_x2apic *)entry;
448 u32 tmp = apic->local_apic_id;
449 68
450 /* Only check enabled APICs*/
451 if (!(apic->lapic_flags & ACPI_MADT_ENABLED)) 69 if (!(apic->lapic_flags & ACPI_MADT_ENABLED))
452 return 0; 70 return 0;
453 71
454 /* Device statement declaration type */ 72 if (device_declaration && (apic->uid == acpi_id)) {
455 if (device_declaration) { 73 *apic_id = apic->local_apic_id;
456 if (apic->uid == acpi_id) 74 return 1;
457 goto found;
458 } 75 }
459 76
460 return 0; 77 return 0;
461found:
462 *apic_id = tmp;
463 return 1;
464} 78}
465 79
466static int map_lsapic_id(struct acpi_subtable_header *entry, 80static int map_lsapic_id(struct acpi_subtable_header *entry,
@@ -468,35 +82,34 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
468{ 82{
469 struct acpi_madt_local_sapic *lsapic = 83 struct acpi_madt_local_sapic *lsapic =
470 (struct acpi_madt_local_sapic *)entry; 84 (struct acpi_madt_local_sapic *)entry;
471 u32 tmp = (lsapic->id << 8) | lsapic->eid;
472 85
473 /* Only check enabled APICs*/
474 if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) 86 if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
475 return 0; 87 return 0;
476 88
477 /* Device statement declaration type */
478 if (device_declaration) { 89 if (device_declaration) {
479 if (entry->length < 16) 90 if ((entry->length < 16) || (lsapic->uid != acpi_id))
480 printk(KERN_ERR PREFIX 91 return 0;
481 "Invalid LSAPIC with Device type processor (SAPIC ID %#x)\n", 92 } else if (lsapic->processor_id != acpi_id)
482 tmp); 93 return 0;
483 else if (lsapic->uid == acpi_id)
484 goto found;
485 /* Processor statement declaration type */
486 } else if (lsapic->processor_id == acpi_id)
487 goto found;
488 94
489 return 0; 95 *apic_id = (lsapic->id << 8) | lsapic->eid;
490found:
491 *apic_id = tmp;
492 return 1; 96 return 1;
493} 97}
494 98
495static int map_madt_entry(int type, u32 acpi_id) 99static int map_madt_entry(int type, u32 acpi_id)
496{ 100{
497 unsigned long madt_end, entry; 101 unsigned long madt_end, entry;
102 static struct acpi_table_madt *madt;
103 static int read_madt;
498 int apic_id = -1; 104 int apic_id = -1;
499 105
106 if (!read_madt) {
107 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0,
108 (struct acpi_table_header **)&madt)))
109 madt = NULL;
110 read_madt++;
111 }
112
500 if (!madt) 113 if (!madt)
501 return apic_id; 114 return apic_id;
502 115
@@ -556,7 +169,7 @@ exit:
556 return apic_id; 169 return apic_id;
557} 170}
558 171
559static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) 172int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
560{ 173{
561 int i; 174 int i;
562 int apic_id = -1; 175 int apic_id = -1;
@@ -573,637 +186,170 @@ static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id)
573 } 186 }
574 return -1; 187 return -1;
575} 188}
189EXPORT_SYMBOL_GPL(acpi_get_cpuid);
576#endif 190#endif
577 191
578/* -------------------------------------------------------------------------- 192static bool processor_physically_present(acpi_handle handle)
579 Driver Interface
580 -------------------------------------------------------------------------- */
581
582static int acpi_processor_get_info(struct acpi_device *device)
583{ 193{
584 acpi_status status = 0; 194 int cpuid, type;
195 u32 acpi_id;
196 acpi_status status;
197 acpi_object_type acpi_type;
198 unsigned long long tmp;
585 union acpi_object object = { 0 }; 199 union acpi_object object = { 0 };
586 struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 200 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
587 struct acpi_processor *pr;
588 int cpu_index, device_declaration = 0;
589 static int cpu0_initialized;
590
591 pr = acpi_driver_data(device);
592 if (!pr)
593 return -EINVAL;
594
595 if (num_online_cpus() > 1)
596 errata.smp = TRUE;
597
598 acpi_processor_errata(pr);
599
600 /*
601 * Check to see if we have bus mastering arbitration control. This
602 * is required for proper C3 usage (to maintain cache coherency).
603 */
604 if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) {
605 pr->flags.bm_control = 1;
606 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
607 "Bus mastering arbitration control present\n"));
608 } else
609 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
610 "No bus mastering arbitration control\n"));
611
612 if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) {
613 /* Declared with "Processor" statement; match ProcessorID */
614 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
615 if (ACPI_FAILURE(status)) {
616 printk(KERN_ERR PREFIX "Evaluating processor object\n");
617 return -ENODEV;
618 }
619
620 /*
621 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
622 * >>> 'acpi_get_processor_id(acpi_id, &id)' in
623 * arch/xxx/acpi.c
624 */
625 pr->acpi_id = object.processor.proc_id;
626 } else {
627 /*
628 * Declared with "Device" statement; match _UID.
629 * Note that we don't handle string _UIDs yet.
630 */
631 unsigned long long value;
632 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
633 NULL, &value);
634 if (ACPI_FAILURE(status)) {
635 printk(KERN_ERR PREFIX
636 "Evaluating processor _UID [%#x]\n", status);
637 return -ENODEV;
638 }
639 device_declaration = 1;
640 pr->acpi_id = value;
641 }
642 cpu_index = get_cpu_id(pr->handle, device_declaration, pr->acpi_id);
643
644 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
645 if (!cpu0_initialized && (cpu_index == -1) &&
646 (num_online_cpus() == 1)) {
647 cpu_index = 0;
648 }
649
650 cpu0_initialized = 1;
651
652 pr->id = cpu_index;
653
654 /*
655 * Extra Processor objects may be enumerated on MP systems with
656 * less than the max # of CPUs. They should be ignored _iff
657 * they are physically not present.
658 */
659 if (pr->id == -1) {
660 if (ACPI_FAILURE
661 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
662 return -ENODEV;
663 }
664 }
665 /*
666 * On some boxes several processors use the same processor bus id.
667 * But they are located in different scope. For example:
668 * \_SB.SCK0.CPU0
669 * \_SB.SCK1.CPU0
670 * Rename the processor device bus id. And the new bus id will be
671 * generated as the following format:
672 * CPU+CPU ID.
673 */
674 sprintf(acpi_device_bid(device), "CPU%X", pr->id);
675 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
676 pr->acpi_id));
677
678 if (!object.processor.pblk_address)
679 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
680 else if (object.processor.pblk_length != 6)
681 printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n",
682 object.processor.pblk_length);
683 else {
684 pr->throttling.address = object.processor.pblk_address;
685 pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset;
686 pr->throttling.duty_width = acpi_gbl_FADT.duty_width;
687
688 pr->pblk = object.processor.pblk_address;
689 201
690 /* 202 status = acpi_get_type(handle, &acpi_type);
691 * We don't care about error returns - we just try to mark 203 if (ACPI_FAILURE(status))
692 * these reserved so that nobody else is confused into thinking 204 return false;
693 * that this region might be unused.. 205
694 * 206 switch (acpi_type) {
695 * (In particular, allocating the IO range for Cardbus) 207 case ACPI_TYPE_PROCESSOR:
696 */ 208 status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
697 request_region(pr->throttling.address, 6, "ACPI CPU throttle"); 209 if (ACPI_FAILURE(status))
698 } 210 return false;
699 211 acpi_id = object.processor.proc_id;
700 /*
701 * If ACPI describes a slot number for this CPU, we can use it
702 * ensure we get the right value in the "physical id" field
703 * of /proc/cpuinfo
704 */
705 status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer);
706 if (ACPI_SUCCESS(status))
707 arch_fix_phys_package_id(pr->id, object.integer.value);
708
709 return 0;
710}
711
712static DEFINE_PER_CPU(void *, processor_device_array);
713
714static void acpi_processor_notify(struct acpi_device *device, u32 event)
715{
716 struct acpi_processor *pr = acpi_driver_data(device);
717 int saved;
718
719 if (!pr)
720 return;
721
722 switch (event) {
723 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
724 saved = pr->performance_platform_limit;
725 acpi_processor_ppc_has_changed(pr);
726 if (saved == pr->performance_platform_limit)
727 break;
728 acpi_bus_generate_proc_event(device, event,
729 pr->performance_platform_limit);
730 acpi_bus_generate_netlink_event(device->pnp.device_class,
731 dev_name(&device->dev), event,
732 pr->performance_platform_limit);
733 break; 212 break;
734 case ACPI_PROCESSOR_NOTIFY_POWER: 213 case ACPI_TYPE_DEVICE:
735 acpi_processor_cst_has_changed(pr); 214 status = acpi_evaluate_integer(handle, "_UID", NULL, &tmp);
736 acpi_bus_generate_proc_event(device, event, 0); 215 if (ACPI_FAILURE(status))
737 acpi_bus_generate_netlink_event(device->pnp.device_class, 216 return false;
738 dev_name(&device->dev), event, 0); 217 acpi_id = tmp;
739 break; 218 break;
740 case ACPI_PROCESSOR_NOTIFY_THROTTLING:
741 acpi_processor_tstate_has_changed(pr);
742 acpi_bus_generate_proc_event(device, event, 0);
743 acpi_bus_generate_netlink_event(device->pnp.device_class,
744 dev_name(&device->dev), event, 0);
745 default: 219 default:
746 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 220 return false;
747 "Unsupported event [0x%x]\n", event));
748 break;
749 } 221 }
750 222
751 return; 223 type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
752} 224 cpuid = acpi_get_cpuid(handle, type, acpi_id);
753 225
754static int acpi_cpu_soft_notify(struct notifier_block *nfb, 226 if (cpuid == -1)
755 unsigned long action, void *hcpu) 227 return false;
756{
757 unsigned int cpu = (unsigned long)hcpu;
758 struct acpi_processor *pr = per_cpu(processors, cpu);
759 228
760 if (action == CPU_ONLINE && pr) { 229 return true;
761 acpi_processor_ppc_has_changed(pr);
762 acpi_processor_cst_has_changed(pr);
763 acpi_processor_tstate_has_changed(pr);
764 }
765 return NOTIFY_OK;
766} 230}
767 231
768static struct notifier_block acpi_cpu_notifier = 232static void acpi_set_pdc_bits(u32 *buf)
769{
770 .notifier_call = acpi_cpu_soft_notify,
771};
772
773static int __cpuinit acpi_processor_add(struct acpi_device *device)
774{ 233{
775 struct acpi_processor *pr = NULL; 234 buf[0] = ACPI_PDC_REVISION_ID;
776 int result = 0; 235 buf[1] = 1;
777 struct sys_device *sysdev;
778
779 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
780 if (!pr)
781 return -ENOMEM;
782
783 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
784 kfree(pr);
785 return -ENOMEM;
786 }
787
788 pr->handle = device->handle;
789 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
790 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
791 device->driver_data = pr;
792
793 result = acpi_processor_get_info(device);
794 if (result) {
795 /* Processor is physically not present */
796 return 0;
797 }
798
799 BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
800
801 /*
802 * Buggy BIOS check
803 * ACPI id of processors can be reported wrongly by the BIOS.
804 * Don't trust it blindly
805 */
806 if (per_cpu(processor_device_array, pr->id) != NULL &&
807 per_cpu(processor_device_array, pr->id) != device) {
808 printk(KERN_WARNING "BIOS reported wrong ACPI id "
809 "for the processor\n");
810 result = -ENODEV;
811 goto err_free_cpumask;
812 }
813 per_cpu(processor_device_array, pr->id) = device;
814
815 per_cpu(processors, pr->id) = pr;
816
817 result = acpi_processor_add_fs(device);
818 if (result)
819 goto err_free_cpumask;
820
821 sysdev = get_cpu_sysdev(pr->id);
822 if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) {
823 result = -EFAULT;
824 goto err_remove_fs;
825 }
826
827 /* _PDC call should be done before doing anything else (if reqd.). */
828 arch_acpi_processor_init_pdc(pr);
829 acpi_processor_set_pdc(pr);
830 arch_acpi_processor_cleanup_pdc(pr);
831
832#ifdef CONFIG_CPU_FREQ
833 acpi_processor_ppc_has_changed(pr);
834#endif
835 acpi_processor_get_throttling_info(pr);
836 acpi_processor_get_limit_info(pr);
837
838
839 acpi_processor_power_init(pr, device);
840
841 pr->cdev = thermal_cooling_device_register("Processor", device,
842 &processor_cooling_ops);
843 if (IS_ERR(pr->cdev)) {
844 result = PTR_ERR(pr->cdev);
845 goto err_power_exit;
846 }
847 236
848 dev_info(&device->dev, "registered as cooling_device%d\n", 237 /* Enable coordination with firmware's _TSD info */
849 pr->cdev->id); 238 buf[2] = ACPI_PDC_SMP_T_SWCOORD;
850 239
851 result = sysfs_create_link(&device->dev.kobj, 240 /* Twiddle arch-specific bits needed for _PDC */
852 &pr->cdev->device.kobj, 241 arch_acpi_set_pdc_bits(buf);
853 "thermal_cooling");
854 if (result) {
855 printk(KERN_ERR PREFIX "Create sysfs link\n");
856 goto err_thermal_unregister;
857 }
858 result = sysfs_create_link(&pr->cdev->device.kobj,
859 &device->dev.kobj,
860 "device");
861 if (result) {
862 printk(KERN_ERR PREFIX "Create sysfs link\n");
863 goto err_remove_sysfs;
864 }
865
866 return 0;
867
868err_remove_sysfs:
869 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
870err_thermal_unregister:
871 thermal_cooling_device_unregister(pr->cdev);
872err_power_exit:
873 acpi_processor_power_exit(pr, device);
874err_remove_fs:
875 acpi_processor_remove_fs(device);
876err_free_cpumask:
877 free_cpumask_var(pr->throttling.shared_cpu_map);
878
879 return result;
880} 242}
881 243
882static int acpi_processor_remove(struct acpi_device *device, int type) 244static struct acpi_object_list *acpi_processor_alloc_pdc(void)
883{ 245{
884 struct acpi_processor *pr = NULL; 246 struct acpi_object_list *obj_list;
885 247 union acpi_object *obj;
886 248 u32 *buf;
887 if (!device || !acpi_driver_data(device))
888 return -EINVAL;
889
890 pr = acpi_driver_data(device);
891
892 if (pr->id >= nr_cpu_ids)
893 goto free;
894 249
895 if (type == ACPI_BUS_REMOVAL_EJECT) { 250 /* allocate and initialize pdc. It will be used later. */
896 if (acpi_processor_handle_eject(pr)) 251 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
897 return -EINVAL; 252 if (!obj_list) {
253 printk(KERN_ERR "Memory allocation error\n");
254 return NULL;
898 } 255 }
899 256
900 acpi_processor_power_exit(pr, device); 257 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
901 258 if (!obj) {
902 sysfs_remove_link(&device->dev.kobj, "sysdev"); 259 printk(KERN_ERR "Memory allocation error\n");
903 260 kfree(obj_list);
904 acpi_processor_remove_fs(device); 261 return NULL;
905
906 if (pr->cdev) {
907 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
908 sysfs_remove_link(&pr->cdev->device.kobj, "device");
909 thermal_cooling_device_unregister(pr->cdev);
910 pr->cdev = NULL;
911 } 262 }
912 263
913 per_cpu(processors, pr->id) = NULL; 264 buf = kmalloc(12, GFP_KERNEL);
914 per_cpu(processor_device_array, pr->id) = NULL; 265 if (!buf) {
915 266 printk(KERN_ERR "Memory allocation error\n");
916free: 267 kfree(obj);
917 free_cpumask_var(pr->throttling.shared_cpu_map); 268 kfree(obj_list);
918 kfree(pr); 269 return NULL;
919
920 return 0;
921}
922
923#ifdef CONFIG_ACPI_HOTPLUG_CPU
924/****************************************************************************
925 * Acpi processor hotplug support *
926 ****************************************************************************/
927
928static int is_processor_present(acpi_handle handle)
929{
930 acpi_status status;
931 unsigned long long sta = 0;
932
933
934 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
935
936 if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT))
937 return 1;
938
939 /*
940 * _STA is mandatory for a processor that supports hot plug
941 */
942 if (status == AE_NOT_FOUND)
943 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
944 "Processor does not support hot plug\n"));
945 else
946 ACPI_EXCEPTION((AE_INFO, status,
947 "Processor Device is not present"));
948 return 0;
949}
950
951static
952int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
953{
954 acpi_handle phandle;
955 struct acpi_device *pdev;
956
957
958 if (acpi_get_parent(handle, &phandle)) {
959 return -ENODEV;
960 } 270 }
961 271
962 if (acpi_bus_get_device(phandle, &pdev)) { 272 acpi_set_pdc_bits(buf);
963 return -ENODEV;
964 }
965 273
966 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { 274 obj->type = ACPI_TYPE_BUFFER;
967 return -ENODEV; 275 obj->buffer.length = 12;
968 } 276 obj->buffer.pointer = (u8 *) buf;
277 obj_list->count = 1;
278 obj_list->pointer = obj;
969 279
970 return 0; 280 return obj_list;
971} 281}
972 282
973static void __ref acpi_processor_hotplug_notify(acpi_handle handle, 283/*
974 u32 event, void *data) 284 * _PDC is required for a BIOS-OS handshake for most of the newer
285 * ACPI processor features.
286 */
287static int
288acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
975{ 289{
976 struct acpi_processor *pr; 290 acpi_status status = AE_OK;
977 struct acpi_device *device = NULL;
978 int result;
979
980
981 switch (event) {
982 case ACPI_NOTIFY_BUS_CHECK:
983 case ACPI_NOTIFY_DEVICE_CHECK:
984 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
985 "Processor driver received %s event\n",
986 (event == ACPI_NOTIFY_BUS_CHECK) ?
987 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"));
988 291
989 if (!is_processor_present(handle)) 292 if (idle_nomwait) {
990 break; 293 /*
294 * If mwait is disabled for CPU C-states, the C2C3_FFH access
295 * mode will be disabled in the parameter of _PDC object.
296 * Of course C1_FFH access mode will also be disabled.
297 */
298 union acpi_object *obj;
299 u32 *buffer = NULL;
991 300
992 if (acpi_bus_get_device(handle, &device)) { 301 obj = pdc_in->pointer;
993 result = acpi_processor_device_add(handle, &device); 302 buffer = (u32 *)(obj->buffer.pointer);
994 if (result) 303 buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
995 printk(KERN_ERR PREFIX
996 "Unable to add the device\n");
997 break;
998 }
999 break;
1000 case ACPI_NOTIFY_EJECT_REQUEST:
1001 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1002 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
1003 304
1004 if (acpi_bus_get_device(handle, &device)) {
1005 printk(KERN_ERR PREFIX
1006 "Device don't exist, dropping EJECT\n");
1007 break;
1008 }
1009 pr = acpi_driver_data(device);
1010 if (!pr) {
1011 printk(KERN_ERR PREFIX
1012 "Driver data is NULL, dropping EJECT\n");
1013 return;
1014 }
1015 break;
1016 default:
1017 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1018 "Unsupported event [0x%x]\n", event));
1019 break;
1020 } 305 }
306 status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
1021 307
1022 return;
1023}
1024
1025static acpi_status
1026processor_walk_namespace_cb(acpi_handle handle,
1027 u32 lvl, void *context, void **rv)
1028{
1029 acpi_status status;
1030 int *action = context;
1031 acpi_object_type type = 0;
1032
1033 status = acpi_get_type(handle, &type);
1034 if (ACPI_FAILURE(status)) 308 if (ACPI_FAILURE(status))
1035 return (AE_OK); 309 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1036 310 "Could not evaluate _PDC, using legacy perf. control.\n"));
1037 if (type != ACPI_TYPE_PROCESSOR)
1038 return (AE_OK);
1039
1040 switch (*action) {
1041 case INSTALL_NOTIFY_HANDLER:
1042 acpi_install_notify_handler(handle,
1043 ACPI_SYSTEM_NOTIFY,
1044 acpi_processor_hotplug_notify,
1045 NULL);
1046 break;
1047 case UNINSTALL_NOTIFY_HANDLER:
1048 acpi_remove_notify_handler(handle,
1049 ACPI_SYSTEM_NOTIFY,
1050 acpi_processor_hotplug_notify);
1051 break;
1052 default:
1053 break;
1054 }
1055 311
1056 return (AE_OK); 312 return status;
1057} 313}
1058 314
1059static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) 315void acpi_processor_set_pdc(acpi_handle handle)
1060{ 316{
317 struct acpi_object_list *obj_list;
1061 318
1062 if (!is_processor_present(handle)) { 319 if (arch_has_acpi_pdc() == false)
1063 return AE_ERROR; 320 return;
1064 }
1065 321
1066 if (acpi_map_lsapic(handle, p_cpu)) 322 obj_list = acpi_processor_alloc_pdc();
1067 return AE_ERROR; 323 if (!obj_list)
324 return;
1068 325
1069 if (arch_register_cpu(*p_cpu)) { 326 acpi_processor_eval_pdc(handle, obj_list);
1070 acpi_unmap_lsapic(*p_cpu);
1071 return AE_ERROR;
1072 }
1073 327
1074 return AE_OK; 328 kfree(obj_list->pointer->buffer.pointer);
329 kfree(obj_list->pointer);
330 kfree(obj_list);
1075} 331}
332EXPORT_SYMBOL_GPL(acpi_processor_set_pdc);
1076 333
1077static int acpi_processor_handle_eject(struct acpi_processor *pr) 334static acpi_status
1078{ 335early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
1079 if (cpu_online(pr->id))
1080 cpu_down(pr->id);
1081
1082 arch_unregister_cpu(pr->id);
1083 acpi_unmap_lsapic(pr->id);
1084 return (0);
1085}
1086#else
1087static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
1088{
1089 return AE_ERROR;
1090}
1091static int acpi_processor_handle_eject(struct acpi_processor *pr)
1092{
1093 return (-EINVAL);
1094}
1095#endif
1096
1097static
1098void acpi_processor_install_hotplug_notify(void)
1099{ 336{
1100#ifdef CONFIG_ACPI_HOTPLUG_CPU 337 if (processor_physically_present(handle) == false)
1101 int action = INSTALL_NOTIFY_HANDLER; 338 return AE_OK;
1102 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
1103 ACPI_ROOT_OBJECT,
1104 ACPI_UINT32_MAX,
1105 processor_walk_namespace_cb, &action, NULL);
1106#endif
1107 register_hotcpu_notifier(&acpi_cpu_notifier);
1108}
1109 339
1110static 340 acpi_processor_set_pdc(handle);
1111void acpi_processor_uninstall_hotplug_notify(void) 341 return AE_OK;
1112{
1113#ifdef CONFIG_ACPI_HOTPLUG_CPU
1114 int action = UNINSTALL_NOTIFY_HANDLER;
1115 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
1116 ACPI_ROOT_OBJECT,
1117 ACPI_UINT32_MAX,
1118 processor_walk_namespace_cb, &action, NULL);
1119#endif
1120 unregister_hotcpu_notifier(&acpi_cpu_notifier);
1121} 342}
1122 343
1123/* 344void __init acpi_early_processor_set_pdc(void)
1124 * We keep the driver loaded even when ACPI is not running.
1125 * This is needed for the powernow-k8 driver, that works even without
1126 * ACPI, but needs symbols from this driver
1127 */
1128
1129static int __init acpi_processor_init(void)
1130{ 345{
1131 int result = 0;
1132
1133 if (acpi_disabled)
1134 return 0;
1135
1136 memset(&errata, 0, sizeof(errata));
1137
1138#ifdef CONFIG_SMP
1139 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0,
1140 (struct acpi_table_header **)&madt)))
1141 madt = NULL;
1142#endif
1143#ifdef CONFIG_ACPI_PROCFS
1144 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1145 if (!acpi_processor_dir)
1146 return -ENOMEM;
1147#endif
1148 /* 346 /*
1149 * Check whether the system is DMI table. If yes, OSPM 347 * Check whether the system is DMI table. If yes, OSPM
1150 * should not use mwait for CPU-states. 348 * should not use mwait for CPU-states.
1151 */ 349 */
1152 dmi_check_system(processor_idle_dmi_table); 350 dmi_check_system(processor_idle_dmi_table);
1153 result = cpuidle_register_driver(&acpi_idle_driver);
1154 if (result < 0)
1155 goto out_proc;
1156
1157 result = acpi_bus_register_driver(&acpi_processor_driver);
1158 if (result < 0)
1159 goto out_cpuidle;
1160
1161 acpi_processor_install_hotplug_notify();
1162
1163 acpi_thermal_cpufreq_init();
1164 351
1165 acpi_processor_ppc_init(); 352 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
1166 353 ACPI_UINT32_MAX,
1167 acpi_processor_throttling_init(); 354 early_init_pdc, NULL, NULL, NULL);
1168
1169 return 0;
1170
1171out_cpuidle:
1172 cpuidle_unregister_driver(&acpi_idle_driver);
1173
1174out_proc:
1175#ifdef CONFIG_ACPI_PROCFS
1176 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1177#endif
1178
1179 return result;
1180}
1181
1182static void __exit acpi_processor_exit(void)
1183{
1184 if (acpi_disabled)
1185 return;
1186
1187 acpi_processor_ppc_exit();
1188
1189 acpi_thermal_cpufreq_exit();
1190
1191 acpi_processor_uninstall_hotplug_notify();
1192
1193 acpi_bus_unregister_driver(&acpi_processor_driver);
1194
1195 cpuidle_unregister_driver(&acpi_idle_driver);
1196
1197#ifdef CONFIG_ACPI_PROCFS
1198 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1199#endif
1200
1201 return;
1202} 355}
1203
1204module_init(acpi_processor_init);
1205module_exit(acpi_processor_exit);
1206
1207EXPORT_SYMBOL(acpi_processor_set_thermal_limit);
1208
1209MODULE_ALIAS("processor");
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
new file mode 100644
index 000000000000..5675d9747e87
--- /dev/null
+++ b/drivers/acpi/processor_driver.c
@@ -0,0 +1,979 @@
1/*
2 * acpi_processor.c - ACPI Processor Driver ($Revision: 71 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * - Added processor hotplug support
9 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 * TBD:
28 * 1. Make # power states dynamic.
29 * 2. Support duty_cycle values that span bit 4.
30 * 3. Optimize by having scheduler determine business instead of
31 * having us try to calculate it here.
32 * 4. Need C1 timing -- must modify kernel (IRQ handler) to get this.
33 */
34
35#include <linux/kernel.h>
36#include <linux/module.h>
37#include <linux/init.h>
38#include <linux/types.h>
39#include <linux/pci.h>
40#include <linux/pm.h>
41#include <linux/cpufreq.h>
42#include <linux/cpu.h>
43#include <linux/proc_fs.h>
44#include <linux/seq_file.h>
45#include <linux/dmi.h>
46#include <linux/moduleparam.h>
47#include <linux/cpuidle.h>
48#include <linux/slab.h>
49
50#include <asm/io.h>
51#include <asm/system.h>
52#include <asm/cpu.h>
53#include <asm/delay.h>
54#include <asm/uaccess.h>
55#include <asm/processor.h>
56#include <asm/smp.h>
57#include <asm/acpi.h>
58
59#include <acpi/acpi_bus.h>
60#include <acpi/acpi_drivers.h>
61#include <acpi/processor.h>
62
63#define PREFIX "ACPI: "
64
65#define ACPI_PROCESSOR_CLASS "processor"
66#define ACPI_PROCESSOR_DEVICE_NAME "Processor"
67#define ACPI_PROCESSOR_FILE_INFO "info"
68#define ACPI_PROCESSOR_FILE_THROTTLING "throttling"
69#define ACPI_PROCESSOR_FILE_LIMIT "limit"
70#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
71#define ACPI_PROCESSOR_NOTIFY_POWER 0x81
72#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
73
74#define ACPI_PROCESSOR_LIMIT_USER 0
75#define ACPI_PROCESSOR_LIMIT_THERMAL 1
76
77#define _COMPONENT ACPI_PROCESSOR_COMPONENT
78ACPI_MODULE_NAME("processor_driver");
79
80MODULE_AUTHOR("Paul Diefenbaugh");
81MODULE_DESCRIPTION("ACPI Processor Driver");
82MODULE_LICENSE("GPL");
83
84static int acpi_processor_add(struct acpi_device *device);
85static int acpi_processor_remove(struct acpi_device *device, int type);
86#ifdef CONFIG_ACPI_PROCFS
87static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
88#endif
89static void acpi_processor_notify(struct acpi_device *device, u32 event);
90static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
91static int acpi_processor_handle_eject(struct acpi_processor *pr);
92
93
94static const struct acpi_device_id processor_device_ids[] = {
95 {ACPI_PROCESSOR_OBJECT_HID, 0},
96 {"ACPI0007", 0},
97 {"", 0},
98};
99MODULE_DEVICE_TABLE(acpi, processor_device_ids);
100
101static struct acpi_driver acpi_processor_driver = {
102 .name = "processor",
103 .class = ACPI_PROCESSOR_CLASS,
104 .ids = processor_device_ids,
105 .ops = {
106 .add = acpi_processor_add,
107 .remove = acpi_processor_remove,
108 .suspend = acpi_processor_suspend,
109 .resume = acpi_processor_resume,
110 .notify = acpi_processor_notify,
111 },
112};
113
114#define INSTALL_NOTIFY_HANDLER 1
115#define UNINSTALL_NOTIFY_HANDLER 2
116#ifdef CONFIG_ACPI_PROCFS
117static const struct file_operations acpi_processor_info_fops = {
118 .owner = THIS_MODULE,
119 .open = acpi_processor_info_open_fs,
120 .read = seq_read,
121 .llseek = seq_lseek,
122 .release = single_release,
123};
124#endif
125
126DEFINE_PER_CPU(struct acpi_processor *, processors);
127EXPORT_PER_CPU_SYMBOL(processors);
128
129struct acpi_processor_errata errata __read_mostly;
130
131/* --------------------------------------------------------------------------
132 Errata Handling
133 -------------------------------------------------------------------------- */
134
135static int acpi_processor_errata_piix4(struct pci_dev *dev)
136{
137 u8 value1 = 0;
138 u8 value2 = 0;
139
140
141 if (!dev)
142 return -EINVAL;
143
144 /*
145 * Note that 'dev' references the PIIX4 ACPI Controller.
146 */
147
148 switch (dev->revision) {
149 case 0:
150 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n"));
151 break;
152 case 1:
153 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n"));
154 break;
155 case 2:
156 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n"));
157 break;
158 case 3:
159 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n"));
160 break;
161 default:
162 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n"));
163 break;
164 }
165
166 switch (dev->revision) {
167
168 case 0: /* PIIX4 A-step */
169 case 1: /* PIIX4 B-step */
170 /*
171 * See specification changes #13 ("Manual Throttle Duty Cycle")
172 * and #14 ("Enabling and Disabling Manual Throttle"), plus
173 * erratum #5 ("STPCLK# Deassertion Time") from the January
174 * 2002 PIIX4 specification update. Applies to only older
175 * PIIX4 models.
176 */
177 errata.piix4.throttle = 1;
178
179 case 2: /* PIIX4E */
180 case 3: /* PIIX4M */
181 /*
182 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA
183 * Livelock") from the January 2002 PIIX4 specification update.
184 * Applies to all PIIX4 models.
185 */
186
187 /*
188 * BM-IDE
189 * ------
190 * Find the PIIX4 IDE Controller and get the Bus Master IDE
191 * Status register address. We'll use this later to read
192 * each IDE controller's DMA status to make sure we catch all
193 * DMA activity.
194 */
195 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
196 PCI_DEVICE_ID_INTEL_82371AB,
197 PCI_ANY_ID, PCI_ANY_ID, NULL);
198 if (dev) {
199 errata.piix4.bmisx = pci_resource_start(dev, 4);
200 pci_dev_put(dev);
201 }
202
203 /*
204 * Type-F DMA
205 * ----------
206 * Find the PIIX4 ISA Controller and read the Motherboard
207 * DMA controller's status to see if Type-F (Fast) DMA mode
208 * is enabled (bit 7) on either channel. Note that we'll
209 * disable C3 support if this is enabled, as some legacy
210 * devices won't operate well if fast DMA is disabled.
211 */
212 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
213 PCI_DEVICE_ID_INTEL_82371AB_0,
214 PCI_ANY_ID, PCI_ANY_ID, NULL);
215 if (dev) {
216 pci_read_config_byte(dev, 0x76, &value1);
217 pci_read_config_byte(dev, 0x77, &value2);
218 if ((value1 & 0x80) || (value2 & 0x80))
219 errata.piix4.fdma = 1;
220 pci_dev_put(dev);
221 }
222
223 break;
224 }
225
226 if (errata.piix4.bmisx)
227 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
228 "Bus master activity detection (BM-IDE) erratum enabled\n"));
229 if (errata.piix4.fdma)
230 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
231 "Type-F DMA livelock erratum (C3 disabled)\n"));
232
233 return 0;
234}
235
236static int acpi_processor_errata(struct acpi_processor *pr)
237{
238 int result = 0;
239 struct pci_dev *dev = NULL;
240
241
242 if (!pr)
243 return -EINVAL;
244
245 /*
246 * PIIX4
247 */
248 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
249 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
250 PCI_ANY_ID, NULL);
251 if (dev) {
252 result = acpi_processor_errata_piix4(dev);
253 pci_dev_put(dev);
254 }
255
256 return result;
257}
258
259/* --------------------------------------------------------------------------
260 FS Interface (/proc)
261 -------------------------------------------------------------------------- */
262
263#ifdef CONFIG_ACPI_PROCFS
264static struct proc_dir_entry *acpi_processor_dir = NULL;
265
266static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
267{
268 struct acpi_processor *pr = seq->private;
269
270
271 if (!pr)
272 goto end;
273
274 seq_printf(seq, "processor id: %d\n"
275 "acpi id: %d\n"
276 "bus mastering control: %s\n"
277 "power management: %s\n"
278 "throttling control: %s\n"
279 "limit interface: %s\n",
280 pr->id,
281 pr->acpi_id,
282 pr->flags.bm_control ? "yes" : "no",
283 pr->flags.power ? "yes" : "no",
284 pr->flags.throttling ? "yes" : "no",
285 pr->flags.limit ? "yes" : "no");
286
287 end:
288 return 0;
289}
290
291static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
292{
293 return single_open(file, acpi_processor_info_seq_show,
294 PDE(inode)->data);
295}
296
297static int __cpuinit acpi_processor_add_fs(struct acpi_device *device)
298{
299 struct proc_dir_entry *entry = NULL;
300
301
302 if (!acpi_device_dir(device)) {
303 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
304 acpi_processor_dir);
305 if (!acpi_device_dir(device))
306 return -ENODEV;
307 }
308
309 /* 'info' [R] */
310 entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO,
311 S_IRUGO, acpi_device_dir(device),
312 &acpi_processor_info_fops,
313 acpi_driver_data(device));
314 if (!entry)
315 return -EIO;
316
317 /* 'throttling' [R/W] */
318 entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING,
319 S_IFREG | S_IRUGO | S_IWUSR,
320 acpi_device_dir(device),
321 &acpi_processor_throttling_fops,
322 acpi_driver_data(device));
323 if (!entry)
324 return -EIO;
325
326 /* 'limit' [R/W] */
327 entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT,
328 S_IFREG | S_IRUGO | S_IWUSR,
329 acpi_device_dir(device),
330 &acpi_processor_limit_fops,
331 acpi_driver_data(device));
332 if (!entry)
333 return -EIO;
334 return 0;
335}
336static int acpi_processor_remove_fs(struct acpi_device *device)
337{
338
339 if (acpi_device_dir(device)) {
340 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
341 acpi_device_dir(device));
342 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
343 acpi_device_dir(device));
344 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
345 acpi_device_dir(device));
346 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
347 acpi_device_dir(device) = NULL;
348 }
349
350 return 0;
351}
352#else
353static inline int acpi_processor_add_fs(struct acpi_device *device)
354{
355 return 0;
356}
357static inline int acpi_processor_remove_fs(struct acpi_device *device)
358{
359 return 0;
360}
361#endif
362
363/* --------------------------------------------------------------------------
364 Driver Interface
365 -------------------------------------------------------------------------- */
366
367static int acpi_processor_get_info(struct acpi_device *device)
368{
369 acpi_status status = 0;
370 union acpi_object object = { 0 };
371 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
372 struct acpi_processor *pr;
373 int cpu_index, device_declaration = 0;
374 static int cpu0_initialized;
375
376 pr = acpi_driver_data(device);
377 if (!pr)
378 return -EINVAL;
379
380 if (num_online_cpus() > 1)
381 errata.smp = TRUE;
382
383 acpi_processor_errata(pr);
384
385 /*
386 * Check to see if we have bus mastering arbitration control. This
387 * is required for proper C3 usage (to maintain cache coherency).
388 */
389 if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) {
390 pr->flags.bm_control = 1;
391 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
392 "Bus mastering arbitration control present\n"));
393 } else
394 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
395 "No bus mastering arbitration control\n"));
396
397 if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) {
398 /* Declared with "Processor" statement; match ProcessorID */
399 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
400 if (ACPI_FAILURE(status)) {
401 printk(KERN_ERR PREFIX "Evaluating processor object\n");
402 return -ENODEV;
403 }
404
405 /*
406 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
407 * >>> 'acpi_get_processor_id(acpi_id, &id)' in
408 * arch/xxx/acpi.c
409 */
410 pr->acpi_id = object.processor.proc_id;
411 } else {
412 /*
413 * Declared with "Device" statement; match _UID.
414 * Note that we don't handle string _UIDs yet.
415 */
416 unsigned long long value;
417 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
418 NULL, &value);
419 if (ACPI_FAILURE(status)) {
420 printk(KERN_ERR PREFIX
421 "Evaluating processor _UID [%#x]\n", status);
422 return -ENODEV;
423 }
424 device_declaration = 1;
425 pr->acpi_id = value;
426 }
427 cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id);
428
429 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
430 if (!cpu0_initialized && (cpu_index == -1) &&
431 (num_online_cpus() == 1)) {
432 cpu_index = 0;
433 }
434
435 cpu0_initialized = 1;
436
437 pr->id = cpu_index;
438
439 /*
440 * Extra Processor objects may be enumerated on MP systems with
441 * less than the max # of CPUs. They should be ignored _iff
442 * they are physically not present.
443 */
444 if (pr->id == -1) {
445 if (ACPI_FAILURE
446 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
447 return -ENODEV;
448 }
449 }
450 /*
451 * On some boxes several processors use the same processor bus id.
452 * But they are located in different scope. For example:
453 * \_SB.SCK0.CPU0
454 * \_SB.SCK1.CPU0
455 * Rename the processor device bus id. And the new bus id will be
456 * generated as the following format:
457 * CPU+CPU ID.
458 */
459 sprintf(acpi_device_bid(device), "CPU%X", pr->id);
460 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
461 pr->acpi_id));
462
463 if (!object.processor.pblk_address)
464 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
465 else if (object.processor.pblk_length != 6)
466 printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n",
467 object.processor.pblk_length);
468 else {
469 pr->throttling.address = object.processor.pblk_address;
470 pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset;
471 pr->throttling.duty_width = acpi_gbl_FADT.duty_width;
472
473 pr->pblk = object.processor.pblk_address;
474
475 /*
476 * We don't care about error returns - we just try to mark
477 * these reserved so that nobody else is confused into thinking
478 * that this region might be unused..
479 *
480 * (In particular, allocating the IO range for Cardbus)
481 */
482 request_region(pr->throttling.address, 6, "ACPI CPU throttle");
483 }
484
485 /*
486 * If ACPI describes a slot number for this CPU, we can use it
487 * ensure we get the right value in the "physical id" field
488 * of /proc/cpuinfo
489 */
490 status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer);
491 if (ACPI_SUCCESS(status))
492 arch_fix_phys_package_id(pr->id, object.integer.value);
493
494 return 0;
495}
496
497static DEFINE_PER_CPU(void *, processor_device_array);
498
499static void acpi_processor_notify(struct acpi_device *device, u32 event)
500{
501 struct acpi_processor *pr = acpi_driver_data(device);
502 int saved;
503
504 if (!pr)
505 return;
506
507 switch (event) {
508 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
509 saved = pr->performance_platform_limit;
510 acpi_processor_ppc_has_changed(pr, 1);
511 if (saved == pr->performance_platform_limit)
512 break;
513 acpi_bus_generate_proc_event(device, event,
514 pr->performance_platform_limit);
515 acpi_bus_generate_netlink_event(device->pnp.device_class,
516 dev_name(&device->dev), event,
517 pr->performance_platform_limit);
518 break;
519 case ACPI_PROCESSOR_NOTIFY_POWER:
520 acpi_processor_cst_has_changed(pr);
521 acpi_bus_generate_proc_event(device, event, 0);
522 acpi_bus_generate_netlink_event(device->pnp.device_class,
523 dev_name(&device->dev), event, 0);
524 break;
525 case ACPI_PROCESSOR_NOTIFY_THROTTLING:
526 acpi_processor_tstate_has_changed(pr);
527 acpi_bus_generate_proc_event(device, event, 0);
528 acpi_bus_generate_netlink_event(device->pnp.device_class,
529 dev_name(&device->dev), event, 0);
530 default:
531 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
532 "Unsupported event [0x%x]\n", event));
533 break;
534 }
535
536 return;
537}
538
539static int acpi_cpu_soft_notify(struct notifier_block *nfb,
540 unsigned long action, void *hcpu)
541{
542 unsigned int cpu = (unsigned long)hcpu;
543 struct acpi_processor *pr = per_cpu(processors, cpu);
544
545 if (action == CPU_ONLINE && pr) {
546 acpi_processor_ppc_has_changed(pr, 0);
547 acpi_processor_cst_has_changed(pr);
548 acpi_processor_tstate_has_changed(pr);
549 }
550 return NOTIFY_OK;
551}
552
553static struct notifier_block acpi_cpu_notifier =
554{
555 .notifier_call = acpi_cpu_soft_notify,
556};
557
558static int __cpuinit acpi_processor_add(struct acpi_device *device)
559{
560 struct acpi_processor *pr = NULL;
561 int result = 0;
562 struct sys_device *sysdev;
563
564 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
565 if (!pr)
566 return -ENOMEM;
567
568 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
569 kfree(pr);
570 return -ENOMEM;
571 }
572
573 pr->handle = device->handle;
574 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
575 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
576 device->driver_data = pr;
577
578 result = acpi_processor_get_info(device);
579 if (result) {
580 /* Processor is physically not present */
581 return 0;
582 }
583
584 BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
585
586 /*
587 * Buggy BIOS check
588 * ACPI id of processors can be reported wrongly by the BIOS.
589 * Don't trust it blindly
590 */
591 if (per_cpu(processor_device_array, pr->id) != NULL &&
592 per_cpu(processor_device_array, pr->id) != device) {
593 printk(KERN_WARNING "BIOS reported wrong ACPI id "
594 "for the processor\n");
595 result = -ENODEV;
596 goto err_free_cpumask;
597 }
598 per_cpu(processor_device_array, pr->id) = device;
599
600 per_cpu(processors, pr->id) = pr;
601
602 result = acpi_processor_add_fs(device);
603 if (result)
604 goto err_free_cpumask;
605
606 sysdev = get_cpu_sysdev(pr->id);
607 if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) {
608 result = -EFAULT;
609 goto err_remove_fs;
610 }
611
612#ifdef CONFIG_CPU_FREQ
613 acpi_processor_ppc_has_changed(pr, 0);
614#endif
615 acpi_processor_get_throttling_info(pr);
616 acpi_processor_get_limit_info(pr);
617
618
619 acpi_processor_power_init(pr, device);
620
621 pr->cdev = thermal_cooling_device_register("Processor", device,
622 &processor_cooling_ops);
623 if (IS_ERR(pr->cdev)) {
624 result = PTR_ERR(pr->cdev);
625 goto err_power_exit;
626 }
627
628 dev_dbg(&device->dev, "registered as cooling_device%d\n",
629 pr->cdev->id);
630
631 result = sysfs_create_link(&device->dev.kobj,
632 &pr->cdev->device.kobj,
633 "thermal_cooling");
634 if (result) {
635 printk(KERN_ERR PREFIX "Create sysfs link\n");
636 goto err_thermal_unregister;
637 }
638 result = sysfs_create_link(&pr->cdev->device.kobj,
639 &device->dev.kobj,
640 "device");
641 if (result) {
642 printk(KERN_ERR PREFIX "Create sysfs link\n");
643 goto err_remove_sysfs;
644 }
645
646 return 0;
647
648err_remove_sysfs:
649 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
650err_thermal_unregister:
651 thermal_cooling_device_unregister(pr->cdev);
652err_power_exit:
653 acpi_processor_power_exit(pr, device);
654err_remove_fs:
655 acpi_processor_remove_fs(device);
656err_free_cpumask:
657 free_cpumask_var(pr->throttling.shared_cpu_map);
658
659 return result;
660}
661
662static int acpi_processor_remove(struct acpi_device *device, int type)
663{
664 struct acpi_processor *pr = NULL;
665
666
667 if (!device || !acpi_driver_data(device))
668 return -EINVAL;
669
670 pr = acpi_driver_data(device);
671
672 if (pr->id >= nr_cpu_ids)
673 goto free;
674
675 if (type == ACPI_BUS_REMOVAL_EJECT) {
676 if (acpi_processor_handle_eject(pr))
677 return -EINVAL;
678 }
679
680 acpi_processor_power_exit(pr, device);
681
682 sysfs_remove_link(&device->dev.kobj, "sysdev");
683
684 acpi_processor_remove_fs(device);
685
686 if (pr->cdev) {
687 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
688 sysfs_remove_link(&pr->cdev->device.kobj, "device");
689 thermal_cooling_device_unregister(pr->cdev);
690 pr->cdev = NULL;
691 }
692
693 per_cpu(processors, pr->id) = NULL;
694 per_cpu(processor_device_array, pr->id) = NULL;
695
696free:
697 free_cpumask_var(pr->throttling.shared_cpu_map);
698 kfree(pr);
699
700 return 0;
701}
702
703#ifdef CONFIG_ACPI_HOTPLUG_CPU
704/****************************************************************************
705 * Acpi processor hotplug support *
706 ****************************************************************************/
707
708static int is_processor_present(acpi_handle handle)
709{
710 acpi_status status;
711 unsigned long long sta = 0;
712
713
714 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
715
716 if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT))
717 return 1;
718
719 /*
720 * _STA is mandatory for a processor that supports hot plug
721 */
722 if (status == AE_NOT_FOUND)
723 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
724 "Processor does not support hot plug\n"));
725 else
726 ACPI_EXCEPTION((AE_INFO, status,
727 "Processor Device is not present"));
728 return 0;
729}
730
731static
732int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
733{
734 acpi_handle phandle;
735 struct acpi_device *pdev;
736
737
738 if (acpi_get_parent(handle, &phandle)) {
739 return -ENODEV;
740 }
741
742 if (acpi_bus_get_device(phandle, &pdev)) {
743 return -ENODEV;
744 }
745
746 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
747 return -ENODEV;
748 }
749
750 return 0;
751}
752
753static void __ref acpi_processor_hotplug_notify(acpi_handle handle,
754 u32 event, void *data)
755{
756 struct acpi_processor *pr;
757 struct acpi_device *device = NULL;
758 int result;
759
760
761 switch (event) {
762 case ACPI_NOTIFY_BUS_CHECK:
763 case ACPI_NOTIFY_DEVICE_CHECK:
764 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
765 "Processor driver received %s event\n",
766 (event == ACPI_NOTIFY_BUS_CHECK) ?
767 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"));
768
769 if (!is_processor_present(handle))
770 break;
771
772 if (acpi_bus_get_device(handle, &device)) {
773 result = acpi_processor_device_add(handle, &device);
774 if (result)
775 printk(KERN_ERR PREFIX
776 "Unable to add the device\n");
777 break;
778 }
779 break;
780 case ACPI_NOTIFY_EJECT_REQUEST:
781 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
782 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
783
784 if (acpi_bus_get_device(handle, &device)) {
785 printk(KERN_ERR PREFIX
786 "Device don't exist, dropping EJECT\n");
787 break;
788 }
789 pr = acpi_driver_data(device);
790 if (!pr) {
791 printk(KERN_ERR PREFIX
792 "Driver data is NULL, dropping EJECT\n");
793 return;
794 }
795 break;
796 default:
797 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
798 "Unsupported event [0x%x]\n", event));
799 break;
800 }
801
802 return;
803}
804
805static acpi_status
806processor_walk_namespace_cb(acpi_handle handle,
807 u32 lvl, void *context, void **rv)
808{
809 acpi_status status;
810 int *action = context;
811 acpi_object_type type = 0;
812
813 status = acpi_get_type(handle, &type);
814 if (ACPI_FAILURE(status))
815 return (AE_OK);
816
817 if (type != ACPI_TYPE_PROCESSOR)
818 return (AE_OK);
819
820 switch (*action) {
821 case INSTALL_NOTIFY_HANDLER:
822 acpi_install_notify_handler(handle,
823 ACPI_SYSTEM_NOTIFY,
824 acpi_processor_hotplug_notify,
825 NULL);
826 break;
827 case UNINSTALL_NOTIFY_HANDLER:
828 acpi_remove_notify_handler(handle,
829 ACPI_SYSTEM_NOTIFY,
830 acpi_processor_hotplug_notify);
831 break;
832 default:
833 break;
834 }
835
836 return (AE_OK);
837}
838
839static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
840{
841
842 if (!is_processor_present(handle)) {
843 return AE_ERROR;
844 }
845
846 if (acpi_map_lsapic(handle, p_cpu))
847 return AE_ERROR;
848
849 if (arch_register_cpu(*p_cpu)) {
850 acpi_unmap_lsapic(*p_cpu);
851 return AE_ERROR;
852 }
853
854 return AE_OK;
855}
856
857static int acpi_processor_handle_eject(struct acpi_processor *pr)
858{
859 if (cpu_online(pr->id))
860 cpu_down(pr->id);
861
862 arch_unregister_cpu(pr->id);
863 acpi_unmap_lsapic(pr->id);
864 return (0);
865}
866#else
867static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
868{
869 return AE_ERROR;
870}
871static int acpi_processor_handle_eject(struct acpi_processor *pr)
872{
873 return (-EINVAL);
874}
875#endif
876
877static
878void acpi_processor_install_hotplug_notify(void)
879{
880#ifdef CONFIG_ACPI_HOTPLUG_CPU
881 int action = INSTALL_NOTIFY_HANDLER;
882 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
883 ACPI_ROOT_OBJECT,
884 ACPI_UINT32_MAX,
885 processor_walk_namespace_cb, NULL, &action, NULL);
886#endif
887 register_hotcpu_notifier(&acpi_cpu_notifier);
888}
889
890static
891void acpi_processor_uninstall_hotplug_notify(void)
892{
893#ifdef CONFIG_ACPI_HOTPLUG_CPU
894 int action = UNINSTALL_NOTIFY_HANDLER;
895 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
896 ACPI_ROOT_OBJECT,
897 ACPI_UINT32_MAX,
898 processor_walk_namespace_cb, NULL, &action, NULL);
899#endif
900 unregister_hotcpu_notifier(&acpi_cpu_notifier);
901}
902
903/*
904 * We keep the driver loaded even when ACPI is not running.
905 * This is needed for the powernow-k8 driver, that works even without
906 * ACPI, but needs symbols from this driver
907 */
908
909static int __init acpi_processor_init(void)
910{
911 int result = 0;
912
913 if (acpi_disabled)
914 return 0;
915
916 memset(&errata, 0, sizeof(errata));
917
918#ifdef CONFIG_ACPI_PROCFS
919 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
920 if (!acpi_processor_dir)
921 return -ENOMEM;
922#endif
923 result = cpuidle_register_driver(&acpi_idle_driver);
924 if (result < 0)
925 goto out_proc;
926
927 result = acpi_bus_register_driver(&acpi_processor_driver);
928 if (result < 0)
929 goto out_cpuidle;
930
931 acpi_processor_install_hotplug_notify();
932
933 acpi_thermal_cpufreq_init();
934
935 acpi_processor_ppc_init();
936
937 acpi_processor_throttling_init();
938
939 return 0;
940
941out_cpuidle:
942 cpuidle_unregister_driver(&acpi_idle_driver);
943
944out_proc:
945#ifdef CONFIG_ACPI_PROCFS
946 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
947#endif
948
949 return result;
950}
951
952static void __exit acpi_processor_exit(void)
953{
954 if (acpi_disabled)
955 return;
956
957 acpi_processor_ppc_exit();
958
959 acpi_thermal_cpufreq_exit();
960
961 acpi_processor_uninstall_hotplug_notify();
962
963 acpi_bus_unregister_driver(&acpi_processor_driver);
964
965 cpuidle_unregister_driver(&acpi_idle_driver);
966
967#ifdef CONFIG_ACPI_PROCFS
968 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
969#endif
970
971 return;
972}
973
974module_init(acpi_processor_init);
975module_exit(acpi_processor_exit);
976
977EXPORT_SYMBOL(acpi_processor_set_thermal_limit);
978
979MODULE_ALIAS("processor");
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index bbd066e7f854..5939e7f7d8e9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -32,6 +32,7 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/cpufreq.h> 34#include <linux/cpufreq.h>
35#include <linux/slab.h>
35#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
36#include <linux/seq_file.h> 37#include <linux/seq_file.h>
37#include <linux/acpi.h> 38#include <linux/acpi.h>
@@ -110,6 +111,14 @@ static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
110 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), 111 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
111 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")}, 112 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")},
112 (void *)2}, 113 (void *)2},
114 { set_max_cstate, "Pavilion zv5000", {
115 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
116 DMI_MATCH(DMI_PRODUCT_NAME,"Pavilion zv5000 (DS502A#ABA)")},
117 (void *)1},
118 { set_max_cstate, "Asus L8400B", {
119 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
120 DMI_MATCH(DMI_PRODUCT_NAME,"L8400B series Notebook PC")},
121 (void *)1},
113 {}, 122 {},
114}; 123};
115 124
@@ -164,7 +173,7 @@ static void lapic_timer_check_state(int state, struct acpi_processor *pr,
164 pr->power.timer_broadcast_on_state = state; 173 pr->power.timer_broadcast_on_state = state;
165} 174}
166 175
167static void lapic_timer_propagate_broadcast(void *arg) 176static void __lapic_timer_propagate_broadcast(void *arg)
168{ 177{
169 struct acpi_processor *pr = (struct acpi_processor *) arg; 178 struct acpi_processor *pr = (struct acpi_processor *) arg;
170 unsigned long reason; 179 unsigned long reason;
@@ -175,6 +184,12 @@ static void lapic_timer_propagate_broadcast(void *arg)
175 clockevents_notify(reason, &pr->id); 184 clockevents_notify(reason, &pr->id);
176} 185}
177 186
187static void lapic_timer_propagate_broadcast(struct acpi_processor *pr)
188{
189 smp_call_function_single(pr->id, __lapic_timer_propagate_broadcast,
190 (void *)pr, 1);
191}
192
178/* Power(C) State timer broadcast control */ 193/* Power(C) State timer broadcast control */
179static void lapic_timer_state_broadcast(struct acpi_processor *pr, 194static void lapic_timer_state_broadcast(struct acpi_processor *pr,
180 struct acpi_processor_cx *cx, 195 struct acpi_processor_cx *cx,
@@ -299,6 +314,28 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
299 pr->power.states[ACPI_STATE_C2].latency = acpi_gbl_FADT.C2latency; 314 pr->power.states[ACPI_STATE_C2].latency = acpi_gbl_FADT.C2latency;
300 pr->power.states[ACPI_STATE_C3].latency = acpi_gbl_FADT.C3latency; 315 pr->power.states[ACPI_STATE_C3].latency = acpi_gbl_FADT.C3latency;
301 316
317 /*
318 * FADT specified C2 latency must be less than or equal to
319 * 100 microseconds.
320 */
321 if (acpi_gbl_FADT.C2latency > ACPI_PROCESSOR_MAX_C2_LATENCY) {
322 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
323 "C2 latency too large [%d]\n", acpi_gbl_FADT.C2latency));
324 /* invalidate C2 */
325 pr->power.states[ACPI_STATE_C2].address = 0;
326 }
327
328 /*
329 * FADT supplied C3 latency must be less than or equal to
330 * 1000 microseconds.
331 */
332 if (acpi_gbl_FADT.C3latency > ACPI_PROCESSOR_MAX_C3_LATENCY) {
333 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
334 "C3 latency too large [%d]\n", acpi_gbl_FADT.C3latency));
335 /* invalidate C3 */
336 pr->power.states[ACPI_STATE_C3].address = 0;
337 }
338
302 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 339 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
303 "lvl2[0x%08x] lvl3[0x%08x]\n", 340 "lvl2[0x%08x] lvl3[0x%08x]\n",
304 pr->power.states[ACPI_STATE_C2].address, 341 pr->power.states[ACPI_STATE_C2].address,
@@ -324,7 +361,7 @@ static int acpi_processor_get_power_info_default(struct acpi_processor *pr)
324static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) 361static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
325{ 362{
326 acpi_status status = 0; 363 acpi_status status = 0;
327 acpi_integer count; 364 u64 count;
328 int current_count; 365 int current_count;
329 int i; 366 int i;
330 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 367 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -488,33 +525,6 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
488 return status; 525 return status;
489} 526}
490 527
491static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
492{
493
494 if (!cx->address)
495 return;
496
497 /*
498 * C2 latency must be less than or equal to 100
499 * microseconds.
500 */
501 else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) {
502 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
503 "latency too large [%d]\n", cx->latency));
504 return;
505 }
506
507 /*
508 * Otherwise we've met all of our C2 requirements.
509 * Normalize the C2 latency to expidite policy
510 */
511 cx->valid = 1;
512
513 cx->latency_ticks = cx->latency;
514
515 return;
516}
517
518static void acpi_processor_power_verify_c3(struct acpi_processor *pr, 528static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
519 struct acpi_processor_cx *cx) 529 struct acpi_processor_cx *cx)
520{ 530{
@@ -526,16 +536,6 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
526 return; 536 return;
527 537
528 /* 538 /*
529 * C3 latency must be less than or equal to 1000
530 * microseconds.
531 */
532 else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) {
533 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
534 "latency too large [%d]\n", cx->latency));
535 return;
536 }
537
538 /*
539 * PIIX4 Erratum #18: We don't support C3 when Type-F (fast) 539 * PIIX4 Erratum #18: We don't support C3 when Type-F (fast)
540 * DMA transfers are used by any ISA device to avoid livelock. 540 * DMA transfers are used by any ISA device to avoid livelock.
541 * Note that we could disable Type-F DMA (as recommended by 541 * Note that we could disable Type-F DMA (as recommended by
@@ -623,7 +623,10 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
623 break; 623 break;
624 624
625 case ACPI_STATE_C2: 625 case ACPI_STATE_C2:
626 acpi_processor_power_verify_c2(cx); 626 if (!cx->address)
627 break;
628 cx->valid = 1;
629 cx->latency_ticks = cx->latency; /* Normalize latency */
627 break; 630 break;
628 631
629 case ACPI_STATE_C3: 632 case ACPI_STATE_C3:
@@ -638,8 +641,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
638 working++; 641 working++;
639 } 642 }
640 643
641 smp_call_function_single(pr->id, lapic_timer_propagate_broadcast, 644 lapic_timer_propagate_broadcast(pr);
642 pr, 1);
643 645
644 return (working); 646 return (working);
645} 647}
@@ -879,12 +881,14 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
879 return(acpi_idle_enter_c1(dev, state)); 881 return(acpi_idle_enter_c1(dev, state));
880 882
881 local_irq_disable(); 883 local_irq_disable();
882 current_thread_info()->status &= ~TS_POLLING; 884 if (cx->entry_method != ACPI_CSTATE_FFH) {
883 /* 885 current_thread_info()->status &= ~TS_POLLING;
884 * TS_POLLING-cleared state must be visible before we test 886 /*
885 * NEED_RESCHED: 887 * TS_POLLING-cleared state must be visible before we test
886 */ 888 * NEED_RESCHED:
887 smp_mb(); 889 */
890 smp_mb();
891 }
888 892
889 if (unlikely(need_resched())) { 893 if (unlikely(need_resched())) {
890 current_thread_info()->status |= TS_POLLING; 894 current_thread_info()->status |= TS_POLLING;
@@ -964,12 +968,14 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
964 } 968 }
965 969
966 local_irq_disable(); 970 local_irq_disable();
967 current_thread_info()->status &= ~TS_POLLING; 971 if (cx->entry_method != ACPI_CSTATE_FFH) {
968 /* 972 current_thread_info()->status &= ~TS_POLLING;
969 * TS_POLLING-cleared state must be visible before we test 973 /*
970 * NEED_RESCHED: 974 * TS_POLLING-cleared state must be visible before we test
971 */ 975 * NEED_RESCHED:
972 smp_mb(); 976 */
977 smp_mb();
978 }
973 979
974 if (unlikely(need_resched())) { 980 if (unlikely(need_resched())) {
975 current_thread_info()->status |= TS_POLLING; 981 current_thread_info()->status |= TS_POLLING;
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 8ba0ed0b9ddb..ba1bd263d903 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/cpufreq.h> 32#include <linux/cpufreq.h>
33#include <linux/slab.h>
33 34
34#ifdef CONFIG_X86 35#ifdef CONFIG_X86
35#include <asm/cpufeature.h> 36#include <asm/cpufeature.h>
@@ -152,21 +153,78 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
152 return 0; 153 return 0;
153} 154}
154 155
155int acpi_processor_ppc_has_changed(struct acpi_processor *pr) 156#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
157/*
158 * acpi_processor_ppc_ost: Notify firmware the _PPC evaluation status
159 * @handle: ACPI processor handle
160 * @status: the status code of _PPC evaluation
161 * 0: success. OSPM is now using the performance state specificed.
162 * 1: failure. OSPM has not changed the number of P-states in use
163 */
164static void acpi_processor_ppc_ost(acpi_handle handle, int status)
165{
166 union acpi_object params[2] = {
167 {.type = ACPI_TYPE_INTEGER,},
168 {.type = ACPI_TYPE_INTEGER,},
169 };
170 struct acpi_object_list arg_list = {2, params};
171 acpi_handle temp;
172
173 params[0].integer.value = ACPI_PROCESSOR_NOTIFY_PERFORMANCE;
174 params[1].integer.value = status;
175
176 /* when there is no _OST , skip it */
177 if (ACPI_FAILURE(acpi_get_handle(handle, "_OST", &temp)))
178 return;
179
180 acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
181 return;
182}
183
184int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
156{ 185{
157 int ret; 186 int ret;
158 187
159 if (ignore_ppc) 188 if (ignore_ppc) {
189 /*
190 * Only when it is notification event, the _OST object
191 * will be evaluated. Otherwise it is skipped.
192 */
193 if (event_flag)
194 acpi_processor_ppc_ost(pr->handle, 1);
160 return 0; 195 return 0;
196 }
161 197
162 ret = acpi_processor_get_platform_limit(pr); 198 ret = acpi_processor_get_platform_limit(pr);
163 199 /*
200 * Only when it is notification event, the _OST object
201 * will be evaluated. Otherwise it is skipped.
202 */
203 if (event_flag) {
204 if (ret < 0)
205 acpi_processor_ppc_ost(pr->handle, 1);
206 else
207 acpi_processor_ppc_ost(pr->handle, 0);
208 }
164 if (ret < 0) 209 if (ret < 0)
165 return (ret); 210 return (ret);
166 else 211 else
167 return cpufreq_update_policy(pr->id); 212 return cpufreq_update_policy(pr->id);
168} 213}
169 214
215int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
216{
217 struct acpi_processor *pr;
218
219 pr = per_cpu(processors, cpu);
220 if (!pr || !pr->performance || !pr->performance->state_count)
221 return -ENODEV;
222 *limit = pr->performance->states[pr->performance_platform_limit].
223 core_frequency * 1000;
224 return 0;
225}
226EXPORT_SYMBOL(acpi_processor_get_bios_limit);
227
170void acpi_processor_ppc_init(void) 228void acpi_processor_ppc_init(void)
171{ 229{
172 if (!cpufreq_register_notifier 230 if (!cpufreq_register_notifier
@@ -356,7 +414,11 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
356 if (result) 414 if (result)
357 goto update_bios; 415 goto update_bios;
358 416
359 return 0; 417 /* We need to call _PPC once when cpufreq starts */
418 if (ignore_ppc != 1)
419 result = acpi_processor_get_platform_limit(pr);
420
421 return result;
360 422
361 /* 423 /*
362 * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that 424 * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that
@@ -500,7 +562,7 @@ end:
500} 562}
501 563
502int acpi_processor_preregister_performance( 564int acpi_processor_preregister_performance(
503 struct acpi_processor_performance *performance) 565 struct acpi_processor_performance __percpu *performance)
504{ 566{
505 int count, count_target; 567 int count, count_target;
506 int retval = 0; 568 int retval = 0;
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 140c5c5b423c..6deafb4aa0da 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -443,8 +443,7 @@ struct thermal_cooling_device_ops processor_cooling_ops = {
443#ifdef CONFIG_ACPI_PROCFS 443#ifdef CONFIG_ACPI_PROCFS
444static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) 444static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
445{ 445{
446 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 446 struct acpi_processor *pr = seq->private;
447
448 447
449 if (!pr) 448 if (!pr)
450 goto end; 449 goto end;
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1c5d7a8b2fdf..9ade1a5b32ed 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/slab.h>
31#include <linux/init.h> 32#include <linux/init.h>
32#include <linux/sched.h> 33#include <linux/sched.h>
33#include <linux/cpufreq.h> 34#include <linux/cpufreq.h>
@@ -660,7 +661,7 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
660 661
661#ifdef CONFIG_X86 662#ifdef CONFIG_X86
662static int acpi_throttling_rdmsr(struct acpi_processor *pr, 663static int acpi_throttling_rdmsr(struct acpi_processor *pr,
663 acpi_integer * value) 664 u64 *value)
664{ 665{
665 struct cpuinfo_x86 *c; 666 struct cpuinfo_x86 *c;
666 u64 msr_high, msr_low; 667 u64 msr_high, msr_low;
@@ -681,13 +682,13 @@ static int acpi_throttling_rdmsr(struct acpi_processor *pr,
681 rdmsr_safe(MSR_IA32_THERM_CONTROL, 682 rdmsr_safe(MSR_IA32_THERM_CONTROL,
682 (u32 *)&msr_low , (u32 *) &msr_high); 683 (u32 *)&msr_low , (u32 *) &msr_high);
683 msr = (msr_high << 32) | msr_low; 684 msr = (msr_high << 32) | msr_low;
684 *value = (acpi_integer) msr; 685 *value = (u64) msr;
685 ret = 0; 686 ret = 0;
686 } 687 }
687 return ret; 688 return ret;
688} 689}
689 690
690static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) 691static int acpi_throttling_wrmsr(struct acpi_processor *pr, u64 value)
691{ 692{
692 struct cpuinfo_x86 *c; 693 struct cpuinfo_x86 *c;
693 unsigned int cpu; 694 unsigned int cpu;
@@ -711,14 +712,14 @@ static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
711} 712}
712#else 713#else
713static int acpi_throttling_rdmsr(struct acpi_processor *pr, 714static int acpi_throttling_rdmsr(struct acpi_processor *pr,
714 acpi_integer * value) 715 u64 *value)
715{ 716{
716 printk(KERN_ERR PREFIX 717 printk(KERN_ERR PREFIX
717 "HARDWARE addr space,NOT supported yet\n"); 718 "HARDWARE addr space,NOT supported yet\n");
718 return -1; 719 return -1;
719} 720}
720 721
721static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) 722static int acpi_throttling_wrmsr(struct acpi_processor *pr, u64 value)
722{ 723{
723 printk(KERN_ERR PREFIX 724 printk(KERN_ERR PREFIX
724 "HARDWARE addr space,NOT supported yet\n"); 725 "HARDWARE addr space,NOT supported yet\n");
@@ -727,7 +728,7 @@ static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
727#endif 728#endif
728 729
729static int acpi_read_throttling_status(struct acpi_processor *pr, 730static int acpi_read_throttling_status(struct acpi_processor *pr,
730 acpi_integer *value) 731 u64 *value)
731{ 732{
732 u32 bit_width, bit_offset; 733 u32 bit_width, bit_offset;
733 u64 ptc_value; 734 u64 ptc_value;
@@ -746,7 +747,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
746 address, (u32 *) &ptc_value, 747 address, (u32 *) &ptc_value,
747 (u32) (bit_width + bit_offset)); 748 (u32) (bit_width + bit_offset));
748 ptc_mask = (1 << bit_width) - 1; 749 ptc_mask = (1 << bit_width) - 1;
749 *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask); 750 *value = (u64) ((ptc_value >> bit_offset) & ptc_mask);
750 ret = 0; 751 ret = 0;
751 break; 752 break;
752 case ACPI_ADR_SPACE_FIXED_HARDWARE: 753 case ACPI_ADR_SPACE_FIXED_HARDWARE:
@@ -760,7 +761,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
760} 761}
761 762
762static int acpi_write_throttling_state(struct acpi_processor *pr, 763static int acpi_write_throttling_state(struct acpi_processor *pr,
763 acpi_integer value) 764 u64 value)
764{ 765{
765 u32 bit_width, bit_offset; 766 u32 bit_width, bit_offset;
766 u64 ptc_value; 767 u64 ptc_value;
@@ -793,7 +794,7 @@ static int acpi_write_throttling_state(struct acpi_processor *pr,
793} 794}
794 795
795static int acpi_get_throttling_state(struct acpi_processor *pr, 796static int acpi_get_throttling_state(struct acpi_processor *pr,
796 acpi_integer value) 797 u64 value)
797{ 798{
798 int i; 799 int i;
799 800
@@ -808,7 +809,7 @@ static int acpi_get_throttling_state(struct acpi_processor *pr,
808} 809}
809 810
810static int acpi_get_throttling_value(struct acpi_processor *pr, 811static int acpi_get_throttling_value(struct acpi_processor *pr,
811 int state, acpi_integer *value) 812 int state, u64 *value)
812{ 813{
813 int ret = -1; 814 int ret = -1;
814 815
@@ -826,7 +827,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
826{ 827{
827 int state = 0; 828 int state = 0;
828 int ret; 829 int ret;
829 acpi_integer value; 830 u64 value;
830 831
831 if (!pr) 832 if (!pr)
832 return -EINVAL; 833 return -EINVAL;
@@ -993,7 +994,7 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
993 int state, bool force) 994 int state, bool force)
994{ 995{
995 int ret; 996 int ret;
996 acpi_integer value; 997 u64 value;
997 998
998 if (!pr) 999 if (!pr)
999 return -EINVAL; 1000 return -EINVAL;
@@ -1133,9 +1134,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
1133 int result = 0; 1134 int result = 0;
1134 struct acpi_processor_throttling *pthrottling; 1135 struct acpi_processor_throttling *pthrottling;
1135 1136
1136 if (!pr)
1137 return -EINVAL;
1138
1139 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1137 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1140 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 1138 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
1141 pr->throttling.address, 1139 pr->throttling.address,
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 52b9db8afc20..4ff76e8174eb 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/slab.h>
28#include <linux/module.h> 29#include <linux/module.h>
29#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
30#include <linux/kernel.h> 31#include <linux/kernel.h>
@@ -217,6 +218,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
217 case POWER_SUPPLY_PROP_TECHNOLOGY: 218 case POWER_SUPPLY_PROP_TECHNOLOGY:
218 val->intval = acpi_battery_technology(battery); 219 val->intval = acpi_battery_technology(battery);
219 break; 220 break;
221 case POWER_SUPPLY_PROP_CYCLE_COUNT:
222 val->intval = battery->cycle_count;
223 break;
220 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 224 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
221 val->intval = battery->design_voltage * 225 val->intval = battery->design_voltage *
222 acpi_battery_vscale(battery) * 1000; 226 acpi_battery_vscale(battery) * 1000;
@@ -276,6 +280,7 @@ static enum power_supply_property sbs_charge_battery_props[] = {
276 POWER_SUPPLY_PROP_STATUS, 280 POWER_SUPPLY_PROP_STATUS,
277 POWER_SUPPLY_PROP_PRESENT, 281 POWER_SUPPLY_PROP_PRESENT,
278 POWER_SUPPLY_PROP_TECHNOLOGY, 282 POWER_SUPPLY_PROP_TECHNOLOGY,
283 POWER_SUPPLY_PROP_CYCLE_COUNT,
279 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 284 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
280 POWER_SUPPLY_PROP_VOLTAGE_NOW, 285 POWER_SUPPLY_PROP_VOLTAGE_NOW,
281 POWER_SUPPLY_PROP_CURRENT_NOW, 286 POWER_SUPPLY_PROP_CURRENT_NOW,
@@ -560,6 +565,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
560 battery->design_voltage * acpi_battery_vscale(battery)); 565 battery->design_voltage * acpi_battery_vscale(battery));
561 seq_printf(seq, "design capacity warning: unknown\n"); 566 seq_printf(seq, "design capacity warning: unknown\n");
562 seq_printf(seq, "design capacity low: unknown\n"); 567 seq_printf(seq, "design capacity low: unknown\n");
568 seq_printf(seq, "cycle count: %i\n", battery->cycle_count);
563 seq_printf(seq, "capacity granularity 1: unknown\n"); 569 seq_printf(seq, "capacity granularity 1: unknown\n");
564 seq_printf(seq, "capacity granularity 2: unknown\n"); 570 seq_printf(seq, "capacity granularity 2: unknown\n");
565 seq_printf(seq, "model number: %s\n", battery->device_name); 571 seq_printf(seq, "model number: %s\n", battery->device_name);
@@ -822,7 +828,10 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
822 828
823static void acpi_battery_remove(struct acpi_sbs *sbs, int id) 829static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
824{ 830{
831#if defined(CONFIG_ACPI_SYSFS_POWER) || defined(CONFIG_ACPI_PROCFS_POWER)
825 struct acpi_battery *battery = &sbs->battery[id]; 832 struct acpi_battery *battery = &sbs->battery[id];
833#endif
834
826#ifdef CONFIG_ACPI_SYSFS_POWER 835#ifdef CONFIG_ACPI_SYSFS_POWER
827 if (battery->bat.dev) { 836 if (battery->bat.dev) {
828 if (battery->have_sysfs_alarm) 837 if (battery->have_sysfs_alarm)
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index d9339806df45..f8be23b6c129 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -11,13 +11,14 @@
11#include <acpi/acpi_bus.h> 11#include <acpi/acpi_bus.h>
12#include <acpi/acpi_drivers.h> 12#include <acpi/acpi_drivers.h>
13#include <linux/wait.h> 13#include <linux/wait.h>
14#include <linux/slab.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include "sbshc.h" 17#include "sbshc.h"
17 18
18#define PREFIX "ACPI: " 19#define PREFIX "ACPI: "
19 20
20#define ACPI_SMB_HC_CLASS "smbus_host_controller" 21#define ACPI_SMB_HC_CLASS "smbus_host_ctl"
21#define ACPI_SMB_HC_DEVICE_NAME "ACPI SMBus HC" 22#define ACPI_SMB_HC_DEVICE_NAME "ACPI SMBus HC"
22 23
23struct acpi_smb_hc { 24struct acpi_smb_hc {
@@ -242,7 +243,7 @@ static int smbus_alarm(void *context)
242 case ACPI_SBS_CHARGER: 243 case ACPI_SBS_CHARGER:
243 case ACPI_SBS_MANAGER: 244 case ACPI_SBS_MANAGER:
244 case ACPI_SBS_BATTERY: 245 case ACPI_SBS_BATTERY:
245 acpi_os_execute(OSL_GPE_HANDLER, 246 acpi_os_execute(OSL_NOTIFY_HANDLER,
246 acpi_smbus_callback, hc); 247 acpi_smbus_callback, hc);
247 default:; 248 default:;
248 } 249 }
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 14a7481c97d7..0338f513a010 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -4,10 +4,12 @@
4 4
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/slab.h>
7#include <linux/kernel.h> 8#include <linux/kernel.h>
8#include <linux/acpi.h> 9#include <linux/acpi.h>
9#include <linux/signal.h> 10#include <linux/signal.h>
10#include <linux/kthread.h> 11#include <linux/kthread.h>
12#include <linux/dmi.h>
11 13
12#include <acpi/acpi_drivers.h> 14#include <acpi/acpi_drivers.h>
13 15
@@ -741,19 +743,40 @@ acpi_bus_extract_wakeup_device_power_package(struct acpi_device *device,
741 return AE_OK; 743 return AE_OK;
742} 744}
743 745
744static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device) 746static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
745{ 747{
746 acpi_status status = 0;
747 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
748 union acpi_object *package = NULL;
749 int psw_error;
750
751 struct acpi_device_id button_device_ids[] = { 748 struct acpi_device_id button_device_ids[] = {
752 {"PNP0C0D", 0}, 749 {"PNP0C0D", 0},
753 {"PNP0C0C", 0}, 750 {"PNP0C0C", 0},
754 {"PNP0C0E", 0}, 751 {"PNP0C0E", 0},
755 {"", 0}, 752 {"", 0},
756 }; 753 };
754 acpi_status status;
755 acpi_event_status event_status;
756
757 device->wakeup.run_wake_count = 0;
758 device->wakeup.flags.notifier_present = 0;
759
760 /* Power button, Lid switch always enable wakeup */
761 if (!acpi_match_device_ids(device, button_device_ids)) {
762 device->wakeup.flags.run_wake = 1;
763 device->wakeup.flags.always_enabled = 1;
764 return;
765 }
766
767 status = acpi_get_gpe_status(NULL, device->wakeup.gpe_number,
768 ACPI_NOT_ISR, &event_status);
769 if (status == AE_OK)
770 device->wakeup.flags.run_wake =
771 !!(event_status & ACPI_EVENT_FLAG_HANDLE);
772}
773
774static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
775{
776 acpi_status status = 0;
777 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
778 union acpi_object *package = NULL;
779 int psw_error;
757 780
758 /* _PRW */ 781 /* _PRW */
759 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer); 782 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
@@ -773,6 +796,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
773 796
774 device->wakeup.flags.valid = 1; 797 device->wakeup.flags.valid = 1;
775 device->wakeup.prepare_count = 0; 798 device->wakeup.prepare_count = 0;
799 acpi_bus_set_run_wake_flags(device);
776 /* Call _PSW/_DSW object to disable its ability to wake the sleeping 800 /* Call _PSW/_DSW object to disable its ability to wake the sleeping
777 * system for the ACPI device with the _PRW object. 801 * system for the ACPI device with the _PRW object.
778 * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW. 802 * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@ -784,10 +808,6 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
784 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 808 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
785 "error in _DSW or _PSW evaluation\n")); 809 "error in _DSW or _PSW evaluation\n"));
786 810
787 /* Power button, Lid switch always enable wakeup */
788 if (!acpi_match_device_ids(device, button_device_ids))
789 device->wakeup.flags.run_wake = 1;
790
791end: 811end:
792 if (ACPI_FAILURE(status)) 812 if (ACPI_FAILURE(status))
793 device->flags.wake_capable = 0; 813 device->flags.wake_capable = 0;
@@ -1014,6 +1034,41 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id)
1014 list_add_tail(&id->list, &device->pnp.ids); 1034 list_add_tail(&id->list, &device->pnp.ids);
1015} 1035}
1016 1036
1037/*
1038 * Old IBM workstations have a DSDT bug wherein the SMBus object
1039 * lacks the SMBUS01 HID and the methods do not have the necessary "_"
1040 * prefix. Work around this.
1041 */
1042static int acpi_ibm_smbus_match(struct acpi_device *device)
1043{
1044 acpi_handle h_dummy;
1045 struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
1046 int result;
1047
1048 if (!dmi_name_in_vendors("IBM"))
1049 return -ENODEV;
1050
1051 /* Look for SMBS object */
1052 result = acpi_get_name(device->handle, ACPI_SINGLE_NAME, &path);
1053 if (result)
1054 return result;
1055
1056 if (strcmp("SMBS", path.pointer)) {
1057 result = -ENODEV;
1058 goto out;
1059 }
1060
1061 /* Does it have the necessary (but misnamed) methods? */
1062 result = -ENODEV;
1063 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "SBI", &h_dummy)) &&
1064 ACPI_SUCCESS(acpi_get_handle(device->handle, "SBR", &h_dummy)) &&
1065 ACPI_SUCCESS(acpi_get_handle(device->handle, "SBW", &h_dummy)))
1066 result = 0;
1067out:
1068 kfree(path.pointer);
1069 return result;
1070}
1071
1017static void acpi_device_set_id(struct acpi_device *device) 1072static void acpi_device_set_id(struct acpi_device *device)
1018{ 1073{
1019 acpi_status status; 1074 acpi_status status;
@@ -1026,12 +1081,6 @@ static void acpi_device_set_id(struct acpi_device *device)
1026 if (ACPI_IS_ROOT_DEVICE(device)) { 1081 if (ACPI_IS_ROOT_DEVICE(device)) {
1027 acpi_add_id(device, ACPI_SYSTEM_HID); 1082 acpi_add_id(device, ACPI_SYSTEM_HID);
1028 break; 1083 break;
1029 } else if (ACPI_IS_ROOT_DEVICE(device->parent)) {
1030 /* \_SB_, the only root-level namespace device */
1031 acpi_add_id(device, ACPI_BUS_HID);
1032 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
1033 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
1034 break;
1035 } 1084 }
1036 1085
1037 status = acpi_get_object_info(device->handle, &info); 1086 status = acpi_get_object_info(device->handle, &info);
@@ -1064,6 +1113,14 @@ static void acpi_device_set_id(struct acpi_device *device)
1064 acpi_add_id(device, ACPI_BAY_HID); 1113 acpi_add_id(device, ACPI_BAY_HID);
1065 else if (ACPI_SUCCESS(acpi_dock_match(device))) 1114 else if (ACPI_SUCCESS(acpi_dock_match(device)))
1066 acpi_add_id(device, ACPI_DOCK_HID); 1115 acpi_add_id(device, ACPI_DOCK_HID);
1116 else if (!acpi_ibm_smbus_match(device))
1117 acpi_add_id(device, ACPI_SMBUS_IBM_HID);
1118 else if (!acpi_device_hid(device) &&
1119 ACPI_IS_ROOT_DEVICE(device->parent)) {
1120 acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
1121 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
1122 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
1123 }
1067 1124
1068 break; 1125 break;
1069 case ACPI_BUS_TYPE_POWER: 1126 case ACPI_BUS_TYPE_POWER:
@@ -1332,13 +1389,29 @@ static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops,
1332 status = acpi_bus_check_add(handle, 0, ops, &device); 1389 status = acpi_bus_check_add(handle, 0, ops, &device);
1333 if (ACPI_SUCCESS(status)) 1390 if (ACPI_SUCCESS(status))
1334 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 1391 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1335 acpi_bus_check_add, ops, &device); 1392 acpi_bus_check_add, NULL, ops, &device);
1336 1393
1337 if (child) 1394 if (child)
1338 *child = device; 1395 *child = device;
1339 return 0; 1396
1397 if (device)
1398 return 0;
1399 else
1400 return -ENODEV;
1340} 1401}
1341 1402
1403/*
1404 * acpi_bus_add and acpi_bus_start
1405 *
1406 * scan a given ACPI tree and (probably recently hot-plugged)
1407 * create and add or starts found devices.
1408 *
1409 * If no devices were found -ENODEV is returned which does not
1410 * mean that this is a real error, there just have been no suitable
1411 * ACPI objects in the table trunk from which the kernel could create
1412 * a device and add/start an appropriate driver.
1413 */
1414
1342int 1415int
1343acpi_bus_add(struct acpi_device **child, 1416acpi_bus_add(struct acpi_device **child,
1344 struct acpi_device *parent, acpi_handle handle, int type) 1417 struct acpi_device *parent, acpi_handle handle, int type)
@@ -1348,8 +1421,7 @@ acpi_bus_add(struct acpi_device **child,
1348 memset(&ops, 0, sizeof(ops)); 1421 memset(&ops, 0, sizeof(ops));
1349 ops.acpi_op_add = 1; 1422 ops.acpi_op_add = 1;
1350 1423
1351 acpi_bus_scan(handle, &ops, child); 1424 return acpi_bus_scan(handle, &ops, child);
1352 return 0;
1353} 1425}
1354EXPORT_SYMBOL(acpi_bus_add); 1426EXPORT_SYMBOL(acpi_bus_add);
1355 1427
@@ -1357,11 +1429,13 @@ int acpi_bus_start(struct acpi_device *device)
1357{ 1429{
1358 struct acpi_bus_ops ops; 1430 struct acpi_bus_ops ops;
1359 1431
1432 if (!device)
1433 return -EINVAL;
1434
1360 memset(&ops, 0, sizeof(ops)); 1435 memset(&ops, 0, sizeof(ops));
1361 ops.acpi_op_start = 1; 1436 ops.acpi_op_start = 1;
1362 1437
1363 acpi_bus_scan(device->handle, &ops, NULL); 1438 return acpi_bus_scan(device->handle, &ops, NULL);
1364 return 0;
1365} 1439}
1366EXPORT_SYMBOL(acpi_bus_start); 1440EXPORT_SYMBOL(acpi_bus_start);
1367 1441
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 5f2c379ab7bf..baa76bbf244a 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -81,6 +81,23 @@ static int acpi_sleep_prepare(u32 acpi_state)
81#ifdef CONFIG_ACPI_SLEEP 81#ifdef CONFIG_ACPI_SLEEP
82static u32 acpi_target_sleep_state = ACPI_STATE_S0; 82static u32 acpi_target_sleep_state = ACPI_STATE_S0;
83/* 83/*
84 * According to the ACPI specification the BIOS should make sure that ACPI is
85 * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
86 * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
87 * on such systems during resume. Unfortunately that doesn't help in
88 * particularly pathological cases in which SCI_EN has to be set directly on
89 * resume, although the specification states very clearly that this flag is
90 * owned by the hardware. The set_sci_en_on_resume variable will be set in such
91 * cases.
92 */
93static bool set_sci_en_on_resume;
94
95void __init acpi_set_sci_en_on_resume(void)
96{
97 set_sci_en_on_resume = true;
98}
99
100/*
84 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the 101 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
85 * user to request that behavior by using the 'acpi_old_suspend_ordering' 102 * user to request that behavior by using the 'acpi_old_suspend_ordering'
86 * kernel command line option that causes the following variable to be set. 103 * kernel command line option that causes the following variable to be set.
@@ -170,18 +187,6 @@ static void acpi_pm_end(void)
170#endif /* CONFIG_ACPI_SLEEP */ 187#endif /* CONFIG_ACPI_SLEEP */
171 188
172#ifdef CONFIG_SUSPEND 189#ifdef CONFIG_SUSPEND
173/*
174 * According to the ACPI specification the BIOS should make sure that ACPI is
175 * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
176 * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
177 * on such systems during resume. Unfortunately that doesn't help in
178 * particularly pathological cases in which SCI_EN has to be set directly on
179 * resume, although the specification states very clearly that this flag is
180 * owned by the hardware. The set_sci_en_on_resume variable will be set in such
181 * cases.
182 */
183static bool set_sci_en_on_resume;
184
185extern void do_suspend_lowlevel(void); 190extern void do_suspend_lowlevel(void);
186 191
187static u32 acpi_suspend_states[] = { 192static u32 acpi_suspend_states[] = {
@@ -445,6 +450,38 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
445 }, 450 },
446 }, 451 },
447 { 452 {
453 .callback = init_set_sci_en_on_resume,
454 .ident = "Lenovo ThinkPad T410",
455 .matches = {
456 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
457 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T410"),
458 },
459 },
460 {
461 .callback = init_set_sci_en_on_resume,
462 .ident = "Lenovo ThinkPad T510",
463 .matches = {
464 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
465 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T510"),
466 },
467 },
468 {
469 .callback = init_set_sci_en_on_resume,
470 .ident = "Lenovo ThinkPad W510",
471 .matches = {
472 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
473 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W510"),
474 },
475 },
476 {
477 .callback = init_set_sci_en_on_resume,
478 .ident = "Lenovo ThinkPad X201[s]",
479 .matches = {
480 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
481 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201"),
482 },
483 },
484 {
448 .callback = init_old_suspend_ordering, 485 .callback = init_old_suspend_ordering,
449 .ident = "Panasonic CF51-2L", 486 .ident = "Panasonic CF51-2L",
450 .matches = { 487 .matches = {
@@ -453,6 +490,30 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
453 DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"), 490 DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"),
454 }, 491 },
455 }, 492 },
493 {
494 .callback = init_set_sci_en_on_resume,
495 .ident = "Dell Studio 1558",
496 .matches = {
497 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
498 DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1558"),
499 },
500 },
501 {
502 .callback = init_set_sci_en_on_resume,
503 .ident = "Dell Studio 1557",
504 .matches = {
505 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
506 DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1557"),
507 },
508 },
509 {
510 .callback = init_set_sci_en_on_resume,
511 .ident = "Dell Studio 1555",
512 .matches = {
513 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
514 DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1555"),
515 },
516 },
456 {}, 517 {},
457}; 518};
458#endif /* CONFIG_SUSPEND */ 519#endif /* CONFIG_SUSPEND */
@@ -547,8 +608,17 @@ static void acpi_hibernation_leave(void)
547 hibernate_nvs_restore(); 608 hibernate_nvs_restore();
548} 609}
549 610
550static void acpi_pm_enable_gpes(void) 611static int acpi_pm_pre_restore(void)
551{ 612{
613 acpi_disable_all_gpes();
614 acpi_os_wait_events_complete(NULL);
615 acpi_ec_suspend_transactions();
616 return 0;
617}
618
619static void acpi_pm_restore_cleanup(void)
620{
621 acpi_ec_resume_transactions();
552 acpi_enable_all_runtime_gpes(); 622 acpi_enable_all_runtime_gpes();
553} 623}
554 624
@@ -560,8 +630,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops = {
560 .prepare = acpi_pm_prepare, 630 .prepare = acpi_pm_prepare,
561 .enter = acpi_hibernation_enter, 631 .enter = acpi_hibernation_enter,
562 .leave = acpi_hibernation_leave, 632 .leave = acpi_hibernation_leave,
563 .pre_restore = acpi_pm_disable_gpes, 633 .pre_restore = acpi_pm_pre_restore,
564 .restore_cleanup = acpi_pm_enable_gpes, 634 .restore_cleanup = acpi_pm_restore_cleanup,
565}; 635};
566 636
567/** 637/**
@@ -613,8 +683,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops_old = {
613 .prepare = acpi_pm_disable_gpes, 683 .prepare = acpi_pm_disable_gpes,
614 .enter = acpi_hibernation_enter, 684 .enter = acpi_hibernation_enter,
615 .leave = acpi_hibernation_leave, 685 .leave = acpi_hibernation_leave,
616 .pre_restore = acpi_pm_disable_gpes, 686 .pre_restore = acpi_pm_pre_restore,
617 .restore_cleanup = acpi_pm_enable_gpes, 687 .restore_cleanup = acpi_pm_restore_cleanup,
618 .recover = acpi_pm_finish, 688 .recover = acpi_pm_finish,
619}; 689};
620#endif /* CONFIG_HIBERNATION */ 690#endif /* CONFIG_HIBERNATION */
@@ -740,9 +810,18 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
740 return -ENODEV; 810 return -ENODEV;
741 } 811 }
742 812
743 error = enable ? 813 if (enable) {
744 acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) : 814 error = acpi_enable_wakeup_device_power(adev,
745 acpi_disable_wakeup_device_power(adev); 815 acpi_target_sleep_state);
816 if (!error)
817 acpi_enable_gpe(adev->wakeup.gpe_device,
818 adev->wakeup.gpe_number,
819 ACPI_GPE_TYPE_WAKE);
820 } else {
821 acpi_disable_gpe(adev->wakeup.gpe_device, adev->wakeup.gpe_number,
822 ACPI_GPE_TYPE_WAKE);
823 error = acpi_disable_wakeup_device_power(adev);
824 }
746 if (!error) 825 if (!error)
747 dev_info(dev, "wake-up capability %s by ACPI\n", 826 dev_info(dev, "wake-up capability %s by ACPI\n",
748 enable ? "enabled" : "disabled"); 827 enable ? "enabled" : "disabled");
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index d11282975f35..4aaf24976138 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/proc_fs.h> 26#include <linux/proc_fs.h>
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/string.h> 30#include <linux/string.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
@@ -101,6 +102,7 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
101 struct acpi_table_header *header = NULL; 102 struct acpi_table_header *header = NULL;
102 struct acpi_table_attr *attr = NULL; 103 struct acpi_table_attr *attr = NULL;
103 104
105 sysfs_attr_init(&table_attr->attr.attr);
104 if (table_header->signature[0] != '\0') 106 if (table_header->signature[0] != '\0')
105 memcpy(table_attr->name, table_header->signature, 107 memcpy(table_attr->name, table_header->signature,
106 ACPI_NAME_SIZE); 108 ACPI_NAME_SIZE);
@@ -387,10 +389,10 @@ static ssize_t counter_set(struct kobject *kobj,
387 if (index < num_gpes) { 389 if (index < num_gpes) {
388 if (!strcmp(buf, "disable\n") && 390 if (!strcmp(buf, "disable\n") &&
389 (status & ACPI_EVENT_FLAG_ENABLED)) 391 (status & ACPI_EVENT_FLAG_ENABLED))
390 result = acpi_disable_gpe(handle, index); 392 result = acpi_set_gpe(handle, index, ACPI_GPE_DISABLE);
391 else if (!strcmp(buf, "enable\n") && 393 else if (!strcmp(buf, "enable\n") &&
392 !(status & ACPI_EVENT_FLAG_ENABLED)) 394 !(status & ACPI_EVENT_FLAG_ENABLED))
393 result = acpi_enable_gpe(handle, index); 395 result = acpi_set_gpe(handle, index, ACPI_GPE_ENABLE);
394 else if (!strcmp(buf, "clear\n") && 396 else if (!strcmp(buf, "clear\n") &&
395 (status & ACPI_EVENT_FLAG_SET)) 397 (status & ACPI_EVENT_FLAG_SET))
396 result = acpi_clear_gpe(handle, index, ACPI_NOT_ISR); 398 result = acpi_clear_gpe(handle, index, ACPI_NOT_ISR);
@@ -475,6 +477,7 @@ void acpi_irq_stats_init(void)
475 goto fail; 477 goto fail;
476 strncpy(name, buffer, strlen(buffer) + 1); 478 strncpy(name, buffer, strlen(buffer) + 1);
477 479
480 sysfs_attr_init(&counter_attrs[i].attr);
478 counter_attrs[i].attr.name = name; 481 counter_attrs[i].attr.name = name;
479 counter_attrs[i].attr.mode = 0644; 482 counter_attrs[i].attr.mode = 0644;
480 counter_attrs[i].show = counter_show; 483 counter_attrs[i].show = counter_show;
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index f336bca7c450..8a0ed2800e63 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -213,7 +213,7 @@ acpi_table_parse_entries(char *id,
213 unsigned long table_end; 213 unsigned long table_end;
214 acpi_size tbl_size; 214 acpi_size tbl_size;
215 215
216 if (acpi_disabled) 216 if (acpi_disabled && !acpi_ht)
217 return -ENODEV; 217 return -ENODEV;
218 218
219 if (!handler) 219 if (!handler)
@@ -280,7 +280,7 @@ int __init acpi_table_parse(char *id, acpi_table_handler handler)
280 struct acpi_table_header *table = NULL; 280 struct acpi_table_header *table = NULL;
281 acpi_size tbl_size; 281 acpi_size tbl_size;
282 282
283 if (acpi_disabled) 283 if (acpi_disabled && !acpi_ht)
284 return -ENODEV; 284 return -ENODEV;
285 285
286 if (!handler) 286 if (!handler)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 65f67815902a..efad1f33aeb5 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -35,6 +35,7 @@
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/dmi.h> 36#include <linux/dmi.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/slab.h>
38#include <linux/types.h> 39#include <linux/types.h>
39#include <linux/proc_fs.h> 40#include <linux/proc_fs.h>
40#include <linux/jiffies.h> 41#include <linux/jiffies.h>
@@ -368,7 +369,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
368 int valid = 0; 369 int valid = 0;
369 int i; 370 int i;
370 371
371 /* Critical Shutdown (required) */ 372 /* Critical Shutdown */
372 if (flag & ACPI_TRIPS_CRITICAL) { 373 if (flag & ACPI_TRIPS_CRITICAL) {
373 status = acpi_evaluate_integer(tz->device->handle, 374 status = acpi_evaluate_integer(tz->device->handle,
374 "_CRT", NULL, &tmp); 375 "_CRT", NULL, &tmp);
@@ -379,17 +380,19 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
379 * Below zero (Celsius) values clearly aren't right for sure.. 380 * Below zero (Celsius) values clearly aren't right for sure..
380 * ... so lets discard those as invalid. 381 * ... so lets discard those as invalid.
381 */ 382 */
382 if (ACPI_FAILURE(status) || 383 if (ACPI_FAILURE(status)) {
383 tz->trips.critical.temperature <= 2732) { 384 tz->trips.critical.flags.valid = 0;
385 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
386 "No critical threshold\n"));
387 } else if (tmp <= 2732) {
388 printk(KERN_WARNING FW_BUG "Invalid critical threshold "
389 "(%llu)\n", tmp);
384 tz->trips.critical.flags.valid = 0; 390 tz->trips.critical.flags.valid = 0;
385 ACPI_EXCEPTION((AE_INFO, status,
386 "No or invalid critical threshold"));
387 return -ENODEV;
388 } else { 391 } else {
389 tz->trips.critical.flags.valid = 1; 392 tz->trips.critical.flags.valid = 1;
390 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 393 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
391 "Found critical threshold [%lu]\n", 394 "Found critical threshold [%lu]\n",
392 tz->trips.critical.temperature)); 395 tz->trips.critical.temperature));
393 } 396 }
394 if (tz->trips.critical.flags.valid == 1) { 397 if (tz->trips.critical.flags.valid == 1) {
395 if (crt == -1) { 398 if (crt == -1) {
@@ -575,7 +578,23 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
575 578
576static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) 579static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
577{ 580{
578 return acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); 581 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT);
582
583 if (ret)
584 return ret;
585
586 valid = tz->trips.critical.flags.valid |
587 tz->trips.hot.flags.valid |
588 tz->trips.passive.flags.valid;
589
590 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
591 valid |= tz->trips.active[i].flags.valid;
592
593 if (!valid) {
594 printk(KERN_WARNING FW_BUG "No valid trip found\n");
595 return -ENODEV;
596 }
597 return 0;
579} 598}
580 599
581static void acpi_thermal_check(void *data) 600static void acpi_thermal_check(void *data)
@@ -1052,6 +1071,13 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
1052 acpi_device_bid(device)); 1071 acpi_device_bid(device));
1053 } 1072 }
1054 seq_puts(seq, "\n"); 1073 seq_puts(seq, "\n");
1074 } else {
1075 seq_printf(seq, "passive (forced):");
1076 if (tz->thermal_zone->forced_passive)
1077 seq_printf(seq, " %i C\n",
1078 tz->thermal_zone->forced_passive / 1000);
1079 else
1080 seq_printf(seq, "<not set>\n");
1055 } 1081 }
1056 1082
1057 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { 1083 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 811fec10462b..b002a471c5d4 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/types.h> 30#include <linux/types.h>
30#include <acpi/acpi_bus.h> 31#include <acpi/acpi_bus.h>
@@ -107,12 +108,12 @@ acpi_extract_package(union acpi_object *package,
107 case ACPI_TYPE_INTEGER: 108 case ACPI_TYPE_INTEGER:
108 switch (format_string[i]) { 109 switch (format_string[i]) {
109 case 'N': 110 case 'N':
110 size_required += sizeof(acpi_integer); 111 size_required += sizeof(u64);
111 tail_offset += sizeof(acpi_integer); 112 tail_offset += sizeof(u64);
112 break; 113 break;
113 case 'S': 114 case 'S':
114 size_required += 115 size_required +=
115 sizeof(char *) + sizeof(acpi_integer) + 116 sizeof(char *) + sizeof(u64) +
116 sizeof(char); 117 sizeof(char);
117 tail_offset += sizeof(char *); 118 tail_offset += sizeof(char *);
118 break; 119 break;
@@ -193,17 +194,17 @@ acpi_extract_package(union acpi_object *package,
193 case ACPI_TYPE_INTEGER: 194 case ACPI_TYPE_INTEGER:
194 switch (format_string[i]) { 195 switch (format_string[i]) {
195 case 'N': 196 case 'N':
196 *((acpi_integer *) head) = 197 *((u64 *) head) =
197 element->integer.value; 198 element->integer.value;
198 head += sizeof(acpi_integer); 199 head += sizeof(u64);
199 break; 200 break;
200 case 'S': 201 case 'S':
201 pointer = (u8 **) head; 202 pointer = (u8 **) head;
202 *pointer = tail; 203 *pointer = tail;
203 *((acpi_integer *) tail) = 204 *((u64 *) tail) =
204 element->integer.value; 205 element->integer.value;
205 head += sizeof(acpi_integer *); 206 head += sizeof(u64 *);
206 tail += sizeof(acpi_integer); 207 tail += sizeof(u64);
207 /* NULL terminate string */ 208 /* NULL terminate string */
208 *tail = (char)0; 209 *tail = (char)0;
209 tail += sizeof(char); 210 tail += sizeof(char);
@@ -289,51 +290,6 @@ acpi_evaluate_integer(acpi_handle handle,
289 290
290EXPORT_SYMBOL(acpi_evaluate_integer); 291EXPORT_SYMBOL(acpi_evaluate_integer);
291 292
292#if 0
293acpi_status
294acpi_evaluate_string(acpi_handle handle,
295 acpi_string pathname,
296 acpi_object_list * arguments, acpi_string * data)
297{
298 acpi_status status = AE_OK;
299 acpi_object *element = NULL;
300 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
301
302
303 if (!data)
304 return AE_BAD_PARAMETER;
305
306 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
307 if (ACPI_FAILURE(status)) {
308 acpi_util_eval_error(handle, pathname, status);
309 return status;
310 }
311
312 element = (acpi_object *) buffer.pointer;
313
314 if ((element->type != ACPI_TYPE_STRING)
315 || (element->type != ACPI_TYPE_BUFFER)
316 || !element->string.length) {
317 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
318 return AE_BAD_DATA;
319 }
320
321 *data = kzalloc(element->string.length + 1, GFP_KERNEL);
322 if (!data) {
323 printk(KERN_ERR PREFIX "Memory allocation\n");
324 return -ENOMEM;
325 }
326
327 memcpy(*data, element->string.pointer, element->string.length);
328
329 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%s]\n", *data));
330
331 kfree(buffer.pointer);
332
333 return AE_OK;
334}
335#endif
336
337acpi_status 293acpi_status
338acpi_evaluate_reference(acpi_handle handle, 294acpi_evaluate_reference(acpi_handle handle,
339 acpi_string pathname, 295 acpi_string pathname,
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 05dff631591c..a0c93b321482 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -39,10 +39,12 @@
39#include <linux/sort.h> 39#include <linux/sort.h>
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/pci_ids.h> 41#include <linux/pci_ids.h>
42#include <linux/slab.h>
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <linux/dmi.h> 44#include <linux/dmi.h>
44#include <acpi/acpi_bus.h> 45#include <acpi/acpi_bus.h>
45#include <acpi/acpi_drivers.h> 46#include <acpi/acpi_drivers.h>
47#include <linux/suspend.h>
46 48
47#define PREFIX "ACPI: " 49#define PREFIX "ACPI: "
48 50
@@ -78,10 +80,16 @@ MODULE_LICENSE("GPL");
78static int brightness_switch_enabled = 1; 80static int brightness_switch_enabled = 1;
79module_param(brightness_switch_enabled, bool, 0644); 81module_param(brightness_switch_enabled, bool, 0644);
80 82
83/*
84 * By default, we don't allow duplicate ACPI video bus devices
85 * under the same VGA controller
86 */
87static int allow_duplicates;
88module_param(allow_duplicates, bool, 0644);
89
81static int register_count = 0; 90static int register_count = 0;
82static int acpi_video_bus_add(struct acpi_device *device); 91static int acpi_video_bus_add(struct acpi_device *device);
83static int acpi_video_bus_remove(struct acpi_device *device, int type); 92static int acpi_video_bus_remove(struct acpi_device *device, int type);
84static int acpi_video_resume(struct acpi_device *device);
85static void acpi_video_bus_notify(struct acpi_device *device, u32 event); 93static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
86 94
87static const struct acpi_device_id video_device_ids[] = { 95static const struct acpi_device_id video_device_ids[] = {
@@ -97,7 +105,6 @@ static struct acpi_driver acpi_video_bus = {
97 .ops = { 105 .ops = {
98 .add = acpi_video_bus_add, 106 .add = acpi_video_bus_add,
99 .remove = acpi_video_bus_remove, 107 .remove = acpi_video_bus_remove,
100 .resume = acpi_video_resume,
101 .notify = acpi_video_bus_notify, 108 .notify = acpi_video_bus_notify,
102 }, 109 },
103}; 110};
@@ -152,6 +159,7 @@ struct acpi_video_bus {
152 struct proc_dir_entry *dir; 159 struct proc_dir_entry *dir;
153 struct input_dev *input; 160 struct input_dev *input;
154 char phys[32]; /* for input device */ 161 char phys[32]; /* for input device */
162 struct notifier_block pm_nb;
155}; 163};
156 164
157struct acpi_video_device_flags { 165struct acpi_video_device_flags {
@@ -320,7 +328,7 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device,
320 int level); 328 int level);
321static int acpi_video_device_lcd_get_level_current( 329static int acpi_video_device_lcd_get_level_current(
322 struct acpi_video_device *device, 330 struct acpi_video_device *device,
323 unsigned long long *level); 331 unsigned long long *level, int init);
324static int acpi_video_get_next_level(struct acpi_video_device *device, 332static int acpi_video_get_next_level(struct acpi_video_device *device,
325 u32 level_current, u32 event); 333 u32 level_current, u32 event);
326static int acpi_video_switch_brightness(struct acpi_video_device *device, 334static int acpi_video_switch_brightness(struct acpi_video_device *device,
@@ -338,7 +346,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd)
338 struct acpi_video_device *vd = 346 struct acpi_video_device *vd =
339 (struct acpi_video_device *)bl_get_data(bd); 347 (struct acpi_video_device *)bl_get_data(bd);
340 348
341 if (acpi_video_device_lcd_get_level_current(vd, &cur_level)) 349 if (acpi_video_device_lcd_get_level_current(vd, &cur_level, 0))
342 return -EINVAL; 350 return -EINVAL;
343 for (i = 2; i < vd->brightness->count; i++) { 351 for (i = 2; i < vd->brightness->count; i++) {
344 if (vd->brightness->levels[i] == cur_level) 352 if (vd->brightness->levels[i] == cur_level)
@@ -407,7 +415,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig
407 unsigned long long level; 415 unsigned long long level;
408 int offset; 416 int offset;
409 417
410 if (acpi_video_device_lcd_get_level_current(video, &level)) 418 if (acpi_video_device_lcd_get_level_current(video, &level, 0))
411 return -EINVAL; 419 return -EINVAL;
412 for (offset = 2; offset < video->brightness->count; offset++) 420 for (offset = 2; offset < video->brightness->count; offset++)
413 if (level == video->brightness->levels[offset]) { 421 if (level == video->brightness->levels[offset]) {
@@ -602,7 +610,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
602 610
603static int 611static int
604acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, 612acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
605 unsigned long long *level) 613 unsigned long long *level, int init)
606{ 614{
607 acpi_status status = AE_OK; 615 acpi_status status = AE_OK;
608 int i; 616 int i;
@@ -626,10 +634,16 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
626 device->brightness->curr = *level; 634 device->brightness->curr = *level;
627 return 0; 635 return 0;
628 } 636 }
629 /* BQC returned an invalid level. Stop using it. */ 637 if (!init) {
630 ACPI_WARNING((AE_INFO, "%s returned an invalid level", 638 /*
631 buf)); 639 * BQC returned an invalid level.
632 device->cap._BQC = device->cap._BCQ = 0; 640 * Stop using it.
641 */
642 ACPI_WARNING((AE_INFO,
643 "%s returned an invalid level",
644 buf));
645 device->cap._BQC = device->cap._BCQ = 0;
646 }
633 } else { 647 } else {
634 /* Fixme: 648 /* Fixme:
635 * should we return an error or ignore this failure? 649 * should we return an error or ignore this failure?
@@ -752,7 +766,7 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video,
752static int 766static int
753acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) 767acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
754{ 768{
755 acpi_integer status = 0; 769 u64 status = 0;
756 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 770 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
757 struct acpi_object_list args = { 1, &arg0 }; 771 struct acpi_object_list args = { 1, &arg0 };
758 772
@@ -885,7 +899,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
885 if (!device->cap._BQC) 899 if (!device->cap._BQC)
886 goto set_level; 900 goto set_level;
887 901
888 result = acpi_video_device_lcd_get_level_current(device, &level_old); 902 result = acpi_video_device_lcd_get_level_current(device, &level_old, 1);
889 if (result) 903 if (result)
890 goto out_free_levels; 904 goto out_free_levels;
891 905
@@ -896,7 +910,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
896 if (result) 910 if (result)
897 goto out_free_levels; 911 goto out_free_levels;
898 912
899 result = acpi_video_device_lcd_get_level_current(device, &level); 913 result = acpi_video_device_lcd_get_level_current(device, &level, 0);
900 if (result) 914 if (result)
901 goto out_free_levels; 915 goto out_free_levels;
902 916
@@ -985,6 +999,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
985 } 999 }
986 1000
987 if (acpi_video_backlight_support()) { 1001 if (acpi_video_backlight_support()) {
1002 struct backlight_properties props;
988 int result; 1003 int result;
989 static int count = 0; 1004 static int count = 0;
990 char *name; 1005 char *name;
@@ -997,10 +1012,21 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
997 return; 1012 return;
998 1013
999 sprintf(name, "acpi_video%d", count++); 1014 sprintf(name, "acpi_video%d", count++);
1000 device->backlight = backlight_device_register(name, 1015 memset(&props, 0, sizeof(struct backlight_properties));
1001 NULL, device, &acpi_backlight_ops); 1016 props.max_brightness = device->brightness->count - 3;
1002 device->backlight->props.max_brightness = device->brightness->count-3; 1017 device->backlight = backlight_device_register(name, NULL, device,
1018 &acpi_backlight_ops,
1019 &props);
1003 kfree(name); 1020 kfree(name);
1021 if (IS_ERR(device->backlight))
1022 return;
1023
1024 /*
1025 * Save current brightness level in case we have to restore it
1026 * before acpi_video_device_lcd_set_level() is called next time.
1027 */
1028 device->backlight->props.brightness =
1029 acpi_video_get_brightness(device->backlight);
1004 1030
1005 result = sysfs_create_link(&device->backlight->dev.kobj, 1031 result = sysfs_create_link(&device->backlight->dev.kobj,
1006 &device->dev->dev.kobj, "device"); 1032 &device->dev->dev.kobj, "device");
@@ -1979,11 +2005,15 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
1979 unsigned long long level_current, level_next; 2005 unsigned long long level_current, level_next;
1980 int result = -EINVAL; 2006 int result = -EINVAL;
1981 2007
2008 /* no warning message if acpi_backlight=vendor is used */
2009 if (!acpi_video_backlight_support())
2010 return 0;
2011
1982 if (!device->brightness) 2012 if (!device->brightness)
1983 goto out; 2013 goto out;
1984 2014
1985 result = acpi_video_device_lcd_get_level_current(device, 2015 result = acpi_video_device_lcd_get_level_current(device,
1986 &level_current); 2016 &level_current, 0);
1987 if (result) 2017 if (result)
1988 goto out; 2018 goto out;
1989 2019
@@ -2100,7 +2130,7 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
2100{ 2130{
2101 struct acpi_video_bus *video = acpi_driver_data(device); 2131 struct acpi_video_bus *video = acpi_driver_data(device);
2102 struct input_dev *input; 2132 struct input_dev *input;
2103 int keycode; 2133 int keycode = 0;
2104 2134
2105 if (!video) 2135 if (!video)
2106 return; 2136 return;
@@ -2136,17 +2166,19 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
2136 break; 2166 break;
2137 2167
2138 default: 2168 default:
2139 keycode = KEY_UNKNOWN;
2140 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 2169 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
2141 "Unsupported event [0x%x]\n", event)); 2170 "Unsupported event [0x%x]\n", event));
2142 break; 2171 break;
2143 } 2172 }
2144 2173
2145 acpi_notifier_call_chain(device, event, 0); 2174 acpi_notifier_call_chain(device, event, 0);
2146 input_report_key(input, keycode, 1); 2175
2147 input_sync(input); 2176 if (keycode) {
2148 input_report_key(input, keycode, 0); 2177 input_report_key(input, keycode, 1);
2149 input_sync(input); 2178 input_sync(input);
2179 input_report_key(input, keycode, 0);
2180 input_sync(input);
2181 }
2150 2182
2151 return; 2183 return;
2152} 2184}
@@ -2157,7 +2189,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
2157 struct acpi_device *device = NULL; 2189 struct acpi_device *device = NULL;
2158 struct acpi_video_bus *bus; 2190 struct acpi_video_bus *bus;
2159 struct input_dev *input; 2191 struct input_dev *input;
2160 int keycode; 2192 int keycode = 0;
2161 2193
2162 if (!video_device) 2194 if (!video_device)
2163 return; 2195 return;
@@ -2198,46 +2230,93 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
2198 keycode = KEY_DISPLAY_OFF; 2230 keycode = KEY_DISPLAY_OFF;
2199 break; 2231 break;
2200 default: 2232 default:
2201 keycode = KEY_UNKNOWN;
2202 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 2233 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
2203 "Unsupported event [0x%x]\n", event)); 2234 "Unsupported event [0x%x]\n", event));
2204 break; 2235 break;
2205 } 2236 }
2206 2237
2207 acpi_notifier_call_chain(device, event, 0); 2238 acpi_notifier_call_chain(device, event, 0);
2208 input_report_key(input, keycode, 1); 2239
2209 input_sync(input); 2240 if (keycode) {
2210 input_report_key(input, keycode, 0); 2241 input_report_key(input, keycode, 1);
2211 input_sync(input); 2242 input_sync(input);
2243 input_report_key(input, keycode, 0);
2244 input_sync(input);
2245 }
2212 2246
2213 return; 2247 return;
2214} 2248}
2215 2249
2216static int instance; 2250static int acpi_video_resume(struct notifier_block *nb,
2217static int acpi_video_resume(struct acpi_device *device) 2251 unsigned long val, void *ign)
2218{ 2252{
2219 struct acpi_video_bus *video; 2253 struct acpi_video_bus *video;
2220 struct acpi_video_device *video_device; 2254 struct acpi_video_device *video_device;
2221 int i; 2255 int i;
2222 2256
2223 if (!device || !acpi_driver_data(device)) 2257 switch (val) {
2224 return -EINVAL; 2258 case PM_HIBERNATION_PREPARE:
2259 case PM_SUSPEND_PREPARE:
2260 case PM_RESTORE_PREPARE:
2261 return NOTIFY_DONE;
2262 }
2225 2263
2226 video = acpi_driver_data(device); 2264 video = container_of(nb, struct acpi_video_bus, pm_nb);
2265
2266 dev_info(&video->device->dev, "Restoring backlight state\n");
2227 2267
2228 for (i = 0; i < video->attached_count; i++) { 2268 for (i = 0; i < video->attached_count; i++) {
2229 video_device = video->attached_array[i].bind_info; 2269 video_device = video->attached_array[i].bind_info;
2230 if (video_device && video_device->backlight) 2270 if (video_device && video_device->backlight)
2231 acpi_video_set_brightness(video_device->backlight); 2271 acpi_video_set_brightness(video_device->backlight);
2232 } 2272 }
2273
2274 return NOTIFY_OK;
2275}
2276
2277static acpi_status
2278acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
2279 void **return_value)
2280{
2281 struct acpi_device *device = context;
2282 struct acpi_device *sibling;
2283 int result;
2284
2285 if (handle == device->handle)
2286 return AE_CTRL_TERMINATE;
2287
2288 result = acpi_bus_get_device(handle, &sibling);
2289 if (result)
2290 return AE_OK;
2291
2292 if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
2293 return AE_ALREADY_EXISTS;
2294
2233 return AE_OK; 2295 return AE_OK;
2234} 2296}
2235 2297
2298static int instance;
2299
2236static int acpi_video_bus_add(struct acpi_device *device) 2300static int acpi_video_bus_add(struct acpi_device *device)
2237{ 2301{
2238 struct acpi_video_bus *video; 2302 struct acpi_video_bus *video;
2239 struct input_dev *input; 2303 struct input_dev *input;
2240 int error; 2304 int error;
2305 acpi_status status;
2306
2307 status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
2308 device->parent->handle, 1,
2309 acpi_video_bus_match, NULL,
2310 device, NULL);
2311 if (status == AE_ALREADY_EXISTS) {
2312 printk(KERN_WARNING FW_BUG
2313 "Duplicate ACPI video bus devices for the"
2314 " same VGA controller, please try module "
2315 "parameter \"video.allow_duplicates=1\""
2316 "if the current driver doesn't work.\n");
2317 if (!allow_duplicates)
2318 return -ENODEV;
2319 }
2241 2320
2242 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); 2321 video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
2243 if (!video) 2322 if (!video)
@@ -2299,7 +2378,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
2299 set_bit(KEY_BRIGHTNESSDOWN, input->keybit); 2378 set_bit(KEY_BRIGHTNESSDOWN, input->keybit);
2300 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); 2379 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit);
2301 set_bit(KEY_DISPLAY_OFF, input->keybit); 2380 set_bit(KEY_DISPLAY_OFF, input->keybit);
2302 set_bit(KEY_UNKNOWN, input->keybit);
2303 2381
2304 error = input_register_device(input); 2382 error = input_register_device(input);
2305 if (error) 2383 if (error)
@@ -2311,6 +2389,10 @@ static int acpi_video_bus_add(struct acpi_device *device)
2311 video->flags.rom ? "yes" : "no", 2389 video->flags.rom ? "yes" : "no",
2312 video->flags.post ? "yes" : "no"); 2390 video->flags.post ? "yes" : "no");
2313 2391
2392 video->pm_nb.notifier_call = acpi_video_resume;
2393 video->pm_nb.priority = 0;
2394 register_pm_notifier(&video->pm_nb);
2395
2314 return 0; 2396 return 0;
2315 2397
2316 err_free_input_dev: 2398 err_free_input_dev:
@@ -2337,6 +2419,8 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
2337 2419
2338 video = acpi_driver_data(device); 2420 video = acpi_driver_data(device);
2339 2421
2422 unregister_pm_notifier(&video->pm_nb);
2423
2340 acpi_video_bus_stop_devices(video); 2424 acpi_video_bus_stop_devices(video);
2341 acpi_video_bus_put_devices(video); 2425 acpi_video_bus_put_devices(video);
2342 acpi_video_bus_remove_fs(device); 2426 acpi_video_bus_remove_fs(device);
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 575593a8b4e6..fc2f26b9b407 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -7,7 +7,7 @@
7 * video_detect.c: 7 * video_detect.c:
8 * Provides acpi_is_video_device() for early scanning of ACPI devices in scan.c 8 * Provides acpi_is_video_device() for early scanning of ACPI devices in scan.c
9 * There a Linux specific (Spec does not provide a HID for video devices) is 9 * There a Linux specific (Spec does not provide a HID for video devices) is
10 * assinged 10 * assigned
11 * 11 *
12 * After PCI devices are glued with ACPI devices 12 * After PCI devices are glued with ACPI devices
13 * acpi_get_pci_dev() can be called to identify ACPI graphics 13 * acpi_get_pci_dev() can be called to identify ACPI graphics
@@ -83,16 +83,16 @@ long acpi_is_video_device(struct acpi_device *device)
83 if (!device) 83 if (!device)
84 return 0; 84 return 0;
85 85
86 /* Does this device able to support video switching ? */ 86 /* Is this device able to support video switching ? */
87 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) || 87 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) ||
88 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy))) 88 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy)))
89 video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; 89 video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING;
90 90
91 /* Does this device able to retrieve a video ROM ? */ 91 /* Is this device able to retrieve a video ROM ? */
92 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy))) 92 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy)))
93 video_caps |= ACPI_VIDEO_ROM_AVAILABLE; 93 video_caps |= ACPI_VIDEO_ROM_AVAILABLE;
94 94
95 /* Does this device able to configure which video head to be POSTed ? */ 95 /* Is this device able to configure which video head to be POSTed ? */
96 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) && 96 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) &&
97 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) && 97 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) &&
98 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy))) 98 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy)))
@@ -101,7 +101,7 @@ long acpi_is_video_device(struct acpi_device *device)
101 /* Only check for backlight functionality if one of the above hit. */ 101 /* Only check for backlight functionality if one of the above hit. */
102 if (video_caps) 102 if (video_caps)
103 acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle, 103 acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle,
104 ACPI_UINT32_MAX, acpi_backlight_cap_match, 104 ACPI_UINT32_MAX, acpi_backlight_cap_match, NULL,
105 &video_caps, NULL); 105 &video_caps, NULL);
106 106
107 return video_caps; 107 return video_caps;
@@ -137,7 +137,7 @@ find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
137 * 137 *
138 * if NULL is passed as argument all ACPI devices are enumerated and 138 * if NULL is passed as argument all ACPI devices are enumerated and
139 * all graphics capabilities of physically present devices are 139 * all graphics capabilities of physically present devices are
140 * summerized and returned. This is cached and done only once. 140 * summarized and returned. This is cached and done only once.
141 */ 141 */
142long acpi_video_get_capabilities(acpi_handle graphics_handle) 142long acpi_video_get_capabilities(acpi_handle graphics_handle)
143{ 143{
@@ -151,7 +151,7 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle)
151 if (!graphics_handle) { 151 if (!graphics_handle) {
152 /* Only do the global walk through all graphics devices once */ 152 /* Only do the global walk through all graphics devices once */
153 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 153 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
154 ACPI_UINT32_MAX, find_video, 154 ACPI_UINT32_MAX, find_video, NULL,
155 &caps, NULL); 155 &caps, NULL);
156 /* There might be boot param flags set already... */ 156 /* There might be boot param flags set already... */
157 acpi_video_support |= caps; 157 acpi_video_support |= caps;
@@ -173,7 +173,7 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle)
173 return 0; 173 return 0;
174 } 174 }
175 acpi_walk_namespace(ACPI_TYPE_DEVICE, graphics_handle, 175 acpi_walk_namespace(ACPI_TYPE_DEVICE, graphics_handle,
176 ACPI_UINT32_MAX, find_video, 176 ACPI_UINT32_MAX, find_video, NULL,
177 &caps, NULL); 177 &caps, NULL);
178 } 178 }
179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "We have 0x%lX video support %s %s\n", 179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "We have 0x%lX video support %s %s\n",
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index e0ee0c036f5a..4b9d339a6e28 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -21,12 +21,12 @@
21ACPI_MODULE_NAME("wakeup_devices") 21ACPI_MODULE_NAME("wakeup_devices")
22 22
23/** 23/**
24 * acpi_enable_wakeup_device_prep - prepare wakeup devices 24 * acpi_enable_wakeup_device_prep - Prepare wake-up devices.
25 * @sleep_state: ACPI state 25 * @sleep_state: ACPI system sleep state.
26 * Enable all wakup devices power if the devices' wakeup level 26 *
27 * is higher than requested sleep level 27 * Enable all wake-up devices' power, unless the requested system sleep state is
28 * too deep.
28 */ 29 */
29
30void acpi_enable_wakeup_device_prep(u8 sleep_state) 30void acpi_enable_wakeup_device_prep(u8 sleep_state)
31{ 31{
32 struct list_head *node, *next; 32 struct list_head *node, *next;
@@ -36,9 +36,8 @@ void acpi_enable_wakeup_device_prep(u8 sleep_state)
36 struct acpi_device, 36 struct acpi_device,
37 wakeup_list); 37 wakeup_list);
38 38
39 if (!dev->wakeup.flags.valid || 39 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled
40 !dev->wakeup.state.enabled || 40 || (sleep_state > (u32) dev->wakeup.sleep_state))
41 (sleep_state > (u32) dev->wakeup.sleep_state))
42 continue; 41 continue;
43 42
44 acpi_enable_wakeup_device_power(dev, sleep_state); 43 acpi_enable_wakeup_device_power(dev, sleep_state);
@@ -46,9 +45,12 @@ void acpi_enable_wakeup_device_prep(u8 sleep_state)
46} 45}
47 46
48/** 47/**
49 * acpi_enable_wakeup_device - enable wakeup devices 48 * acpi_enable_wakeup_device - Enable wake-up device GPEs.
50 * @sleep_state: ACPI state 49 * @sleep_state: ACPI system sleep state.
51 * Enable all wakup devices's GPE 50 *
51 * Enable all wake-up devices' GPEs, with the assumption that
52 * acpi_disable_all_gpes() was executed before, so we don't need to disable any
53 * GPEs here.
52 */ 54 */
53void acpi_enable_wakeup_device(u8 sleep_state) 55void acpi_enable_wakeup_device(u8 sleep_state)
54{ 56{
@@ -65,29 +67,22 @@ void acpi_enable_wakeup_device(u8 sleep_state)
65 if (!dev->wakeup.flags.valid) 67 if (!dev->wakeup.flags.valid)
66 continue; 68 continue;
67 69
68 /* If users want to disable run-wake GPE,
69 * we only disable it for wake and leave it for runtime
70 */
71 if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count) 70 if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count)
72 || sleep_state > (u32) dev->wakeup.sleep_state) { 71 || sleep_state > (u32) dev->wakeup.sleep_state)
73 if (dev->wakeup.flags.run_wake) {
74 /* set_gpe_type will disable GPE, leave it like that */
75 acpi_set_gpe_type(dev->wakeup.gpe_device,
76 dev->wakeup.gpe_number,
77 ACPI_GPE_TYPE_RUNTIME);
78 }
79 continue; 72 continue;
80 } 73
81 if (!dev->wakeup.flags.run_wake) 74 /* The wake-up power should have been enabled already. */
82 acpi_enable_gpe(dev->wakeup.gpe_device, 75 acpi_set_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
83 dev->wakeup.gpe_number); 76 ACPI_GPE_ENABLE);
84 } 77 }
85} 78}
86 79
87/** 80/**
88 * acpi_disable_wakeup_device - disable devices' wakeup capability 81 * acpi_disable_wakeup_device - Disable devices' wakeup capability.
89 * @sleep_state: ACPI state 82 * @sleep_state: ACPI system sleep state.
90 * Disable all wakup devices's GPE and wakeup capability 83 *
84 * This function only affects devices with wakeup.state.enabled set, which means
85 * that it reverses the changes made by acpi_enable_wakeup_device_prep().
91 */ 86 */
92void acpi_disable_wakeup_device(u8 sleep_state) 87void acpi_disable_wakeup_device(u8 sleep_state)
93{ 88{
@@ -97,30 +92,11 @@ void acpi_disable_wakeup_device(u8 sleep_state)
97 struct acpi_device *dev = 92 struct acpi_device *dev =
98 container_of(node, struct acpi_device, wakeup_list); 93 container_of(node, struct acpi_device, wakeup_list);
99 94
100 if (!dev->wakeup.flags.valid) 95 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled
101 continue; 96 || (sleep_state > (u32) dev->wakeup.sleep_state))
102
103 if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count)
104 || sleep_state > (u32) dev->wakeup.sleep_state) {
105 if (dev->wakeup.flags.run_wake) {
106 acpi_set_gpe_type(dev->wakeup.gpe_device,
107 dev->wakeup.gpe_number,
108 ACPI_GPE_TYPE_WAKE_RUN);
109 /* Re-enable it, since set_gpe_type will disable it */
110 acpi_enable_gpe(dev->wakeup.gpe_device,
111 dev->wakeup.gpe_number);
112 }
113 continue; 97 continue;
114 }
115 98
116 acpi_disable_wakeup_device_power(dev); 99 acpi_disable_wakeup_device_power(dev);
117 /* Never disable run-wake GPE */
118 if (!dev->wakeup.flags.run_wake) {
119 acpi_disable_gpe(dev->wakeup.gpe_device,
120 dev->wakeup.gpe_number);
121 acpi_clear_gpe(dev->wakeup.gpe_device,
122 dev->wakeup.gpe_number, ACPI_NOT_ISR);
123 }
124 } 100 }
125} 101}
126 102
@@ -134,13 +110,11 @@ int __init acpi_wakeup_device_init(void)
134 struct acpi_device, 110 struct acpi_device,
135 wakeup_list); 111 wakeup_list);
136 /* In case user doesn't load button driver */ 112 /* In case user doesn't load button driver */
137 if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled) 113 if (!dev->wakeup.flags.always_enabled ||
114 dev->wakeup.state.enabled)
138 continue; 115 continue;
139 acpi_set_gpe_type(dev->wakeup.gpe_device, 116 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
140 dev->wakeup.gpe_number, 117 ACPI_GPE_TYPE_WAKE);
141 ACPI_GPE_TYPE_WAKE_RUN);
142 acpi_enable_gpe(dev->wakeup.gpe_device,
143 dev->wakeup.gpe_number);
144 dev->wakeup.state.enabled = 1; 118 dev->wakeup.state.enabled = 1;
145 } 119 }
146 mutex_unlock(&acpi_device_lock); 120 mutex_unlock(&acpi_device_lock);