aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/acpi
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig28
-rw-r--r--drivers/acpi/Makefile16
-rw-r--r--drivers/acpi/ac.c25
-rw-r--r--drivers/acpi/acpi_i2c.c103
-rw-r--r--drivers/acpi/acpi_memhotplug.c212
-rw-r--r--drivers/acpi/acpi_pad.c19
-rw-r--r--drivers/acpi/acpi_platform.c104
-rw-r--r--drivers/acpi/acpica/Makefile166
-rw-r--r--drivers/acpi/acpica/accommon.h3
-rw-r--r--drivers/acpi/acpica/acdebug.h94
-rw-r--r--drivers/acpi/acpica/acdispat.h13
-rw-r--r--drivers/acpi/acpica/acevents.h32
-rw-r--r--drivers/acpi/acpica/acglobal.h112
-rw-r--r--drivers/acpi/acpica/achware.h37
-rw-r--r--drivers/acpi/acpica/acinterp.h4
-rw-r--r--drivers/acpi/acpica/aclocal.h109
-rw-r--r--drivers/acpi/acpica/acmacros.h206
-rw-r--r--drivers/acpi/acpica/acnamesp.h7
-rw-r--r--drivers/acpi/acpica/acobject.h30
-rw-r--r--drivers/acpi/acpica/acopcode.h12
-rw-r--r--drivers/acpi/acpica/acparser.h5
-rw-r--r--drivers/acpi/acpica/acpredef.h60
-rw-r--r--drivers/acpi/acpica/acresrc.h115
-rw-r--r--drivers/acpi/acpica/acstruct.h6
-rw-r--r--drivers/acpi/acpica/actables.h7
-rw-r--r--drivers/acpi/acpica/acutils.h81
-rw-r--r--drivers/acpi/acpica/amlcode.h33
-rw-r--r--drivers/acpi/acpica/amlresrc.h143
-rw-r--r--drivers/acpi/acpica/dsargs.c20
-rw-r--r--drivers/acpi/acpica/dscontrol.c8
-rw-r--r--drivers/acpi/acpica/dsfield.c182
-rw-r--r--drivers/acpi/acpica/dsinit.c6
-rw-r--r--drivers/acpi/acpica/dsmethod.c14
-rw-r--r--drivers/acpi/acpica/dsmthdat.c48
-rw-r--r--drivers/acpi/acpica/dsobject.c22
-rw-r--r--drivers/acpi/acpica/dsopcode.c19
-rw-r--r--drivers/acpi/acpica/dsutils.c41
-rw-r--r--drivers/acpi/acpica/dswexec.c12
-rw-r--r--drivers/acpi/acpica/dswload.c16
-rw-r--r--drivers/acpi/acpica/dswload2.c20
-rw-r--r--drivers/acpi/acpica/dswscope.c6
-rw-r--r--drivers/acpi/acpica/dswstate.c48
-rw-r--r--drivers/acpi/acpica/evevent.c20
-rw-r--r--drivers/acpi/acpica/evglock.c16
-rw-r--r--drivers/acpi/acpica/evgpe.c72
-rw-r--r--drivers/acpi/acpica/evgpeblk.c11
-rw-r--r--drivers/acpi/acpica/evgpeinit.c6
-rw-r--r--drivers/acpi/acpica/evgpeutil.c28
-rw-r--r--drivers/acpi/acpica/evmisc.c193
-rw-r--r--drivers/acpi/acpica/evregion.c55
-rw-r--r--drivers/acpi/acpica/evrgnini.c37
-rw-r--r--drivers/acpi/acpica/evsci.c10
-rw-r--r--drivers/acpi/acpica/evxface.c761
-rw-r--r--drivers/acpi/acpica/evxfevnt.c13
-rw-r--r--drivers/acpi/acpica/evxfgpe.c131
-rw-r--r--drivers/acpi/acpica/evxfregn.c21
-rw-r--r--drivers/acpi/acpica/exconfig.c16
-rw-r--r--drivers/acpi/acpica/exconvrt.c16
-rw-r--r--drivers/acpi/acpica/excreate.c42
-rw-r--r--drivers/acpi/acpica/exdebug.c16
-rw-r--r--drivers/acpi/acpica/exdump.c80
-rw-r--r--drivers/acpi/acpica/exfield.c34
-rw-r--r--drivers/acpi/acpica/exfldio.c67
-rw-r--r--drivers/acpi/acpica/exmisc.c33
-rw-r--r--drivers/acpi/acpica/exmutex.c17
-rw-r--r--drivers/acpi/acpica/exnames.c11
-rw-r--r--drivers/acpi/acpica/exoparg1.c13
-rw-r--r--drivers/acpi/acpica/exoparg2.c4
-rw-r--r--drivers/acpi/acpica/exoparg3.c5
-rw-r--r--drivers/acpi/acpica/exoparg6.c7
-rw-r--r--drivers/acpi/acpica/exprep.c46
-rw-r--r--drivers/acpi/acpica/exregion.c43
-rw-r--r--drivers/acpi/acpica/exresnte.c11
-rw-r--r--drivers/acpi/acpica/exresolv.c9
-rw-r--r--drivers/acpi/acpica/exresop.c20
-rw-r--r--drivers/acpi/acpica/exstore.c12
-rw-r--r--drivers/acpi/acpica/exstoren.c13
-rw-r--r--drivers/acpi/acpica/exstorob.c9
-rw-r--r--drivers/acpi/acpica/exsystem.c19
-rw-r--r--drivers/acpi/acpica/exutils.c40
-rw-r--r--drivers/acpi/acpica/hwacpi.c10
-rw-r--r--drivers/acpi/acpica/hwesleep.c235
-rw-r--r--drivers/acpi/acpica/hwgpe.c25
-rw-r--r--drivers/acpi/acpica/hwpci.c6
-rw-r--r--drivers/acpi/acpica/hwregs.c52
-rw-r--r--drivers/acpi/acpica/hwsleep.c382
-rw-r--r--drivers/acpi/acpica/hwtimer.c15
-rw-r--r--drivers/acpi/acpica/hwvalid.c9
-rw-r--r--drivers/acpi/acpica/hwxface.c65
-rw-r--r--drivers/acpi/acpica/hwxfsleep.c424
-rw-r--r--drivers/acpi/acpica/nsaccess.c17
-rw-r--r--drivers/acpi/acpica/nsalloc.c16
-rw-r--r--drivers/acpi/acpica/nsdump.c47
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c10
-rw-r--r--drivers/acpi/acpica/nseval.c12
-rw-r--r--drivers/acpi/acpica/nsinit.c12
-rw-r--r--drivers/acpi/acpica/nsload.c16
-rw-r--r--drivers/acpi/acpica/nsnames.c14
-rw-r--r--drivers/acpi/acpica/nsobject.c38
-rw-r--r--drivers/acpi/acpica/nsparse.c10
-rw-r--r--drivers/acpi/acpica/nspredef.c73
-rw-r--r--drivers/acpi/acpica/nsrepair.c176
-rw-r--r--drivers/acpi/acpica/nsrepair2.c33
-rw-r--r--drivers/acpi/acpica/nssearch.c31
-rw-r--r--drivers/acpi/acpica/nsutils.c48
-rw-r--r--drivers/acpi/acpica/nswalk.c20
-rw-r--r--drivers/acpi/acpica/nsxfeval.c49
-rw-r--r--drivers/acpi/acpica/nsxfname.c81
-rw-r--r--drivers/acpi/acpica/nsxfobj.c15
-rw-r--r--drivers/acpi/acpica/psargs.c157
-rw-r--r--drivers/acpi/acpica/psloop.c79
-rw-r--r--drivers/acpi/acpica/psopcode.c48
-rw-r--r--drivers/acpi/acpica/psparse.c21
-rw-r--r--drivers/acpi/acpica/psscope.c8
-rw-r--r--drivers/acpi/acpica/pstree.c22
-rw-r--r--drivers/acpi/acpica/psutils.c14
-rw-r--r--drivers/acpi/acpica/pswalk.c2
-rw-r--r--drivers/acpi/acpica/psxface.c18
-rw-r--r--drivers/acpi/acpica/rsaddr.c16
-rw-r--r--drivers/acpi/acpica/rscalc.c105
-rw-r--r--drivers/acpi/acpica/rscreate.c75
-rw-r--r--drivers/acpi/acpica/rsdump.c206
-rw-r--r--drivers/acpi/acpica/rsinfo.c58
-rw-r--r--drivers/acpi/acpica/rsio.c2
-rw-r--r--drivers/acpi/acpica/rsirq.c33
-rw-r--r--drivers/acpi/acpica/rslist.c79
-rw-r--r--drivers/acpi/acpica/rsmemory.c2
-rw-r--r--drivers/acpi/acpica/rsmisc.c291
-rw-r--r--drivers/acpi/acpica/rsserial.c441
-rw-r--r--drivers/acpi/acpica/rsutils.c96
-rw-r--r--drivers/acpi/acpica/rsxface.c65
-rw-r--r--drivers/acpi/acpica/tbfadt.c189
-rw-r--r--drivers/acpi/acpica/tbfind.c6
-rw-r--r--drivers/acpi/acpica/tbinstal.c164
-rw-r--r--drivers/acpi/acpica/tbutils.c162
-rw-r--r--drivers/acpi/acpica/tbxface.c274
-rw-r--r--drivers/acpi/acpica/tbxfload.c389
-rw-r--r--drivers/acpi/acpica/tbxfroot.c17
-rw-r--r--drivers/acpi/acpica/utaddress.c294
-rw-r--r--drivers/acpi/acpica/utalloc.c22
-rw-r--r--drivers/acpi/acpica/utcache.c323
-rw-r--r--drivers/acpi/acpica/utcopy.c4
-rw-r--r--drivers/acpi/acpica/utdebug.c70
-rw-r--r--drivers/acpi/acpica/utdecode.c105
-rw-r--r--drivers/acpi/acpica/utdelete.c53
-rw-r--r--drivers/acpi/acpica/uteval.c8
-rw-r--r--drivers/acpi/acpica/utexcep.c153
-rw-r--r--drivers/acpi/acpica/utglobal.c29
-rw-r--r--drivers/acpi/acpica/utids.c108
-rw-r--r--drivers/acpi/acpica/utinit.c40
-rw-r--r--drivers/acpi/acpica/utlock.c8
-rw-r--r--drivers/acpi/acpica/utmath.c8
-rw-r--r--drivers/acpi/acpica/utmisc.c256
-rw-r--r--drivers/acpi/acpica/utmutex.c33
-rw-r--r--drivers/acpi/acpica/utobject.c24
-rw-r--r--drivers/acpi/acpica/utosi.c5
-rw-r--r--drivers/acpi/acpica/utresrc.c292
-rw-r--r--drivers/acpi/acpica/utstate.c20
-rw-r--r--drivers/acpi/acpica/uttrack.c692
-rw-r--r--drivers/acpi/acpica/utxface.c404
-rw-r--r--drivers/acpi/acpica/utxferror.c95
-rw-r--r--drivers/acpi/acpica/utxfinit.c317
-rw-r--r--drivers/acpi/acpica/utxfmutex.c187
-rw-r--r--drivers/acpi/apei/Kconfig1
-rw-r--r--drivers/acpi/apei/apei-base.c186
-rw-r--r--drivers/acpi/apei/apei-internal.h15
-rw-r--r--drivers/acpi/apei/cper.c2
-rw-r--r--drivers/acpi/apei/einj.c328
-rw-r--r--drivers/acpi/apei/erst-dbg.c11
-rw-r--r--drivers/acpi/apei/erst.c64
-rw-r--r--drivers/acpi/apei/ghes.c130
-rw-r--r--drivers/acpi/apei/hest.c7
-rw-r--r--drivers/acpi/battery.c115
-rw-r--r--drivers/acpi/bgrt.c118
-rw-r--r--drivers/acpi/blacklist.c1
-rw-r--r--drivers/acpi/bus.c144
-rw-r--r--drivers/acpi/button.c26
-rw-r--r--drivers/acpi/container.c68
-rw-r--r--drivers/acpi/debugfs.c1
-rw-r--r--drivers/acpi/device_pm.c667
-rw-r--r--drivers/acpi/dock.c58
-rw-r--r--drivers/acpi/ec.c145
-rw-r--r--drivers/acpi/ec_sys.c11
-rw-r--r--drivers/acpi/event.c1
-rw-r--r--drivers/acpi/fan.c47
-rw-r--r--drivers/acpi/glue.c188
-rw-r--r--drivers/acpi/hed.c24
-rw-r--r--drivers/acpi/internal.h11
-rw-r--r--drivers/acpi/numa.c18
-rw-r--r--drivers/acpi/nvs.c57
-rw-r--r--drivers/acpi/osl.c574
-rw-r--r--drivers/acpi/pci_bind.c12
-rw-r--r--drivers/acpi/pci_irq.c42
-rw-r--r--drivers/acpi/pci_link.c12
-rw-r--r--drivers/acpi/pci_root.c258
-rw-r--r--drivers/acpi/pci_slot.c46
-rw-r--r--drivers/acpi/power.c200
-rw-r--r--drivers/acpi/proc.c69
-rw-r--r--drivers/acpi/processor_core.c29
-rw-r--r--drivers/acpi/processor_driver.c345
-rw-r--r--drivers/acpi/processor_idle.c385
-rw-r--r--drivers/acpi/processor_perflib.c82
-rw-r--r--drivers/acpi/processor_thermal.c46
-rw-r--r--drivers/acpi/processor_throttling.c5
-rw-r--r--drivers/acpi/resource.c526
-rw-r--r--drivers/acpi/sbs.c12
-rw-r--r--drivers/acpi/sbshc.c19
-rw-r--r--drivers/acpi/scan.c313
-rw-r--r--drivers/acpi/sleep.c523
-rw-r--r--drivers/acpi/sysfs.c22
-rw-r--r--drivers/acpi/thermal.c170
-rw-r--r--drivers/acpi/utils.c113
-rw-r--r--drivers/acpi/video.c104
-rw-r--r--drivers/acpi/video_detect.c71
214 files changed, 5300 insertions, 13853 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 38c5078da11..de0e3df7677 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -181,12 +181,6 @@ config ACPI_DOCK
181 This driver supports ACPI-controlled docking stations and removable 181 This driver supports ACPI-controlled docking stations and removable
182 drive bays such as the IBM Ultrabay and the Dell Module Bay. 182 drive bays such as the IBM Ultrabay and the Dell Module Bay.
183 183
184config ACPI_I2C
185 def_tristate I2C
186 depends on I2C
187 help
188 ACPI I2C enumeration support.
189
190config ACPI_PROCESSOR 184config ACPI_PROCESSOR
191 tristate "Processor" 185 tristate "Processor"
192 select THERMAL 186 select THERMAL
@@ -214,7 +208,7 @@ config ACPI_IPMI
214 208
215config ACPI_HOTPLUG_CPU 209config ACPI_HOTPLUG_CPU
216 bool 210 bool
217 depends on EXPERIMENTAL && ACPI_PROCESSOR && HOTPLUG_CPU 211 depends on ACPI_PROCESSOR && HOTPLUG_CPU
218 select ACPI_CONTAINER 212 select ACPI_CONTAINER
219 default y 213 default y
220 214
@@ -267,15 +261,6 @@ config ACPI_CUSTOM_DSDT
267 bool 261 bool
268 default ACPI_CUSTOM_DSDT_FILE != "" 262 default ACPI_CUSTOM_DSDT_FILE != ""
269 263
270config ACPI_INITRD_TABLE_OVERRIDE
271 bool "ACPI tables can be passed via uncompressed cpio in initrd"
272 default n
273 help
274 This option provides functionality to override arbitrary ACPI tables
275 via initrd. No functional change if no ACPI tables are passed via
276 initrd, therefore it's safe to say Y.
277 See Documentation/acpi/initrd_table_override.txt for details
278
279config ACPI_BLACKLIST_YEAR 264config ACPI_BLACKLIST_YEAR
280 int "Disable ACPI for systems before Jan 1st this year" if X86_32 265 int "Disable ACPI for systems before Jan 1st this year" if X86_32
281 default 0 266 default 0
@@ -389,7 +374,7 @@ config ACPI_CUSTOM_METHOD
389 depends on DEBUG_FS 374 depends on DEBUG_FS
390 default n 375 default n
391 help 376 help
392 This debug facility allows ACPI AML methods to be inserted and/or 377 This debug facility allows ACPI AML methods to me inserted and/or
393 replaced without rebooting the system. For details refer to: 378 replaced without rebooting the system. For details refer to:
394 Documentation/acpi/method-customizing.txt. 379 Documentation/acpi/method-customizing.txt.
395 380
@@ -399,15 +384,6 @@ config ACPI_CUSTOM_METHOD
399 load additional kernel modules after boot, this feature may be used 384 load additional kernel modules after boot, this feature may be used
400 to override that restriction). 385 to override that restriction).
401 386
402config ACPI_BGRT
403 bool "Boottime Graphics Resource Table support"
404 depends on EFI
405 help
406 This driver adds support for exposing the ACPI Boottime Graphics
407 Resource Table, which allows the operating system to obtain
408 data from the firmware boot splash. It will appear under
409 /sys/firmware/acpi/bgrt/ .
410
411source "drivers/acpi/apei/Kconfig" 387source "drivers/acpi/apei/Kconfig"
412 388
413endif # ACPI 389endif # ACPI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 2a4502becd1..ecb26b4f29a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -19,13 +19,12 @@ 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 += nvs.o 22acpi-y += atomicio.o
23 23
24# Power management related files 24# sleep related files
25acpi-y += wakeup.o 25acpi-y += wakeup.o
26acpi-y += sleep.o 26acpi-y += sleep.o
27acpi-$(CONFIG_PM) += device_pm.o 27acpi-$(CONFIG_ACPI_SLEEP) += proc.o nvs.o
28acpi-$(CONFIG_ACPI_SLEEP) += proc.o
29 28
30 29
31# 30#
@@ -33,12 +32,10 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o
33# 32#
34acpi-y += bus.o glue.o 33acpi-y += bus.o glue.o
35acpi-y += scan.o 34acpi-y += scan.o
36acpi-y += resource.o
37acpi-y += processor_core.o 35acpi-y += processor_core.o
38acpi-y += ec.o 36acpi-y += ec.o
39acpi-$(CONFIG_ACPI_DOCK) += dock.o 37acpi-$(CONFIG_ACPI_DOCK) += dock.o
40acpi-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
41acpi-y += acpi_platform.o
42acpi-y += power.o 39acpi-y += power.o
43acpi-y += event.o 40acpi-y += event.o
44acpi-y += sysfs.o 41acpi-y += sysfs.o
@@ -50,10 +47,6 @@ acpi-y += video_detect.o
50endif 47endif
51 48
52# These are (potentially) separate modules 49# These are (potentially) separate modules
53
54# IPMI may be used by other drivers, so it has to initialise before them
55obj-$(CONFIG_ACPI_IPMI) += acpi_ipmi.o
56
57obj-$(CONFIG_ACPI_AC) += ac.o 50obj-$(CONFIG_ACPI_AC) += ac.o
58obj-$(CONFIG_ACPI_BUTTON) += button.o 51obj-$(CONFIG_ACPI_BUTTON) += button.o
59obj-$(CONFIG_ACPI_FAN) += fan.o 52obj-$(CONFIG_ACPI_FAN) += fan.o
@@ -69,8 +62,6 @@ obj-$(CONFIG_ACPI_SBS) += sbs.o
69obj-$(CONFIG_ACPI_HED) += hed.o 62obj-$(CONFIG_ACPI_HED) += hed.o
70obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o 63obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
71obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o 64obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
72obj-$(CONFIG_ACPI_BGRT) += bgrt.o
73obj-$(CONFIG_ACPI_I2C) += acpi_i2c.o
74 65
75# processor has its own "processor." module_param namespace 66# processor has its own "processor." module_param namespace
76processor-y := processor_driver.o processor_throttling.o 67processor-y := processor_driver.o processor_throttling.o
@@ -78,5 +69,6 @@ processor-y += processor_idle.o processor_thermal.o
78processor-$(CONFIG_CPU_FREQ) += processor_perflib.o 69processor-$(CONFIG_CPU_FREQ) += processor_perflib.o
79 70
80obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o 71obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o
72obj-$(CONFIG_ACPI_IPMI) += acpi_ipmi.o
81 73
82obj-$(CONFIG_ACPI_APEI) += apei/ 74obj-$(CONFIG_ACPI_APEI) += apei/
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index d5fdd36190c..6512b20aecc 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -61,6 +61,7 @@ static int acpi_ac_open_fs(struct inode *inode, struct file *file);
61 61
62static int acpi_ac_add(struct acpi_device *device); 62static int acpi_ac_add(struct acpi_device *device);
63static int acpi_ac_remove(struct acpi_device *device, int type); 63static int acpi_ac_remove(struct acpi_device *device, int type);
64static int acpi_ac_resume(struct acpi_device *device);
64static void acpi_ac_notify(struct acpi_device *device, u32 event); 65static void acpi_ac_notify(struct acpi_device *device, u32 event);
65 66
66static const struct acpi_device_id ac_device_ids[] = { 67static const struct acpi_device_id ac_device_ids[] = {
@@ -69,11 +70,6 @@ static const struct acpi_device_id ac_device_ids[] = {
69}; 70};
70MODULE_DEVICE_TABLE(acpi, ac_device_ids); 71MODULE_DEVICE_TABLE(acpi, ac_device_ids);
71 72
72#ifdef CONFIG_PM_SLEEP
73static int acpi_ac_resume(struct device *dev);
74#endif
75static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
76
77static struct acpi_driver acpi_ac_driver = { 73static struct acpi_driver acpi_ac_driver = {
78 .name = "ac", 74 .name = "ac",
79 .class = ACPI_AC_CLASS, 75 .class = ACPI_AC_CLASS,
@@ -82,9 +78,9 @@ static struct acpi_driver acpi_ac_driver = {
82 .ops = { 78 .ops = {
83 .add = acpi_ac_add, 79 .add = acpi_ac_add,
84 .remove = acpi_ac_remove, 80 .remove = acpi_ac_remove,
81 .resume = acpi_ac_resume,
85 .notify = acpi_ac_notify, 82 .notify = acpi_ac_notify,
86 }, 83 },
87 .drv.pm = &acpi_ac_pm,
88}; 84};
89 85
90struct acpi_ac { 86struct acpi_ac {
@@ -296,9 +292,7 @@ static int acpi_ac_add(struct acpi_device *device)
296 ac->charger.properties = ac_props; 292 ac->charger.properties = ac_props;
297 ac->charger.num_properties = ARRAY_SIZE(ac_props); 293 ac->charger.num_properties = ARRAY_SIZE(ac_props);
298 ac->charger.get_property = get_ac_property; 294 ac->charger.get_property = get_ac_property;
299 result = power_supply_register(&ac->device->dev, &ac->charger); 295 power_supply_register(&ac->device->dev, &ac->charger);
300 if (result)
301 goto end;
302 296
303 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 297 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
304 acpi_device_name(device), acpi_device_bid(device), 298 acpi_device_name(device), acpi_device_bid(device),
@@ -315,19 +309,13 @@ static int acpi_ac_add(struct acpi_device *device)
315 return result; 309 return result;
316} 310}
317 311
318#ifdef CONFIG_PM_SLEEP 312static int acpi_ac_resume(struct acpi_device *device)
319static int acpi_ac_resume(struct device *dev)
320{ 313{
321 struct acpi_ac *ac; 314 struct acpi_ac *ac;
322 unsigned old_state; 315 unsigned old_state;
323 316 if (!device || !acpi_driver_data(device))
324 if (!dev)
325 return -EINVAL;
326
327 ac = acpi_driver_data(to_acpi_device(dev));
328 if (!ac)
329 return -EINVAL; 317 return -EINVAL;
330 318 ac = acpi_driver_data(device);
331 old_state = ac->state; 319 old_state = ac->state;
332 if (acpi_ac_get_state(ac)) 320 if (acpi_ac_get_state(ac))
333 return 0; 321 return 0;
@@ -335,7 +323,6 @@ static int acpi_ac_resume(struct device *dev)
335 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 323 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
336 return 0; 324 return 0;
337} 325}
338#endif
339 326
340static int acpi_ac_remove(struct acpi_device *device, int type) 327static int acpi_ac_remove(struct acpi_device *device, int type)
341{ 328{
diff --git a/drivers/acpi/acpi_i2c.c b/drivers/acpi/acpi_i2c.c
deleted file mode 100644
index 82045e3f5ca..00000000000
--- a/drivers/acpi/acpi_i2c.c
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2 * ACPI I2C enumeration support
3 *
4 * Copyright (C) 2012, Intel Corporation
5 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/acpi.h>
13#include <linux/device.h>
14#include <linux/export.h>
15#include <linux/i2c.h>
16#include <linux/ioport.h>
17
18ACPI_MODULE_NAME("i2c");
19
20static int acpi_i2c_add_resource(struct acpi_resource *ares, void *data)
21{
22 struct i2c_board_info *info = data;
23
24 if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
25 struct acpi_resource_i2c_serialbus *sb;
26
27 sb = &ares->data.i2c_serial_bus;
28 if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
29 info->addr = sb->slave_address;
30 if (sb->access_mode == ACPI_I2C_10BIT_MODE)
31 info->flags |= I2C_CLIENT_TEN;
32 }
33 } else if (info->irq < 0) {
34 struct resource r;
35
36 if (acpi_dev_resource_interrupt(ares, 0, &r))
37 info->irq = r.start;
38 }
39
40 /* Tell the ACPI core to skip this resource */
41 return 1;
42}
43
44static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level,
45 void *data, void **return_value)
46{
47 struct i2c_adapter *adapter = data;
48 struct list_head resource_list;
49 struct i2c_board_info info;
50 struct acpi_device *adev;
51 int ret;
52
53 if (acpi_bus_get_device(handle, &adev))
54 return AE_OK;
55 if (acpi_bus_get_status(adev) || !adev->status.present)
56 return AE_OK;
57
58 memset(&info, 0, sizeof(info));
59 info.acpi_node.handle = handle;
60 info.irq = -1;
61
62 INIT_LIST_HEAD(&resource_list);
63 ret = acpi_dev_get_resources(adev, &resource_list,
64 acpi_i2c_add_resource, &info);
65 acpi_dev_free_resource_list(&resource_list);
66
67 if (ret < 0 || !info.addr)
68 return AE_OK;
69
70 strlcpy(info.type, dev_name(&adev->dev), sizeof(info.type));
71 if (!i2c_new_device(adapter, &info)) {
72 dev_err(&adapter->dev,
73 "failed to add I2C device %s from ACPI\n",
74 dev_name(&adev->dev));
75 }
76
77 return AE_OK;
78}
79
80/**
81 * acpi_i2c_register_devices - enumerate I2C slave devices behind adapter
82 * @adapter: pointer to adapter
83 *
84 * Enumerate all I2C slave devices behind this adapter by walking the ACPI
85 * namespace. When a device is found it will be added to the Linux device
86 * model and bound to the corresponding ACPI handle.
87 */
88void acpi_i2c_register_devices(struct i2c_adapter *adapter)
89{
90 acpi_handle handle;
91 acpi_status status;
92
93 handle = ACPI_HANDLE(&adapter->dev);
94 if (!handle)
95 return;
96
97 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
98 acpi_i2c_add_device, NULL,
99 adapter, NULL);
100 if (ACPI_FAILURE(status))
101 dev_warn(&adapter->dev, "failed to enumerate I2C slaves\n");
102}
103EXPORT_SYMBOL_GPL(acpi_i2c_register_devices);
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index b679bf8478f..d9857138565 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -31,7 +31,6 @@
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 <linux/slab.h>
34#include <linux/acpi.h>
35#include <acpi/acpi_drivers.h> 34#include <acpi/acpi_drivers.h>
36 35
37#define ACPI_MEMORY_DEVICE_CLASS "memory" 36#define ACPI_MEMORY_DEVICE_CLASS "memory"
@@ -79,7 +78,6 @@ struct acpi_memory_info {
79 unsigned short caching; /* memory cache attribute */ 78 unsigned short caching; /* memory cache attribute */
80 unsigned short write_protect; /* memory read/write attribute */ 79 unsigned short write_protect; /* memory read/write attribute */
81 unsigned int enabled:1; 80 unsigned int enabled:1;
82 unsigned int failed:1;
83}; 81};
84 82
85struct acpi_memory_device { 83struct acpi_memory_device {
@@ -88,6 +86,8 @@ struct acpi_memory_device {
88 struct list_head res_list; 86 struct list_head res_list;
89}; 87};
90 88
89static int acpi_hotmem_initialized;
90
91static acpi_status 91static acpi_status
92acpi_memory_get_resource(struct acpi_resource *resource, void *context) 92acpi_memory_get_resource(struct acpi_resource *resource, void *context)
93{ 93{
@@ -125,20 +125,12 @@ acpi_memory_get_resource(struct acpi_resource *resource, void *context)
125 return AE_OK; 125 return AE_OK;
126} 126}
127 127
128static void
129acpi_memory_free_device_resources(struct acpi_memory_device *mem_device)
130{
131 struct acpi_memory_info *info, *n;
132
133 list_for_each_entry_safe(info, n, &mem_device->res_list, list)
134 kfree(info);
135 INIT_LIST_HEAD(&mem_device->res_list);
136}
137
138static int 128static int
139acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) 129acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
140{ 130{
141 acpi_status status; 131 acpi_status status;
132 struct acpi_memory_info *info, *n;
133
142 134
143 if (!list_empty(&mem_device->res_list)) 135 if (!list_empty(&mem_device->res_list))
144 return 0; 136 return 0;
@@ -146,7 +138,9 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
146 status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS, 138 status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
147 acpi_memory_get_resource, mem_device); 139 acpi_memory_get_resource, mem_device);
148 if (ACPI_FAILURE(status)) { 140 if (ACPI_FAILURE(status)) {
149 acpi_memory_free_device_resources(mem_device); 141 list_for_each_entry_safe(info, n, &mem_device->res_list, list)
142 kfree(info);
143 INIT_LIST_HEAD(&mem_device->res_list);
150 return -EINVAL; 144 return -EINVAL;
151 } 145 }
152 146
@@ -176,7 +170,7 @@ acpi_memory_get_device(acpi_handle handle,
176 /* Get the parent device */ 170 /* Get the parent device */
177 result = acpi_bus_get_device(phandle, &pdevice); 171 result = acpi_bus_get_device(phandle, &pdevice);
178 if (result) { 172 if (result) {
179 acpi_handle_warn(phandle, "Cannot get acpi bus device\n"); 173 printk(KERN_WARNING PREFIX "Cannot get acpi bus device");
180 return -EINVAL; 174 return -EINVAL;
181 } 175 }
182 176
@@ -186,14 +180,14 @@ acpi_memory_get_device(acpi_handle handle,
186 */ 180 */
187 result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 181 result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
188 if (result) { 182 if (result) {
189 acpi_handle_warn(handle, "Cannot add acpi bus\n"); 183 printk(KERN_WARNING PREFIX "Cannot add acpi bus");
190 return -EINVAL; 184 return -EINVAL;
191 } 185 }
192 186
193 end: 187 end:
194 *mem_device = acpi_driver_data(device); 188 *mem_device = acpi_driver_data(device);
195 if (!(*mem_device)) { 189 if (!(*mem_device)) {
196 dev_err(&device->dev, "driver data not found\n"); 190 printk(KERN_ERR "\n driver data not found");
197 return -ENODEV; 191 return -ENODEV;
198 } 192 }
199 193
@@ -226,6 +220,15 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
226 struct acpi_memory_info *info; 220 struct acpi_memory_info *info;
227 int node; 221 int node;
228 222
223
224 /* Get the range from the _CRS */
225 result = acpi_memory_get_device_resources(mem_device);
226 if (result) {
227 printk(KERN_ERR PREFIX "get_device_resources failed\n");
228 mem_device->state = MEMORY_INVALID_STATE;
229 return result;
230 }
231
229 node = acpi_get_node(mem_device->device->handle); 232 node = acpi_get_node(mem_device->device->handle);
230 /* 233 /*
231 * Tell the VM there is more memory here... 234 * Tell the VM there is more memory here...
@@ -248,27 +251,13 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
248 node = memory_add_physaddr_to_nid(info->start_addr); 251 node = memory_add_physaddr_to_nid(info->start_addr);
249 252
250 result = add_memory(node, info->start_addr, info->length); 253 result = add_memory(node, info->start_addr, info->length);
251 254 if (result)
252 /*
253 * If the memory block has been used by the kernel, add_memory()
254 * returns -EEXIST. If add_memory() returns the other error, it
255 * means that this memory block is not used by the kernel.
256 */
257 if (result && result != -EEXIST) {
258 info->failed = 1;
259 continue; 255 continue;
260 } 256 info->enabled = 1;
261
262 if (!result)
263 info->enabled = 1;
264 /*
265 * Add num_enable even if add_memory() returns -EEXIST, so the
266 * device is bound to this driver.
267 */
268 num_enabled++; 257 num_enabled++;
269 } 258 }
270 if (!num_enabled) { 259 if (!num_enabled) {
271 dev_err(&mem_device->device->dev, "add_memory failed\n"); 260 printk(KERN_ERR PREFIX "add_memory failed\n");
272 mem_device->state = MEMORY_INVALID_STATE; 261 mem_device->state = MEMORY_INVALID_STATE;
273 return -EINVAL; 262 return -EINVAL;
274 } 263 }
@@ -283,31 +272,68 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
283 return 0; 272 return 0;
284} 273}
285 274
286static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device) 275static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
287{ 276{
288 int result = 0; 277 acpi_status status;
289 struct acpi_memory_info *info, *n; 278 struct acpi_object_list arg_list;
279 union acpi_object arg;
280 unsigned long long current_status;
290 281
291 list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
292 if (info->failed)
293 /* The kernel does not use this memory block */
294 continue;
295 282
296 if (!info->enabled) 283 /* Issue the _EJ0 command */
297 /* 284 arg_list.count = 1;
298 * The kernel uses this memory block, but it may be not 285 arg_list.pointer = &arg;
299 * managed by us. 286 arg.type = ACPI_TYPE_INTEGER;
300 */ 287 arg.integer.value = 1;
301 return -EBUSY; 288 status = acpi_evaluate_object(mem_device->device->handle,
289 "_EJ0", &arg_list, NULL);
290 /* Return on _EJ0 failure */
291 if (ACPI_FAILURE(status)) {
292 ACPI_EXCEPTION((AE_INFO, status, "_EJ0 failed"));
293 return -ENODEV;
294 }
295
296 /* Evalute _STA to check if the device is disabled */
297 status = acpi_evaluate_integer(mem_device->device->handle, "_STA",
298 NULL, &current_status);
299 if (ACPI_FAILURE(status))
300 return -ENODEV;
301
302 /* Check for device status. Device should be disabled */
303 if (current_status & ACPI_STA_DEVICE_ENABLED)
304 return -EINVAL;
305
306 return 0;
307}
308
309static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
310{
311 int result;
312 struct acpi_memory_info *info, *n;
302 313
303 result = remove_memory(info->start_addr, info->length);
304 if (result)
305 return result;
306 314
307 list_del(&info->list); 315 /*
316 * Ask the VM to offline this memory range.
317 * Note: Assume that this function returns zero on success
318 */
319 list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
320 if (info->enabled) {
321 result = remove_memory(info->start_addr, info->length);
322 if (result)
323 return result;
324 }
308 kfree(info); 325 kfree(info);
309 } 326 }
310 327
328 /* Power-off and eject the device */
329 result = acpi_memory_powerdown_device(mem_device);
330 if (result) {
331 /* Set the status of the device to invalid */
332 mem_device->state = MEMORY_INVALID_STATE;
333 return result;
334 }
335
336 mem_device->state = MEMORY_POWER_OFF_STATE;
311 return result; 337 return result;
312} 338}
313 339
@@ -315,8 +341,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
315{ 341{
316 struct acpi_memory_device *mem_device; 342 struct acpi_memory_device *mem_device;
317 struct acpi_device *device; 343 struct acpi_device *device;
318 struct acpi_eject_event *ej_event = NULL; 344
319 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
320 345
321 switch (event) { 346 switch (event) {
322 case ACPI_NOTIFY_BUS_CHECK: 347 case ACPI_NOTIFY_BUS_CHECK:
@@ -328,62 +353,52 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
328 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 353 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
329 "\nReceived DEVICE CHECK notification for device\n")); 354 "\nReceived DEVICE CHECK notification for device\n"));
330 if (acpi_memory_get_device(handle, &mem_device)) { 355 if (acpi_memory_get_device(handle, &mem_device)) {
331 acpi_handle_err(handle, "Cannot find driver data\n"); 356 printk(KERN_ERR PREFIX "Cannot find driver data\n");
332 break; 357 return;
333 } 358 }
334 359
335 ost_code = ACPI_OST_SC_SUCCESS; 360 if (!acpi_memory_check_device(mem_device)) {
361 if (acpi_memory_enable_device(mem_device))
362 printk(KERN_ERR PREFIX
363 "Cannot enable memory device\n");
364 }
336 break; 365 break;
337
338 case ACPI_NOTIFY_EJECT_REQUEST: 366 case ACPI_NOTIFY_EJECT_REQUEST:
339 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 367 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
340 "\nReceived EJECT REQUEST notification for device\n")); 368 "\nReceived EJECT REQUEST notification for device\n"));
341 369
342 if (acpi_bus_get_device(handle, &device)) { 370 if (acpi_bus_get_device(handle, &device)) {
343 acpi_handle_err(handle, "Device doesn't exist\n"); 371 printk(KERN_ERR PREFIX "Device doesn't exist\n");
344 break; 372 break;
345 } 373 }
346 mem_device = acpi_driver_data(device); 374 mem_device = acpi_driver_data(device);
347 if (!mem_device) { 375 if (!mem_device) {
348 acpi_handle_err(handle, "Driver Data is NULL\n"); 376 printk(KERN_ERR PREFIX "Driver Data is NULL\n");
349 break; 377 break;
350 } 378 }
351 379
352 ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); 380 /*
353 if (!ej_event) { 381 * Currently disabling memory device from kernel mode
354 pr_err(PREFIX "No memory, dropping EJECT\n"); 382 * TBD: Can also be disabled from user mode scripts
355 break; 383 * TBD: Can also be disabled by Callback registration
356 } 384 * with generic sysfs driver
357 385 */
358 ej_event->handle = handle; 386 if (acpi_memory_disable_device(mem_device))
359 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 387 printk(KERN_ERR PREFIX
360 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 388 "Disable memory device\n");
361 (void *)ej_event); 389 /*
362 390 * TBD: Invoke acpi_bus_remove to cleanup data structures
363 /* eject is performed asynchronously */ 391 */
364 return; 392 break;
365 default: 393 default:
366 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 394 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
367 "Unsupported event [0x%x]\n", event)); 395 "Unsupported event [0x%x]\n", event));
368 396 break;
369 /* non-hotplug event; possibly handled by other handler */
370 return;
371 } 397 }
372 398
373 /* Inform firmware that the hotplug operation has completed */
374 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL);
375 return; 399 return;
376} 400}
377 401
378static void acpi_memory_device_free(struct acpi_memory_device *mem_device)
379{
380 if (!mem_device)
381 return;
382
383 acpi_memory_free_device_resources(mem_device);
384 kfree(mem_device);
385}
386
387static int acpi_memory_device_add(struct acpi_device *device) 402static int acpi_memory_device_add(struct acpi_device *device)
388{ 403{
389 int result; 404 int result;
@@ -413,16 +428,23 @@ static int acpi_memory_device_add(struct acpi_device *device)
413 /* Set the device state */ 428 /* Set the device state */
414 mem_device->state = MEMORY_POWER_ON_STATE; 429 mem_device->state = MEMORY_POWER_ON_STATE;
415 430
416 pr_debug("%s\n", acpi_device_name(device)); 431 printk(KERN_DEBUG "%s \n", acpi_device_name(device));
432
433 /*
434 * Early boot code has recognized memory area by EFI/E820.
435 * If DSDT shows these memory devices on boot, hotplug is not necessary
436 * for them. So, it just returns until completion of this driver's
437 * start up.
438 */
439 if (!acpi_hotmem_initialized)
440 return 0;
417 441
418 if (!acpi_memory_check_device(mem_device)) { 442 if (!acpi_memory_check_device(mem_device)) {
419 /* call add_memory func */ 443 /* call add_memory func */
420 result = acpi_memory_enable_device(mem_device); 444 result = acpi_memory_enable_device(mem_device);
421 if (result) { 445 if (result)
422 dev_err(&device->dev, 446 printk(KERN_ERR PREFIX
423 "Error in acpi_memory_enable_device\n"); 447 "Error in acpi_memory_enable_device\n");
424 acpi_memory_device_free(mem_device);
425 }
426 } 448 }
427 return result; 449 return result;
428} 450}
@@ -430,18 +452,13 @@ static int acpi_memory_device_add(struct acpi_device *device)
430static int acpi_memory_device_remove(struct acpi_device *device, int type) 452static int acpi_memory_device_remove(struct acpi_device *device, int type)
431{ 453{
432 struct acpi_memory_device *mem_device = NULL; 454 struct acpi_memory_device *mem_device = NULL;
433 int result; 455
434 456
435 if (!device || !acpi_driver_data(device)) 457 if (!device || !acpi_driver_data(device))
436 return -EINVAL; 458 return -EINVAL;
437 459
438 mem_device = acpi_driver_data(device); 460 mem_device = acpi_driver_data(device);
439 461 kfree(mem_device);
440 result = acpi_memory_remove_memory(mem_device);
441 if (result)
442 return result;
443
444 acpi_memory_device_free(mem_device);
445 462
446 return 0; 463 return 0;
447} 464}
@@ -530,6 +547,7 @@ static int __init acpi_memory_device_init(void)
530 return -ENODEV; 547 return -ENODEV;
531 } 548 }
532 549
550 acpi_hotmem_initialized = 1;
533 return 0; 551 return 0;
534} 552}
535 553
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 16fa979f718..a43fa1a57d5 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -36,7 +36,6 @@
36#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" 36#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
37#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80 37#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
38static DEFINE_MUTEX(isolated_cpus_lock); 38static DEFINE_MUTEX(isolated_cpus_lock);
39static DEFINE_MUTEX(round_robin_lock);
40 39
41static unsigned long power_saving_mwait_eax; 40static unsigned long power_saving_mwait_eax;
42 41
@@ -108,7 +107,7 @@ static void round_robin_cpu(unsigned int tsk_index)
108 if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) 107 if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
109 return; 108 return;
110 109
111 mutex_lock(&round_robin_lock); 110 mutex_lock(&isolated_cpus_lock);
112 cpumask_clear(tmp); 111 cpumask_clear(tmp);
113 for_each_cpu(cpu, pad_busy_cpus) 112 for_each_cpu(cpu, pad_busy_cpus)
114 cpumask_or(tmp, tmp, topology_thread_cpumask(cpu)); 113 cpumask_or(tmp, tmp, topology_thread_cpumask(cpu));
@@ -117,7 +116,7 @@ static void round_robin_cpu(unsigned int tsk_index)
117 if (cpumask_empty(tmp)) 116 if (cpumask_empty(tmp))
118 cpumask_andnot(tmp, cpu_online_mask, pad_busy_cpus); 117 cpumask_andnot(tmp, cpu_online_mask, pad_busy_cpus);
119 if (cpumask_empty(tmp)) { 118 if (cpumask_empty(tmp)) {
120 mutex_unlock(&round_robin_lock); 119 mutex_unlock(&isolated_cpus_lock);
121 return; 120 return;
122 } 121 }
123 for_each_cpu(cpu, tmp) { 122 for_each_cpu(cpu, tmp) {
@@ -132,7 +131,7 @@ static void round_robin_cpu(unsigned int tsk_index)
132 tsk_in_cpu[tsk_index] = preferred_cpu; 131 tsk_in_cpu[tsk_index] = preferred_cpu;
133 cpumask_set_cpu(preferred_cpu, pad_busy_cpus); 132 cpumask_set_cpu(preferred_cpu, pad_busy_cpus);
134 cpu_weight[preferred_cpu]++; 133 cpu_weight[preferred_cpu]++;
135 mutex_unlock(&round_robin_lock); 134 mutex_unlock(&isolated_cpus_lock);
136 135
137 set_cpus_allowed_ptr(current, cpumask_of(preferred_cpu)); 136 set_cpus_allowed_ptr(current, cpumask_of(preferred_cpu));
138} 137}
@@ -145,7 +144,7 @@ static void exit_round_robin(unsigned int tsk_index)
145} 144}
146 145
147static unsigned int idle_pct = 5; /* percentage */ 146static unsigned int idle_pct = 5; /* percentage */
148static unsigned int round_robin_time = 1; /* second */ 147static unsigned int round_robin_time = 10; /* second */
149static int power_saving_thread(void *data) 148static int power_saving_thread(void *data)
150{ 149{
151 struct sched_param param = {.sched_priority = 1}; 150 struct sched_param param = {.sched_priority = 1};
@@ -235,7 +234,7 @@ static int create_power_saving_task(void)
235 234
236 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, 235 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread,
237 (void *)(unsigned long)ps_tsk_num, 236 (void *)(unsigned long)ps_tsk_num,
238 "acpi_pad/%d", ps_tsk_num); 237 "power_saving/%d", ps_tsk_num);
239 rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0; 238 rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0;
240 if (!rc) 239 if (!rc)
241 ps_tsk_num++; 240 ps_tsk_num++;
@@ -286,7 +285,7 @@ static ssize_t acpi_pad_rrtime_store(struct device *dev,
286 struct device_attribute *attr, const char *buf, size_t count) 285 struct device_attribute *attr, const char *buf, size_t count)
287{ 286{
288 unsigned long num; 287 unsigned long num;
289 if (kstrtoul(buf, 0, &num)) 288 if (strict_strtoul(buf, 0, &num))
290 return -EINVAL; 289 return -EINVAL;
291 if (num < 1 || num >= 100) 290 if (num < 1 || num >= 100)
292 return -EINVAL; 291 return -EINVAL;
@@ -309,7 +308,7 @@ static ssize_t acpi_pad_idlepct_store(struct device *dev,
309 struct device_attribute *attr, const char *buf, size_t count) 308 struct device_attribute *attr, const char *buf, size_t count)
310{ 309{
311 unsigned long num; 310 unsigned long num;
312 if (kstrtoul(buf, 0, &num)) 311 if (strict_strtoul(buf, 0, &num))
313 return -EINVAL; 312 return -EINVAL;
314 if (num < 1 || num >= 100) 313 if (num < 1 || num >= 100)
315 return -EINVAL; 314 return -EINVAL;
@@ -332,7 +331,7 @@ static ssize_t acpi_pad_idlecpus_store(struct device *dev,
332 struct device_attribute *attr, const char *buf, size_t count) 331 struct device_attribute *attr, const char *buf, size_t count)
333{ 332{
334 unsigned long num; 333 unsigned long num;
335 if (kstrtoul(buf, 0, &num)) 334 if (strict_strtoul(buf, 0, &num))
336 return -EINVAL; 335 return -EINVAL;
337 mutex_lock(&isolated_cpus_lock); 336 mutex_lock(&isolated_cpus_lock);
338 acpi_pad_idle_cpus(num); 337 acpi_pad_idle_cpus(num);
@@ -457,7 +456,7 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
457 dev_name(&device->dev), event, 0); 456 dev_name(&device->dev), event, 0);
458 break; 457 break;
459 default: 458 default:
460 pr_warn("Unsupported event [0x%x]\n", event); 459 printk(KERN_WARNING "Unsupported event [0x%x]\n", event);
461 break; 460 break;
462 } 461 }
463} 462}
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
deleted file mode 100644
index db129b9f52c..00000000000
--- a/drivers/acpi/acpi_platform.c
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * ACPI support for platform bus type.
3 *
4 * Copyright (C) 2012, Intel Corporation
5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Mathias Nyman <mathias.nyman@linux.intel.com>
7 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/acpi.h>
15#include <linux/device.h>
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/platform_device.h>
19
20#include "internal.h"
21
22ACPI_MODULE_NAME("platform");
23
24/**
25 * acpi_create_platform_device - Create platform device for ACPI device node
26 * @adev: ACPI device node to create a platform device for.
27 *
28 * Check if the given @adev can be represented as a platform device and, if
29 * that's the case, create and register a platform device, populate its common
30 * resources and returns a pointer to it. Otherwise, return %NULL.
31 *
32 * The platform device's name will be taken from the @adev's _HID and _UID.
33 */
34struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
35{
36 struct platform_device *pdev = NULL;
37 struct acpi_device *acpi_parent;
38 struct platform_device_info pdevinfo;
39 struct resource_list_entry *rentry;
40 struct list_head resource_list;
41 struct resource *resources;
42 int count;
43
44 /* If the ACPI node already has a physical device attached, skip it. */
45 if (adev->physical_node_count)
46 return NULL;
47
48 INIT_LIST_HEAD(&resource_list);
49 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
50 if (count <= 0)
51 return NULL;
52
53 resources = kmalloc(count * sizeof(struct resource), GFP_KERNEL);
54 if (!resources) {
55 dev_err(&adev->dev, "No memory for resources\n");
56 acpi_dev_free_resource_list(&resource_list);
57 return NULL;
58 }
59 count = 0;
60 list_for_each_entry(rentry, &resource_list, node)
61 resources[count++] = rentry->res;
62
63 acpi_dev_free_resource_list(&resource_list);
64
65 memset(&pdevinfo, 0, sizeof(pdevinfo));
66 /*
67 * If the ACPI node has a parent and that parent has a physical device
68 * attached to it, that physical device should be the parent of the
69 * platform device we are about to create.
70 */
71 pdevinfo.parent = NULL;
72 acpi_parent = adev->parent;
73 if (acpi_parent) {
74 struct acpi_device_physical_node *entry;
75 struct list_head *list;
76
77 mutex_lock(&acpi_parent->physical_node_lock);
78 list = &acpi_parent->physical_node_list;
79 if (!list_empty(list)) {
80 entry = list_first_entry(list,
81 struct acpi_device_physical_node,
82 node);
83 pdevinfo.parent = entry->dev;
84 }
85 mutex_unlock(&acpi_parent->physical_node_lock);
86 }
87 pdevinfo.name = dev_name(&adev->dev);
88 pdevinfo.id = -1;
89 pdevinfo.res = resources;
90 pdevinfo.num_res = count;
91 pdevinfo.acpi_node.handle = adev->handle;
92 pdev = platform_device_register_full(&pdevinfo);
93 if (IS_ERR(pdev)) {
94 dev_err(&adev->dev, "platform device creation failed: %ld\n",
95 PTR_ERR(pdev));
96 pdev = NULL;
97 } else {
98 dev_dbg(&adev->dev, "created platform device %s\n",
99 dev_name(&pdev->dev));
100 }
101
102 kfree(resources);
103 return pdev;
104}
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index bc7a03ded06..301bd2d388a 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -8,159 +8,41 @@ ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
8# use acpi.o to put all files here into acpi.o modparam namespace 8# use acpi.o to put all files here into acpi.o modparam namespace
9obj-y += acpi.o 9obj-y += acpi.o
10 10
11acpi-y := \ 11acpi-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
12 dsargs.o \ 12 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \
13 dscontrol.o \ 13 dsinit.o dsargs.o dscontrol.o dswload2.o
14 dsfield.o \
15 dsinit.o \
16 dsmethod.o \
17 dsmthdat.o \
18 dsobject.o \
19 dsopcode.o \
20 dsutils.o \
21 dswexec.o \
22 dswload.o \
23 dswload2.o \
24 dswscope.o \
25 dswstate.o
26 14
27acpi-y += \ 15acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \
28 evevent.o \ 16 evmisc.o evrgnini.o evxface.o evxfregn.o \
29 evgpe.o \ 17 evgpe.o evgpeblk.o evgpeinit.o evgpeutil.o evxfgpe.o evglock.o
30 evgpeblk.o \
31 evgpeinit.o \
32 evgpeutil.o \
33 evglock.o \
34 evmisc.o \
35 evregion.o \
36 evrgnini.o \
37 evsci.o \
38 evxface.o \
39 evxfevnt.o \
40 evxfgpe.o \
41 evxfregn.o
42 18
43acpi-y += \ 19acpi-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\
44 exconfig.o \ 20 exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\
45 exconvrt.o \ 21 excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \
46 excreate.o \ 22 exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o exdebug.o
47 exdebug.o \
48 exdump.o \
49 exfield.o \
50 exfldio.o \
51 exmutex.o \
52 exnames.o \
53 exoparg1.o \
54 exoparg2.o \
55 exoparg3.o \
56 exoparg6.o \
57 exprep.o \
58 exmisc.o \
59 exregion.o \
60 exresnte.o \
61 exresolv.o \
62 exresop.o \
63 exstore.o \
64 exstoren.o \
65 exstorob.o \
66 exsystem.o \
67 exutils.o
68 23
69acpi-y += \ 24acpi-y += hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o hwvalid.o hwpci.o
70 hwacpi.o \
71 hwesleep.o \
72 hwgpe.o \
73 hwpci.o \
74 hwregs.o \
75 hwsleep.o \
76 hwvalid.o \
77 hwxface.o \
78 hwxfsleep.o
79 25
80acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o 26acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o
81 27
82acpi-y += \ 28acpi-y += nsaccess.o nsload.o nssearch.o nsxfeval.o \
83 nsaccess.o \ 29 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
84 nsalloc.o \ 30 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
85 nsdump.o \ 31 nsparse.o nspredef.o nsrepair.o nsrepair2.o
86 nseval.o \
87 nsinit.o \
88 nsload.o \
89 nsnames.o \
90 nsobject.o \
91 nsparse.o \
92 nspredef.o \
93 nsrepair.o \
94 nsrepair2.o \
95 nssearch.o \
96 nsutils.o \
97 nswalk.o \
98 nsxfeval.o \
99 nsxfname.o \
100 nsxfobj.o
101 32
102acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o 33acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
103 34
104acpi-y += \ 35acpi-y += psargs.o psparse.o psloop.o pstree.o pswalk.o \
105 psargs.o \ 36 psopcode.o psscope.o psutils.o psxface.o
106 psloop.o \
107 psopcode.o \
108 psparse.o \
109 psscope.o \
110 pstree.o \
111 psutils.o \
112 pswalk.o \
113 psxface.o
114 37
115acpi-y += \ 38acpi-y += rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
116 rsaddr.o \ 39 rscalc.o rsirq.o rsmemory.o rsutils.o
117 rscalc.o \
118 rscreate.o \
119 rsinfo.o \
120 rsio.o \
121 rsirq.o \
122 rslist.o \
123 rsmemory.o \
124 rsmisc.o \
125 rsserial.o \
126 rsutils.o \
127 rsxface.o
128 40
129acpi-$(ACPI_FUTURE_USAGE) += rsdump.o 41acpi-$(ACPI_FUTURE_USAGE) += rsdump.o
130 42
131acpi-y += \ 43acpi-y += tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
132 tbfadt.o \
133 tbfind.o \
134 tbinstal.o \
135 tbutils.o \
136 tbxface.o \
137 tbxfload.o \
138 tbxfroot.o
139
140acpi-y += \
141 utaddress.o \
142 utalloc.o \
143 utcopy.o \
144 utexcep.o \
145 utdebug.o \
146 utdecode.o \
147 utdelete.o \
148 uteval.o \
149 utglobal.o \
150 utids.o \
151 utinit.o \
152 utlock.o \
153 utmath.o \
154 utmisc.o \
155 utmutex.o \
156 utobject.o \
157 utosi.o \
158 utresrc.o \
159 utstate.o \
160 utxface.o \
161 utxfinit.o \
162 utxferror.o \
163 utxfmutex.o
164
165acpi-$(ACPI_FUTURE_USAGE) += uttrack.o utcache.o
166 44
45acpi-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
46 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
47 utstate.o utmutex.o utobject.o utresrc.o utlock.o utids.o \
48 utosi.o utxferror.o utdecode.o
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
index 8a7d51bfb3b..e0ba17f0a7c 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,7 @@
51 * 51 *
52 * Note: The order of these include files is important. 52 * Note: The order of these include files is important.
53 */ 53 */
54#include "acconfig.h" /* Global configuration constants */
54#include "acmacros.h" /* C macros */ 55#include "acmacros.h" /* C macros */
55#include "aclocal.h" /* Internal data types */ 56#include "aclocal.h" /* Internal data types */
56#include "acobject.h" /* ACPI internal object */ 57#include "acobject.h" /* ACPI internal object */
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 432a318c9ed..eb0b1f8dee6 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,28 +44,17 @@
44#ifndef __ACDEBUG_H__ 44#ifndef __ACDEBUG_H__
45#define __ACDEBUG_H__ 45#define __ACDEBUG_H__
46 46
47#define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */ 47#define ACPI_DEBUG_BUFFER_SIZE 4196
48 48
49struct acpi_db_command_info { 49struct command_info {
50 char *name; /* Command Name */ 50 char *name; /* Command Name */
51 u8 min_args; /* Minimum arguments required */ 51 u8 min_args; /* Minimum arguments required */
52}; 52};
53 53
54struct acpi_db_command_help { 54struct argument_info {
55 u8 line_count; /* Number of help lines */
56 char *invocation; /* Command Invocation */
57 char *description; /* Command Description */
58};
59
60struct acpi_db_argument_info {
61 char *name; /* Argument Name */ 55 char *name; /* Argument Name */
62}; 56};
63 57
64struct acpi_db_execute_walk {
65 u32 count;
66 u32 max_count;
67};
68
69#define PARAM_LIST(pl) pl 58#define PARAM_LIST(pl) pl
70#define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose) 59#define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose)
71#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ 60#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\
@@ -88,35 +77,12 @@ acpi_db_single_step(struct acpi_walk_state *walk_state,
88/* 77/*
89 * dbcmds - debug commands and output routines 78 * dbcmds - debug commands and output routines
90 */ 79 */
91struct acpi_namespace_node *acpi_db_convert_to_node(char *in_string); 80acpi_status acpi_db_disassemble_method(char *name);
92 81
93void acpi_db_display_table_info(char *table_arg); 82void acpi_db_display_table_info(char *table_arg);
94 83
95void acpi_db_display_template(char *buffer_arg); 84void acpi_db_unload_acpi_table(char *table_arg, char *instance_arg);
96
97void acpi_db_unload_acpi_table(char *name);
98
99void acpi_db_send_notify(char *name, u32 value);
100
101void acpi_db_display_interfaces(char *action_arg, char *interface_name_arg);
102
103acpi_status acpi_db_sleep(char *object_arg);
104
105void acpi_db_display_locks(void);
106
107void acpi_db_display_resources(char *object_arg);
108
109ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_display_gpes(void))
110
111void acpi_db_display_handlers(void);
112 85
113ACPI_HW_DEPENDENT_RETURN_VOID(void
114 acpi_db_generate_gpe(char *gpe_arg,
115 char *block_arg))
116
117/*
118 * dbmethod - control method commands
119 */
120void 86void
121acpi_db_set_method_breakpoint(char *location, 87acpi_db_set_method_breakpoint(char *location,
122 struct acpi_walk_state *walk_state, 88 struct acpi_walk_state *walk_state,
@@ -124,35 +90,44 @@ acpi_db_set_method_breakpoint(char *location,
124 90
125void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op); 91void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op);
126 92
127void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg); 93void acpi_db_get_bus_info(void);
128
129acpi_status acpi_db_disassemble_method(char *name);
130 94
131void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op); 95void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op);
132 96
133void acpi_db_batch_execute(char *count_arg);
134
135/*
136 * dbnames - namespace commands
137 */
138void acpi_db_set_scope(char *name);
139
140void acpi_db_dump_namespace(char *start_arg, char *depth_arg); 97void acpi_db_dump_namespace(char *start_arg, char *depth_arg);
141 98
142void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg); 99void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg);
143 100
144acpi_status acpi_db_find_name_in_namespace(char *name_arg); 101void acpi_db_send_notify(char *name, u32 value);
145 102
146void acpi_db_check_predefined_names(void); 103void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg);
147 104
148acpi_status 105acpi_status
149acpi_db_display_objects(char *obj_type_arg, char *display_count_arg); 106acpi_db_display_objects(char *obj_type_arg, char *display_count_arg);
150 107
151void acpi_db_check_integrity(void); 108void acpi_db_display_interfaces(char *action_arg, char *interface_name_arg);
109
110acpi_status acpi_db_find_name_in_namespace(char *name_arg);
111
112void acpi_db_set_scope(char *name);
113
114acpi_status acpi_db_sleep(char *object_arg);
152 115
153void acpi_db_find_references(char *object_arg); 116void acpi_db_find_references(char *object_arg);
154 117
155void acpi_db_get_bus_info(void); 118void acpi_db_display_locks(void);
119
120void acpi_db_display_resources(char *object_arg);
121
122void acpi_db_display_gpes(void);
123
124void acpi_db_check_integrity(void);
125
126void acpi_db_generate_gpe(char *gpe_arg, char *block_arg);
127
128void acpi_db_check_predefined_names(void);
129
130void acpi_db_batch_execute(void);
156 131
157/* 132/*
158 * dbdisply - debug display commands 133 * dbdisply - debug display commands
@@ -184,8 +159,7 @@ acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
184/* 159/*
185 * dbexec - debugger control method execution 160 * dbexec - debugger control method execution
186 */ 161 */
187void 162void acpi_db_execute(char *name, char **args, u32 flags);
188acpi_db_execute(char *name, char **args, acpi_object_type * types, u32 flags);
189 163
190void 164void
191acpi_db_create_execution_threads(char *num_threads_arg, 165acpi_db_create_execution_threads(char *num_threads_arg,
@@ -199,8 +173,7 @@ u32 acpi_db_get_cache_info(struct acpi_memory_list *cache);
199 * dbfileio - Debugger file I/O commands 173 * dbfileio - Debugger file I/O commands
200 */ 174 */
201acpi_object_type 175acpi_object_type
202acpi_db_match_argument(char *user_argument, 176acpi_db_match_argument(char *user_argument, struct argument_info *arguments);
203 struct acpi_db_argument_info *arguments);
204 177
205void acpi_db_close_debug_file(void); 178void acpi_db_close_debug_file(void);
206 179
@@ -233,11 +206,6 @@ acpi_db_command_dispatch(char *input_buffer,
233 206
234void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context); 207void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
235 208
236acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op);
237
238char *acpi_db_get_next_token(char *string,
239 char **next, acpi_object_type * return_type);
240
241/* 209/*
242 * dbstats - Generation and display of ACPI table statistics 210 * dbstats - Generation and display of ACPI table statistics
243 */ 211 */
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index ed33ebcdaeb..2d1b7ffa377 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -309,13 +309,10 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state);
309acpi_status 309acpi_status
310acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state); 310acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state);
311 311
312struct acpi_walk_state * acpi_ds_create_walk_state(acpi_owner_id owner_id, 312struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, union acpi_parse_object
313 union acpi_parse_object 313 *origin, union acpi_operand_object
314 *origin, 314 *mth_desc, struct acpi_thread_state
315 union acpi_operand_object 315 *thread);
316 *mth_desc,
317 struct acpi_thread_state
318 *thread);
319 316
320acpi_status 317acpi_status
321acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state, 318acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index e975c672044..bea3b489918 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -69,10 +69,11 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node *node,
69 */ 69 */
70acpi_status acpi_ev_init_global_lock_handler(void); 70acpi_status acpi_ev_init_global_lock_handler(void);
71 71
72ACPI_HW_DEPENDENT_RETURN_OK(acpi_status 72acpi_status acpi_ev_acquire_global_lock(u16 timeout);
73 acpi_ev_acquire_global_lock(u16 timeout)) 73
74 ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void)) 74acpi_status acpi_ev_release_global_lock(void);
75 acpi_status acpi_ev_remove_global_lock_handler(void); 75
76acpi_status acpi_ev_remove_global_lock_handler(void);
76 77
77/* 78/*
78 * evgpe - Low-level GPE support 79 * evgpe - Low-level GPE support
@@ -84,11 +85,9 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info);
84 85
85acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info); 86acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info);
86 87
87acpi_status 88acpi_status acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info);
88acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info);
89 89
90acpi_status 90acpi_status acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info);
91acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info);
92 91
93struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, 92struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
94 u32 gpe_number); 93 u32 gpe_number);
@@ -115,9 +114,7 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
115 struct acpi_gpe_block_info *gpe_block, 114 struct acpi_gpe_block_info *gpe_block,
116 void *context); 115 void *context);
117 116
118ACPI_HW_DEPENDENT_RETURN_OK(acpi_status 117acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block);
119 acpi_ev_delete_gpe_block(struct acpi_gpe_block_info
120 *gpe_block))
121 118
122u32 119u32
123acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, 120acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
@@ -129,10 +126,9 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
129 */ 126 */
130acpi_status acpi_ev_gpe_initialize(void); 127acpi_status acpi_ev_gpe_initialize(void);
131 128
132ACPI_HW_DEPENDENT_RETURN_VOID(void 129void acpi_ev_update_gpes(acpi_owner_id table_owner_id);
133 acpi_ev_update_gpes(acpi_owner_id table_owner_id))
134 130
135 acpi_status 131acpi_status
136acpi_ev_match_gpe_method(acpi_handle obj_handle, 132acpi_ev_match_gpe_method(acpi_handle obj_handle,
137 u32 level, void *context, void **return_value); 133 u32 level, void *context, void **return_value);
138 134
@@ -166,7 +162,6 @@ acpi_status acpi_ev_initialize_op_regions(void);
166 162
167acpi_status 163acpi_status
168acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, 164acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
169 union acpi_operand_object *field_obj,
170 u32 function, 165 u32 function,
171 u32 region_offset, u32 bit_width, u64 *value); 166 u32 region_offset, u32 bit_width, u64 *value);
172 167
@@ -239,7 +234,8 @@ u32 acpi_ev_install_sci_handler(void);
239 234
240acpi_status acpi_ev_remove_sci_handler(void); 235acpi_status acpi_ev_remove_sci_handler(void);
241 236
242u32 acpi_ev_initialize_SCI(u32 program_SCI); 237u32 acpi_ev_initialize_sCI(u32 program_sCI);
238
239void acpi_ev_terminate(void);
243 240
244ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_ev_terminate(void))
245#endif /* __ACEVENTS_H__ */ 241#endif /* __ACEVENTS_H__ */
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 64472e4ec32..76dc02f1557 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,7 +70,7 @@
70 70
71/* 71/*
72 * Enable "slack" in the AML interpreter? Default is FALSE, and the 72 * Enable "slack" in the AML interpreter? Default is FALSE, and the
73 * interpreter strictly follows the ACPI specification. Setting to TRUE 73 * interpreter strictly follows the ACPI specification. Setting to TRUE
74 * allows the interpreter to ignore certain errors and/or bad AML constructs. 74 * allows the interpreter to ignore certain errors and/or bad AML constructs.
75 * 75 *
76 * Currently, these features are enabled by this flag: 76 * Currently, these features are enabled by this flag:
@@ -108,7 +108,7 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE);
108/* 108/*
109 * Optionally enable output from the AML Debug Object. 109 * Optionally enable output from the AML Debug Object.
110 */ 110 */
111bool ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE); 111u32 ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
112 112
113/* 113/*
114 * Optionally copy the entire DSDT to local memory (instead of simply 114 * Optionally copy the entire DSDT to local memory (instead of simply
@@ -140,18 +140,27 @@ u32 acpi_gbl_trace_flags;
140acpi_name acpi_gbl_trace_method_name; 140acpi_name acpi_gbl_trace_method_name;
141u8 acpi_gbl_system_awake_and_running; 141u8 acpi_gbl_system_awake_and_running;
142 142
143/* 143#endif
144 * ACPI 5.0 introduces the concept of a "reduced hardware platform", meaning
145 * that the ACPI hardware is no longer required. A flag in the FADT indicates
146 * a reduced HW machine, and that flag is duplicated here for convenience.
147 */
148u8 acpi_gbl_reduced_hardware;
149 144
150#endif /* DEFINE_ACPI_GLOBALS */ 145/*****************************************************************************
146 *
147 * Debug support
148 *
149 ****************************************************************************/
151 150
152/* Do not disassemble buffers to resource descriptors */ 151/* Procedure nesting level for debug output */
153 152
154ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_no_resource_disassembly, FALSE); 153extern u32 acpi_gbl_nesting_level;
154
155ACPI_EXTERN u32 acpi_gpe_count;
156ACPI_EXTERN u32 acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS];
157
158/* Support for dynamic control method tracing mechanism */
159
160ACPI_EXTERN u32 acpi_gbl_original_dbg_level;
161ACPI_EXTERN u32 acpi_gbl_original_dbg_layer;
162ACPI_EXTERN u32 acpi_gbl_trace_dbg_level;
163ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
155 164
156/***************************************************************************** 165/*****************************************************************************
157 * 166 *
@@ -164,12 +173,8 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_no_resource_disassembly, FALSE);
164 * found in the RSDT/XSDT. 173 * found in the RSDT/XSDT.
165 */ 174 */
166ACPI_EXTERN struct acpi_table_list acpi_gbl_root_table_list; 175ACPI_EXTERN struct acpi_table_list acpi_gbl_root_table_list;
167
168#if (!ACPI_REDUCED_HARDWARE)
169ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS; 176ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
170 177
171#endif /* !ACPI_REDUCED_HARDWARE */
172
173/* These addresses are calculated from the FADT Event Block addresses */ 178/* These addresses are calculated from the FADT Event Block addresses */
174 179
175ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_status; 180ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_status;
@@ -202,7 +207,7 @@ ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock;
202 207
203/***************************************************************************** 208/*****************************************************************************
204 * 209 *
205 * Mutual exclusion within ACPICA subsystem 210 * Mutual exlusion within ACPICA subsystem
206 * 211 *
207 ****************************************************************************/ 212 ****************************************************************************/
208 213
@@ -239,6 +244,15 @@ ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE reg
239 * 244 *
240 ****************************************************************************/ 245 ****************************************************************************/
241 246
247#ifdef ACPI_DBG_TRACK_ALLOCATIONS
248
249/* Lists for tracking memory allocations */
250
251ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list;
252ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list;
253ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats;
254#endif
255
242/* Object caches */ 256/* Object caches */
243 257
244ACPI_EXTERN acpi_cache_t *acpi_gbl_namespace_cache; 258ACPI_EXTERN acpi_cache_t *acpi_gbl_namespace_cache;
@@ -249,7 +263,8 @@ ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache;
249 263
250/* Global handlers */ 264/* Global handlers */
251 265
252ACPI_EXTERN struct acpi_global_notify_handler acpi_gbl_global_notify[2]; 266ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify;
267ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
253ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; 268ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
254ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; 269ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
255ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler; 270ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler;
@@ -280,8 +295,6 @@ ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
280ACPI_EXTERN u8 acpi_gbl_events_initialized; 295ACPI_EXTERN u8 acpi_gbl_events_initialized;
281ACPI_EXTERN u8 acpi_gbl_osi_data; 296ACPI_EXTERN u8 acpi_gbl_osi_data;
282ACPI_EXTERN struct acpi_interface_info *acpi_gbl_supported_interfaces; 297ACPI_EXTERN struct acpi_interface_info *acpi_gbl_supported_interfaces;
283ACPI_EXTERN struct acpi_address_range
284 *acpi_gbl_address_range_list[ACPI_ADDRESS_RANGE_MAX];
285 298
286#ifndef DEFINE_ACPI_GLOBALS 299#ifndef DEFINE_ACPI_GLOBALS
287 300
@@ -297,14 +310,13 @@ extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
297 310
298#endif 311#endif
299 312
300#ifdef ACPI_DBG_TRACK_ALLOCATIONS 313/* Exception codes */
301
302/* Lists for tracking memory allocations */
303 314
304ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; 315extern char const *acpi_gbl_exception_names_env[];
305ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; 316extern char const *acpi_gbl_exception_names_pgm[];
306ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats; 317extern char const *acpi_gbl_exception_names_tbl[];
307#endif 318extern char const *acpi_gbl_exception_names_aml[];
319extern char const *acpi_gbl_exception_names_ctrl[];
308 320
309/***************************************************************************** 321/*****************************************************************************
310 * 322 *
@@ -372,37 +384,10 @@ ACPI_EXTERN struct acpi_fixed_event_handler
372ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; 384ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
373ACPI_EXTERN struct acpi_gpe_block_info 385ACPI_EXTERN struct acpi_gpe_block_info
374*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; 386*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
375
376#if (!ACPI_REDUCED_HARDWARE)
377
378ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized; 387ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized;
379ACPI_EXTERN acpi_gbl_event_handler acpi_gbl_global_event_handler; 388ACPI_EXTERN ACPI_GBL_EVENT_HANDLER acpi_gbl_global_event_handler;
380ACPI_EXTERN void *acpi_gbl_global_event_handler_context; 389ACPI_EXTERN void *acpi_gbl_global_event_handler_context;
381 390
382#endif /* !ACPI_REDUCED_HARDWARE */
383
384/*****************************************************************************
385 *
386 * Debug support
387 *
388 ****************************************************************************/
389
390/* Procedure nesting level for debug output */
391
392extern u32 acpi_gbl_nesting_level;
393
394/* Event counters */
395
396ACPI_EXTERN u32 acpi_gpe_count;
397ACPI_EXTERN u32 acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS];
398
399/* Support for dynamic control method tracing mechanism */
400
401ACPI_EXTERN u32 acpi_gbl_original_dbg_level;
402ACPI_EXTERN u32 acpi_gbl_original_dbg_layer;
403ACPI_EXTERN u32 acpi_gbl_trace_dbg_level;
404ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
405
406/***************************************************************************** 391/*****************************************************************************
407 * 392 *
408 * Debugger globals 393 * Debugger globals
@@ -428,11 +413,10 @@ ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
428ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; 413ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
429 414
430ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; 415ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
431ACPI_EXTERN acpi_object_type acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]; 416ACPI_EXTERN char acpi_gbl_db_line_buf[80];
432ACPI_EXTERN char acpi_gbl_db_line_buf[ACPI_DB_LINE_BUFFER_SIZE]; 417ACPI_EXTERN char acpi_gbl_db_parsed_buf[80];
433ACPI_EXTERN char acpi_gbl_db_parsed_buf[ACPI_DB_LINE_BUFFER_SIZE]; 418ACPI_EXTERN char acpi_gbl_db_scope_buf[40];
434ACPI_EXTERN char acpi_gbl_db_scope_buf[80]; 419ACPI_EXTERN char acpi_gbl_db_debug_filename[40];
435ACPI_EXTERN char acpi_gbl_db_debug_filename[80];
436ACPI_EXTERN u8 acpi_gbl_db_output_to_file; 420ACPI_EXTERN u8 acpi_gbl_db_output_to_file;
437ACPI_EXTERN char *acpi_gbl_db_buffer; 421ACPI_EXTERN char *acpi_gbl_db_buffer;
438ACPI_EXTERN char *acpi_gbl_db_filename; 422ACPI_EXTERN char *acpi_gbl_db_filename;
@@ -457,12 +441,4 @@ ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
457 441
458#endif /* ACPI_DEBUGGER */ 442#endif /* ACPI_DEBUGGER */
459 443
460/*****************************************************************************
461 *
462 * Info/help support
463 *
464 ****************************************************************************/
465
466extern const struct ah_predefined_name asl_predefined_info[];
467
468#endif /* __ACGLOBAL_H__ */ 444#endif /* __ACGLOBAL_H__ */
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index d902d31abc6..e7213beaafc 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -81,26 +81,6 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value);
81acpi_status acpi_hw_clear_acpi_status(void); 81acpi_status acpi_hw_clear_acpi_status(void);
82 82
83/* 83/*
84 * hwsleep - sleep/wake support (Legacy sleep registers)
85 */
86acpi_status acpi_hw_legacy_sleep(u8 sleep_state);
87
88acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state);
89
90acpi_status acpi_hw_legacy_wake(u8 sleep_state);
91
92/*
93 * hwesleep - sleep/wake support (Extended FADT-V5 sleep registers)
94 */
95void acpi_hw_execute_sleep_method(char *method_name, u32 integer_argument);
96
97acpi_status acpi_hw_extended_sleep(u8 sleep_state);
98
99acpi_status acpi_hw_extended_wake_prep(u8 sleep_state);
100
101acpi_status acpi_hw_extended_wake(u8 sleep_state);
102
103/*
104 * hwvalid - Port I/O with validation 84 * hwvalid - Port I/O with validation
105 */ 85 */
106acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width); 86acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width);
@@ -110,7 +90,8 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
110/* 90/*
111 * hwgpe - GPE support 91 * hwgpe - GPE support
112 */ 92 */
113u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info); 93u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
94 struct acpi_gpe_register_info *gpe_register_info);
114 95
115acpi_status 96acpi_status
116acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action); 97acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action);
@@ -147,4 +128,16 @@ acpi_status
147acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id, 128acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id,
148 acpi_handle root_pci_device, acpi_handle pci_region); 129 acpi_handle root_pci_device, acpi_handle pci_region);
149 130
131#ifdef ACPI_FUTURE_USAGE
132/*
133 * hwtimer - ACPI Timer prototypes
134 */
135acpi_status acpi_get_timer_resolution(u32 * resolution);
136
137acpi_status acpi_get_timer(u32 * ticks);
138
139acpi_status
140acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed);
141#endif /* ACPI_FUTURE_USAGE */
142
150#endif /* __ACHWARE_H__ */ 143#endif /* __ACHWARE_H__ */
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index eb308635da7..3731e1c34b8 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -468,8 +468,6 @@ void acpi_ex_eisa_id_to_string(char *dest, u64 compressed_id);
468 468
469void acpi_ex_integer_to_string(char *dest, u64 value); 469void acpi_ex_integer_to_string(char *dest, u64 value);
470 470
471u8 acpi_is_valid_space_id(u8 space_id);
472
473/* 471/*
474 * exregion - default op_region handlers 472 * exregion - default op_region handlers
475 */ 473 */
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index ff8bd0061e8..5552125d834 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -53,7 +53,7 @@ typedef u32 acpi_mutex_handle;
53 53
54/* Total number of aml opcodes defined */ 54/* Total number of aml opcodes defined */
55 55
56#define AML_NUM_OPCODES 0x81 56#define AML_NUM_OPCODES 0x7F
57 57
58/* Forward declarations */ 58/* Forward declarations */
59 59
@@ -249,23 +249,19 @@ struct acpi_create_field_info {
249 struct acpi_namespace_node *field_node; 249 struct acpi_namespace_node *field_node;
250 struct acpi_namespace_node *register_node; 250 struct acpi_namespace_node *register_node;
251 struct acpi_namespace_node *data_register_node; 251 struct acpi_namespace_node *data_register_node;
252 struct acpi_namespace_node *connection_node;
253 u8 *resource_buffer;
254 u32 bank_value; 252 u32 bank_value;
255 u32 field_bit_position; 253 u32 field_bit_position;
256 u32 field_bit_length; 254 u32 field_bit_length;
257 u16 resource_length;
258 u8 field_flags; 255 u8 field_flags;
259 u8 attribute; 256 u8 attribute;
260 u8 field_type; 257 u8 field_type;
261 u8 access_length;
262}; 258};
263 259
264typedef 260typedef
265acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state); 261acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state);
266 262
267/* 263/*
268 * Bitmapped ACPI types. Used internally only 264 * Bitmapped ACPI types. Used internally only
269 */ 265 */
270#define ACPI_BTYPE_ANY 0x00000000 266#define ACPI_BTYPE_ANY 0x00000000
271#define ACPI_BTYPE_INTEGER 0x00000001 267#define ACPI_BTYPE_INTEGER 0x00000001
@@ -299,7 +295,7 @@ acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state);
299 * Information structure for ACPI predefined names. 295 * Information structure for ACPI predefined names.
300 * Each entry in the table contains the following items: 296 * Each entry in the table contains the following items:
301 * 297 *
302 * name - The ACPI reserved name 298 * Name - The ACPI reserved name
303 * param_count - Number of arguments to the method 299 * param_count - Number of arguments to the method
304 * expected_return_btypes - Allowed type(s) for the return value 300 * expected_return_btypes - Allowed type(s) for the return value
305 */ 301 */
@@ -319,8 +315,7 @@ struct acpi_name_info {
319 315
320/* 316/*
321 * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2, 317 * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2,
322 * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT, 318 * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT
323 * ACPI_PTYPE2_FIX_VAR
324 */ 319 */
325struct acpi_package_info { 320struct acpi_package_info {
326 u8 type; 321 u8 type;
@@ -370,7 +365,6 @@ struct acpi_predefined_data {
370/* Defines for Flags field above */ 365/* Defines for Flags field above */
371 366
372#define ACPI_OBJECT_REPAIRED 1 367#define ACPI_OBJECT_REPAIRED 1
373#define ACPI_OBJECT_WRAPPED 2
374 368
375/* 369/*
376 * Bitmapped return value types 370 * Bitmapped return value types
@@ -404,13 +398,6 @@ struct acpi_gpe_handler_info {
404 u8 originally_enabled; /* True if GPE was originally enabled */ 398 u8 originally_enabled; /* True if GPE was originally enabled */
405}; 399};
406 400
407/* Notify info for implicit notify, multiple device objects */
408
409struct acpi_gpe_notify_info {
410 struct acpi_namespace_node *device_node; /* Device to be notified */
411 struct acpi_gpe_notify_info *next;
412};
413
414struct acpi_gpe_notify_object { 401struct acpi_gpe_notify_object {
415 struct acpi_namespace_node *node; 402 struct acpi_namespace_node *node;
416 struct acpi_gpe_notify_object *next; 403 struct acpi_gpe_notify_object *next;
@@ -419,7 +406,7 @@ struct acpi_gpe_notify_object {
419union acpi_gpe_dispatch_info { 406union acpi_gpe_dispatch_info {
420 struct acpi_namespace_node *method_node; /* Method node for this GPE level */ 407 struct acpi_namespace_node *method_node; /* Method node for this GPE level */
421 struct acpi_gpe_handler_info *handler; /* Installed GPE handler */ 408 struct acpi_gpe_handler_info *handler; /* Installed GPE handler */
422 struct acpi_gpe_notify_info *notify_list; /* List of _PRW devices for implicit notifies */ 409 struct acpi_gpe_notify_object device; /* List of _PRW devices for implicit notify */
423}; 410};
424 411
425/* 412/*
@@ -427,7 +414,7 @@ union acpi_gpe_dispatch_info {
427 * NOTE: Important to keep this struct as small as possible. 414 * NOTE: Important to keep this struct as small as possible.
428 */ 415 */
429struct acpi_gpe_event_info { 416struct acpi_gpe_event_info {
430 union acpi_gpe_dispatch_info dispatch; /* Either Method, Handler, or notify_list */ 417 union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */
431 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */ 418 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
432 u8 flags; /* Misc info about this GPE */ 419 u8 flags; /* Misc info about this GPE */
433 u8 gpe_number; /* This GPE */ 420 u8 gpe_number; /* This GPE */
@@ -486,10 +473,8 @@ struct acpi_gpe_device_info {
486 struct acpi_namespace_node *gpe_device; 473 struct acpi_namespace_node *gpe_device;
487}; 474};
488 475
489typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info * 476typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *gpe_xrupt_info,
490 gpe_xrupt_info, 477 struct acpi_gpe_block_info *gpe_block, void *context);
491 struct acpi_gpe_block_info *gpe_block,
492 void *context);
493 478
494/* Information about each particular fixed event */ 479/* Information about each particular fixed event */
495 480
@@ -584,7 +569,7 @@ struct acpi_pscope_state {
584}; 569};
585 570
586/* 571/*
587 * Thread state - one per thread across multiple walk states. Multiple walk 572 * Thread state - one per thread across multiple walk states. Multiple walk
588 * states are created when there are nested control methods executing. 573 * states are created when there are nested control methods executing.
589 */ 574 */
590struct acpi_thread_state { 575struct acpi_thread_state {
@@ -609,22 +594,13 @@ acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state,
609 594
610typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state); 595typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
611 596
612/* Global handlers for AML Notifies */
613
614struct acpi_global_notify_handler {
615 acpi_notify_handler handler;
616 void *context;
617};
618
619/* 597/*
620 * Notify info - used to pass info to the deferred notify 598 * Notify info - used to pass info to the deferred notify
621 * handler/dispatcher. 599 * handler/dispatcher.
622 */ 600 */
623struct acpi_notify_info { 601struct acpi_notify_info {
624 ACPI_STATE_COMMON u8 handler_list_id; 602 ACPI_STATE_COMMON struct acpi_namespace_node *node;
625 struct acpi_namespace_node *node; 603 union acpi_operand_object *handler_obj;
626 union acpi_operand_object *handler_list_head;
627 struct acpi_global_notify_handler *global;
628}; 604};
629 605
630/* Generic state is union of structs above */ 606/* Generic state is union of structs above */
@@ -647,16 +623,7 @@ union acpi_generic_state {
647 * 623 *
648 ****************************************************************************/ 624 ****************************************************************************/
649 625
650typedef acpi_status(*acpi_execute_op) (struct acpi_walk_state * walk_state); 626typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state);
651
652/* Address Range info block */
653
654struct acpi_address_range {
655 struct acpi_address_range *next;
656 struct acpi_namespace_node *region_node;
657 acpi_physical_address start_address;
658 acpi_physical_address end_address;
659};
660 627
661/***************************************************************************** 628/*****************************************************************************
662 * 629 *
@@ -709,18 +676,15 @@ union acpi_parse_value {
709 u8 disasm_opcode; /* Subtype used for disassembly */\ 676 u8 disasm_opcode; /* Subtype used for disassembly */\
710 char aml_op_name[16]) /* Op name (debug only) */ 677 char aml_op_name[16]) /* Op name (debug only) */
711 678
712/* Flags for disasm_flags field above */ 679#define ACPI_DASM_BUFFER 0x00
713 680#define ACPI_DASM_RESOURCE 0x01
714#define ACPI_DASM_BUFFER 0x00 /* Buffer is a simple data buffer */ 681#define ACPI_DASM_STRING 0x02
715#define ACPI_DASM_RESOURCE 0x01 /* Buffer is a Resource Descriptor */ 682#define ACPI_DASM_UNICODE 0x03
716#define ACPI_DASM_STRING 0x02 /* Buffer is a ASCII string */ 683#define ACPI_DASM_EISAID 0x04
717#define ACPI_DASM_UNICODE 0x03 /* Buffer is a Unicode string */ 684#define ACPI_DASM_MATCHOP 0x05
718#define ACPI_DASM_PLD_METHOD 0x04 /* Buffer is a _PLD method bit-packed buffer */ 685#define ACPI_DASM_LNOT_PREFIX 0x06
719#define ACPI_DASM_EISAID 0x05 /* Integer is an EISAID */ 686#define ACPI_DASM_LNOT_SUFFIX 0x07
720#define ACPI_DASM_MATCHOP 0x06 /* Parent opcode is a Match() operator */ 687#define ACPI_DASM_IGNORE 0x08
721#define ACPI_DASM_LNOT_PREFIX 0x07 /* Start of a Lnot_equal (etc.) pair of opcodes */
722#define ACPI_DASM_LNOT_SUFFIX 0x08 /* End of a Lnot_equal (etc.) pair of opcodes */
723#define ACPI_DASM_IGNORE 0x09 /* Not used at this time */
724 688
725/* 689/*
726 * Generic operation (for example: If, While, Store) 690 * Generic operation (for example: If, While, Store)
@@ -739,7 +703,7 @@ struct acpi_parse_obj_named {
739 u32 name; /* 4-byte name or zero if no name */ 703 u32 name; /* 4-byte name or zero if no name */
740}; 704};
741 705
742/* This version is used by the iASL compiler only */ 706/* This version is used by the i_aSL compiler only */
743 707
744#define ACPI_MAX_PARSEOP_NAME 20 708#define ACPI_MAX_PARSEOP_NAME 20
745 709
@@ -808,7 +772,6 @@ struct acpi_parse_state {
808#define ACPI_PARSEOP_IGNORE 0x01 772#define ACPI_PARSEOP_IGNORE 0x01
809#define ACPI_PARSEOP_PARAMLIST 0x02 773#define ACPI_PARSEOP_PARAMLIST 0x02
810#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 774#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
811#define ACPI_PARSEOP_PREDEF_CHECKED 0x08
812#define ACPI_PARSEOP_SPECIAL 0x10 775#define ACPI_PARSEOP_SPECIAL 0x10
813 776
814/***************************************************************************** 777/*****************************************************************************
@@ -937,7 +900,6 @@ struct acpi_bit_register_info {
937#define ACPI_OSI_WIN_VISTA_SP1 0x09 900#define ACPI_OSI_WIN_VISTA_SP1 0x09
938#define ACPI_OSI_WIN_VISTA_SP2 0x0A 901#define ACPI_OSI_WIN_VISTA_SP2 0x0A
939#define ACPI_OSI_WIN_7 0x0B 902#define ACPI_OSI_WIN_7 0x0B
940#define ACPI_OSI_WIN_8 0x0C
941 903
942#define ACPI_ALWAYS_ILLEGAL 0x00 904#define ACPI_ALWAYS_ILLEGAL 0x00
943 905
@@ -989,7 +951,7 @@ struct acpi_port_info {
989#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 951#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38
990#define ACPI_RESOURCE_NAME_IO 0x40 952#define ACPI_RESOURCE_NAME_IO 0x40
991#define ACPI_RESOURCE_NAME_FIXED_IO 0x48 953#define ACPI_RESOURCE_NAME_FIXED_IO 0x48
992#define ACPI_RESOURCE_NAME_FIXED_DMA 0x50 954#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50
993#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 955#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58
994#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 956#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60
995#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 957#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68
@@ -1011,9 +973,7 @@ struct acpi_port_info {
1011#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 973#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89
1012#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A 974#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A
1013#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B 975#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B
1014#define ACPI_RESOURCE_NAME_GPIO 0x8C 976#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B
1015#define ACPI_RESOURCE_NAME_SERIAL_BUS 0x8E
1016#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8E
1017 977
1018/***************************************************************************** 978/*****************************************************************************
1019 * 979 *
@@ -1030,10 +990,8 @@ struct acpi_port_info {
1030 ****************************************************************************/ 990 ****************************************************************************/
1031 991
1032struct acpi_db_method_info { 992struct acpi_db_method_info {
1033 acpi_handle method;
1034 acpi_handle main_thread_gate; 993 acpi_handle main_thread_gate;
1035 acpi_handle thread_complete_gate; 994 acpi_handle thread_complete_gate;
1036 acpi_handle info_gate;
1037 acpi_thread_id *threads; 995 acpi_thread_id *threads;
1038 u32 num_threads; 996 u32 num_threads;
1039 u32 num_created; 997 u32 num_created;
@@ -1044,7 +1002,6 @@ struct acpi_db_method_info {
1044 u32 num_loops; 1002 u32 num_loops;
1045 char pathname[128]; 1003 char pathname[128];
1046 char **args; 1004 char **args;
1047 acpi_object_type *types;
1048 1005
1049 /* 1006 /*
1050 * Arguments to be passed to method for the command 1007 * Arguments to be passed to method for the command
@@ -1101,18 +1058,4 @@ struct acpi_debug_mem_block {
1101#define ACPI_MEM_LIST_MAX 1 1058#define ACPI_MEM_LIST_MAX 1
1102#define ACPI_NUM_MEM_LISTS 2 1059#define ACPI_NUM_MEM_LISTS 2
1103 1060
1104/*****************************************************************************
1105 *
1106 * Info/help support
1107 *
1108 ****************************************************************************/
1109
1110struct ah_predefined_name {
1111 char *name;
1112 char *description;
1113#ifndef ACPI_ASL_COMPILER
1114 char *action;
1115#endif
1116};
1117
1118#endif /* __ACLOCAL_H__ */ 1061#endif /* __ACLOCAL_H__ */
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 5efad99f216..b7491ee1fba 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -62,7 +62,7 @@
62 * printf() format helpers 62 * printf() format helpers
63 */ 63 */
64 64
65/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */ 65/* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */
66 66
67#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i) 67#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i)
68 68
@@ -84,29 +84,29 @@
84 84
85/* These macros reverse the bytes during the move, converting little-endian to big endian */ 85/* These macros reverse the bytes during the move, converting little-endian to big endian */
86 86
87 /* Big Endian <== Little Endian */ 87 /* Big Endian <== Little Endian */
88 /* Hi...Lo Lo...Hi */ 88 /* Hi...Lo Lo...Hi */
89/* 16-bit source, 16/32/64 destination */ 89/* 16-bit source, 16/32/64 destination */
90 90
91#define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\ 91#define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\
92 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];} 92 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];}
93 93
94#define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d))=0;\ 94#define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d))=0;\
95 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ 95 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
96 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} 96 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
97 97
98#define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\ 98#define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\
99 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\ 99 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
100 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];} 100 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
101 101
102/* 32-bit source, 16/32/64 destination */ 102/* 32-bit source, 16/32/64 destination */
103 103
104#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ 104#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
105 105
106#define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ 106#define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\
107 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ 107 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\
108 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ 108 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
109 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} 109 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
110 110
111#define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\ 111#define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\
112 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\ 112 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
@@ -196,12 +196,24 @@
196#endif 196#endif
197#endif 197#endif
198 198
199/* Macros based on machine integer width */
200
201#if ACPI_MACHINE_WIDTH == 32
202#define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_32_TO_16(d, s)
203
204#elif ACPI_MACHINE_WIDTH == 64
205#define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_64_TO_16(d, s)
206
207#else
208#error unknown ACPI_MACHINE_WIDTH
209#endif
210
199/* 211/*
200 * Fast power-of-two math macros for non-optimized compilers 212 * Fast power-of-two math macros for non-optimized compilers
201 */ 213 */
202#define _ACPI_DIV(value, power_of2) ((u32) ((value) >> (power_of2))) 214#define _ACPI_DIV(value, power_of2) ((u32) ((value) >> (power_of2)))
203#define _ACPI_MUL(value, power_of2) ((u32) ((value) << (power_of2))) 215#define _ACPI_MUL(value, power_of2) ((u32) ((value) << (power_of2)))
204#define _ACPI_MOD(value, divisor) ((u32) ((value) & ((divisor) -1))) 216#define _ACPI_MOD(value, divisor) ((u32) ((value) & ((divisor) -1)))
205 217
206#define ACPI_DIV_2(a) _ACPI_DIV(a, 1) 218#define ACPI_DIV_2(a) _ACPI_DIV(a, 1)
207#define ACPI_MUL_2(a) _ACPI_MUL(a, 1) 219#define ACPI_MUL_2(a) _ACPI_MUL(a, 1)
@@ -226,12 +238,12 @@
226/* 238/*
227 * Rounding macros (Power of two boundaries only) 239 * Rounding macros (Power of two boundaries only)
228 */ 240 */
229#define ACPI_ROUND_DOWN(value, boundary) (((acpi_size)(value)) & \ 241#define ACPI_ROUND_DOWN(value, boundary) (((acpi_size)(value)) & \
230 (~(((acpi_size) boundary)-1))) 242 (~(((acpi_size) boundary)-1)))
231 243
232#define ACPI_ROUND_UP(value, boundary) ((((acpi_size)(value)) + \ 244#define ACPI_ROUND_UP(value, boundary) ((((acpi_size)(value)) + \
233 (((acpi_size) boundary)-1)) & \ 245 (((acpi_size) boundary)-1)) & \
234 (~(((acpi_size) boundary)-1))) 246 (~(((acpi_size) boundary)-1)))
235 247
236/* Note: sizeof(acpi_size) evaluates to either 4 or 8 (32- vs 64-bit mode) */ 248/* Note: sizeof(acpi_size) evaluates to either 4 or 8 (32- vs 64-bit mode) */
237 249
@@ -252,7 +264,7 @@
252 264
253#define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary)) 265#define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary))
254 266
255#define ACPI_IS_MISALIGNED(value) (((acpi_size) value) & (sizeof(acpi_size)-1)) 267#define ACPI_IS_MISALIGNED(value) (((acpi_size) value) & (sizeof(acpi_size)-1))
256 268
257/* 269/*
258 * Bitmask creation 270 * Bitmask creation
@@ -265,37 +277,14 @@
265 277
266/* Bitfields within ACPI registers */ 278/* Bitfields within ACPI registers */
267 279
268#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) \ 280#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask)
269 ((val << pos) & mask) 281#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
270
271#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) \
272 reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
273 282
274#define ACPI_INSERT_BITS(target, mask, source) \ 283#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask))
275 target = ((target & (~(mask))) | (source & mask))
276
277/* Generic bitfield macros and masks */
278
279#define ACPI_GET_BITS(source_ptr, position, mask) \
280 ((*source_ptr >> position) & mask)
281
282#define ACPI_SET_BITS(target_ptr, position, mask, value) \
283 (*target_ptr |= ((value & mask) << position))
284
285#define ACPI_1BIT_MASK 0x00000001
286#define ACPI_2BIT_MASK 0x00000003
287#define ACPI_3BIT_MASK 0x00000007
288#define ACPI_4BIT_MASK 0x0000000F
289#define ACPI_5BIT_MASK 0x0000001F
290#define ACPI_6BIT_MASK 0x0000003F
291#define ACPI_7BIT_MASK 0x0000007F
292#define ACPI_8BIT_MASK 0x000000FF
293#define ACPI_16BIT_MASK 0x0000FFFF
294#define ACPI_24BIT_MASK 0x00FFFFFF
295 284
296/* 285/*
297 * An object of type struct acpi_namespace_node can appear in some contexts 286 * A struct acpi_namespace_node can appear in some contexts
298 * where a pointer to an object of type union acpi_operand_object can also 287 * where a pointer to a union acpi_operand_object can also
299 * appear. This macro is used to distinguish them. 288 * appear. This macro is used to distinguish them.
300 * 289 *
301 * The "Descriptor" field is the first field in both structures. 290 * The "Descriptor" field is the first field in both structures.
@@ -343,6 +332,7 @@
343 * Ascii error messages can be configured out 332 * Ascii error messages can be configured out
344 */ 333 */
345#ifndef ACPI_NO_ERROR_MESSAGES 334#ifndef ACPI_NO_ERROR_MESSAGES
335
346/* 336/*
347 * Error reporting. Callers module and line number are inserted by AE_INFO, 337 * Error reporting. Callers module and line number are inserted by AE_INFO,
348 * the plist contains a set of parens to allow variable-length lists. 338 * the plist contains a set of parens to allow variable-length lists.
@@ -362,15 +352,18 @@
362#define ACPI_WARN_PREDEFINED(plist) 352#define ACPI_WARN_PREDEFINED(plist)
363#define ACPI_INFO_PREDEFINED(plist) 353#define ACPI_INFO_PREDEFINED(plist)
364 354
365#endif /* ACPI_NO_ERROR_MESSAGES */ 355#endif /* ACPI_NO_ERROR_MESSAGES */
366 356
367/* 357/*
368 * Debug macros that are conditionally compiled 358 * Debug macros that are conditionally compiled
369 */ 359 */
370#ifdef ACPI_DEBUG_OUTPUT 360#ifdef ACPI_DEBUG_OUTPUT
361
371/* 362/*
372 * Function entry tracing 363 * Function entry tracing
373 */ 364 */
365#ifdef CONFIG_ACPI_DEBUG_FUNC_TRACE
366
374#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 367#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
375 acpi_ut_trace(ACPI_DEBUG_PARAMETERS) 368 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
376#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \ 369#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \
@@ -448,19 +441,45 @@
448 441
449#endif /* ACPI_SIMPLE_RETURN_MACROS */ 442#endif /* ACPI_SIMPLE_RETURN_MACROS */
450 443
444#else /* !CONFIG_ACPI_DEBUG_FUNC_TRACE */
445
446#define ACPI_FUNCTION_TRACE(a)
447#define ACPI_FUNCTION_TRACE_PTR(a,b)
448#define ACPI_FUNCTION_TRACE_U32(a,b)
449#define ACPI_FUNCTION_TRACE_STR(a,b)
450#define ACPI_FUNCTION_EXIT
451#define ACPI_FUNCTION_STATUS_EXIT(s)
452#define ACPI_FUNCTION_VALUE_EXIT(s)
453#define ACPI_FUNCTION_TRACE(a)
454#define ACPI_FUNCTION_ENTRY()
455
456#define return_VOID return
457#define return_ACPI_STATUS(s) return(s)
458#define return_VALUE(s) return(s)
459#define return_UINT8(s) return(s)
460#define return_UINT32(s) return(s)
461#define return_PTR(s) return(s)
462
463#endif /* CONFIG_ACPI_DEBUG_FUNC_TRACE */
464
451/* Conditional execution */ 465/* Conditional execution */
452 466
453#define ACPI_DEBUG_EXEC(a) a 467#define ACPI_DEBUG_EXEC(a) a
468#define ACPI_NORMAL_EXEC(a)
469
470#define ACPI_DEBUG_DEFINE(a) a;
454#define ACPI_DEBUG_ONLY_MEMBERS(a) a; 471#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
455#define _VERBOSE_STRUCTURES 472#define _VERBOSE_STRUCTURES
456 473
457/* Various object display routines for debug */ 474/* Stack and buffer dumping */
458 475
459#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0) 476#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0)
460#define ACPI_DUMP_OPERANDS(a, b ,c) acpi_ex_dump_operands(a, b, c) 477#define ACPI_DUMP_OPERANDS(a, b, c) acpi_ex_dump_operands(a, b, c)
478
461#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b) 479#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b)
462#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d) 480#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
463#define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) 481#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a)
482#define ACPI_DUMP_BUFFER(a, b) acpi_ut_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
464 483
465#else 484#else
466/* 485/*
@@ -468,23 +487,25 @@
468 * leaving no executable debug code! 487 * leaving no executable debug code!
469 */ 488 */
470#define ACPI_DEBUG_EXEC(a) 489#define ACPI_DEBUG_EXEC(a)
471#define ACPI_DEBUG_ONLY_MEMBERS(a) 490#define ACPI_NORMAL_EXEC(a) a;
472#define ACPI_FUNCTION_TRACE(a) 491
473#define ACPI_FUNCTION_TRACE_PTR(a, b) 492#define ACPI_DEBUG_DEFINE(a) do { } while(0)
474#define ACPI_FUNCTION_TRACE_U32(a, b) 493#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0)
475#define ACPI_FUNCTION_TRACE_STR(a, b) 494#define ACPI_FUNCTION_TRACE(a) do { } while(0)
476#define ACPI_FUNCTION_EXIT 495#define ACPI_FUNCTION_TRACE_PTR(a, b) do { } while(0)
477#define ACPI_FUNCTION_STATUS_EXIT(s) 496#define ACPI_FUNCTION_TRACE_U32(a, b) do { } while(0)
478#define ACPI_FUNCTION_VALUE_EXIT(s) 497#define ACPI_FUNCTION_TRACE_STR(a, b) do { } while(0)
479#define ACPI_FUNCTION_ENTRY() 498#define ACPI_FUNCTION_EXIT do { } while(0)
480#define ACPI_DUMP_STACK_ENTRY(a) 499#define ACPI_FUNCTION_STATUS_EXIT(s) do { } while(0)
481#define ACPI_DUMP_OPERANDS(a, b, c) 500#define ACPI_FUNCTION_VALUE_EXIT(s) do { } while(0)
482#define ACPI_DUMP_ENTRY(a, b) 501#define ACPI_FUNCTION_ENTRY() do { } while(0)
483#define ACPI_DUMP_TABLES(a, b) 502#define ACPI_DUMP_STACK_ENTRY(a) do { } while(0)
484#define ACPI_DUMP_PATHNAME(a, b, c, d) 503#define ACPI_DUMP_OPERANDS(a, b, c) do { } while(0)
485#define ACPI_DUMP_BUFFER(a, b) 504#define ACPI_DUMP_ENTRY(a, b) do { } while(0)
486#define ACPI_DEBUG_PRINT(pl) 505#define ACPI_DUMP_TABLES(a, b) do { } while(0)
487#define ACPI_DEBUG_PRINT_RAW(pl) 506#define ACPI_DUMP_PATHNAME(a, b, c, d) do { } while(0)
507#define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0)
508#define ACPI_DUMP_BUFFER(a, b) do { } while(0)
488 509
489#define return_VOID return 510#define return_VOID return
490#define return_ACPI_STATUS(s) return(s) 511#define return_ACPI_STATUS(s) return(s)
@@ -495,12 +516,6 @@
495 516
496#endif /* ACPI_DEBUG_OUTPUT */ 517#endif /* ACPI_DEBUG_OUTPUT */
497 518
498#if (!ACPI_REDUCED_HARDWARE)
499#define ACPI_HW_OPTIONAL_FUNCTION(addr) addr
500#else
501#define ACPI_HW_OPTIONAL_FUNCTION(addr) NULL
502#endif
503
504/* 519/*
505 * Some code only gets executed when the debugger is built in. 520 * Some code only gets executed when the debugger is built in.
506 * Note that this is entirely independent of whether the 521 * Note that this is entirely independent of whether the
@@ -512,6 +527,18 @@
512#define ACPI_DEBUGGER_EXEC(a) 527#define ACPI_DEBUGGER_EXEC(a)
513#endif 528#endif
514 529
530#ifdef ACPI_DEBUG_OUTPUT
531/*
532 * 1) Set name to blanks
533 * 2) Copy the object name
534 */
535#define ACPI_ADD_OBJECT_NAME(a,b) ACPI_MEMSET (a->common.name, ' ', sizeof (a->common.name));\
536 ACPI_STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name))
537#else
538
539#define ACPI_ADD_OBJECT_NAME(a,b)
540#endif
541
515/* 542/*
516 * Memory allocation tracking (DEBUG ONLY) 543 * Memory allocation tracking (DEBUG ONLY)
517 */ 544 */
@@ -522,13 +549,13 @@
522/* Memory allocation */ 549/* Memory allocation */
523 550
524#ifndef ACPI_ALLOCATE 551#ifndef ACPI_ALLOCATE
525#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size) (a), ACPI_MEM_PARAMETERS) 552#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a), ACPI_MEM_PARAMETERS)
526#endif 553#endif
527#ifndef ACPI_ALLOCATE_ZEROED 554#ifndef ACPI_ALLOCATE_ZEROED
528#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size) (a), ACPI_MEM_PARAMETERS) 555#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), ACPI_MEM_PARAMETERS)
529#endif 556#endif
530#ifndef ACPI_FREE 557#ifndef ACPI_FREE
531#define ACPI_FREE(a) acpi_os_free(a) 558#define ACPI_FREE(a) acpio_os_free(a)
532#endif 559#endif
533#define ACPI_MEM_TRACKING(a) 560#define ACPI_MEM_TRACKING(a)
534 561
@@ -536,25 +563,16 @@
536 563
537/* Memory allocation */ 564/* Memory allocation */
538 565
539#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size) (a), ACPI_MEM_PARAMETERS) 566#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS)
540#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size) (a), ACPI_MEM_PARAMETERS) 567#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS)
541#define ACPI_FREE(a) acpi_ut_free_and_track(a, ACPI_MEM_PARAMETERS) 568#define ACPI_FREE(a) acpi_ut_free_and_track(a, ACPI_MEM_PARAMETERS)
542#define ACPI_MEM_TRACKING(a) a 569#define ACPI_MEM_TRACKING(a) a
543 570
544#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 571#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
545 572
546/* 573/* Preemption point */
547 * Macros used for ACPICA utilities only 574#ifndef ACPI_PREEMPTION_POINT
548 */ 575#define ACPI_PREEMPTION_POINT() /* no preemption */
549 576#endif
550/* Generate a UUID */
551
552#define ACPI_INIT_UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
553 (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \
554 (b) & 0xFF, ((b) >> 8) & 0xFF, \
555 (c) & 0xFF, ((c) >> 8) & 0xFF, \
556 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)
557
558#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7'))
559 577
560#endif /* ACMACROS_H */ 578#endif /* ACMACROS_H */
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 9b19d4b8642..79a598c67fe 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -283,9 +283,8 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
283 union acpi_operand_object **return_object_ptr); 283 union acpi_operand_object **return_object_ptr);
284 284
285acpi_status 285acpi_status
286acpi_ns_wrap_with_package(struct acpi_predefined_data *data, 286acpi_ns_repair_package_list(struct acpi_predefined_data *data,
287 union acpi_operand_object *original_object, 287 union acpi_operand_object **obj_desc_ptr);
288 union acpi_operand_object **obj_desc_ptr);
289 288
290acpi_status 289acpi_status
291acpi_ns_repair_null_element(struct acpi_predefined_data *data, 290acpi_ns_repair_null_element(struct acpi_predefined_data *data,
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index 24eb9eac951..1055769f2f0 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Name: acobject.h - Definition of union acpi_operand_object (Internal object only) 4 * Name: acobject.h - Definition of union acpi_operand_object (Internal object only)
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -112,8 +113,8 @@ struct acpi_object_integer {
112}; 113};
113 114
114/* 115/*
115 * Note: The String and Buffer object must be identical through the 116 * Note: The String and Buffer object must be identical through the Pointer
116 * pointer and length elements. There is code that depends on this. 117 * and length elements. There is code that depends on this.
117 * 118 *
118 * Fields common to both Strings and Buffers 119 * Fields common to both Strings and Buffers
119 */ 120 */
@@ -178,7 +179,7 @@ struct acpi_object_method {
178 union acpi_operand_object *mutex; 179 union acpi_operand_object *mutex;
179 u8 *aml_start; 180 u8 *aml_start;
180 union { 181 union {
181 acpi_internal_method implementation; 182 ACPI_INTERNAL_METHOD implementation;
182 union acpi_operand_object *handler; 183 union acpi_operand_object *handler;
183 } dispatch; 184 } dispatch;
184 185
@@ -197,7 +198,7 @@ struct acpi_object_method {
197 198
198/****************************************************************************** 199/******************************************************************************
199 * 200 *
200 * Objects that can be notified. All share a common notify_info area. 201 * Objects that can be notified. All share a common notify_info area.
201 * 202 *
202 *****************************************************************************/ 203 *****************************************************************************/
203 204
@@ -205,7 +206,8 @@ struct acpi_object_method {
205 * Common fields for objects that support ASL notifications 206 * Common fields for objects that support ASL notifications
206 */ 207 */
207#define ACPI_COMMON_NOTIFY_INFO \ 208#define ACPI_COMMON_NOTIFY_INFO \
208 union acpi_operand_object *notify_list[2]; /* Handlers for system/device notifies */\ 209 union acpi_operand_object *system_notify; /* Handler for system notifies */\
210 union acpi_operand_object *device_notify; /* Handler for driver notifies */\
209 union acpi_operand_object *handler; /* Handler for Address space */ 211 union acpi_operand_object *handler; /* Handler for Address space */
210 212
211struct acpi_object_notify_common { /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ 213struct acpi_object_notify_common { /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
@@ -234,7 +236,7 @@ ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
234 236
235/****************************************************************************** 237/******************************************************************************
236 * 238 *
237 * Fields. All share a common header/info field. 239 * Fields. All share a common header/info field.
238 * 240 *
239 *****************************************************************************/ 241 *****************************************************************************/
240 242
@@ -252,7 +254,6 @@ ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
252 u32 base_byte_offset; /* Byte offset within containing object */\ 254 u32 base_byte_offset; /* Byte offset within containing object */\
253 u32 value; /* Value to store into the Bank or Index register */\ 255 u32 value; /* Value to store into the Bank or Index register */\
254 u8 start_field_bit_offset;/* Bit offset within first field datum (0-63) */\ 256 u8 start_field_bit_offset;/* Bit offset within first field datum (0-63) */\
255 u8 access_length; /* For serial regions/fields */
256 257
257 258
258struct acpi_object_field_common { /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ 259struct acpi_object_field_common { /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
@@ -260,9 +261,7 @@ struct acpi_object_field_common { /* COMMON FIELD (for BUFFER, REGION, BANK, and
260}; 261};
261 262
262struct acpi_object_region_field { 263struct acpi_object_region_field {
263 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO u16 resource_length; 264 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */
264 union acpi_operand_object *region_obj; /* Containing op_region object */
265 u8 *resource_buffer; /* resource_template for serial regions/fields */
266}; 265};
267 266
268struct acpi_object_bank_field { 267struct acpi_object_bank_field {
@@ -294,10 +293,10 @@ struct acpi_object_buffer_field {
294 293
295struct acpi_object_notify_handler { 294struct acpi_object_notify_handler {
296 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Parent device */ 295 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Parent device */
297 u32 handler_type; /* Type: Device/System/Both */ 296 u32 handler_type;
298 acpi_notify_handler handler; /* Handler address */ 297 acpi_notify_handler handler;
299 void *context; 298 void *context;
300 union acpi_operand_object *next[2]; /* Device and System handler lists */ 299 struct acpi_object_notify_handler *next;
301}; 300};
302 301
303struct acpi_object_addr_handler { 302struct acpi_object_addr_handler {
@@ -359,7 +358,6 @@ typedef enum {
359 */ 358 */
360struct acpi_object_extra { 359struct acpi_object_extra {
361 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */ 360 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */
362 struct acpi_namespace_node *scope_node;
363 void *region_context; /* Region-specific data */ 361 void *region_context; /* Region-specific data */
364 u8 *aml_start; 362 u8 *aml_start;
365 u32 aml_length; 363 u32 aml_length;
@@ -380,7 +378,7 @@ struct acpi_object_cache_list {
380 378
381/****************************************************************************** 379/******************************************************************************
382 * 380 *
383 * union acpi_operand_object descriptor - a giant union of all of the above 381 * union acpi_operand_object Descriptor - a giant union of all of the above
384 * 382 *
385 *****************************************************************************/ 383 *****************************************************************************/
386 384
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index d786a5128b7..bb2ccfad737 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,7 +54,7 @@
54#define _UNK 0x6B 54#define _UNK 0x6B
55 55
56/* 56/*
57 * Reserved ASCII characters. Do not use any of these for 57 * Reserved ASCII characters. Do not use any of these for
58 * internal opcodes, since they are used to differentiate 58 * internal opcodes, since they are used to differentiate
59 * name strings from AML opcodes 59 * name strings from AML opcodes
60 */ 60 */
@@ -63,7 +63,7 @@
63#define _PFX 0x6D 63#define _PFX 0x6D
64 64
65/* 65/*
66 * All AML opcodes and the parse-time arguments for each. Used by the AML 66 * All AML opcodes and the parse-time arguments for each. Used by the AML
67 * parser Each list is compressed into a 32-bit number and stored in the 67 * parser Each list is compressed into a 32-bit number and stored in the
68 * master opcode table (in psopcode.c). 68 * master opcode table (in psopcode.c).
69 */ 69 */
@@ -93,7 +93,6 @@
93#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) 93#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
94#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) 94#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
95#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) 95#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME)
96#define ARGP_CONNECTFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
97#define ARGP_CONTINUE_OP ARG_NONE 96#define ARGP_CONTINUE_OP ARG_NONE
98#define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME) 97#define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME)
99#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) 98#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
@@ -165,7 +164,6 @@
165#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) 164#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG)
166#define ARGP_REVISION_OP ARG_NONE 165#define ARGP_REVISION_OP ARG_NONE
167#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) 166#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST)
168#define ARGP_SERIALFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
169#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) 167#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
170#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) 168#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
171#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) 169#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME)
@@ -193,7 +191,7 @@
193#define ARGP_ZERO_OP ARG_NONE 191#define ARGP_ZERO_OP ARG_NONE
194 192
195/* 193/*
196 * All AML opcodes and the runtime arguments for each. Used by the AML 194 * All AML opcodes and the runtime arguments for each. Used by the AML
197 * interpreter Each list is compressed into a 32-bit number and stored 195 * interpreter Each list is compressed into a 32-bit number and stored
198 * in the master opcode table (in psopcode.c). 196 * in the master opcode table (in psopcode.c).
199 * 197 *
@@ -225,7 +223,6 @@
225#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) 223#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF)
226#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) 224#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF)
227#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) 225#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
228#define ARGI_CONNECTFIELD_OP ARGI_INVALID_OPCODE
229#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE 226#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE
230#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET) 227#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET)
231#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) 228#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
@@ -297,7 +294,6 @@
297#define ARGI_RETURN_OP ARGI_INVALID_OPCODE 294#define ARGI_RETURN_OP ARGI_INVALID_OPCODE
298#define ARGI_REVISION_OP ARG_NONE 295#define ARGI_REVISION_OP ARG_NONE
299#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE 296#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE
300#define ARGI_SERIALFIELD_OP ARGI_INVALID_OPCODE
301#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) 297#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
302#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) 298#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
303#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) 299#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT)
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
index eefcf47a61a..5ea1e06afa2 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -150,7 +150,8 @@ u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state);
150 150
151void 151void
152acpi_ps_pop_scope(struct acpi_parse_state *parser_state, 152acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
153 union acpi_parse_object **op, u32 *arg_list, u32 *arg_count); 153 union acpi_parse_object **op,
154 u32 * arg_list, u32 * arg_count);
154 155
155acpi_status 156acpi_status
156acpi_ps_push_scope(struct acpi_parse_state *parser_state, 157acpi_ps_push_scope(struct acpi_parse_state *parser_state,
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 9dfa1c83bd4..c445cca490e 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -94,14 +94,6 @@
94 * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length 94 * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length
95 * (Used for _ART, _FPS) 95 * (Used for _ART, _FPS)
96 * 96 *
97 * ACPI_PTYPE2_FIX_VAR: Each subpackage consists of some fixed-length elements
98 * followed by an optional element
99 * object type
100 * count
101 * object type
102 * count = 0 (optional)
103 * (Used for _DLM)
104 *
105 *****************************************************************************/ 97 *****************************************************************************/
106 98
107enum acpi_return_package_types { 99enum acpi_return_package_types {
@@ -113,8 +105,7 @@ enum acpi_return_package_types {
113 ACPI_PTYPE2_PKG_COUNT = 6, 105 ACPI_PTYPE2_PKG_COUNT = 6,
114 ACPI_PTYPE2_FIXED = 7, 106 ACPI_PTYPE2_FIXED = 7,
115 ACPI_PTYPE2_MIN = 8, 107 ACPI_PTYPE2_MIN = 8,
116 ACPI_PTYPE2_REV_FIXED = 9, 108 ACPI_PTYPE2_REV_FIXED = 9
117 ACPI_PTYPE2_FIX_VAR = 10
118}; 109};
119 110
120#ifdef ACPI_CREATE_PREDEFINED_TABLE 111#ifdef ACPI_CREATE_PREDEFINED_TABLE
@@ -140,7 +131,7 @@ enum acpi_return_package_types {
140 * 131 *
141 * The main entries in the table each contain the following items: 132 * The main entries in the table each contain the following items:
142 * 133 *
143 * name - The ACPI reserved name 134 * Name - The ACPI reserved name
144 * param_count - Number of arguments to the method 135 * param_count - Number of arguments to the method
145 * expected_btypes - Allowed type(s) for the return value. 136 * expected_btypes - Allowed type(s) for the return value.
146 * 0 means that no return value is expected. 137 * 0 means that no return value is expected.
@@ -150,7 +141,8 @@ enum acpi_return_package_types {
150 * is saved here (rather than in a separate table) in order to minimize the 141 * is saved here (rather than in a separate table) in order to minimize the
151 * overall size of the stored data. 142 * overall size of the stored data.
152 */ 143 */
153static const union acpi_predefined_info predefined_names[] = { 144static const union acpi_predefined_info predefined_names[] =
145{
154 {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, 146 {{"_AC0", 0, ACPI_RTYPE_INTEGER}},
155 {{"_AC1", 0, ACPI_RTYPE_INTEGER}}, 147 {{"_AC1", 0, ACPI_RTYPE_INTEGER}},
156 {{"_AC2", 0, ACPI_RTYPE_INTEGER}}, 148 {{"_AC2", 0, ACPI_RTYPE_INTEGER}},
@@ -162,7 +154,6 @@ static const union acpi_predefined_info predefined_names[] = {
162 {{"_AC8", 0, ACPI_RTYPE_INTEGER}}, 154 {{"_AC8", 0, ACPI_RTYPE_INTEGER}},
163 {{"_AC9", 0, ACPI_RTYPE_INTEGER}}, 155 {{"_AC9", 0, ACPI_RTYPE_INTEGER}},
164 {{"_ADR", 0, ACPI_RTYPE_INTEGER}}, 156 {{"_ADR", 0, ACPI_RTYPE_INTEGER}},
165 {{"_AEI", 0, ACPI_RTYPE_BUFFER}},
166 {{"_AL0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ 157 {{"_AL0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
167 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, 158 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
168 159
@@ -238,13 +229,6 @@ static const union acpi_predefined_info predefined_names[] = {
238 {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */ 229 {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */
239 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0}, 0,0}}, 230 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0}, 0,0}},
240 231
241 {{"_CLS", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */
242 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0}, 0, 0}},
243
244 {{"_CPC", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Bufs) */
245 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER, 0, 0}, 0,
246 0}},
247
248 {{"_CRS", 0, ACPI_RTYPE_BUFFER}}, 232 {{"_CRS", 0, ACPI_RTYPE_BUFFER}},
249 {{"_CRT", 0, ACPI_RTYPE_INTEGER}}, 233 {{"_CRT", 0, ACPI_RTYPE_INTEGER}},
250 {{"_CSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n-1 Int) */ 234 {{"_CSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n-1 Int) */
@@ -253,21 +237,12 @@ static const union acpi_predefined_info predefined_names[] = {
253 {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */ 237 {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */
254 {{{ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,0}}, 238 {{{ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,0}},
255 239
256 {{"_CWS", 1, ACPI_RTYPE_INTEGER}},
257 {{"_DCK", 1, ACPI_RTYPE_INTEGER}}, 240 {{"_DCK", 1, ACPI_RTYPE_INTEGER}},
258 {{"_DCS", 0, ACPI_RTYPE_INTEGER}}, 241 {{"_DCS", 0, ACPI_RTYPE_INTEGER}},
259 {{"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}}, 242 {{"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}},
260 {{"_DDN", 0, ACPI_RTYPE_STRING}}, 243 {{"_DDN", 0, ACPI_RTYPE_STRING}},
261 {{"_DEP", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
262 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}},
263
264 {{"_DGS", 0, ACPI_RTYPE_INTEGER}}, 244 {{"_DGS", 0, ACPI_RTYPE_INTEGER}},
265 {{"_DIS", 0, 0}}, 245 {{"_DIS", 0, 0}},
266
267 {{"_DLM", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (1 Ref, 0/1 Optional Buf/Ref) */
268 {{{ACPI_PTYPE2_FIX_VAR, ACPI_RTYPE_REFERENCE, 1,
269 ACPI_RTYPE_REFERENCE | ACPI_RTYPE_BUFFER}, 0, 0}},
270
271 {{"_DMA", 0, ACPI_RTYPE_BUFFER}}, 246 {{"_DMA", 0, ACPI_RTYPE_BUFFER}},
272 {{"_DOD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ 247 {{"_DOD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */
273 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, 248 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}},
@@ -287,7 +262,6 @@ static const union acpi_predefined_info predefined_names[] = {
287 {{"_EJ3", 1, 0}}, 262 {{"_EJ3", 1, 0}},
288 {{"_EJ4", 1, 0}}, 263 {{"_EJ4", 1, 0}},
289 {{"_EJD", 0, ACPI_RTYPE_STRING}}, 264 {{"_EJD", 0, ACPI_RTYPE_STRING}},
290 {{"_EVT", 1, 0}},
291 {{"_FDE", 0, ACPI_RTYPE_BUFFER}}, 265 {{"_FDE", 0, ACPI_RTYPE_BUFFER}},
292 {{"_FDI", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int) */ 266 {{"_FDI", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int) */
293 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0}, 0,0}}, 267 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0}, 0,0}},
@@ -307,17 +281,14 @@ static const union acpi_predefined_info predefined_names[] = {
307 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0}, 0, 0}}, 281 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0}, 0, 0}},
308 282
309 {{"_GAI", 0, ACPI_RTYPE_INTEGER}}, 283 {{"_GAI", 0, ACPI_RTYPE_INTEGER}},
310 {{"_GCP", 0, ACPI_RTYPE_INTEGER}},
311 {{"_GHL", 0, ACPI_RTYPE_INTEGER}}, 284 {{"_GHL", 0, ACPI_RTYPE_INTEGER}},
312 {{"_GLK", 0, ACPI_RTYPE_INTEGER}}, 285 {{"_GLK", 0, ACPI_RTYPE_INTEGER}},
313 {{"_GPD", 0, ACPI_RTYPE_INTEGER}}, 286 {{"_GPD", 0, ACPI_RTYPE_INTEGER}},
314 {{"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */ 287 {{"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */
315 {{"_GRT", 0, ACPI_RTYPE_BUFFER}},
316 {{"_GSB", 0, ACPI_RTYPE_INTEGER}}, 288 {{"_GSB", 0, ACPI_RTYPE_INTEGER}},
317 {{"_GTF", 0, ACPI_RTYPE_BUFFER}}, 289 {{"_GTF", 0, ACPI_RTYPE_BUFFER}},
318 {{"_GTM", 0, ACPI_RTYPE_BUFFER}}, 290 {{"_GTM", 0, ACPI_RTYPE_BUFFER}},
319 {{"_GTS", 1, 0}}, 291 {{"_GTS", 1, 0}},
320 {{"_GWS", 1, ACPI_RTYPE_INTEGER}},
321 {{"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, 292 {{"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}},
322 {{"_HOT", 0, ACPI_RTYPE_INTEGER}}, 293 {{"_HOT", 0, ACPI_RTYPE_INTEGER}},
323 {{"_HPP", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ 294 {{"_HPP", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */
@@ -332,7 +303,6 @@ static const union acpi_predefined_info predefined_names[] = {
332 {{"_HPX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (var Ints) */ 303 {{"_HPX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (var Ints) */
333 {{{ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, 304 {{{ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0}, 0,0}},
334 305
335 {{"_HRV", 0, ACPI_RTYPE_INTEGER}},
336 {{"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ 306 {{"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */
337 {{"_INI", 0, 0}}, 307 {{"_INI", 0, 0}},
338 {{"_IRC", 0, 0}}, 308 {{"_IRC", 0, 0}},
@@ -391,9 +361,6 @@ static const union acpi_predefined_info predefined_names[] = {
391 {{"_PR3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ 361 {{"_PR3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
392 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}}, 362 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}},
393 363
394 {{"_PRE", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
395 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}},
396
397 {{"_PRL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ 364 {{"_PRL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
398 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}}, 365 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}},
399 366
@@ -424,7 +391,6 @@ static const union acpi_predefined_info predefined_names[] = {
424 {{"_PSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (5 Int) with count */ 391 {{"_PSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (5 Int) with count */
425 {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER,0,0}, 0,0}}, 392 {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER,0,0}, 0,0}},
426 393
427 {{"_PSE", 1, 0}},
428 {{"_PSL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ 394 {{"_PSL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
429 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, 395 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
430 396
@@ -491,7 +457,6 @@ static const union acpi_predefined_info predefined_names[] = {
491 {{"_SLI", 0, ACPI_RTYPE_BUFFER}}, 457 {{"_SLI", 0, ACPI_RTYPE_BUFFER}},
492 {{"_SPD", 1, ACPI_RTYPE_INTEGER}}, 458 {{"_SPD", 1, ACPI_RTYPE_INTEGER}},
493 {{"_SRS", 1, 0}}, 459 {{"_SRS", 1, 0}},
494 {{"_SRT", 1, ACPI_RTYPE_INTEGER}},
495 {{"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ 460 {{"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */
496 {{"_SST", 1, 0}}, 461 {{"_SST", 1, 0}},
497 {{"_STA", 0, ACPI_RTYPE_INTEGER}}, 462 {{"_STA", 0, ACPI_RTYPE_INTEGER}},
@@ -499,7 +464,6 @@ static const union acpi_predefined_info predefined_names[] = {
499 {{"_STP", 2, ACPI_RTYPE_INTEGER}}, 464 {{"_STP", 2, ACPI_RTYPE_INTEGER}},
500 {{"_STR", 0, ACPI_RTYPE_BUFFER}}, 465 {{"_STR", 0, ACPI_RTYPE_BUFFER}},
501 {{"_STV", 2, ACPI_RTYPE_INTEGER}}, 466 {{"_STV", 2, ACPI_RTYPE_INTEGER}},
502 {{"_SUB", 0, ACPI_RTYPE_STRING}},
503 {{"_SUN", 0, ACPI_RTYPE_INTEGER}}, 467 {{"_SUN", 0, ACPI_RTYPE_INTEGER}},
504 {{"_SWS", 0, ACPI_RTYPE_INTEGER}}, 468 {{"_SWS", 0, ACPI_RTYPE_INTEGER}},
505 {{"_TC1", 0, ACPI_RTYPE_INTEGER}}, 469 {{"_TC1", 0, ACPI_RTYPE_INTEGER}},
@@ -510,14 +474,14 @@ static const union acpi_predefined_info predefined_names[] = {
510 {{"_TMP", 0, ACPI_RTYPE_INTEGER}}, 474 {{"_TMP", 0, ACPI_RTYPE_INTEGER}},
511 {{"_TPC", 0, ACPI_RTYPE_INTEGER}}, 475 {{"_TPC", 0, ACPI_RTYPE_INTEGER}},
512 {{"_TPT", 1, 0}}, 476 {{"_TPT", 1, 0}},
513 {{"_TRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2 Ref/6 Int */ 477 {{"_TRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2_ref/6_int */
514 {{{ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 6, 0}}, 478 {{{ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 6, 0}},
515 479
516 {{"_TSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5 Int with count */ 480 {{"_TSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5_int with count */
517 {{{ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, 481 {{{ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0}, 0,0}},
518 482
519 {{"_TSP", 0, ACPI_RTYPE_INTEGER}}, 483 {{"_TSP", 0, ACPI_RTYPE_INTEGER}},
520 {{"_TSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5 Int */ 484 {{"_TSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5_int */
521 {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, 485 {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0}, 0,0}},
522 486
523 {{"_TST", 0, ACPI_RTYPE_INTEGER}}, 487 {{"_TST", 0, ACPI_RTYPE_INTEGER}},
@@ -537,8 +501,7 @@ static const union acpi_predefined_info predefined_names[] = {
537 501
538 /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ 502 /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */
539 503
540 {{"_WAK", 1, 504 {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}},
541 ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}},
542 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ 505 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */
543 506
544 /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */ 507 /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */
@@ -551,12 +514,11 @@ static const union acpi_predefined_info predefined_names[] = {
551}; 514};
552 515
553#if 0 516#if 0
554
555 /* This is an internally implemented control method, no need to check */ 517 /* This is an internally implemented control method, no need to check */
556{ { 518 {{"_OSI", 1, ACPI_RTYPE_INTEGER}},
557"_OSI", 1, ACPI_RTYPE_INTEGER}},
558 519
559 /* TBD: */ 520 /* TBD: */
521
560 _PRT - currently ignore reversed entries. attempt to fix here? 522 _PRT - currently ignore reversed entries. attempt to fix here?
561 think about possibly fixing package elements like _BIF, etc. 523 think about possibly fixing package elements like _BIF, etc.
562#endif 524#endif
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
index 0347d099349..f08b55b7f3a 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -73,40 +73,28 @@ typedef const struct acpi_rsconvert_info {
73 73
74/* Resource conversion opcodes */ 74/* Resource conversion opcodes */
75 75
76typedef enum { 76#define ACPI_RSC_INITGET 0
77 ACPI_RSC_INITGET = 0, 77#define ACPI_RSC_INITSET 1
78 ACPI_RSC_INITSET, 78#define ACPI_RSC_FLAGINIT 2
79 ACPI_RSC_FLAGINIT, 79#define ACPI_RSC_1BITFLAG 3
80 ACPI_RSC_1BITFLAG, 80#define ACPI_RSC_2BITFLAG 4
81 ACPI_RSC_2BITFLAG, 81#define ACPI_RSC_COUNT 5
82 ACPI_RSC_3BITFLAG, 82#define ACPI_RSC_COUNT16 6
83 ACPI_RSC_ADDRESS, 83#define ACPI_RSC_LENGTH 7
84 ACPI_RSC_BITMASK, 84#define ACPI_RSC_MOVE8 8
85 ACPI_RSC_BITMASK16, 85#define ACPI_RSC_MOVE16 9
86 ACPI_RSC_COUNT, 86#define ACPI_RSC_MOVE32 10
87 ACPI_RSC_COUNT16, 87#define ACPI_RSC_MOVE64 11
88 ACPI_RSC_COUNT_GPIO_PIN, 88#define ACPI_RSC_SET8 12
89 ACPI_RSC_COUNT_GPIO_RES, 89#define ACPI_RSC_DATA8 13
90 ACPI_RSC_COUNT_GPIO_VEN, 90#define ACPI_RSC_ADDRESS 14
91 ACPI_RSC_COUNT_SERIAL_RES, 91#define ACPI_RSC_SOURCE 15
92 ACPI_RSC_COUNT_SERIAL_VEN, 92#define ACPI_RSC_SOURCEX 16
93 ACPI_RSC_DATA8, 93#define ACPI_RSC_BITMASK 17
94 ACPI_RSC_EXIT_EQ, 94#define ACPI_RSC_BITMASK16 18
95 ACPI_RSC_EXIT_LE, 95#define ACPI_RSC_EXIT_NE 19
96 ACPI_RSC_EXIT_NE, 96#define ACPI_RSC_EXIT_LE 20
97 ACPI_RSC_LENGTH, 97#define ACPI_RSC_EXIT_EQ 21
98 ACPI_RSC_MOVE_GPIO_PIN,
99 ACPI_RSC_MOVE_GPIO_RES,
100 ACPI_RSC_MOVE_SERIAL_RES,
101 ACPI_RSC_MOVE_SERIAL_VEN,
102 ACPI_RSC_MOVE8,
103 ACPI_RSC_MOVE16,
104 ACPI_RSC_MOVE32,
105 ACPI_RSC_MOVE64,
106 ACPI_RSC_SET8,
107 ACPI_RSC_SOURCE,
108 ACPI_RSC_SOURCEX
109} ACPI_RSCONVERT_OPCODES;
110 98
111/* Resource Conversion sub-opcodes */ 99/* Resource Conversion sub-opcodes */
112 100
@@ -118,9 +106,6 @@ typedef enum {
118#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f) 106#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f)
119#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f) 107#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f)
120 108
121/*
122 * Individual entry for the resource dump tables
123 */
124typedef const struct acpi_rsdump_info { 109typedef const struct acpi_rsdump_info {
125 u8 opcode; 110 u8 opcode;
126 u8 offset; 111 u8 offset;
@@ -131,25 +116,20 @@ typedef const struct acpi_rsdump_info {
131 116
132/* Values for the Opcode field above */ 117/* Values for the Opcode field above */
133 118
134typedef enum { 119#define ACPI_RSD_TITLE 0
135 ACPI_RSD_TITLE = 0, 120#define ACPI_RSD_LITERAL 1
136 ACPI_RSD_1BITFLAG, 121#define ACPI_RSD_STRING 2
137 ACPI_RSD_2BITFLAG, 122#define ACPI_RSD_UINT8 3
138 ACPI_RSD_3BITFLAG, 123#define ACPI_RSD_UINT16 4
139 ACPI_RSD_ADDRESS, 124#define ACPI_RSD_UINT32 5
140 ACPI_RSD_DWORDLIST, 125#define ACPI_RSD_UINT64 6
141 ACPI_RSD_LITERAL, 126#define ACPI_RSD_1BITFLAG 7
142 ACPI_RSD_LONGLIST, 127#define ACPI_RSD_2BITFLAG 8
143 ACPI_RSD_SHORTLIST, 128#define ACPI_RSD_SHORTLIST 9
144 ACPI_RSD_SHORTLISTX, 129#define ACPI_RSD_LONGLIST 10
145 ACPI_RSD_SOURCE, 130#define ACPI_RSD_DWORDLIST 11
146 ACPI_RSD_STRING, 131#define ACPI_RSD_ADDRESS 12
147 ACPI_RSD_UINT8, 132#define ACPI_RSD_SOURCE 13
148 ACPI_RSD_UINT16,
149 ACPI_RSD_UINT32,
150 ACPI_RSD_UINT64,
151 ACPI_RSD_WORDLIST
152} ACPI_RSDUMP_OPCODES;
153 133
154/* restore default alignment */ 134/* restore default alignment */
155 135
@@ -158,18 +138,13 @@ typedef enum {
158/* Resource tables indexed by internal resource type */ 138/* Resource tables indexed by internal resource type */
159 139
160extern const u8 acpi_gbl_aml_resource_sizes[]; 140extern const u8 acpi_gbl_aml_resource_sizes[];
161extern const u8 acpi_gbl_aml_resource_serial_bus_sizes[];
162extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[]; 141extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
163 142
164/* Resource tables indexed by raw AML resource descriptor type */ 143/* Resource tables indexed by raw AML resource descriptor type */
165 144
166extern const u8 acpi_gbl_resource_struct_sizes[]; 145extern const u8 acpi_gbl_resource_struct_sizes[];
167extern const u8 acpi_gbl_resource_struct_serial_bus_sizes[];
168extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[]; 146extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
169 147
170extern struct acpi_rsconvert_info
171 *acpi_gbl_convert_resource_serial_bus_dispatch[];
172
173struct acpi_vendor_walk_info { 148struct acpi_vendor_walk_info {
174 struct acpi_vendor_uuid *uuid; 149 struct acpi_vendor_uuid *uuid;
175 struct acpi_buffer *buffer; 150 struct acpi_buffer *buffer;
@@ -215,10 +190,6 @@ acpi_status
215acpi_rs_set_srs_method_data(struct acpi_namespace_node *node, 190acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
216 struct acpi_buffer *ret_buffer); 191 struct acpi_buffer *ret_buffer);
217 192
218acpi_status
219acpi_rs_get_aei_method_data(struct acpi_namespace_node *node,
220 struct acpi_buffer *ret_buffer);
221
222/* 193/*
223 * rscalc 194 * rscalc
224 */ 195 */
@@ -322,11 +293,6 @@ extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
322extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[]; 293extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
323extern struct acpi_rsconvert_info acpi_rs_convert_address64[]; 294extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
324extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[]; 295extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
325extern struct acpi_rsconvert_info acpi_rs_convert_gpio[];
326extern struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[];
327extern struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[];
328extern struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[];
329extern struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[];
330 296
331/* These resources require separate get/set tables */ 297/* These resources require separate get/set tables */
332 298
@@ -344,7 +310,6 @@ extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
344 * rsinfo 310 * rsinfo
345 */ 311 */
346extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[]; 312extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
347extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[];
348 313
349/* 314/*
350 * rsdump 315 * rsdump
@@ -366,12 +331,6 @@ extern struct acpi_rsdump_info acpi_rs_dump_address64[];
366extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[]; 331extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
367extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[]; 332extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
368extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[]; 333extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
369extern struct acpi_rsdump_info acpi_rs_dump_gpio[];
370extern struct acpi_rsdump_info acpi_rs_dump_fixed_dma[];
371extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[];
372extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[];
373extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[];
374extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[];
375#endif 334#endif
376 335
377#endif /* __ACRESRC_H__ */ 336#endif /* __ACRESRC_H__ */
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 937e66c65d1..1623b245dde 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -53,7 +53,7 @@
53 ****************************************************************************/ 53 ****************************************************************************/
54 54
55/* 55/*
56 * Walk state - current state of a parse tree walk. Used for both a leisurely 56 * Walk state - current state of a parse tree walk. Used for both a leisurely
57 * stroll through the tree (for whatever reason), and for control method 57 * stroll through the tree (for whatever reason), and for control method
58 * execution. 58 * execution.
59 */ 59 */
@@ -68,7 +68,7 @@
68#define ACPI_WALK_METHOD 0x01 68#define ACPI_WALK_METHOD 0x01
69#define ACPI_WALK_METHOD_RESTART 0x02 69#define ACPI_WALK_METHOD_RESTART 0x02
70 70
71/* Flags for iASL compiler only */ 71/* Flags for i_aSL compiler only */
72 72
73#define ACPI_WALK_CONST_REQUIRED 0x10 73#define ACPI_WALK_CONST_REQUIRED 0x10
74#define ACPI_WALK_CONST_OPTIONAL 0x20 74#define ACPI_WALK_CONST_OPTIONAL 0x20
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 6712965ba8a..967f08124eb 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -67,11 +67,6 @@ acpi_status acpi_tb_resize_root_table_list(void);
67 67
68acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc); 68acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc);
69 69
70struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
71 *table_header,
72 struct acpi_table_desc
73 *table_desc);
74
75acpi_status 70acpi_status
76acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index); 71acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index);
77 72
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index b0f5f92b674..99c140d8e34 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -45,7 +45,6 @@
45#define _ACUTILS_H 45#define _ACUTILS_H
46 46
47extern const u8 acpi_gbl_resource_aml_sizes[]; 47extern const u8 acpi_gbl_resource_aml_sizes[];
48extern const u8 acpi_gbl_resource_aml_serial_bus_sizes[];
49 48
50/* Strings used by the disassembler and debugger resource dump routines */ 49/* Strings used by the disassembler and debugger resource dump routines */
51 50
@@ -69,22 +68,6 @@ extern const char *acpi_gbl_siz_decode[];
69extern const char *acpi_gbl_trs_decode[]; 68extern const char *acpi_gbl_trs_decode[];
70extern const char *acpi_gbl_ttp_decode[]; 69extern const char *acpi_gbl_ttp_decode[];
71extern const char *acpi_gbl_typ_decode[]; 70extern const char *acpi_gbl_typ_decode[];
72extern const char *acpi_gbl_ppc_decode[];
73extern const char *acpi_gbl_ior_decode[];
74extern const char *acpi_gbl_dts_decode[];
75extern const char *acpi_gbl_ct_decode[];
76extern const char *acpi_gbl_sbt_decode[];
77extern const char *acpi_gbl_am_decode[];
78extern const char *acpi_gbl_sm_decode[];
79extern const char *acpi_gbl_wm_decode[];
80extern const char *acpi_gbl_cph_decode[];
81extern const char *acpi_gbl_cpo_decode[];
82extern const char *acpi_gbl_dp_decode[];
83extern const char *acpi_gbl_ed_decode[];
84extern const char *acpi_gbl_bpb_decode[];
85extern const char *acpi_gbl_sb_decode[];
86extern const char *acpi_gbl_fc_decode[];
87extern const char *acpi_gbl_pt_decode[];
88#endif 71#endif
89 72
90/* Types for Resource descriptor entries */ 73/* Types for Resource descriptor entries */
@@ -95,14 +78,14 @@ extern const char *acpi_gbl_pt_decode[];
95#define ACPI_SMALL_VARIABLE_LENGTH 3 78#define ACPI_SMALL_VARIABLE_LENGTH 3
96 79
97typedef 80typedef
98acpi_status(*acpi_walk_aml_callback) (u8 *aml, 81acpi_status(*acpi_walk_aml_callback) (u8 * aml,
99 u32 length, 82 u32 length,
100 u32 offset, 83 u32 offset,
101 u8 resource_index, void **context); 84 u8 resource_index, void **context);
102 85
103typedef 86typedef
104acpi_status(*acpi_pkg_callback) (u8 object_type, 87acpi_status(*acpi_pkg_callback) (u8 object_type,
105 union acpi_operand_object *source_object, 88 union acpi_operand_object * source_object,
106 union acpi_generic_state * state, 89 union acpi_generic_state * state,
107 void *context); 90 void *context);
108 91
@@ -218,9 +201,7 @@ extern const u8 _acpi_ctype[];
218#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) 201#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
219#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) 202#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
220 203
221#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ 204#endif /* ACPI_USE_SYSTEM_CLIBRARY */
222
223#define ACPI_IS_ASCII(c) ((c) < 0x80)
224 205
225/* 206/*
226 * utcopy - Object construction and conversion interfaces 207 * utcopy - Object construction and conversion interfaces
@@ -228,11 +209,11 @@ extern const u8 _acpi_ctype[];
228acpi_status 209acpi_status
229acpi_ut_build_simple_object(union acpi_operand_object *obj, 210acpi_ut_build_simple_object(union acpi_operand_object *obj,
230 union acpi_object *user_obj, 211 union acpi_object *user_obj,
231 u8 *data_space, u32 *buffer_space_used); 212 u8 * data_space, u32 * buffer_space_used);
232 213
233acpi_status 214acpi_status
234acpi_ut_build_package_object(union acpi_operand_object *obj, 215acpi_ut_build_package_object(union acpi_operand_object *obj,
235 u8 *buffer, u32 *space_used); 216 u8 * buffer, u32 * space_used);
236 217
237acpi_status 218acpi_status
238acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj, 219acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj,
@@ -305,10 +286,9 @@ acpi_ut_ptr_exit(u32 line_number,
305 const char *function_name, 286 const char *function_name,
306 const char *module_name, u32 component_id, u8 *ptr); 287 const char *module_name, u32 component_id, u8 *ptr);
307 288
308void 289void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id);
309acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id);
310 290
311void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset); 291void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display);
312 292
313void acpi_ut_report_error(char *module_name, u32 line_number); 293void acpi_ut_report_error(char *module_name, u32 line_number);
314 294
@@ -356,19 +336,15 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
356 */ 336 */
357acpi_status 337acpi_status
358acpi_ut_execute_HID(struct acpi_namespace_node *device_node, 338acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
359 struct acpi_pnp_device_id ** return_id); 339 struct acpica_device_id **return_id);
360 340
361acpi_status 341acpi_status
362acpi_ut_execute_UID(struct acpi_namespace_node *device_node, 342acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
363 struct acpi_pnp_device_id ** return_id); 343 struct acpica_device_id **return_id);
364
365acpi_status
366acpi_ut_execute_SUB(struct acpi_namespace_node *device_node,
367 struct acpi_pnp_device_id **return_id);
368 344
369acpi_status 345acpi_status
370acpi_ut_execute_CID(struct acpi_namespace_node *device_node, 346acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
371 struct acpi_pnp_device_id_list ** return_cid_list); 347 struct acpica_device_id_list **return_cid_list);
372 348
373/* 349/*
374 * utlock - reader/writer locks 350 * utlock - reader/writer locks
@@ -483,8 +459,6 @@ acpi_ut_short_divide(u64 in_dividend,
483/* 459/*
484 * utmisc 460 * utmisc
485 */ 461 */
486void ut_convert_backslashes(char *pathname);
487
488const char *acpi_ut_validate_exception(acpi_status status); 462const char *acpi_ut_validate_exception(acpi_status status);
489 463
490u8 acpi_ut_is_pci_root_bridge(char *id); 464u8 acpi_ut_is_pci_root_bridge(char *id);
@@ -502,19 +476,15 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
502 476
503void acpi_ut_strupr(char *src_string); 477void acpi_ut_strupr(char *src_string);
504 478
505void acpi_ut_strlwr(char *src_string);
506
507int acpi_ut_stricmp(char *string1, char *string2);
508
509void acpi_ut_print_string(char *string, u8 max_length); 479void acpi_ut_print_string(char *string, u8 max_length);
510 480
511u8 acpi_ut_valid_acpi_name(u32 name); 481u8 acpi_ut_valid_acpi_name(u32 name);
512 482
513void acpi_ut_repair_name(char *name); 483acpi_name acpi_ut_repair_name(char *name);
514 484
515u8 acpi_ut_valid_acpi_char(char character, u32 position); 485u8 acpi_ut_valid_acpi_char(char character, u32 position);
516 486
517acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer); 487acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer);
518 488
519/* Values for Base above (16=Hex, 10=Decimal) */ 489/* Values for Base above (16=Hex, 10=Decimal) */
520 490
@@ -535,12 +505,12 @@ acpi_ut_display_init_pathname(u8 type,
535 * utresrc 505 * utresrc
536 */ 506 */
537acpi_status 507acpi_status
538acpi_ut_walk_aml_resources(u8 *aml, 508acpi_ut_walk_aml_resources(u8 * aml,
539 acpi_size aml_length, 509 acpi_size aml_length,
540 acpi_walk_aml_callback user_function, 510 acpi_walk_aml_callback user_function,
541 void **context); 511 void **context);
542 512
543acpi_status acpi_ut_validate_resource(void *aml, u8 *return_index); 513acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index);
544 514
545u32 acpi_ut_get_descriptor_length(void *aml); 515u32 acpi_ut_get_descriptor_length(void *aml);
546 516
@@ -551,7 +521,8 @@ u8 acpi_ut_get_resource_header_length(void *aml);
551u8 acpi_ut_get_resource_type(void *aml); 521u8 acpi_ut_get_resource_type(void *aml);
552 522
553acpi_status 523acpi_status
554acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag); 524acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc,
525 u8 ** end_tag);
555 526
556/* 527/*
557 * utmutex - mutex support 528 * utmutex - mutex support
@@ -608,24 +579,6 @@ acpi_ut_create_list(char *list_name,
608#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 579#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
609 580
610/* 581/*
611 * utaddress - address range check
612 */
613acpi_status
614acpi_ut_add_address_range(acpi_adr_space_type space_id,
615 acpi_physical_address address,
616 u32 length, struct acpi_namespace_node *region_node);
617
618void
619acpi_ut_remove_address_range(acpi_adr_space_type space_id,
620 struct acpi_namespace_node *region_node);
621
622u32
623acpi_ut_check_address_range(acpi_adr_space_type space_id,
624 acpi_physical_address address, u32 length, u8 warn);
625
626void acpi_ut_delete_address_lists(void);
627
628/*
629 * utxferror - various error/warning output functions 582 * utxferror - various error/warning output functions
630 */ 583 */
631void ACPI_INTERNAL_VAR_XFACE 584void ACPI_INTERNAL_VAR_XFACE
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index c26f8ff6c3b..1077f17859e 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 - 2012, Intel Corp. 10 * Copyright (C) 2000 - 2011, 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
@@ -182,21 +182,13 @@
182 182
183/* 183/*
184 * Combination opcodes (actually two one-byte opcodes) 184 * Combination opcodes (actually two one-byte opcodes)
185 * Used by the disassembler and iASL compiler 185 * Used by the disassembler and i_aSL compiler
186 */ 186 */
187#define AML_LGREATEREQUAL_OP (u16) 0x9295 187#define AML_LGREATEREQUAL_OP (u16) 0x9295
188#define AML_LLESSEQUAL_OP (u16) 0x9294 188#define AML_LLESSEQUAL_OP (u16) 0x9294
189#define AML_LNOTEQUAL_OP (u16) 0x9293 189#define AML_LNOTEQUAL_OP (u16) 0x9293
190 190
191/* 191/*
192 * Opcodes for "Field" operators
193 */
194#define AML_FIELD_OFFSET_OP (u8) 0x00
195#define AML_FIELD_ACCESS_OP (u8) 0x01
196#define AML_FIELD_CONNECTION_OP (u8) 0x02 /* ACPI 5.0 */
197#define AML_FIELD_EXT_ACCESS_OP (u8) 0x03 /* ACPI 5.0 */
198
199/*
200 * Internal opcodes 192 * Internal opcodes
201 * Use only "Unknown" AML opcodes, don't attempt to use 193 * Use only "Unknown" AML opcodes, don't attempt to use
202 * any valid ACPI ASCII values (A-Z, 0-9, '-') 194 * any valid ACPI ASCII values (A-Z, 0-9, '-')
@@ -210,8 +202,6 @@
210#define AML_INT_METHODCALL_OP (u16) 0x0035 202#define AML_INT_METHODCALL_OP (u16) 0x0035
211#define AML_INT_RETURN_VALUE_OP (u16) 0x0036 203#define AML_INT_RETURN_VALUE_OP (u16) 0x0036
212#define AML_INT_EVAL_SUBTREE_OP (u16) 0x0037 204#define AML_INT_EVAL_SUBTREE_OP (u16) 0x0037
213#define AML_INT_CONNECTION_OP (u16) 0x0038
214#define AML_INT_EXTACCESSFIELD_OP (u16) 0x0039
215 205
216#define ARG_NONE 0x0 206#define ARG_NONE 0x0
217 207
@@ -280,7 +270,7 @@
280 270
281/* Multiple/complex types */ 271/* Multiple/complex types */
282 272
283#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a node - Used only by size_of operator */ 273#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by size_of operator */
284#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ 274#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */
285#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ 275#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */
286#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */ 276#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */
@@ -466,16 +456,13 @@ typedef enum {
466 * access_as keyword 456 * access_as keyword
467 */ 457 */
468typedef enum { 458typedef enum {
469 AML_FIELD_ATTRIB_QUICK = 0x02, 459 AML_FIELD_ATTRIB_SMB_QUICK = 0x02,
470 AML_FIELD_ATTRIB_SEND_RCV = 0x04, 460 AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04,
471 AML_FIELD_ATTRIB_BYTE = 0x06, 461 AML_FIELD_ATTRIB_SMB_BYTE = 0x06,
472 AML_FIELD_ATTRIB_WORD = 0x08, 462 AML_FIELD_ATTRIB_SMB_WORD = 0x08,
473 AML_FIELD_ATTRIB_BLOCK = 0x0A, 463 AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A,
474 AML_FIELD_ATTRIB_MULTIBYTE = 0x0B, 464 AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C,
475 AML_FIELD_ATTRIB_WORD_CALL = 0x0C, 465 AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D
476 AML_FIELD_ATTRIB_BLOCK_CALL = 0x0D,
477 AML_FIELD_ATTRIB_RAW_BYTES = 0x0E,
478 AML_FIELD_ATTRIB_RAW_PROCESS = 0x0F
479} AML_ACCESS_ATTRIBUTE; 466} AML_ACCESS_ATTRIBUTE;
480 467
481/* Bit fields in the AML method_flags byte */ 468/* Bit fields in the AML method_flags byte */
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 968449685e0..59122cde247 100644
--- a/drivers/acpi/acpica/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: amlresrc.h - AML resource descriptors 4 * Module Name: amlresrc.h - AML resource descriptors
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -57,48 +58,29 @@
57#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" 58#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
58#define ACPI_RESTAG_BASEADDRESS "_BAS" 59#define ACPI_RESTAG_BASEADDRESS "_BAS"
59#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ 60#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
60#define ACPI_RESTAG_DEBOUNCETIME "_DBT"
61#define ACPI_RESTAG_DECODE "_DEC" 61#define ACPI_RESTAG_DECODE "_DEC"
62#define ACPI_RESTAG_DEVICEPOLARITY "_DPL"
63#define ACPI_RESTAG_DMA "_DMA" 62#define ACPI_RESTAG_DMA "_DMA"
64#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ 63#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
65#define ACPI_RESTAG_DRIVESTRENGTH "_DRS"
66#define ACPI_RESTAG_ENDIANNESS "_END"
67#define ACPI_RESTAG_FLOWCONTROL "_FLC"
68#define ACPI_RESTAG_GRANULARITY "_GRA" 64#define ACPI_RESTAG_GRANULARITY "_GRA"
69#define ACPI_RESTAG_INTERRUPT "_INT" 65#define ACPI_RESTAG_INTERRUPT "_INT"
70#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */ 66#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */
71#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */ 67#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */
72#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ 68#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
73#define ACPI_RESTAG_IORESTRICTION "_IOR"
74#define ACPI_RESTAG_LENGTH "_LEN" 69#define ACPI_RESTAG_LENGTH "_LEN"
75#define ACPI_RESTAG_LINE "_LIN"
76#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ 70#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
77#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ 71#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
78#define ACPI_RESTAG_MAXADDR "_MAX" 72#define ACPI_RESTAG_MAXADDR "_MAX"
79#define ACPI_RESTAG_MINADDR "_MIN" 73#define ACPI_RESTAG_MINADDR "_MIN"
80#define ACPI_RESTAG_MAXTYPE "_MAF" 74#define ACPI_RESTAG_MAXTYPE "_MAF"
81#define ACPI_RESTAG_MINTYPE "_MIF" 75#define ACPI_RESTAG_MINTYPE "_MIF"
82#define ACPI_RESTAG_MODE "_MOD"
83#define ACPI_RESTAG_PARITY "_PAR"
84#define ACPI_RESTAG_PHASE "_PHA"
85#define ACPI_RESTAG_PIN "_PIN"
86#define ACPI_RESTAG_PINCONFIG "_PPI"
87#define ACPI_RESTAG_POLARITY "_POL"
88#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" 76#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
89#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" 77#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
90#define ACPI_RESTAG_RANGETYPE "_RNG" 78#define ACPI_RESTAG_RANGETYPE "_RNG"
91#define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */ 79#define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */
92#define ACPI_RESTAG_LENGTH_RX "_RXL"
93#define ACPI_RESTAG_LENGTH_TX "_TXL"
94#define ACPI_RESTAG_SLAVEMODE "_SLV"
95#define ACPI_RESTAG_SPEED "_SPE"
96#define ACPI_RESTAG_STOPBITS "_STB"
97#define ACPI_RESTAG_TRANSLATION "_TRA" 80#define ACPI_RESTAG_TRANSLATION "_TRA"
98#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ 81#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
99#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ 82#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
100#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */ 83#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8_and16(1), 16(2) */
101#define ACPI_RESTAG_VENDORDATA "_VEN"
102 84
103/* Default sizes for "small" resource descriptors */ 85/* Default sizes for "small" resource descriptors */
104 86
@@ -108,7 +90,6 @@
108#define ASL_RDESC_END_DEPEND_SIZE 0x00 90#define ASL_RDESC_END_DEPEND_SIZE 0x00
109#define ASL_RDESC_IO_SIZE 0x07 91#define ASL_RDESC_IO_SIZE 0x07
110#define ASL_RDESC_FIXED_IO_SIZE 0x03 92#define ASL_RDESC_FIXED_IO_SIZE 0x03
111#define ASL_RDESC_FIXED_DMA_SIZE 0x05
112#define ASL_RDESC_END_TAG_SIZE 0x01 93#define ASL_RDESC_END_TAG_SIZE 0x01
113 94
114struct asl_resource_node { 95struct asl_resource_node {
@@ -183,12 +164,6 @@ struct aml_resource_end_tag {
183 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum; 164 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
184}; 165};
185 166
186struct aml_resource_fixed_dma {
187 AML_RESOURCE_SMALL_HEADER_COMMON u16 request_lines;
188 u16 channels;
189 u8 width;
190};
191
192/* 167/*
193 * LARGE descriptors 168 * LARGE descriptors
194 */ 169 */
@@ -234,7 +209,7 @@ AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
234 209
235struct aml_resource_extended_address64 { 210struct aml_resource_extended_address64 {
236 AML_RESOURCE_LARGE_HEADER_COMMON 211 AML_RESOURCE_LARGE_HEADER_COMMON
237 AML_RESOURCE_ADDRESS_COMMON u8 revision_ID; 212 AML_RESOURCE_ADDRESS_COMMON u8 revision_iD;
238 u8 reserved; 213 u8 reserved;
239 u64 granularity; 214 u64 granularity;
240 u64 minimum; 215 u64 minimum;
@@ -288,110 +263,6 @@ struct aml_resource_generic_register {
288 u64 address; 263 u64 address;
289}; 264};
290 265
291/* Common descriptor for gpio_int and gpio_io (ACPI 5.0) */
292
293struct aml_resource_gpio {
294 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id;
295 u8 connection_type;
296 u16 flags;
297 u16 int_flags;
298 u8 pin_config;
299 u16 drive_strength;
300 u16 debounce_timeout;
301 u16 pin_table_offset;
302 u8 res_source_index;
303 u16 res_source_offset;
304 u16 vendor_offset;
305 u16 vendor_length;
306 /*
307 * Optional fields follow immediately:
308 * 1) PIN list (Words)
309 * 2) Resource Source String
310 * 3) Vendor Data bytes
311 */
312};
313
314#define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */
315
316/* Values for connection_type above */
317
318#define AML_RESOURCE_GPIO_TYPE_INT 0
319#define AML_RESOURCE_GPIO_TYPE_IO 1
320#define AML_RESOURCE_MAX_GPIOTYPE 1
321
322/* Common preamble for all serial descriptors (ACPI 5.0) */
323
324#define AML_RESOURCE_SERIAL_COMMON \
325 u8 revision_id; \
326 u8 res_source_index; \
327 u8 type; \
328 u8 flags; \
329 u16 type_specific_flags; \
330 u8 type_revision_id; \
331 u16 type_data_length; \
332
333/* Values for the type field above */
334
335#define AML_RESOURCE_I2C_SERIALBUSTYPE 1
336#define AML_RESOURCE_SPI_SERIALBUSTYPE 2
337#define AML_RESOURCE_UART_SERIALBUSTYPE 3
338#define AML_RESOURCE_MAX_SERIALBUSTYPE 3
339#define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
340
341struct aml_resource_common_serialbus {
342AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON};
343
344struct aml_resource_i2c_serialbus {
345 AML_RESOURCE_LARGE_HEADER_COMMON
346 AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
347 u16 slave_address;
348 /*
349 * Optional fields follow immediately:
350 * 1) Vendor Data bytes
351 * 2) Resource Source String
352 */
353};
354
355#define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */
356#define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */
357#define AML_RESOURCE_I2C_MIN_DATA_LEN 6
358
359struct aml_resource_spi_serialbus {
360 AML_RESOURCE_LARGE_HEADER_COMMON
361 AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
362 u8 data_bit_length;
363 u8 clock_phase;
364 u8 clock_polarity;
365 u16 device_selection;
366 /*
367 * Optional fields follow immediately:
368 * 1) Vendor Data bytes
369 * 2) Resource Source String
370 */
371};
372
373#define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */
374#define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */
375#define AML_RESOURCE_SPI_MIN_DATA_LEN 9
376
377struct aml_resource_uart_serialbus {
378 AML_RESOURCE_LARGE_HEADER_COMMON
379 AML_RESOURCE_SERIAL_COMMON u32 default_baud_rate;
380 u16 rx_fifo_size;
381 u16 tx_fifo_size;
382 u8 parity;
383 u8 lines_enabled;
384 /*
385 * Optional fields follow immediately:
386 * 1) Vendor Data bytes
387 * 2) Resource Source String
388 */
389};
390
391#define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */
392#define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */
393#define AML_RESOURCE_UART_MIN_DATA_LEN 10
394
395/* restore default alignment */ 266/* restore default alignment */
396 267
397#pragma pack() 268#pragma pack()
@@ -413,7 +284,6 @@ union aml_resource {
413 struct aml_resource_end_dependent end_dpf; 284 struct aml_resource_end_dependent end_dpf;
414 struct aml_resource_io io; 285 struct aml_resource_io io;
415 struct aml_resource_fixed_io fixed_io; 286 struct aml_resource_fixed_io fixed_io;
416 struct aml_resource_fixed_dma fixed_dma;
417 struct aml_resource_vendor_small vendor_small; 287 struct aml_resource_vendor_small vendor_small;
418 struct aml_resource_end_tag end_tag; 288 struct aml_resource_end_tag end_tag;
419 289
@@ -429,11 +299,6 @@ union aml_resource {
429 struct aml_resource_address64 address64; 299 struct aml_resource_address64 address64;
430 struct aml_resource_extended_address64 ext_address64; 300 struct aml_resource_extended_address64 ext_address64;
431 struct aml_resource_extended_irq extended_irq; 301 struct aml_resource_extended_irq extended_irq;
432 struct aml_resource_gpio gpio;
433 struct aml_resource_i2c_serialbus i2c_serial_bus;
434 struct aml_resource_spi_serialbus spi_serial_bus;
435 struct aml_resource_uart_serialbus uart_serial_bus;
436 struct aml_resource_common_serialbus common_serial_bus;
437 302
438 /* Utility overlays */ 303 /* Utility overlays */
439 304
diff --git a/drivers/acpi/acpica/dsargs.c b/drivers/acpi/acpica/dsargs.c
index c8b5e2565b9..8c7b99728aa 100644
--- a/drivers/acpi/acpica/dsargs.c
+++ b/drivers/acpi/acpica/dsargs.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -62,7 +62,7 @@ acpi_ds_execute_arguments(struct acpi_namespace_node *node,
62 * 62 *
63 * FUNCTION: acpi_ds_execute_arguments 63 * FUNCTION: acpi_ds_execute_arguments
64 * 64 *
65 * PARAMETERS: node - Object NS node 65 * PARAMETERS: Node - Object NS node
66 * scope_node - Parent NS node 66 * scope_node - Parent NS node
67 * aml_length - Length of executable AML 67 * aml_length - Length of executable AML
68 * aml_start - Pointer to the AML 68 * aml_start - Pointer to the AML
@@ -250,13 +250,6 @@ acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
250 status = acpi_ds_execute_arguments(node, node->parent, 250 status = acpi_ds_execute_arguments(node, node->parent,
251 extra_desc->extra.aml_length, 251 extra_desc->extra.aml_length,
252 extra_desc->extra.aml_start); 252 extra_desc->extra.aml_start);
253 if (ACPI_FAILURE(status)) {
254 return_ACPI_STATUS(status);
255 }
256
257 status = acpi_ut_add_address_range(obj_desc->region.space_id,
258 obj_desc->region.address,
259 obj_desc->region.length, node);
260 return_ACPI_STATUS(status); 253 return_ACPI_STATUS(status);
261} 254}
262 255
@@ -391,15 +384,8 @@ acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
391 384
392 /* Execute the argument AML */ 385 /* Execute the argument AML */
393 386
394 status = acpi_ds_execute_arguments(node, extra_desc->extra.scope_node, 387 status = acpi_ds_execute_arguments(node, node->parent,
395 extra_desc->extra.aml_length, 388 extra_desc->extra.aml_length,
396 extra_desc->extra.aml_start); 389 extra_desc->extra.aml_start);
397 if (ACPI_FAILURE(status)) {
398 return_ACPI_STATUS(status);
399 }
400
401 status = acpi_ut_add_address_range(obj_desc->region.space_id,
402 obj_desc->region.address,
403 obj_desc->region.length, node);
404 return_ACPI_STATUS(status); 390 return_ACPI_STATUS(status);
405} 391}
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c
index 57895db3231..26c49fff58d 100644
--- a/drivers/acpi/acpica/dscontrol.c
+++ b/drivers/acpi/acpica/dscontrol.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -56,7 +56,7 @@ ACPI_MODULE_NAME("dscontrol")
56 * FUNCTION: acpi_ds_exec_begin_control_op 56 * FUNCTION: acpi_ds_exec_begin_control_op
57 * 57 *
58 * PARAMETERS: walk_list - The list that owns the walk stack 58 * PARAMETERS: walk_list - The list that owns the walk stack
59 * op - The control Op 59 * Op - The control Op
60 * 60 *
61 * RETURN: Status 61 * RETURN: Status
62 * 62 *
@@ -153,7 +153,7 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
153 * FUNCTION: acpi_ds_exec_end_control_op 153 * FUNCTION: acpi_ds_exec_end_control_op
154 * 154 *
155 * PARAMETERS: walk_list - The list that owns the walk stack 155 * PARAMETERS: walk_list - The list that owns the walk stack
156 * op - The control Op 156 * Op - The control Op
157 * 157 *
158 * RETURN: Status 158 * RETURN: Status
159 * 159 *
@@ -280,7 +280,7 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
280 280
281 /* 281 /*
282 * Get the return value and save as the last result 282 * Get the return value and save as the last result
283 * value. This is the only place where walk_state->return_desc 283 * value. This is the only place where walk_state->return_desc
284 * is set to anything other than zero! 284 * is set to anything other than zero!
285 */ 285 */
286 walk_state->return_desc = walk_state->operands[0]; 286 walk_state->return_desc = walk_state->operands[0];
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index b5b904ee815..34be60c0e44 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -53,84 +53,16 @@
53ACPI_MODULE_NAME("dsfield") 53ACPI_MODULE_NAME("dsfield")
54 54
55/* Local prototypes */ 55/* Local prototypes */
56#ifdef ACPI_ASL_COMPILER
57#include "acdisasm.h"
58static acpi_status
59acpi_ds_create_external_region(acpi_status lookup_status,
60 union acpi_parse_object *op,
61 char *path,
62 struct acpi_walk_state *walk_state,
63 struct acpi_namespace_node **node);
64#endif
65
66static acpi_status 56static acpi_status
67acpi_ds_get_field_names(struct acpi_create_field_info *info, 57acpi_ds_get_field_names(struct acpi_create_field_info *info,
68 struct acpi_walk_state *walk_state, 58 struct acpi_walk_state *walk_state,
69 union acpi_parse_object *arg); 59 union acpi_parse_object *arg);
70 60
71#ifdef ACPI_ASL_COMPILER
72/*******************************************************************************
73 *
74 * FUNCTION: acpi_ds_create_external_region (iASL Disassembler only)
75 *
76 * PARAMETERS: lookup_status - Status from ns_lookup operation
77 * op - Op containing the Field definition and args
78 * path - Pathname of the region
79 * ` walk_state - Current method state
80 * node - Where the new region node is returned
81 *
82 * RETURN: Status
83 *
84 * DESCRIPTION: Add region to the external list if NOT_FOUND. Create a new
85 * region node/object.
86 *
87 ******************************************************************************/
88
89static acpi_status
90acpi_ds_create_external_region(acpi_status lookup_status,
91 union acpi_parse_object *op,
92 char *path,
93 struct acpi_walk_state *walk_state,
94 struct acpi_namespace_node **node)
95{
96 acpi_status status;
97 union acpi_operand_object *obj_desc;
98
99 if (lookup_status != AE_NOT_FOUND) {
100 return (lookup_status);
101 }
102
103 /*
104 * Table disassembly:
105 * operation_region not found. Generate an External for it, and
106 * insert the name into the namespace.
107 */
108 acpi_dm_add_to_external_list(op, path, ACPI_TYPE_REGION, 0);
109 status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION,
110 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
111 walk_state, node);
112 if (ACPI_FAILURE(status)) {
113 return (status);
114 }
115
116 /* Must create and install a region object for the new node */
117
118 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
119 if (!obj_desc) {
120 return (AE_NO_MEMORY);
121 }
122
123 obj_desc->region.node = *node;
124 status = acpi_ns_attach_object(*node, obj_desc, ACPI_TYPE_REGION);
125 return (status);
126}
127#endif
128
129/******************************************************************************* 61/*******************************************************************************
130 * 62 *
131 * FUNCTION: acpi_ds_create_buffer_field 63 * FUNCTION: acpi_ds_create_buffer_field
132 * 64 *
133 * PARAMETERS: op - Current parse op (create_XXField) 65 * PARAMETERS: Op - Current parse op (create_xXField)
134 * walk_state - Current state 66 * walk_state - Current state
135 * 67 *
136 * RETURN: Status 68 * RETURN: Status
@@ -167,7 +99,7 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op,
167 99
168 arg = acpi_ps_get_arg(op, 3); 100 arg = acpi_ps_get_arg(op, 3);
169 } else { 101 } else {
170 /* For all other create_XXXField operators, name is the 3rd argument */ 102 /* For all other create_xXXField operators, name is the 3rd argument */
171 103
172 arg = acpi_ps_get_arg(op, 2); 104 arg = acpi_ps_get_arg(op, 2);
173 } 105 }
@@ -271,13 +203,13 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op,
271 * 203 *
272 * FUNCTION: acpi_ds_get_field_names 204 * FUNCTION: acpi_ds_get_field_names
273 * 205 *
274 * PARAMETERS: info - create_field info structure 206 * PARAMETERS: Info - create_field info structure
275 * ` walk_state - Current method state 207 * ` walk_state - Current method state
276 * arg - First parser arg for the field name list 208 * Arg - First parser arg for the field name list
277 * 209 *
278 * RETURN: Status 210 * RETURN: Status
279 * 211 *
280 * DESCRIPTION: Process all named fields in a field declaration. Names are 212 * DESCRIPTION: Process all named fields in a field declaration. Names are
281 * entered into the namespace. 213 * entered into the namespace.
282 * 214 *
283 ******************************************************************************/ 215 ******************************************************************************/
@@ -289,7 +221,6 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
289{ 221{
290 acpi_status status; 222 acpi_status status;
291 u64 position; 223 u64 position;
292 union acpi_parse_object *child;
293 224
294 ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info); 225 ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info);
295 226
@@ -301,11 +232,10 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
301 232
302 while (arg) { 233 while (arg) {
303 /* 234 /*
304 * Four types of field elements are handled: 235 * Three types of field elements are handled:
305 * 1) name - Enters a new named field into the namespace 236 * 1) Offset - specifies a bit offset
306 * 2) offset - specifies a bit offset 237 * 2) access_as - changes the access mode
307 * 3) access_as - changes the access mode/attributes 238 * 3) Name - Enters a new named field into the namespace
308 * 4) connection - Associate a resource template with the field
309 */ 239 */
310 switch (arg->common.aml_opcode) { 240 switch (arg->common.aml_opcode) {
311 case AML_INT_RESERVEDFIELD_OP: 241 case AML_INT_RESERVEDFIELD_OP:
@@ -323,70 +253,21 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
323 break; 253 break;
324 254
325 case AML_INT_ACCESSFIELD_OP: 255 case AML_INT_ACCESSFIELD_OP:
326 case AML_INT_EXTACCESSFIELD_OP: 256
327 /* 257 /*
328 * Get new access_type, access_attribute, and access_length fields 258 * Get a new access_type and access_attribute -- to be used for all
329 * -- to be used for all field units that follow, until the 259 * field units that follow, until field end or another access_as
330 * end-of-field or another access_as keyword is encountered. 260 * keyword.
331 * NOTE. These three bytes are encoded in the integer value
332 * of the parseop for convenience.
333 * 261 *
334 * In field_flags, preserve the flag bits other than the 262 * In field_flags, preserve the flag bits other than the
335 * ACCESS_TYPE bits. 263 * ACCESS_TYPE bits
336 */ 264 */
337
338 /* access_type (byte_acc, word_acc, etc.) */
339
340 info->field_flags = (u8) 265 info->field_flags = (u8)
341 ((info-> 266 ((info->
342 field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | 267 field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
343 ((u8)((u32)(arg->common.value.integer & 0x07)))); 268 ((u8) ((u32) arg->common.value.integer >> 8)));
344 269
345 /* access_attribute (attrib_quick, attrib_byte, etc.) */ 270 info->attribute = (u8) (arg->common.value.integer);
346
347 info->attribute =
348 (u8)((arg->common.value.integer >> 8) & 0xFF);
349
350 /* access_length (for serial/buffer protocols) */
351
352 info->access_length =
353 (u8)((arg->common.value.integer >> 16) & 0xFF);
354 break;
355
356 case AML_INT_CONNECTION_OP:
357 /*
358 * Clear any previous connection. New connection is used for all
359 * fields that follow, similar to access_as
360 */
361 info->resource_buffer = NULL;
362 info->connection_node = NULL;
363
364 /*
365 * A Connection() is either an actual resource descriptor (buffer)
366 * or a named reference to a resource template
367 */
368 child = arg->common.value.arg;
369 if (child->common.aml_opcode == AML_INT_BYTELIST_OP) {
370 info->resource_buffer = child->named.data;
371 info->resource_length =
372 (u16)child->named.value.integer;
373 } else {
374 /* Lookup the Connection() namepath, it should already exist */
375
376 status = acpi_ns_lookup(walk_state->scope_info,
377 child->common.value.
378 name, ACPI_TYPE_ANY,
379 ACPI_IMODE_EXECUTE,
380 ACPI_NS_DONT_OPEN_SCOPE,
381 walk_state,
382 &info->connection_node);
383 if (ACPI_FAILURE(status)) {
384 ACPI_ERROR_NAMESPACE(child->common.
385 value.name,
386 status);
387 return_ACPI_STATUS(status);
388 }
389 }
390 break; 271 break;
391 272
392 case AML_INT_NAMEDFIELD_OP: 273 case AML_INT_NAMEDFIELD_OP:
@@ -457,7 +338,7 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
457 * 338 *
458 * FUNCTION: acpi_ds_create_field 339 * FUNCTION: acpi_ds_create_field
459 * 340 *
460 * PARAMETERS: op - Op containing the Field definition and args 341 * PARAMETERS: Op - Op containing the Field definition and args
461 * region_node - Object for the containing Operation Region 342 * region_node - Object for the containing Operation Region
462 * ` walk_state - Current method state 343 * ` walk_state - Current method state
463 * 344 *
@@ -481,27 +362,18 @@ acpi_ds_create_field(union acpi_parse_object *op,
481 /* First arg is the name of the parent op_region (must already exist) */ 362 /* First arg is the name of the parent op_region (must already exist) */
482 363
483 arg = op->common.value.arg; 364 arg = op->common.value.arg;
484
485 if (!region_node) { 365 if (!region_node) {
486 status = 366 status =
487 acpi_ns_lookup(walk_state->scope_info, 367 acpi_ns_lookup(walk_state->scope_info,
488 arg->common.value.name, ACPI_TYPE_REGION, 368 arg->common.value.name, ACPI_TYPE_REGION,
489 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 369 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
490 walk_state, &region_node); 370 walk_state, &region_node);
491#ifdef ACPI_ASL_COMPILER
492 status = acpi_ds_create_external_region(status, arg,
493 arg->common.value.name,
494 walk_state,
495 &region_node);
496#endif
497 if (ACPI_FAILURE(status)) { 371 if (ACPI_FAILURE(status)) {
498 ACPI_ERROR_NAMESPACE(arg->common.value.name, status); 372 ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
499 return_ACPI_STATUS(status); 373 return_ACPI_STATUS(status);
500 } 374 }
501 } 375 }
502 376
503 ACPI_MEMSET(&info, 0, sizeof(struct acpi_create_field_info));
504
505 /* Second arg is the field flags */ 377 /* Second arg is the field flags */
506 378
507 arg = arg->common.next; 379 arg = arg->common.next;
@@ -514,6 +386,7 @@ acpi_ds_create_field(union acpi_parse_object *op,
514 info.region_node = region_node; 386 info.region_node = region_node;
515 387
516 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next); 388 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
389
517 return_ACPI_STATUS(status); 390 return_ACPI_STATUS(status);
518} 391}
519 392
@@ -521,7 +394,7 @@ acpi_ds_create_field(union acpi_parse_object *op,
521 * 394 *
522 * FUNCTION: acpi_ds_init_field_objects 395 * FUNCTION: acpi_ds_init_field_objects
523 * 396 *
524 * PARAMETERS: op - Op containing the Field definition and args 397 * PARAMETERS: Op - Op containing the Field definition and args
525 * ` walk_state - Current method state 398 * ` walk_state - Current method state
526 * 399 *
527 * RETURN: Status 400 * RETURN: Status
@@ -601,8 +474,8 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
601 */ 474 */
602 while (arg) { 475 while (arg) {
603 /* 476 /*
604 * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested 477 * Ignore OFFSET and ACCESSAS terms here; we are only interested in the
605 * in the field names in order to enter them into the namespace. 478 * field names in order to enter them into the namespace.
606 */ 479 */
607 if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) { 480 if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
608 status = acpi_ns_lookup(walk_state->scope_info, 481 status = acpi_ns_lookup(walk_state->scope_info,
@@ -636,7 +509,7 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
636 * 509 *
637 * FUNCTION: acpi_ds_create_bank_field 510 * FUNCTION: acpi_ds_create_bank_field
638 * 511 *
639 * PARAMETERS: op - Op containing the Field definition and args 512 * PARAMETERS: Op - Op containing the Field definition and args
640 * region_node - Object for the containing Operation Region 513 * region_node - Object for the containing Operation Region
641 * walk_state - Current method state 514 * walk_state - Current method state
642 * 515 *
@@ -666,12 +539,6 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
666 arg->common.value.name, ACPI_TYPE_REGION, 539 arg->common.value.name, ACPI_TYPE_REGION,
667 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 540 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
668 walk_state, &region_node); 541 walk_state, &region_node);
669#ifdef ACPI_ASL_COMPILER
670 status = acpi_ds_create_external_region(status, arg,
671 arg->common.value.name,
672 walk_state,
673 &region_node);
674#endif
675 if (ACPI_FAILURE(status)) { 542 if (ACPI_FAILURE(status)) {
676 ACPI_ERROR_NAMESPACE(arg->common.value.name, status); 543 ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
677 return_ACPI_STATUS(status); 544 return_ACPI_STATUS(status);
@@ -726,7 +593,7 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
726 * 593 *
727 * FUNCTION: acpi_ds_create_index_field 594 * FUNCTION: acpi_ds_create_index_field
728 * 595 *
729 * PARAMETERS: op - Op containing the Field definition and args 596 * PARAMETERS: Op - Op containing the Field definition and args
730 * region_node - Object for the containing Operation Region 597 * region_node - Object for the containing Operation Region
731 * ` walk_state - Current method state 598 * ` walk_state - Current method state
732 * 599 *
@@ -784,5 +651,6 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
784 info.region_node = region_node; 651 info.region_node = region_node;
785 652
786 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next); 653 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
654
787 return_ACPI_STATUS(status); 655 return_ACPI_STATUS(status);
788} 656}
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index 87eff701ecf..a7718bf2b9a 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -60,8 +60,8 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
60 * FUNCTION: acpi_ds_init_one_object 60 * FUNCTION: acpi_ds_init_one_object
61 * 61 *
62 * PARAMETERS: obj_handle - Node for the object 62 * PARAMETERS: obj_handle - Node for the object
63 * level - Current nesting level 63 * Level - Current nesting level
64 * context - Points to a init info struct 64 * Context - Points to a init info struct
65 * return_value - Not used 65 * return_value - Not used
66 * 66 *
67 * RETURN: Status 67 * RETURN: Status
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 52eb4e01622..5d797751e20 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -61,7 +61,7 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc);
61 * 61 *
62 * FUNCTION: acpi_ds_method_error 62 * FUNCTION: acpi_ds_method_error
63 * 63 *
64 * PARAMETERS: status - Execution status 64 * PARAMETERS: Status - Execution status
65 * walk_state - Current state 65 * walk_state - Current state
66 * 66 *
67 * RETURN: Status 67 * RETURN: Status
@@ -170,7 +170,7 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
170 * 170 *
171 * RETURN: Status 171 * RETURN: Status
172 * 172 *
173 * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, 173 * DESCRIPTION: Prepare a method for execution. Parses the method if necessary,
174 * increments the thread count, and waits at the method semaphore 174 * increments the thread count, and waits at the method semaphore
175 * for clearance to execute. 175 * for clearance to execute.
176 * 176 *
@@ -306,9 +306,9 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
306 * 306 *
307 * FUNCTION: acpi_ds_call_control_method 307 * FUNCTION: acpi_ds_call_control_method
308 * 308 *
309 * PARAMETERS: thread - Info for this thread 309 * PARAMETERS: Thread - Info for this thread
310 * this_walk_state - Current walk state 310 * this_walk_state - Current walk state
311 * op - Current Op to be walked 311 * Op - Current Op to be walked
312 * 312 *
313 * RETURN: Status 313 * RETURN: Status
314 * 314 *
@@ -444,7 +444,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
444 * RETURN: Status 444 * RETURN: Status
445 * 445 *
446 * DESCRIPTION: Restart a method that was preempted by another (nested) method 446 * DESCRIPTION: Restart a method that was preempted by another (nested) method
447 * invocation. Handle the return value (if any) from the callee. 447 * invocation. Handle the return value (if any) from the callee.
448 * 448 *
449 ******************************************************************************/ 449 ******************************************************************************/
450 450
@@ -530,7 +530,7 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
530 * 530 *
531 * RETURN: None 531 * RETURN: None
532 * 532 *
533 * DESCRIPTION: Terminate a control method. Delete everything that the method 533 * DESCRIPTION: Terminate a control method. Delete everything that the method
534 * created, delete all locals and arguments, and delete the parse 534 * created, delete all locals and arguments, and delete the parse
535 * tree if requested. 535 * tree if requested.
536 * 536 *
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index 9a83b7e0f3b..905ce29a92e 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,7 +76,7 @@ acpi_ds_method_data_get_type(u16 opcode,
76 * RETURN: Status 76 * RETURN: Status
77 * 77 *
78 * DESCRIPTION: Initialize the data structures that hold the method's arguments 78 * DESCRIPTION: Initialize the data structures that hold the method's arguments
79 * and locals. The data struct is an array of namespace nodes for 79 * and locals. The data struct is an array of namespace nodes for
80 * each - this allows ref_of and de_ref_of to work properly for these 80 * each - this allows ref_of and de_ref_of to work properly for these
81 * special data types. 81 * special data types.
82 * 82 *
@@ -129,7 +129,7 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
129 * 129 *
130 * RETURN: None 130 * RETURN: None
131 * 131 *
132 * DESCRIPTION: Delete method locals and arguments. Arguments are only 132 * DESCRIPTION: Delete method locals and arguments. Arguments are only
133 * deleted if this method was called from another method. 133 * deleted if this method was called from another method.
134 * 134 *
135 ******************************************************************************/ 135 ******************************************************************************/
@@ -177,13 +177,13 @@ void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
177 * 177 *
178 * FUNCTION: acpi_ds_method_data_init_args 178 * FUNCTION: acpi_ds_method_data_init_args
179 * 179 *
180 * PARAMETERS: *params - Pointer to a parameter list for the method 180 * PARAMETERS: *Params - Pointer to a parameter list for the method
181 * max_param_count - The arg count for this method 181 * max_param_count - The arg count for this method
182 * walk_state - Current walk state object 182 * walk_state - Current walk state object
183 * 183 *
184 * RETURN: Status 184 * RETURN: Status
185 * 185 *
186 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list 186 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
187 * of ACPI operand objects, either null terminated or whose length 187 * of ACPI operand objects, either null terminated or whose length
188 * is defined by max_param_count. 188 * is defined by max_param_count.
189 * 189 *
@@ -232,11 +232,11 @@ acpi_ds_method_data_init_args(union acpi_operand_object **params,
232 * 232 *
233 * FUNCTION: acpi_ds_method_data_get_node 233 * FUNCTION: acpi_ds_method_data_get_node
234 * 234 *
235 * PARAMETERS: type - Either ACPI_REFCLASS_LOCAL or 235 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
236 * ACPI_REFCLASS_ARG 236 * ACPI_REFCLASS_ARG
237 * index - Which Local or Arg whose type to get 237 * Index - Which Local or Arg whose type to get
238 * walk_state - Current walk state object 238 * walk_state - Current walk state object
239 * node - Where the node is returned. 239 * Node - Where the node is returned.
240 * 240 *
241 * RETURN: Status and node 241 * RETURN: Status and node
242 * 242 *
@@ -296,10 +296,10 @@ acpi_ds_method_data_get_node(u8 type,
296 * 296 *
297 * FUNCTION: acpi_ds_method_data_set_value 297 * FUNCTION: acpi_ds_method_data_set_value
298 * 298 *
299 * PARAMETERS: type - Either ACPI_REFCLASS_LOCAL or 299 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
300 * ACPI_REFCLASS_ARG 300 * ACPI_REFCLASS_ARG
301 * index - Which Local or Arg to get 301 * Index - Which Local or Arg to get
302 * object - Object to be inserted into the stack entry 302 * Object - Object to be inserted into the stack entry
303 * walk_state - Current walk state object 303 * walk_state - Current walk state object
304 * 304 *
305 * RETURN: Status 305 * RETURN: Status
@@ -336,7 +336,7 @@ acpi_ds_method_data_set_value(u8 type,
336 * Increment ref count so object can't be deleted while installed. 336 * Increment ref count so object can't be deleted while installed.
337 * NOTE: We do not copy the object in order to preserve the call by 337 * NOTE: We do not copy the object in order to preserve the call by
338 * reference semantics of ACPI Control Method invocation. 338 * reference semantics of ACPI Control Method invocation.
339 * (See ACPI Specification 2.0C) 339 * (See ACPI Specification 2.0_c)
340 */ 340 */
341 acpi_ut_add_reference(object); 341 acpi_ut_add_reference(object);
342 342
@@ -350,9 +350,9 @@ acpi_ds_method_data_set_value(u8 type,
350 * 350 *
351 * FUNCTION: acpi_ds_method_data_get_value 351 * FUNCTION: acpi_ds_method_data_get_value
352 * 352 *
353 * PARAMETERS: type - Either ACPI_REFCLASS_LOCAL or 353 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
354 * ACPI_REFCLASS_ARG 354 * ACPI_REFCLASS_ARG
355 * index - Which localVar or argument to get 355 * Index - Which local_var or argument to get
356 * walk_state - Current walk state object 356 * walk_state - Current walk state object
357 * dest_desc - Where Arg or Local value is returned 357 * dest_desc - Where Arg or Local value is returned
358 * 358 *
@@ -401,7 +401,7 @@ acpi_ds_method_data_get_value(u8 type,
401 * This means that either 1) The expected argument was 401 * This means that either 1) The expected argument was
402 * not passed to the method, or 2) A local variable 402 * not passed to the method, or 2) A local variable
403 * was referenced by the method (via the ASL) 403 * was referenced by the method (via the ASL)
404 * before it was initialized. Either case is an error. 404 * before it was initialized. Either case is an error.
405 */ 405 */
406 406
407 /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ 407 /* If slack enabled, init the local_x/arg_x to an Integer of value zero */
@@ -458,14 +458,14 @@ acpi_ds_method_data_get_value(u8 type,
458 * 458 *
459 * FUNCTION: acpi_ds_method_data_delete_value 459 * FUNCTION: acpi_ds_method_data_delete_value
460 * 460 *
461 * PARAMETERS: type - Either ACPI_REFCLASS_LOCAL or 461 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
462 * ACPI_REFCLASS_ARG 462 * ACPI_REFCLASS_ARG
463 * index - Which localVar or argument to delete 463 * Index - Which local_var or argument to delete
464 * walk_state - Current walk state object 464 * walk_state - Current walk state object
465 * 465 *
466 * RETURN: None 466 * RETURN: None
467 * 467 *
468 * DESCRIPTION: Delete the entry at Opcode:Index. Inserts 468 * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
469 * a null into the stack slot after the object is deleted. 469 * a null into the stack slot after the object is deleted.
470 * 470 *
471 ******************************************************************************/ 471 ******************************************************************************/
@@ -515,15 +515,15 @@ acpi_ds_method_data_delete_value(u8 type,
515 * 515 *
516 * FUNCTION: acpi_ds_store_object_to_local 516 * FUNCTION: acpi_ds_store_object_to_local
517 * 517 *
518 * PARAMETERS: type - Either ACPI_REFCLASS_LOCAL or 518 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
519 * ACPI_REFCLASS_ARG 519 * ACPI_REFCLASS_ARG
520 * index - Which Local or Arg to set 520 * Index - Which Local or Arg to set
521 * obj_desc - Value to be stored 521 * obj_desc - Value to be stored
522 * walk_state - Current walk state 522 * walk_state - Current walk state
523 * 523 *
524 * RETURN: Status 524 * RETURN: Status
525 * 525 *
526 * DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed 526 * DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed
527 * as the new value for the Arg or Local and the reference count 527 * as the new value for the Arg or Local and the reference count
528 * for obj_desc is incremented. 528 * for obj_desc is incremented.
529 * 529 *
@@ -566,7 +566,7 @@ acpi_ds_store_object_to_local(u8 type,
566 566
567 /* 567 /*
568 * If the reference count on the object is more than one, we must 568 * If the reference count on the object is more than one, we must
569 * take a copy of the object before we store. A reference count 569 * take a copy of the object before we store. A reference count
570 * of exactly 1 means that the object was just created during the 570 * of exactly 1 means that the object was just created during the
571 * evaluation of an expression, and we can safely use it since it 571 * evaluation of an expression, and we can safely use it since it
572 * is not used anywhere else. 572 * is not used anywhere else.
@@ -670,8 +670,8 @@ acpi_ds_store_object_to_local(u8 type,
670 * 670 *
671 * FUNCTION: acpi_ds_method_data_get_type 671 * FUNCTION: acpi_ds_method_data_get_type
672 * 672 *
673 * PARAMETERS: opcode - Either AML_LOCAL_OP or AML_ARG_OP 673 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
674 * index - Which Local or Arg whose type to get 674 * Index - Which Local or Arg whose type to get
675 * walk_state - Current walk state object 675 * walk_state - Current walk state object
676 * 676 *
677 * RETURN: Data type of current value of the selected Arg or Local 677 * RETURN: Data type of current value of the selected Arg or Local
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index c9f15d3a368..f42e17e5c25 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -64,7 +64,7 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
64 * FUNCTION: acpi_ds_build_internal_object 64 * FUNCTION: acpi_ds_build_internal_object
65 * 65 *
66 * PARAMETERS: walk_state - Current walk state 66 * PARAMETERS: walk_state - Current walk state
67 * op - Parser object to be translated 67 * Op - Parser object to be translated
68 * obj_desc_ptr - Where the ACPI internal object is returned 68 * obj_desc_ptr - Where the ACPI internal object is returned
69 * 69 *
70 * RETURN: Status 70 * RETURN: Status
@@ -250,7 +250,7 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
250 * FUNCTION: acpi_ds_build_internal_buffer_obj 250 * FUNCTION: acpi_ds_build_internal_buffer_obj
251 * 251 *
252 * PARAMETERS: walk_state - Current walk state 252 * PARAMETERS: walk_state - Current walk state
253 * op - Parser object to be translated 253 * Op - Parser object to be translated
254 * buffer_length - Length of the buffer 254 * buffer_length - Length of the buffer
255 * obj_desc_ptr - Where the ACPI internal object is returned 255 * obj_desc_ptr - Where the ACPI internal object is returned
256 * 256 *
@@ -293,7 +293,7 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
293 293
294 /* 294 /*
295 * Second arg is the buffer data (optional) byte_list can be either 295 * Second arg is the buffer data (optional) byte_list can be either
296 * individual bytes or a string initializer. In either case, a 296 * individual bytes or a string initializer. In either case, a
297 * byte_list appears in the AML. 297 * byte_list appears in the AML.
298 */ 298 */
299 arg = op->common.value.arg; /* skip first arg */ 299 arg = op->common.value.arg; /* skip first arg */
@@ -354,7 +354,7 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
354 * FUNCTION: acpi_ds_build_internal_package_obj 354 * FUNCTION: acpi_ds_build_internal_package_obj
355 * 355 *
356 * PARAMETERS: walk_state - Current walk state 356 * PARAMETERS: walk_state - Current walk state
357 * op - Parser object to be translated 357 * Op - Parser object to be translated
358 * element_count - Number of elements in the package - this is 358 * element_count - Number of elements in the package - this is
359 * the num_elements argument to Package() 359 * the num_elements argument to Package()
360 * obj_desc_ptr - Where the ACPI internal object is returned 360 * obj_desc_ptr - Where the ACPI internal object is returned
@@ -547,8 +547,8 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
547 * FUNCTION: acpi_ds_create_node 547 * FUNCTION: acpi_ds_create_node
548 * 548 *
549 * PARAMETERS: walk_state - Current walk state 549 * PARAMETERS: walk_state - Current walk state
550 * node - NS Node to be initialized 550 * Node - NS Node to be initialized
551 * op - Parser object to be translated 551 * Op - Parser object to be translated
552 * 552 *
553 * RETURN: Status 553 * RETURN: Status
554 * 554 *
@@ -568,7 +568,7 @@ acpi_ds_create_node(struct acpi_walk_state *walk_state,
568 568
569 /* 569 /*
570 * Because of the execution pass through the non-control-method 570 * Because of the execution pass through the non-control-method
571 * parts of the table, we can arrive here twice. Only init 571 * parts of the table, we can arrive here twice. Only init
572 * the named object node the first time through 572 * the named object node the first time through
573 */ 573 */
574 if (acpi_ns_get_attached_object(node)) { 574 if (acpi_ns_get_attached_object(node)) {
@@ -611,14 +611,14 @@ acpi_ds_create_node(struct acpi_walk_state *walk_state,
611 * FUNCTION: acpi_ds_init_object_from_op 611 * FUNCTION: acpi_ds_init_object_from_op
612 * 612 *
613 * PARAMETERS: walk_state - Current walk state 613 * PARAMETERS: walk_state - Current walk state
614 * op - Parser op used to init the internal object 614 * Op - Parser op used to init the internal object
615 * opcode - AML opcode associated with the object 615 * Opcode - AML opcode associated with the object
616 * ret_obj_desc - Namespace object to be initialized 616 * ret_obj_desc - Namespace object to be initialized
617 * 617 *
618 * RETURN: Status 618 * RETURN: Status
619 * 619 *
620 * DESCRIPTION: Initialize a namespace object from a parser Op and its 620 * DESCRIPTION: Initialize a namespace object from a parser Op and its
621 * associated arguments. The namespace object is a more compact 621 * associated arguments. The namespace object is a more compact
622 * representation of the Op and its arguments. 622 * representation of the Op and its arguments.
623 * 623 *
624 ******************************************************************************/ 624 ******************************************************************************/
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index d09c6b4bab2..c627a288e02 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -1,11 +1,11 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: dsopcode - Dispatcher support for regions and fields 3 * Module Name: dsopcode - Dispatcher suport for regions and fields
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -286,7 +286,7 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
286 * FUNCTION: acpi_ds_eval_buffer_field_operands 286 * FUNCTION: acpi_ds_eval_buffer_field_operands
287 * 287 *
288 * PARAMETERS: walk_state - Current walk 288 * PARAMETERS: walk_state - Current walk
289 * op - A valid buffer_field Op object 289 * Op - A valid buffer_field Op object
290 * 290 *
291 * RETURN: Status 291 * RETURN: Status
292 * 292 *
@@ -370,7 +370,7 @@ acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
370 * FUNCTION: acpi_ds_eval_region_operands 370 * FUNCTION: acpi_ds_eval_region_operands
371 * 371 *
372 * PARAMETERS: walk_state - Current walk 372 * PARAMETERS: walk_state - Current walk
373 * op - A valid region Op object 373 * Op - A valid region Op object
374 * 374 *
375 * RETURN: Status 375 * RETURN: Status
376 * 376 *
@@ -397,7 +397,7 @@ acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
397 */ 397 */
398 node = op->common.node; 398 node = op->common.node;
399 399
400 /* next_op points to the op that holds the space_ID */ 400 /* next_op points to the op that holds the space_iD */
401 401
402 next_op = op->common.value.arg; 402 next_op = op->common.value.arg;
403 403
@@ -461,7 +461,7 @@ acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
461 * FUNCTION: acpi_ds_eval_table_region_operands 461 * FUNCTION: acpi_ds_eval_table_region_operands
462 * 462 *
463 * PARAMETERS: walk_state - Current walk 463 * PARAMETERS: walk_state - Current walk
464 * op - A valid region Op object 464 * Op - A valid region Op object
465 * 465 *
466 * RETURN: Status 466 * RETURN: Status
467 * 467 *
@@ -560,7 +560,7 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
560 * FUNCTION: acpi_ds_eval_data_object_operands 560 * FUNCTION: acpi_ds_eval_data_object_operands
561 * 561 *
562 * PARAMETERS: walk_state - Current walk 562 * PARAMETERS: walk_state - Current walk
563 * op - A valid data_object Op object 563 * Op - A valid data_object Op object
564 * obj_desc - data_object 564 * obj_desc - data_object
565 * 565 *
566 * RETURN: Status 566 * RETURN: Status
@@ -649,8 +649,7 @@ acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
649 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && 649 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
650 (op->common.parent->common.aml_opcode != 650 (op->common.parent->common.aml_opcode !=
651 AML_VAR_PACKAGE_OP) 651 AML_VAR_PACKAGE_OP)
652 && (op->common.parent->common.aml_opcode != 652 && (op->common.parent->common.aml_opcode != AML_NAME_OP))) {
653 AML_NAME_OP))) {
654 walk_state->result_obj = obj_desc; 653 walk_state->result_obj = obj_desc;
655 } 654 }
656 } 655 }
@@ -663,7 +662,7 @@ acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
663 * FUNCTION: acpi_ds_eval_bank_field_operands 662 * FUNCTION: acpi_ds_eval_bank_field_operands
664 * 663 *
665 * PARAMETERS: walk_state - Current walk 664 * PARAMETERS: walk_state - Current walk
666 * op - A valid bank_field Op object 665 * Op - A valid bank_field Op object
667 * 666 *
668 * RETURN: Status 667 * RETURN: Status
669 * 668 *
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index afeb99f4948..2c477ce172f 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -61,7 +61,7 @@ ACPI_MODULE_NAME("dsutils")
61 * 61 *
62 * RETURN: None. 62 * RETURN: None.
63 * 63 *
64 * DESCRIPTION: Clear and remove a reference on an implicit return value. Used 64 * DESCRIPTION: Clear and remove a reference on an implicit return value. Used
65 * to delete "stale" return values (if enabled, the return value 65 * to delete "stale" return values (if enabled, the return value
66 * from every operator is saved at least momentarily, in case the 66 * from every operator is saved at least momentarily, in case the
67 * parent method exits.) 67 * parent method exits.)
@@ -107,7 +107,7 @@ void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state)
107 * 107 *
108 * DESCRIPTION: Implements the optional "implicit return". We save the result 108 * DESCRIPTION: Implements the optional "implicit return". We save the result
109 * of every ASL operator and control method invocation in case the 109 * of every ASL operator and control method invocation in case the
110 * parent method exit. Before storing a new return value, we 110 * parent method exit. Before storing a new return value, we
111 * delete the previous return value. 111 * delete the previous return value.
112 * 112 *
113 ******************************************************************************/ 113 ******************************************************************************/
@@ -157,7 +157,7 @@ acpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
157 * 157 *
158 * FUNCTION: acpi_ds_is_result_used 158 * FUNCTION: acpi_ds_is_result_used
159 * 159 *
160 * PARAMETERS: op - Current Op 160 * PARAMETERS: Op - Current Op
161 * walk_state - Current State 161 * walk_state - Current State
162 * 162 *
163 * RETURN: TRUE if result is used, FALSE otherwise 163 * RETURN: TRUE if result is used, FALSE otherwise
@@ -198,7 +198,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
198 * 198 *
199 * If there is no parent, or the parent is a scope_op, we are executing 199 * If there is no parent, or the parent is a scope_op, we are executing
200 * at the method level. An executing method typically has no parent, 200 * at the method level. An executing method typically has no parent,
201 * since each method is parsed separately. A method invoked externally 201 * since each method is parsed separately. A method invoked externally
202 * via execute_control_method has a scope_op as the parent. 202 * via execute_control_method has a scope_op as the parent.
203 */ 203 */
204 if ((!op->common.parent) || 204 if ((!op->common.parent) ||
@@ -223,7 +223,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
223 } 223 }
224 224
225 /* 225 /*
226 * Decide what to do with the result based on the parent. If 226 * Decide what to do with the result based on the parent. If
227 * the parent opcode will not use the result, delete the object. 227 * the parent opcode will not use the result, delete the object.
228 * Otherwise leave it as is, it will be deleted when it is used 228 * Otherwise leave it as is, it will be deleted when it is used
229 * as an operand later. 229 * as an operand later.
@@ -266,7 +266,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
266 266
267 /* 267 /*
268 * These opcodes allow term_arg(s) as operands and therefore 268 * These opcodes allow term_arg(s) as operands and therefore
269 * the operands can be method calls. The result is used. 269 * the operands can be method calls. The result is used.
270 */ 270 */
271 goto result_used; 271 goto result_used;
272 272
@@ -284,7 +284,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
284 AML_BANK_FIELD_OP)) { 284 AML_BANK_FIELD_OP)) {
285 /* 285 /*
286 * These opcodes allow term_arg(s) as operands and therefore 286 * These opcodes allow term_arg(s) as operands and therefore
287 * the operands can be method calls. The result is used. 287 * the operands can be method calls. The result is used.
288 */ 288 */
289 goto result_used; 289 goto result_used;
290 } 290 }
@@ -323,15 +323,15 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
323 * 323 *
324 * FUNCTION: acpi_ds_delete_result_if_not_used 324 * FUNCTION: acpi_ds_delete_result_if_not_used
325 * 325 *
326 * PARAMETERS: op - Current parse Op 326 * PARAMETERS: Op - Current parse Op
327 * result_obj - Result of the operation 327 * result_obj - Result of the operation
328 * walk_state - Current state 328 * walk_state - Current state
329 * 329 *
330 * RETURN: Status 330 * RETURN: Status
331 * 331 *
332 * DESCRIPTION: Used after interpretation of an opcode. If there is an internal 332 * DESCRIPTION: Used after interpretation of an opcode. If there is an internal
333 * result descriptor, check if the parent opcode will actually use 333 * result descriptor, check if the parent opcode will actually use
334 * this result. If not, delete the result now so that it will 334 * this result. If not, delete the result now so that it will
335 * not become orphaned. 335 * not become orphaned.
336 * 336 *
337 ******************************************************************************/ 337 ******************************************************************************/
@@ -376,7 +376,7 @@ acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
376 * 376 *
377 * RETURN: Status 377 * RETURN: Status
378 * 378 *
379 * DESCRIPTION: Resolve all operands to their values. Used to prepare 379 * DESCRIPTION: Resolve all operands to their values. Used to prepare
380 * arguments to a control method invocation (a call from one 380 * arguments to a control method invocation (a call from one
381 * method to another.) 381 * method to another.)
382 * 382 *
@@ -391,7 +391,7 @@ acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state)
391 391
392 /* 392 /*
393 * Attempt to resolve each of the valid operands 393 * Attempt to resolve each of the valid operands
394 * Method arguments are passed by reference, not by value. This means 394 * Method arguments are passed by reference, not by value. This means
395 * that the actual objects are passed, not copies of the objects. 395 * that the actual objects are passed, not copies of the objects.
396 */ 396 */
397 for (i = 0; i < walk_state->num_operands; i++) { 397 for (i = 0; i < walk_state->num_operands; i++) {
@@ -445,13 +445,13 @@ void acpi_ds_clear_operands(struct acpi_walk_state *walk_state)
445 * FUNCTION: acpi_ds_create_operand 445 * FUNCTION: acpi_ds_create_operand
446 * 446 *
447 * PARAMETERS: walk_state - Current walk state 447 * PARAMETERS: walk_state - Current walk state
448 * arg - Parse object for the argument 448 * Arg - Parse object for the argument
449 * arg_index - Which argument (zero based) 449 * arg_index - Which argument (zero based)
450 * 450 *
451 * RETURN: Status 451 * RETURN: Status
452 * 452 *
453 * DESCRIPTION: Translate a parse tree object that is an argument to an AML 453 * DESCRIPTION: Translate a parse tree object that is an argument to an AML
454 * opcode to the equivalent interpreter object. This may include 454 * opcode to the equivalent interpreter object. This may include
455 * looking up a name or entering a new name into the internal 455 * looking up a name or entering a new name into the internal
456 * namespace. 456 * namespace.
457 * 457 *
@@ -496,9 +496,9 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
496 /* 496 /*
497 * Special handling for buffer_field declarations. This is a deferred 497 * Special handling for buffer_field declarations. This is a deferred
498 * opcode that unfortunately defines the field name as the last 498 * opcode that unfortunately defines the field name as the last
499 * parameter instead of the first. We get here when we are performing 499 * parameter instead of the first. We get here when we are performing
500 * the deferred execution, so the actual name of the field is already 500 * the deferred execution, so the actual name of the field is already
501 * in the namespace. We don't want to attempt to look it up again 501 * in the namespace. We don't want to attempt to look it up again
502 * because we may be executing in a different scope than where the 502 * because we may be executing in a different scope than where the
503 * actual opcode exists. 503 * actual opcode exists.
504 */ 504 */
@@ -560,8 +560,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
560 * indicate this to the interpreter, set the 560 * indicate this to the interpreter, set the
561 * object to the root 561 * object to the root
562 */ 562 */
563 obj_desc = 563 obj_desc = ACPI_CAST_PTR(union
564 ACPI_CAST_PTR(union
565 acpi_operand_object, 564 acpi_operand_object,
566 acpi_gbl_root_node); 565 acpi_gbl_root_node);
567 status = AE_OK; 566 status = AE_OK;
@@ -605,8 +604,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
605 /* 604 /*
606 * If the name is null, this means that this is an 605 * If the name is null, this means that this is an
607 * optional result parameter that was not specified 606 * optional result parameter that was not specified
608 * in the original ASL. Create a Zero Constant for a 607 * in the original ASL. Create a Zero Constant for a
609 * placeholder. (Store to a constant is a Noop.) 608 * placeholder. (Store to a constant is a Noop.)
610 */ 609 */
611 opcode = AML_ZERO_OP; /* Has no arguments! */ 610 opcode = AML_ZERO_OP; /* Has no arguments! */
612 611
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index 58593931be9..fe40e4c6554 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -57,7 +57,7 @@ ACPI_MODULE_NAME("dswexec")
57/* 57/*
58 * Dispatch table for opcode classes 58 * Dispatch table for opcode classes
59 */ 59 */
60static acpi_execute_op acpi_gbl_op_type_dispatch[] = { 60static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch[] = {
61 acpi_ex_opcode_0A_0T_1R, 61 acpi_ex_opcode_0A_0T_1R,
62 acpi_ex_opcode_1A_0T_0R, 62 acpi_ex_opcode_1A_0T_0R,
63 acpi_ex_opcode_1A_0T_1R, 63 acpi_ex_opcode_1A_0T_1R,
@@ -204,7 +204,7 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
204 * RETURN: Status 204 * RETURN: Status
205 * 205 *
206 * DESCRIPTION: Descending callback used during the execution of control 206 * DESCRIPTION: Descending callback used during the execution of control
207 * methods. This is where most operators and operands are 207 * methods. This is where most operators and operands are
208 * dispatched to the interpreter. 208 * dispatched to the interpreter.
209 * 209 *
210 ****************************************************************************/ 210 ****************************************************************************/
@@ -297,7 +297,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
297 if (walk_state->walk_type & ACPI_WALK_METHOD) { 297 if (walk_state->walk_type & ACPI_WALK_METHOD) {
298 /* 298 /*
299 * Found a named object declaration during method execution; 299 * Found a named object declaration during method execution;
300 * we must enter this object into the namespace. The created 300 * we must enter this object into the namespace. The created
301 * object is temporary and will be deleted upon completion of 301 * object is temporary and will be deleted upon completion of
302 * the execution of this method. 302 * the execution of this method.
303 * 303 *
@@ -348,7 +348,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
348 * RETURN: Status 348 * RETURN: Status
349 * 349 *
350 * DESCRIPTION: Ascending callback used during the execution of control 350 * DESCRIPTION: Ascending callback used during the execution of control
351 * methods. The only thing we really need to do here is to 351 * methods. The only thing we really need to do here is to
352 * notice the beginning of IF, ELSE, and WHILE blocks. 352 * notice the beginning of IF, ELSE, and WHILE blocks.
353 * 353 *
354 ****************************************************************************/ 354 ****************************************************************************/
@@ -432,7 +432,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
432 if (ACPI_SUCCESS(status)) { 432 if (ACPI_SUCCESS(status)) {
433 /* 433 /*
434 * Dispatch the request to the appropriate interpreter handler 434 * Dispatch the request to the appropriate interpreter handler
435 * routine. There is one routine per opcode "type" based upon the 435 * routine. There is one routine per opcode "type" based upon the
436 * number of opcode arguments and return type. 436 * number of opcode arguments and return type.
437 */ 437 */
438 status = 438 status =
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 557510084c7..324acec1179 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -230,20 +230,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
230 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 230 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
231 break; 231 break;
232 232
233 case ACPI_TYPE_METHOD:
234
235 /*
236 * Allow scope change to root during execution of module-level
237 * code. Root is typed METHOD during this time.
238 */
239 if ((node == acpi_gbl_root_node) &&
240 (walk_state->
241 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
242 break;
243 }
244
245 /*lint -fallthrough */
246
247 default: 233 default:
248 234
249 /* All other types are an error */ 235 /* All other types are an error */
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
index 37983574835..976318138c5 100644
--- a/drivers/acpi/acpica/dswload2.c
+++ b/drivers/acpi/acpica/dswload2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -230,20 +230,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
230 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 230 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
231 break; 231 break;
232 232
233 case ACPI_TYPE_METHOD:
234
235 /*
236 * Allow scope change to root during execution of module-level
237 * code. Root is typed METHOD during this time.
238 */
239 if ((node == acpi_gbl_root_node) &&
240 (walk_state->
241 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
242 break;
243 }
244
245 /*lint -fallthrough */
246
247 default: 233 default:
248 234
249 /* All other types are an error */ 235 /* All other types are an error */
@@ -254,7 +240,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
254 acpi_ut_get_type_name(node->type), 240 acpi_ut_get_type_name(node->type),
255 acpi_ut_get_node_name(node))); 241 acpi_ut_get_node_name(node)));
256 242
257 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 243 return (AE_AML_OPERAND_TYPE);
258 } 244 }
259 break; 245 break;
260 246
@@ -602,7 +588,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
602 region_space, 588 region_space,
603 walk_state); 589 walk_state);
604 if (ACPI_FAILURE(status)) { 590 if (ACPI_FAILURE(status)) {
605 return_ACPI_STATUS(status); 591 return (status);
606 } 592 }
607 593
608 acpi_ex_exit_interpreter(); 594 acpi_ex_exit_interpreter();
diff --git a/drivers/acpi/acpica/dswscope.c b/drivers/acpi/acpica/dswscope.c
index f6c4295470a..76a661fc1e0 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -85,8 +85,8 @@ void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state)
85 * 85 *
86 * FUNCTION: acpi_ds_scope_stack_push 86 * FUNCTION: acpi_ds_scope_stack_push
87 * 87 *
88 * PARAMETERS: node - Name to be made current 88 * PARAMETERS: Node - Name to be made current
89 * type - Type of frame being pushed 89 * Type - Type of frame being pushed
90 * walk_state - Current state 90 * walk_state - Current state
91 * 91 *
92 * RETURN: Status 92 * RETURN: Status
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
index 3e65a15a735..a6c374ef991 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,15 +51,14 @@
51ACPI_MODULE_NAME("dswstate") 51ACPI_MODULE_NAME("dswstate")
52 52
53 /* Local prototypes */ 53 /* Local prototypes */
54static acpi_status 54static acpi_status acpi_ds_result_stack_push(struct acpi_walk_state *ws);
55acpi_ds_result_stack_push(struct acpi_walk_state *walk_state); 55static acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *ws);
56static acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state);
57 56
58/******************************************************************************* 57/*******************************************************************************
59 * 58 *
60 * FUNCTION: acpi_ds_result_pop 59 * FUNCTION: acpi_ds_result_pop
61 * 60 *
62 * PARAMETERS: object - Where to return the popped object 61 * PARAMETERS: Object - Where to return the popped object
63 * walk_state - Current Walk state 62 * walk_state - Current Walk state
64 * 63 *
65 * RETURN: Status 64 * RETURN: Status
@@ -133,7 +132,7 @@ acpi_ds_result_pop(union acpi_operand_object **object,
133 * 132 *
134 * FUNCTION: acpi_ds_result_push 133 * FUNCTION: acpi_ds_result_push
135 * 134 *
136 * PARAMETERS: object - Where to return the popped object 135 * PARAMETERS: Object - Where to return the popped object
137 * walk_state - Current Walk state 136 * walk_state - Current Walk state
138 * 137 *
139 * RETURN: Status 138 * RETURN: Status
@@ -297,7 +296,7 @@ static acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state)
297 * 296 *
298 * FUNCTION: acpi_ds_obj_stack_push 297 * FUNCTION: acpi_ds_obj_stack_push
299 * 298 *
300 * PARAMETERS: object - Object to push 299 * PARAMETERS: Object - Object to push
301 * walk_state - Current Walk state 300 * walk_state - Current Walk state
302 * 301 *
303 * RETURN: Status 302 * RETURN: Status
@@ -348,7 +347,7 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state)
348 * 347 *
349 * RETURN: Status 348 * RETURN: Status
350 * 349 *
351 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT 350 * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
352 * deleted by this routine. 351 * deleted by this routine.
353 * 352 *
354 ******************************************************************************/ 353 ******************************************************************************/
@@ -434,7 +433,7 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
434 * 433 *
435 * FUNCTION: acpi_ds_get_current_walk_state 434 * FUNCTION: acpi_ds_get_current_walk_state
436 * 435 *
437 * PARAMETERS: thread - Get current active state for this Thread 436 * PARAMETERS: Thread - Get current active state for this Thread
438 * 437 *
439 * RETURN: Pointer to the current walk state 438 * RETURN: Pointer to the current walk state
440 * 439 *
@@ -463,7 +462,7 @@ struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
463 * FUNCTION: acpi_ds_push_walk_state 462 * FUNCTION: acpi_ds_push_walk_state
464 * 463 *
465 * PARAMETERS: walk_state - State to push 464 * PARAMETERS: walk_state - State to push
466 * thread - Thread state object 465 * Thread - Thread state object
467 * 466 *
468 * RETURN: None 467 * RETURN: None
469 * 468 *
@@ -487,12 +486,12 @@ acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
487 * 486 *
488 * FUNCTION: acpi_ds_pop_walk_state 487 * FUNCTION: acpi_ds_pop_walk_state
489 * 488 *
490 * PARAMETERS: thread - Current thread state 489 * PARAMETERS: Thread - Current thread state
491 * 490 *
492 * RETURN: A walk_state object popped from the thread's stack 491 * RETURN: A walk_state object popped from the thread's stack
493 * 492 *
494 * DESCRIPTION: Remove and return the walkstate object that is at the head of 493 * DESCRIPTION: Remove and return the walkstate object that is at the head of
495 * the walk stack for the given walk list. NULL indicates that 494 * the walk stack for the given walk list. NULL indicates that
496 * the list is empty. 495 * the list is empty.
497 * 496 *
498 ******************************************************************************/ 497 ******************************************************************************/
@@ -526,23 +525,20 @@ struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
526 * FUNCTION: acpi_ds_create_walk_state 525 * FUNCTION: acpi_ds_create_walk_state
527 * 526 *
528 * PARAMETERS: owner_id - ID for object creation 527 * PARAMETERS: owner_id - ID for object creation
529 * origin - Starting point for this walk 528 * Origin - Starting point for this walk
530 * method_desc - Method object 529 * method_desc - Method object
531 * thread - Current thread state 530 * Thread - Current thread state
532 * 531 *
533 * RETURN: Pointer to the new walk state. 532 * RETURN: Pointer to the new walk state.
534 * 533 *
535 * DESCRIPTION: Allocate and initialize a new walk state. The current walk 534 * DESCRIPTION: Allocate and initialize a new walk state. The current walk
536 * state is set to this new state. 535 * state is set to this new state.
537 * 536 *
538 ******************************************************************************/ 537 ******************************************************************************/
539 538
540struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, 539struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, union acpi_parse_object
541 union acpi_parse_object 540 *origin, union acpi_operand_object
542 *origin, 541 *method_desc, struct acpi_thread_state
543 union acpi_operand_object
544 *method_desc,
545 struct acpi_thread_state
546 *thread) 542 *thread)
547{ 543{
548 struct acpi_walk_state *walk_state; 544 struct acpi_walk_state *walk_state;
@@ -582,11 +578,11 @@ struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
582 * FUNCTION: acpi_ds_init_aml_walk 578 * FUNCTION: acpi_ds_init_aml_walk
583 * 579 *
584 * PARAMETERS: walk_state - New state to be initialized 580 * PARAMETERS: walk_state - New state to be initialized
585 * op - Current parse op 581 * Op - Current parse op
586 * method_node - Control method NS node, if any 582 * method_node - Control method NS node, if any
587 * aml_start - Start of AML 583 * aml_start - Start of AML
588 * aml_length - Length of AML 584 * aml_length - Length of AML
589 * info - Method info block (params, etc.) 585 * Info - Method info block (params, etc.)
590 * pass_number - 1, 2, or 3 586 * pass_number - 1, 2, or 3
591 * 587 *
592 * RETURN: Status 588 * RETURN: Status
@@ -657,7 +653,7 @@ acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
657 /* 653 /*
658 * Setup the current scope. 654 * Setup the current scope.
659 * Find a Named Op that has a namespace node associated with it. 655 * Find a Named Op that has a namespace node associated with it.
660 * search upwards from this Op. Current scope is the first 656 * search upwards from this Op. Current scope is the first
661 * Op with a namespace node. 657 * Op with a namespace node.
662 */ 658 */
663 extra_op = parser_state->start_op; 659 extra_op = parser_state->start_op;
@@ -708,13 +704,13 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
708 ACPI_FUNCTION_TRACE_PTR(ds_delete_walk_state, walk_state); 704 ACPI_FUNCTION_TRACE_PTR(ds_delete_walk_state, walk_state);
709 705
710 if (!walk_state) { 706 if (!walk_state) {
711 return_VOID; 707 return;
712 } 708 }
713 709
714 if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) { 710 if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) {
715 ACPI_ERROR((AE_INFO, "%p is not a valid walk state", 711 ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
716 walk_state)); 712 walk_state));
717 return_VOID; 713 return;
718 } 714 }
719 715
720 /* There should not be any open scopes */ 716 /* There should not be any open scopes */
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index d4acfbbe5b2..d458b041e65 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -47,7 +47,7 @@
47 47
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evevent") 49ACPI_MODULE_NAME("evevent")
50#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 50
51/* Local prototypes */ 51/* Local prototypes */
52static acpi_status acpi_ev_fixed_event_initialize(void); 52static acpi_status acpi_ev_fixed_event_initialize(void);
53 53
@@ -71,12 +71,6 @@ acpi_status acpi_ev_initialize_events(void)
71 71
72 ACPI_FUNCTION_TRACE(ev_initialize_events); 72 ACPI_FUNCTION_TRACE(ev_initialize_events);
73 73
74 /* If Hardware Reduced flag is set, there are no fixed events */
75
76 if (acpi_gbl_reduced_hardware) {
77 return_ACPI_STATUS(AE_OK);
78 }
79
80 /* 74 /*
81 * Initialize the Fixed and General Purpose Events. This is done prior to 75 * Initialize the Fixed and General Purpose Events. This is done prior to
82 * enabling SCIs to prevent interrupts from occurring before the handlers 76 * enabling SCIs to prevent interrupts from occurring before the handlers
@@ -117,12 +111,6 @@ acpi_status acpi_ev_install_xrupt_handlers(void)
117 111
118 ACPI_FUNCTION_TRACE(ev_install_xrupt_handlers); 112 ACPI_FUNCTION_TRACE(ev_install_xrupt_handlers);
119 113
120 /* If Hardware Reduced flag is set, there is no ACPI h/w */
121
122 if (acpi_gbl_reduced_hardware) {
123 return_ACPI_STATUS(AE_OK);
124 }
125
126 /* Install the SCI handler */ 114 /* Install the SCI handler */
127 115
128 status = acpi_ev_install_sci_handler(); 116 status = acpi_ev_install_sci_handler();
@@ -251,7 +239,7 @@ u32 acpi_ev_fixed_event_detect(void)
251 * 239 *
252 * FUNCTION: acpi_ev_fixed_event_dispatch 240 * FUNCTION: acpi_ev_fixed_event_dispatch
253 * 241 *
254 * PARAMETERS: event - Event type 242 * PARAMETERS: Event - Event type
255 * 243 *
256 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED 244 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
257 * 245 *
@@ -291,5 +279,3 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
291 return ((acpi_gbl_fixed_event_handlers[event]. 279 return ((acpi_gbl_fixed_event_handlers[event].
292 handler) (acpi_gbl_fixed_event_handlers[event].context)); 280 handler) (acpi_gbl_fixed_event_handlers[event].context));
293} 281}
294
295#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evglock.c b/drivers/acpi/acpica/evglock.c
index af14a713763..56a562a1e5d 100644
--- a/drivers/acpi/acpica/evglock.c
+++ b/drivers/acpi/acpica/evglock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evglock") 50ACPI_MODULE_NAME("evglock")
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51
52/* Local prototypes */ 52/* Local prototypes */
53static u32 acpi_ev_global_lock_handler(void *context); 53static u32 acpi_ev_global_lock_handler(void *context);
54 54
@@ -70,12 +70,6 @@ acpi_status acpi_ev_init_global_lock_handler(void)
70 70
71 ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); 71 ACPI_FUNCTION_TRACE(ev_init_global_lock_handler);
72 72
73 /* If Hardware Reduced flag is set, there is no global lock */
74
75 if (acpi_gbl_reduced_hardware) {
76 return_ACPI_STATUS(AE_OK);
77 }
78
79 /* Attempt installation of the global lock handler */ 73 /* Attempt installation of the global lock handler */
80 74
81 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, 75 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
@@ -135,7 +129,7 @@ acpi_status acpi_ev_remove_global_lock_handler(void)
135 * 129 *
136 * FUNCTION: acpi_ev_global_lock_handler 130 * FUNCTION: acpi_ev_global_lock_handler
137 * 131 *
138 * PARAMETERS: context - From thread interface, not used 132 * PARAMETERS: Context - From thread interface, not used
139 * 133 *
140 * RETURN: ACPI_INTERRUPT_HANDLED 134 * RETURN: ACPI_INTERRUPT_HANDLED
141 * 135 *
@@ -182,7 +176,7 @@ static u32 acpi_ev_global_lock_handler(void *context)
182 * 176 *
183 * FUNCTION: acpi_ev_acquire_global_lock 177 * FUNCTION: acpi_ev_acquire_global_lock
184 * 178 *
185 * PARAMETERS: timeout - Max time to wait for the lock, in millisec. 179 * PARAMETERS: Timeout - Max time to wait for the lock, in millisec.
186 * 180 *
187 * RETURN: Status 181 * RETURN: Status
188 * 182 *
@@ -339,5 +333,3 @@ acpi_status acpi_ev_release_global_lock(void)
339 acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex); 333 acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex);
340 return_ACPI_STATUS(status); 334 return_ACPI_STATUS(status);
341} 335}
342
343#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 36d12057442..65c79add3b1 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evgpe") 50ACPI_MODULE_NAME("evgpe")
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51
52/* Local prototypes */ 52/* Local prototypes */
53static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context); 53static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
54 54
@@ -80,7 +80,8 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info)
80 return_ACPI_STATUS(AE_NOT_EXIST); 80 return_ACPI_STATUS(AE_NOT_EXIST);
81 } 81 }
82 82
83 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info); 83 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
84 gpe_register_info);
84 85
85 /* Clear the run bit up front */ 86 /* Clear the run bit up front */
86 87
@@ -89,8 +90,7 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info)
89 /* Set the mask bit only if there are references to this GPE */ 90 /* Set the mask bit only if there are references to this GPE */
90 91
91 if (gpe_event_info->runtime_count) { 92 if (gpe_event_info->runtime_count) {
92 ACPI_SET_BIT(gpe_register_info->enable_for_run, 93 ACPI_SET_BIT(gpe_register_info->enable_for_run, (u8)register_bit);
93 (u8)register_bit);
94 } 94 }
95 95
96 return_ACPI_STATUS(AE_OK); 96 return_ACPI_STATUS(AE_OK);
@@ -107,7 +107,8 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info)
107 * DESCRIPTION: Clear a GPE of stale events and enable it. 107 * DESCRIPTION: Clear a GPE of stale events and enable it.
108 * 108 *
109 ******************************************************************************/ 109 ******************************************************************************/
110acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) 110acpi_status
111acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
111{ 112{
112 acpi_status status; 113 acpi_status status;
113 114
@@ -131,8 +132,8 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
131 } 132 }
132 133
133 /* Enable the requested GPE */ 134 /* Enable the requested GPE */
134
135 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE); 135 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
136
136 return_ACPI_STATUS(status); 137 return_ACPI_STATUS(status);
137} 138}
138 139
@@ -150,8 +151,7 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
150 * 151 *
151 ******************************************************************************/ 152 ******************************************************************************/
152 153
153acpi_status 154acpi_status acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
154acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
155{ 155{
156 acpi_status status = AE_OK; 156 acpi_status status = AE_OK;
157 157
@@ -192,8 +192,7 @@ acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
192 * 192 *
193 ******************************************************************************/ 193 ******************************************************************************/
194 194
195acpi_status 195acpi_status acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
196acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
197{ 196{
198 acpi_status status = AE_OK; 197 acpi_status status = AE_OK;
199 198
@@ -210,8 +209,7 @@ acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
210 209
211 status = acpi_ev_update_gpe_enable_mask(gpe_event_info); 210 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
212 if (ACPI_SUCCESS(status)) { 211 if (ACPI_SUCCESS(status)) {
213 status = 212 status = acpi_hw_low_set_gpe(gpe_event_info,
214 acpi_hw_low_set_gpe(gpe_event_info,
215 ACPI_GPE_DISABLE); 213 ACPI_GPE_DISABLE);
216 } 214 }
217 215
@@ -309,8 +307,7 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
309 307
310 /* A Non-NULL gpe_device means this is a GPE Block Device */ 308 /* A Non-NULL gpe_device means this is a GPE Block Device */
311 309
312 obj_desc = 310 obj_desc = acpi_ns_get_attached_object((struct acpi_namespace_node *)
313 acpi_ns_get_attached_object((struct acpi_namespace_node *)
314 gpe_device); 311 gpe_device);
315 if (!obj_desc || !obj_desc->device.gpe_block) { 312 if (!obj_desc || !obj_desc->device.gpe_block) {
316 return (NULL); 313 return (NULL);
@@ -382,18 +379,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
382 */ 379 */
383 if (!(gpe_register_info->enable_for_run | 380 if (!(gpe_register_info->enable_for_run |
384 gpe_register_info->enable_for_wake)) { 381 gpe_register_info->enable_for_wake)) {
385 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
386 "Ignore disabled registers for GPE%02X-GPE%02X: "
387 "RunEnable=%02X, WakeEnable=%02X\n",
388 gpe_register_info->
389 base_gpe_number,
390 gpe_register_info->
391 base_gpe_number +
392 (ACPI_GPE_REGISTER_WIDTH - 1),
393 gpe_register_info->
394 enable_for_run,
395 gpe_register_info->
396 enable_for_wake));
397 continue; 382 continue;
398 } 383 }
399 384
@@ -416,14 +401,9 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
416 } 401 }
417 402
418 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, 403 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
419 "Read registers for GPE%02X-GPE%02X: Status=%02X, Enable=%02X, " 404 "Read GPE Register at GPE%02X: Status=%02X, Enable=%02X\n",
420 "RunEnable=%02X, WakeEnable=%02X\n",
421 gpe_register_info->base_gpe_number, 405 gpe_register_info->base_gpe_number,
422 gpe_register_info->base_gpe_number + 406 status_reg, enable_reg));
423 (ACPI_GPE_REGISTER_WIDTH - 1),
424 status_reg, enable_reg,
425 gpe_register_info->enable_for_run,
426 gpe_register_info->enable_for_wake));
427 407
428 /* Check if there is anything active at all in this register */ 408 /* Check if there is anything active at all in this register */
429 409
@@ -486,7 +466,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
486 acpi_status status; 466 acpi_status status;
487 struct acpi_gpe_event_info *local_gpe_event_info; 467 struct acpi_gpe_event_info *local_gpe_event_info;
488 struct acpi_evaluate_info *info; 468 struct acpi_evaluate_info *info;
489 struct acpi_gpe_notify_info *notify; 469 struct acpi_gpe_notify_object *notify_object;
490 470
491 ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method); 471 ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method);
492 472
@@ -537,17 +517,17 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
537 * completes. The notify handlers are NOT invoked synchronously 517 * completes. The notify handlers are NOT invoked synchronously
538 * from this thread -- because handlers may in turn run other 518 * from this thread -- because handlers may in turn run other
539 * control methods. 519 * control methods.
540 *
541 * June 2012: Expand implicit notify mechanism to support
542 * notifies on multiple device objects.
543 */ 520 */
544 notify = local_gpe_event_info->dispatch.notify_list; 521 status = acpi_ev_queue_notify_request(
545 while (ACPI_SUCCESS(status) && notify) { 522 local_gpe_event_info->dispatch.device.node,
546 status = 523 ACPI_NOTIFY_DEVICE_WAKE);
547 acpi_ev_queue_notify_request(notify->device_node, 524
548 ACPI_NOTIFY_DEVICE_WAKE); 525 notify_object = local_gpe_event_info->dispatch.device.next;
549 526 while (ACPI_SUCCESS(status) && notify_object) {
550 notify = notify->next; 527 status = acpi_ev_queue_notify_request(
528 notify_object->node,
529 ACPI_NOTIFY_DEVICE_WAKE);
530 notify_object = notify_object->next;
551 } 531 }
552 532
553 break; 533 break;
@@ -786,5 +766,3 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
786 766
787 return_UINT32(ACPI_INTERRUPT_HANDLED); 767 return_UINT32(ACPI_INTERRUPT_HANDLED);
788} 768}
789
790#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 1571a61a783..ca2c41a5331 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evgpeblk") 50ACPI_MODULE_NAME("evgpeblk")
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51
52/* Local prototypes */ 52/* Local prototypes */
53static acpi_status 53static acpi_status
54acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, 54acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
@@ -318,7 +318,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
318 * FUNCTION: acpi_ev_create_gpe_block 318 * FUNCTION: acpi_ev_create_gpe_block
319 * 319 *
320 * PARAMETERS: gpe_device - Handle to the parent GPE block 320 * PARAMETERS: gpe_device - Handle to the parent GPE block
321 * gpe_block_address - Address and space_ID 321 * gpe_block_address - Address and space_iD
322 * register_count - Number of GPE register pairs in the block 322 * register_count - Number of GPE register pairs in the block
323 * gpe_block_base_number - Starting GPE number for the block 323 * gpe_block_base_number - Starting GPE number for the block
324 * interrupt_number - H/W interrupt for the block 324 * interrupt_number - H/W interrupt for the block
@@ -486,8 +486,7 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
486 if (ACPI_FAILURE(status)) { 486 if (ACPI_FAILURE(status)) {
487 ACPI_EXCEPTION((AE_INFO, status, 487 ACPI_EXCEPTION((AE_INFO, status,
488 "Could not enable GPE 0x%02X", 488 "Could not enable GPE 0x%02X",
489 gpe_index + 489 gpe_index + gpe_block->block_base_number));
490 gpe_block->block_base_number));
491 continue; 490 continue;
492 } 491 }
493 492
@@ -505,5 +504,3 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
505 504
506 return_ACPI_STATUS(AE_OK); 505 return_ACPI_STATUS(AE_OK);
507} 506}
508
509#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index da0add858f8..ce9aa9f9a97 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evgpeinit") 50ACPI_MODULE_NAME("evgpeinit")
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51
52/* 52/*
53 * Note: History of _PRW support in ACPICA 53 * Note: History of _PRW support in ACPICA
54 * 54 *
@@ -440,5 +440,3 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
440 name, gpe_number)); 440 name, gpe_number));
441 return_ACPI_STATUS(AE_OK); 441 return_ACPI_STATUS(AE_OK);
442} 442}
443
444#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c
index 228a0c3b1d4..80a81d0c4a8 100644
--- a/drivers/acpi/acpica/evgpeutil.c
+++ b/drivers/acpi/acpica/evgpeutil.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -48,13 +48,12 @@
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evgpeutil") 49ACPI_MODULE_NAME("evgpeutil")
50 50
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/******************************************************************************* 51/*******************************************************************************
53 * 52 *
54 * FUNCTION: acpi_ev_walk_gpe_list 53 * FUNCTION: acpi_ev_walk_gpe_list
55 * 54 *
56 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block 55 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block
57 * context - Value passed to callback 56 * Context - Value passed to callback
58 * 57 *
59 * RETURN: Status 58 * RETURN: Status
60 * 59 *
@@ -347,8 +346,6 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
347 void *context) 346 void *context)
348{ 347{
349 struct acpi_gpe_event_info *gpe_event_info; 348 struct acpi_gpe_event_info *gpe_event_info;
350 struct acpi_gpe_notify_info *notify;
351 struct acpi_gpe_notify_info *next;
352 u32 i; 349 u32 i;
353 u32 j; 350 u32 j;
354 351
@@ -367,34 +364,13 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
367 364
368 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 365 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
369 ACPI_GPE_DISPATCH_HANDLER) { 366 ACPI_GPE_DISPATCH_HANDLER) {
370
371 /* Delete an installed handler block */
372
373 ACPI_FREE(gpe_event_info->dispatch.handler); 367 ACPI_FREE(gpe_event_info->dispatch.handler);
374 gpe_event_info->dispatch.handler = NULL; 368 gpe_event_info->dispatch.handler = NULL;
375 gpe_event_info->flags &= 369 gpe_event_info->flags &=
376 ~ACPI_GPE_DISPATCH_MASK; 370 ~ACPI_GPE_DISPATCH_MASK;
377 } else
378 if ((gpe_event_info->
379 flags & ACPI_GPE_DISPATCH_MASK) ==
380 ACPI_GPE_DISPATCH_NOTIFY) {
381
382 /* Delete the implicit notification device list */
383
384 notify = gpe_event_info->dispatch.notify_list;
385 while (notify) {
386 next = notify->next;
387 ACPI_FREE(notify);
388 notify = next;
389 }
390 gpe_event_info->dispatch.notify_list = NULL;
391 gpe_event_info->flags &=
392 ~ACPI_GPE_DISPATCH_MASK;
393 } 371 }
394 } 372 }
395 } 373 }
396 374
397 return_ACPI_STATUS(AE_OK); 375 return_ACPI_STATUS(AE_OK);
398} 376}
399
400#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 51f537937c1..d0b33184442 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -56,7 +56,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
56 * 56 *
57 * FUNCTION: acpi_ev_is_notify_object 57 * FUNCTION: acpi_ev_is_notify_object
58 * 58 *
59 * PARAMETERS: node - Node to check 59 * PARAMETERS: Node - Node to check
60 * 60 *
61 * RETURN: TRUE if notifies allowed on this object 61 * RETURN: TRUE if notifies allowed on this object
62 * 62 *
@@ -86,7 +86,7 @@ u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node)
86 * 86 *
87 * FUNCTION: acpi_ev_queue_notify_request 87 * FUNCTION: acpi_ev_queue_notify_request
88 * 88 *
89 * PARAMETERS: node - NS node for the notified object 89 * PARAMETERS: Node - NS node for the notified object
90 * notify_value - Value from the Notify() request 90 * notify_value - Value from the Notify() request
91 * 91 *
92 * RETURN: Status 92 * RETURN: Status
@@ -101,77 +101,99 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
101 u32 notify_value) 101 u32 notify_value)
102{ 102{
103 union acpi_operand_object *obj_desc; 103 union acpi_operand_object *obj_desc;
104 union acpi_operand_object *handler_list_head = NULL; 104 union acpi_operand_object *handler_obj = NULL;
105 union acpi_generic_state *info; 105 union acpi_generic_state *notify_info;
106 u8 handler_list_id = 0;
107 acpi_status status = AE_OK; 106 acpi_status status = AE_OK;
108 107
109 ACPI_FUNCTION_NAME(ev_queue_notify_request); 108 ACPI_FUNCTION_NAME(ev_queue_notify_request);
110 109
111 /* Are Notifies allowed on this object? */ 110 /*
111 * For value 3 (Ejection Request), some device method may need to be run.
112 * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need
113 * to be run.
114 * For value 0x80 (Status Change) on the power button or sleep button,
115 * initiate soft-off or sleep operation?
116 */
117 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
118 "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n",
119 acpi_ut_get_node_name(node), node, notify_value,
120 acpi_ut_get_notify_name(notify_value)));
112 121
113 if (!acpi_ev_is_notify_object(node)) { 122 /* Get the notify object attached to the NS Node */
114 return (AE_TYPE);
115 }
116 123
117 /* Get the correct notify list type (System or Device) */ 124 obj_desc = acpi_ns_get_attached_object(node);
125 if (obj_desc) {
118 126
119 if (notify_value <= ACPI_MAX_SYS_NOTIFY) { 127 /* We have the notify object, Get the right handler */
120 handler_list_id = ACPI_SYSTEM_HANDLER_LIST;
121 } else {
122 handler_list_id = ACPI_DEVICE_HANDLER_LIST;
123 }
124 128
125 /* Get the notify object attached to the namespace Node */ 129 switch (node->type) {
126 130
127 obj_desc = acpi_ns_get_attached_object(node); 131 /* Notify allowed only on these types */
128 if (obj_desc) {
129 132
130 /* We have an attached object, Get the correct handler list */ 133 case ACPI_TYPE_DEVICE:
134 case ACPI_TYPE_THERMAL:
135 case ACPI_TYPE_PROCESSOR:
131 136
132 handler_list_head = 137 if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
133 obj_desc->common_notify.notify_list[handler_list_id]; 138 handler_obj =
134 } 139 obj_desc->common_notify.system_notify;
140 } else {
141 handler_obj =
142 obj_desc->common_notify.device_notify;
143 }
144 break;
135 145
136 /* 146 default:
137 * If there is no notify handler (Global or Local)
138 * for this object, just ignore the notify
139 */
140 if (!acpi_gbl_global_notify[handler_list_id].handler
141 && !handler_list_head) {
142 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
143 "No notify handler for Notify, ignoring (%4.4s, %X) node %p\n",
144 acpi_ut_get_node_name(node), notify_value,
145 node));
146 147
147 return (AE_OK); 148 /* All other types are not supported */
149
150 return (AE_TYPE);
151 }
148 } 152 }
149 153
150 /* Setup notify info and schedule the notify dispatcher */ 154 /*
155 * If there is any handler to run, schedule the dispatcher.
156 * Check for:
157 * 1) Global system notify handler
158 * 2) Global device notify handler
159 * 3) Per-device notify handler
160 */
161 if ((acpi_gbl_system_notify.handler &&
162 (notify_value <= ACPI_MAX_SYS_NOTIFY)) ||
163 (acpi_gbl_device_notify.handler &&
164 (notify_value > ACPI_MAX_SYS_NOTIFY)) || handler_obj) {
165 notify_info = acpi_ut_create_generic_state();
166 if (!notify_info) {
167 return (AE_NO_MEMORY);
168 }
151 169
152 info = acpi_ut_create_generic_state(); 170 if (!handler_obj) {
153 if (!info) { 171 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
154 return (AE_NO_MEMORY); 172 "Executing system notify handler for Notify (%4.4s, %X) "
155 } 173 "node %p\n",
174 acpi_ut_get_node_name(node),
175 notify_value, node));
176 }
156 177
157 info->common.descriptor_type = ACPI_DESC_TYPE_STATE_NOTIFY; 178 notify_info->common.descriptor_type =
179 ACPI_DESC_TYPE_STATE_NOTIFY;
180 notify_info->notify.node = node;
181 notify_info->notify.value = (u16) notify_value;
182 notify_info->notify.handler_obj = handler_obj;
158 183
159 info->notify.node = node; 184 status =
160 info->notify.value = (u16)notify_value; 185 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_notify_dispatch,
161 info->notify.handler_list_id = handler_list_id; 186 notify_info);
162 info->notify.handler_list_head = handler_list_head; 187 if (ACPI_FAILURE(status)) {
163 info->notify.global = &acpi_gbl_global_notify[handler_list_id]; 188 acpi_ut_delete_generic_state(notify_info);
189 }
190 } else {
191 /* There is no notify handler (per-device or system) for this device */
164 192
165 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 193 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
166 "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n", 194 "No notify handler for Notify (%4.4s, %X) node %p\n",
167 acpi_ut_get_node_name(node), 195 acpi_ut_get_node_name(node), notify_value,
168 acpi_ut_get_type_name(node->type), notify_value, 196 node));
169 acpi_ut_get_notify_name(notify_value), node));
170
171 status = acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_notify_dispatch,
172 info);
173 if (ACPI_FAILURE(status)) {
174 acpi_ut_delete_generic_state(info);
175 } 197 }
176 198
177 return (status); 199 return (status);
@@ -181,7 +203,7 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
181 * 203 *
182 * FUNCTION: acpi_ev_notify_dispatch 204 * FUNCTION: acpi_ev_notify_dispatch
183 * 205 *
184 * PARAMETERS: context - To be passed to the notify handler 206 * PARAMETERS: Context - To be passed to the notify handler
185 * 207 *
186 * RETURN: None. 208 * RETURN: None.
187 * 209 *
@@ -192,37 +214,62 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
192 214
193static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context) 215static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
194{ 216{
195 union acpi_generic_state *info = (union acpi_generic_state *)context; 217 union acpi_generic_state *notify_info =
218 (union acpi_generic_state *)context;
219 acpi_notify_handler global_handler = NULL;
220 void *global_context = NULL;
196 union acpi_operand_object *handler_obj; 221 union acpi_operand_object *handler_obj;
197 222
198 ACPI_FUNCTION_ENTRY(); 223 ACPI_FUNCTION_ENTRY();
199 224
200 /* Invoke a global notify handler if installed */ 225 /*
226 * We will invoke a global notify handler if installed. This is done
227 * _before_ we invoke the per-device handler attached to the device.
228 */
229 if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) {
201 230
202 if (info->notify.global->handler) { 231 /* Global system notification handler */
203 info->notify.global->handler(info->notify.node, 232
204 info->notify.value, 233 if (acpi_gbl_system_notify.handler) {
205 info->notify.global->context); 234 global_handler = acpi_gbl_system_notify.handler;
235 global_context = acpi_gbl_system_notify.context;
236 }
237 } else {
238 /* Global driver notification handler */
239
240 if (acpi_gbl_device_notify.handler) {
241 global_handler = acpi_gbl_device_notify.handler;
242 global_context = acpi_gbl_device_notify.context;
243 }
206 } 244 }
207 245
208 /* Now invoke the local notify handler(s) if any are installed */ 246 /* Invoke the system handler first, if present */
209 247
210 handler_obj = info->notify.handler_list_head; 248 if (global_handler) {
211 while (handler_obj) { 249 global_handler(notify_info->notify.node,
212 handler_obj->notify.handler(info->notify.node, 250 notify_info->notify.value, global_context);
213 info->notify.value, 251 }
214 handler_obj->notify.context); 252
253 /* Now invoke the per-device handler, if present */
254
255 handler_obj = notify_info->notify.handler_obj;
256 if (handler_obj) {
257 struct acpi_object_notify_handler *notifier;
215 258
216 handler_obj = 259 notifier = &handler_obj->notify;
217 handler_obj->notify.next[info->notify.handler_list_id]; 260 while (notifier) {
261 notifier->handler(notify_info->notify.node,
262 notify_info->notify.value,
263 notifier->context);
264 notifier = notifier->next;
265 }
218 } 266 }
219 267
220 /* All done with the info object */ 268 /* All done with the info object */
221 269
222 acpi_ut_delete_generic_state(info); 270 acpi_ut_delete_generic_state(notify_info);
223} 271}
224 272
225#if (!ACPI_REDUCED_HARDWARE)
226/****************************************************************************** 273/******************************************************************************
227 * 274 *
228 * FUNCTION: acpi_ev_terminate 275 * FUNCTION: acpi_ev_terminate
@@ -291,5 +338,3 @@ void acpi_ev_terminate(void)
291 } 338 }
292 return_VOID; 339 return_VOID;
293} 340}
294
295#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 0cc6a16fedc..f0edf5c43c0 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -150,7 +150,7 @@ acpi_status acpi_ev_install_region_handlers(void)
150 * 150 *
151 * FUNCTION: acpi_ev_has_default_handler 151 * FUNCTION: acpi_ev_has_default_handler
152 * 152 *
153 * PARAMETERS: node - Namespace node for the device 153 * PARAMETERS: Node - Namespace node for the device
154 * space_id - The address space ID 154 * space_id - The address space ID
155 * 155 *
156 * RETURN: TRUE if default handler is installed, FALSE otherwise 156 * RETURN: TRUE if default handler is installed, FALSE otherwise
@@ -244,7 +244,7 @@ acpi_status acpi_ev_initialize_op_regions(void)
244 * FUNCTION: acpi_ev_execute_reg_method 244 * FUNCTION: acpi_ev_execute_reg_method
245 * 245 *
246 * PARAMETERS: region_obj - Region object 246 * PARAMETERS: region_obj - Region object
247 * function - Passed to _REG: On (1) or Off (0) 247 * Function - Passed to _REG: On (1) or Off (0)
248 * 248 *
249 * RETURN: Status 249 * RETURN: Status
250 * 250 *
@@ -286,10 +286,10 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
286 /* 286 /*
287 * The _REG method has two arguments: 287 * The _REG method has two arguments:
288 * 288 *
289 * arg0 - Integer: 289 * Arg0 - Integer:
290 * Operation region space ID Same value as region_obj->Region.space_id 290 * Operation region space ID Same value as region_obj->Region.space_id
291 * 291 *
292 * arg1 - Integer: 292 * Arg1 - Integer:
293 * connection status 1 for connecting the handler, 0 for disconnecting 293 * connection status 1 for connecting the handler, 0 for disconnecting
294 * the handler (Passed as a parameter) 294 * the handler (Passed as a parameter)
295 */ 295 */
@@ -329,11 +329,10 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
329 * FUNCTION: acpi_ev_address_space_dispatch 329 * FUNCTION: acpi_ev_address_space_dispatch
330 * 330 *
331 * PARAMETERS: region_obj - Internal region object 331 * PARAMETERS: region_obj - Internal region object
332 * field_obj - Corresponding field. Can be NULL. 332 * Function - Read or Write operation
333 * function - Read or Write operation
334 * region_offset - Where in the region to read or write 333 * region_offset - Where in the region to read or write
335 * bit_width - Field width in bits (8, 16, 32, or 64) 334 * bit_width - Field width in bits (8, 16, 32, or 64)
336 * value - Pointer to in or out value, must be 335 * Value - Pointer to in or out value, must be
337 * a full 64-bit integer 336 * a full 64-bit integer
338 * 337 *
339 * RETURN: Status 338 * RETURN: Status
@@ -345,7 +344,6 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
345 344
346acpi_status 345acpi_status
347acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, 346acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
348 union acpi_operand_object *field_obj,
349 u32 function, 347 u32 function,
350 u32 region_offset, u32 bit_width, u64 *value) 348 u32 region_offset, u32 bit_width, u64 *value)
351{ 349{
@@ -355,7 +353,6 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
355 union acpi_operand_object *handler_desc; 353 union acpi_operand_object *handler_desc;
356 union acpi_operand_object *region_obj2; 354 union acpi_operand_object *region_obj2;
357 void *region_context = NULL; 355 void *region_context = NULL;
358 struct acpi_connection_info *context;
359 356
360 ACPI_FUNCTION_TRACE(ev_address_space_dispatch); 357 ACPI_FUNCTION_TRACE(ev_address_space_dispatch);
361 358
@@ -378,8 +375,6 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
378 return_ACPI_STATUS(AE_NOT_EXIST); 375 return_ACPI_STATUS(AE_NOT_EXIST);
379 } 376 }
380 377
381 context = handler_desc->address_space.context;
382
383 /* 378 /*
384 * It may be the case that the region has never been initialized. 379 * It may be the case that the region has never been initialized.
385 * Some types of regions require special init code 380 * Some types of regions require special init code
@@ -409,7 +404,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
409 acpi_ex_exit_interpreter(); 404 acpi_ex_exit_interpreter();
410 405
411 status = region_setup(region_obj, ACPI_REGION_ACTIVATE, 406 status = region_setup(region_obj, ACPI_REGION_ACTIVATE,
412 context, &region_context); 407 handler_desc->address_space.context,
408 &region_context);
413 409
414 /* Re-enter the interpreter */ 410 /* Re-enter the interpreter */
415 411
@@ -459,25 +455,6 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
459 acpi_ut_get_region_name(region_obj->region. 455 acpi_ut_get_region_name(region_obj->region.
460 space_id))); 456 space_id)));
461 457
462 /*
463 * Special handling for generic_serial_bus and general_purpose_io:
464 * There are three extra parameters that must be passed to the
465 * handler via the context:
466 * 1) Connection buffer, a resource template from Connection() op.
467 * 2) Length of the above buffer.
468 * 3) Actual access length from the access_as() op.
469 */
470 if (((region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) ||
471 (region_obj->region.space_id == ACPI_ADR_SPACE_GPIO)) &&
472 context && field_obj) {
473
474 /* Get the Connection (resource_template) buffer */
475
476 context->connection = field_obj->field.resource_buffer;
477 context->length = field_obj->field.resource_length;
478 context->access_length = field_obj->field.access_length;
479 }
480
481 if (!(handler_desc->address_space.handler_flags & 458 if (!(handler_desc->address_space.handler_flags &
482 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { 459 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
483 /* 460 /*
@@ -492,7 +469,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
492 469
493 status = handler(function, 470 status = handler(function,
494 (region_obj->region.address + region_offset), 471 (region_obj->region.address + region_offset),
495 bit_width, value, context, 472 bit_width, value, handler_desc->address_space.context,
496 region_obj2->extra.region_context); 473 region_obj2->extra.region_context);
497 474
498 if (ACPI_FAILURE(status)) { 475 if (ACPI_FAILURE(status)) {
@@ -840,11 +817,11 @@ acpi_ev_install_handler(acpi_handle obj_handle,
840 * 817 *
841 * FUNCTION: acpi_ev_install_space_handler 818 * FUNCTION: acpi_ev_install_space_handler
842 * 819 *
843 * PARAMETERS: node - Namespace node for the device 820 * PARAMETERS: Node - Namespace node for the device
844 * space_id - The address space ID 821 * space_id - The address space ID
845 * handler - Address of the handler 822 * Handler - Address of the handler
846 * setup - Address of the setup function 823 * Setup - Address of the setup function
847 * context - Value passed to the handler on each access 824 * Context - Value passed to the handler on each access
848 * 825 *
849 * RETURN: Status 826 * RETURN: Status
850 * 827 *
@@ -1061,7 +1038,7 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
1061 * 1038 *
1062 * FUNCTION: acpi_ev_execute_reg_methods 1039 * FUNCTION: acpi_ev_execute_reg_methods
1063 * 1040 *
1064 * PARAMETERS: node - Namespace node for the device 1041 * PARAMETERS: Node - Namespace node for the device
1065 * space_id - The address space ID 1042 * space_id - The address space ID
1066 * 1043 *
1067 * RETURN: Status 1044 * RETURN: Status
@@ -1104,7 +1081,7 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
1104 * 1081 *
1105 * PARAMETERS: walk_namespace callback 1082 * PARAMETERS: walk_namespace callback
1106 * 1083 *
1107 * DESCRIPTION: Run _REG method for region objects of the requested spaceID 1084 * DESCRIPTION: Run _REG method for region objects of the requested space_iD
1108 * 1085 *
1109 ******************************************************************************/ 1086 ******************************************************************************/
1110 1087
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 1474241bfc7..55a5d35ef34 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -56,8 +56,8 @@ static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node);
56 * 56 *
57 * FUNCTION: acpi_ev_system_memory_region_setup 57 * FUNCTION: acpi_ev_system_memory_region_setup
58 * 58 *
59 * PARAMETERS: handle - Region we are interested in 59 * PARAMETERS: Handle - Region we are interested in
60 * function - Start or stop 60 * Function - Start or stop
61 * handler_context - Address space handler context 61 * handler_context - Address space handler context
62 * region_context - Region specific context 62 * region_context - Region specific context
63 * 63 *
@@ -118,8 +118,8 @@ acpi_ev_system_memory_region_setup(acpi_handle handle,
118 * 118 *
119 * FUNCTION: acpi_ev_io_space_region_setup 119 * FUNCTION: acpi_ev_io_space_region_setup
120 * 120 *
121 * PARAMETERS: handle - Region we are interested in 121 * PARAMETERS: Handle - Region we are interested in
122 * function - Start or stop 122 * Function - Start or stop
123 * handler_context - Address space handler context 123 * handler_context - Address space handler context
124 * region_context - Region specific context 124 * region_context - Region specific context
125 * 125 *
@@ -149,8 +149,8 @@ acpi_ev_io_space_region_setup(acpi_handle handle,
149 * 149 *
150 * FUNCTION: acpi_ev_pci_config_region_setup 150 * FUNCTION: acpi_ev_pci_config_region_setup
151 * 151 *
152 * PARAMETERS: handle - Region we are interested in 152 * PARAMETERS: Handle - Region we are interested in
153 * function - Start or stop 153 * Function - Start or stop
154 * handler_context - Address space handler context 154 * handler_context - Address space handler context
155 * region_context - Region specific context 155 * region_context - Region specific context
156 * 156 *
@@ -227,7 +227,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
227 227
228 /* Install a handler for this PCI root bridge */ 228 /* Install a handler for this PCI root bridge */
229 229
230 status = acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); 230 status =
231 acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL);
231 if (ACPI_FAILURE(status)) { 232 if (ACPI_FAILURE(status)) {
232 if (status == AE_SAME_HANDLER) { 233 if (status == AE_SAME_HANDLER) {
233 /* 234 /*
@@ -337,7 +338,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
337 * 338 *
338 * FUNCTION: acpi_ev_is_pci_root_bridge 339 * FUNCTION: acpi_ev_is_pci_root_bridge
339 * 340 *
340 * PARAMETERS: node - Device node being examined 341 * PARAMETERS: Node - Device node being examined
341 * 342 *
342 * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge 343 * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge
343 * 344 *
@@ -349,8 +350,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
349static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node) 350static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
350{ 351{
351 acpi_status status; 352 acpi_status status;
352 struct acpi_pnp_device_id *hid; 353 struct acpica_device_id *hid;
353 struct acpi_pnp_device_id_list *cid; 354 struct acpica_device_id_list *cid;
354 u32 i; 355 u32 i;
355 u8 match; 356 u8 match;
356 357
@@ -392,14 +393,14 @@ static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
392 * 393 *
393 * FUNCTION: acpi_ev_pci_bar_region_setup 394 * FUNCTION: acpi_ev_pci_bar_region_setup
394 * 395 *
395 * PARAMETERS: handle - Region we are interested in 396 * PARAMETERS: Handle - Region we are interested in
396 * function - Start or stop 397 * Function - Start or stop
397 * handler_context - Address space handler context 398 * handler_context - Address space handler context
398 * region_context - Region specific context 399 * region_context - Region specific context
399 * 400 *
400 * RETURN: Status 401 * RETURN: Status
401 * 402 *
402 * DESCRIPTION: Setup a pci_BAR operation region 403 * DESCRIPTION: Setup a pci_bAR operation region
403 * 404 *
404 * MUTEX: Assumes namespace is not locked 405 * MUTEX: Assumes namespace is not locked
405 * 406 *
@@ -419,8 +420,8 @@ acpi_ev_pci_bar_region_setup(acpi_handle handle,
419 * 420 *
420 * FUNCTION: acpi_ev_cmos_region_setup 421 * FUNCTION: acpi_ev_cmos_region_setup
421 * 422 *
422 * PARAMETERS: handle - Region we are interested in 423 * PARAMETERS: Handle - Region we are interested in
423 * function - Start or stop 424 * Function - Start or stop
424 * handler_context - Address space handler context 425 * handler_context - Address space handler context
425 * region_context - Region specific context 426 * region_context - Region specific context
426 * 427 *
@@ -446,8 +447,8 @@ acpi_ev_cmos_region_setup(acpi_handle handle,
446 * 447 *
447 * FUNCTION: acpi_ev_default_region_setup 448 * FUNCTION: acpi_ev_default_region_setup
448 * 449 *
449 * PARAMETERS: handle - Region we are interested in 450 * PARAMETERS: Handle - Region we are interested in
450 * function - Start or stop 451 * Function - Start or stop
451 * handler_context - Address space handler context 452 * handler_context - Address space handler context
452 * region_context - Region specific context 453 * region_context - Region specific context
453 * 454 *
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index f9661e2b46a..2ebd40e1a3e 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evsci") 50ACPI_MODULE_NAME("evsci")
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51
52/* Local prototypes */ 52/* Local prototypes */
53static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context); 53static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context);
54 54
@@ -56,7 +56,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context);
56 * 56 *
57 * FUNCTION: acpi_ev_sci_xrupt_handler 57 * FUNCTION: acpi_ev_sci_xrupt_handler
58 * 58 *
59 * PARAMETERS: context - Calling Context 59 * PARAMETERS: Context - Calling Context
60 * 60 *
61 * RETURN: Status code indicates whether interrupt was handled. 61 * RETURN: Status code indicates whether interrupt was handled.
62 * 62 *
@@ -96,7 +96,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
96 * 96 *
97 * FUNCTION: acpi_ev_gpe_xrupt_handler 97 * FUNCTION: acpi_ev_gpe_xrupt_handler
98 * 98 *
99 * PARAMETERS: context - Calling Context 99 * PARAMETERS: Context - Calling Context
100 * 100 *
101 * RETURN: Status code indicates whether interrupt was handled. 101 * RETURN: Status code indicates whether interrupt was handled.
102 * 102 *
@@ -181,5 +181,3 @@ acpi_status acpi_ev_remove_sci_handler(void)
181 181
182 return_ACPI_STATUS(status); 182 return_ACPI_STATUS(status);
183} 183}
184
185#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index ae668f32cf1..e1141402dbe 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include "accommon.h" 45#include "accommon.h"
47#include "acnamesp.h" 46#include "acnamesp.h"
@@ -51,298 +50,11 @@
51#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
52ACPI_MODULE_NAME("evxface") 51ACPI_MODULE_NAME("evxface")
53 52
54
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_install_notify_handler
58 *
59 * PARAMETERS: Device - The device for which notifies will be handled
60 * handler_type - The type of handler:
61 * ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
62 * ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
63 * ACPI_ALL_NOTIFY: Both System and Device
64 * Handler - Address of the handler
65 * Context - Value passed to the handler on each GPE
66 *
67 * RETURN: Status
68 *
69 * DESCRIPTION: Install a handler for notifications on an ACPI Device,
70 * thermal_zone, or Processor object.
71 *
72 * NOTES: The Root namespace object may have only one handler for each
73 * type of notify (System/Device). Device/Thermal/Processor objects
74 * may have one device notify handler, and multiple system notify
75 * handlers.
76 *
77 ******************************************************************************/
78acpi_status
79acpi_install_notify_handler(acpi_handle device,
80 u32 handler_type,
81 acpi_notify_handler handler, void *context)
82{
83 struct acpi_namespace_node *node =
84 ACPI_CAST_PTR(struct acpi_namespace_node, device);
85 union acpi_operand_object *obj_desc;
86 union acpi_operand_object *handler_obj;
87 acpi_status status;
88 u32 i;
89
90 ACPI_FUNCTION_TRACE(acpi_install_notify_handler);
91
92 /* Parameter validation */
93
94 if ((!device) || (!handler) || (!handler_type) ||
95 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
96 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 }
98
99 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
100 if (ACPI_FAILURE(status)) {
101 return_ACPI_STATUS(status);
102 }
103
104 /*
105 * Root Object:
106 * Registering a notify handler on the root object indicates that the
107 * caller wishes to receive notifications for all objects. Note that
108 * only one global handler can be registered per notify type.
109 * Ensure that a handler is not already installed.
110 */
111 if (device == ACPI_ROOT_OBJECT) {
112 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
113 if (handler_type & (i + 1)) {
114 if (acpi_gbl_global_notify[i].handler) {
115 status = AE_ALREADY_EXISTS;
116 goto unlock_and_exit;
117 }
118
119 acpi_gbl_global_notify[i].handler = handler;
120 acpi_gbl_global_notify[i].context = context;
121 }
122 }
123
124 goto unlock_and_exit; /* Global notify handler installed, all done */
125 }
126
127 /*
128 * All Other Objects:
129 * Caller will only receive notifications specific to the target
130 * object. Note that only certain object types are allowed to
131 * receive notifications.
132 */
133
134 /* Are Notifies allowed on this object? */
135
136 if (!acpi_ev_is_notify_object(node)) {
137 status = AE_TYPE;
138 goto unlock_and_exit;
139 }
140
141 /* Check for an existing internal object, might not exist */
142
143 obj_desc = acpi_ns_get_attached_object(node);
144 if (!obj_desc) {
145
146 /* Create a new object */
147
148 obj_desc = acpi_ut_create_internal_object(node->type);
149 if (!obj_desc) {
150 status = AE_NO_MEMORY;
151 goto unlock_and_exit;
152 }
153
154 /* Attach new object to the Node, remove local reference */
155
156 status = acpi_ns_attach_object(device, obj_desc, node->type);
157 acpi_ut_remove_reference(obj_desc);
158 if (ACPI_FAILURE(status)) {
159 goto unlock_and_exit;
160 }
161 }
162
163 /* Ensure that the handler is not already installed in the lists */
164
165 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
166 if (handler_type & (i + 1)) {
167 handler_obj = obj_desc->common_notify.notify_list[i];
168 while (handler_obj) {
169 if (handler_obj->notify.handler == handler) {
170 status = AE_ALREADY_EXISTS;
171 goto unlock_and_exit;
172 }
173
174 handler_obj = handler_obj->notify.next[i];
175 }
176 }
177 }
178
179 /* Create and populate a new notify handler object */
180
181 handler_obj = acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_NOTIFY);
182 if (!handler_obj) {
183 status = AE_NO_MEMORY;
184 goto unlock_and_exit;
185 }
186
187 handler_obj->notify.node = node;
188 handler_obj->notify.handler_type = handler_type;
189 handler_obj->notify.handler = handler;
190 handler_obj->notify.context = context;
191
192 /* Install the handler at the list head(s) */
193
194 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
195 if (handler_type & (i + 1)) {
196 handler_obj->notify.next[i] =
197 obj_desc->common_notify.notify_list[i];
198
199 obj_desc->common_notify.notify_list[i] = handler_obj;
200 }
201 }
202
203 /* Add an extra reference if handler was installed in both lists */
204
205 if (handler_type == ACPI_ALL_NOTIFY) {
206 acpi_ut_add_reference(handler_obj);
207 }
208
209unlock_and_exit:
210 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
211 return_ACPI_STATUS(status);
212}
213
214ACPI_EXPORT_SYMBOL(acpi_install_notify_handler)
215
216/*******************************************************************************
217 *
218 * FUNCTION: acpi_remove_notify_handler
219 *
220 * PARAMETERS: Device - The device for which the handler is installed
221 * handler_type - The type of handler:
222 * ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
223 * ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
224 * ACPI_ALL_NOTIFY: Both System and Device
225 * Handler - Address of the handler
226 *
227 * RETURN: Status
228 *
229 * DESCRIPTION: Remove a handler for notifies on an ACPI device
230 *
231 ******************************************************************************/
232acpi_status
233acpi_remove_notify_handler(acpi_handle device,
234 u32 handler_type, acpi_notify_handler handler)
235{
236 struct acpi_namespace_node *node =
237 ACPI_CAST_PTR(struct acpi_namespace_node, device);
238 union acpi_operand_object *obj_desc;
239 union acpi_operand_object *handler_obj;
240 union acpi_operand_object *previous_handler_obj;
241 acpi_status status;
242 u32 i;
243
244 ACPI_FUNCTION_TRACE(acpi_remove_notify_handler);
245
246 /* Parameter validation */
247
248 if ((!device) || (!handler) || (!handler_type) ||
249 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
250 return_ACPI_STATUS(AE_BAD_PARAMETER);
251 }
252 /* Make sure all deferred tasks are completed */
253
254 acpi_os_wait_events_complete();
255
256 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
257 if (ACPI_FAILURE(status)) {
258 return_ACPI_STATUS(status);
259 }
260
261 /* Root Object. Global handlers are removed here */
262
263 if (device == ACPI_ROOT_OBJECT) {
264 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
265 if (handler_type & (i + 1)) {
266 if (!acpi_gbl_global_notify[i].handler ||
267 (acpi_gbl_global_notify[i].handler !=
268 handler)) {
269 status = AE_NOT_EXIST;
270 goto unlock_and_exit;
271 }
272
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
274 "Removing global notify handler\n"));
275
276 acpi_gbl_global_notify[i].handler = NULL;
277 acpi_gbl_global_notify[i].context = NULL;
278 }
279 }
280
281 goto unlock_and_exit;
282 }
283
284 /* All other objects: Are Notifies allowed on this object? */
285
286 if (!acpi_ev_is_notify_object(node)) {
287 status = AE_TYPE;
288 goto unlock_and_exit;
289 }
290
291 /* Must have an existing internal object */
292
293 obj_desc = acpi_ns_get_attached_object(node);
294 if (!obj_desc) {
295 status = AE_NOT_EXIST;
296 goto unlock_and_exit;
297 }
298
299 /* Internal object exists. Find the handler and remove it */
300
301 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
302 if (handler_type & (i + 1)) {
303 handler_obj = obj_desc->common_notify.notify_list[i];
304 previous_handler_obj = NULL;
305
306 /* Attempt to find the handler in the handler list */
307
308 while (handler_obj &&
309 (handler_obj->notify.handler != handler)) {
310 previous_handler_obj = handler_obj;
311 handler_obj = handler_obj->notify.next[i];
312 }
313
314 if (!handler_obj) {
315 status = AE_NOT_EXIST;
316 goto unlock_and_exit;
317 }
318
319 /* Remove the handler object from the list */
320
321 if (previous_handler_obj) { /* Handler is not at the list head */
322 previous_handler_obj->notify.next[i] =
323 handler_obj->notify.next[i];
324 } else { /* Handler is at the list head */
325
326 obj_desc->common_notify.notify_list[i] =
327 handler_obj->notify.next[i];
328 }
329
330 acpi_ut_remove_reference(handler_obj);
331 }
332 }
333
334unlock_and_exit:
335 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
336 return_ACPI_STATUS(status);
337}
338
339ACPI_EXPORT_SYMBOL(acpi_remove_notify_handler)
340
341/******************************************************************************* 53/*******************************************************************************
342 * 54 *
343 * FUNCTION: acpi_install_exception_handler 55 * FUNCTION: acpi_install_exception_handler
344 * 56 *
345 * PARAMETERS: handler - Pointer to the handler function for the 57 * PARAMETERS: Handler - Pointer to the handler function for the
346 * event 58 * event
347 * 59 *
348 * RETURN: Status 60 * RETURN: Status
@@ -381,13 +93,12 @@ acpi_status acpi_install_exception_handler(acpi_exception_handler handler)
381ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) 93ACPI_EXPORT_SYMBOL(acpi_install_exception_handler)
382#endif /* ACPI_FUTURE_USAGE */ 94#endif /* ACPI_FUTURE_USAGE */
383 95
384#if (!ACPI_REDUCED_HARDWARE)
385/******************************************************************************* 96/*******************************************************************************
386 * 97 *
387 * FUNCTION: acpi_install_global_event_handler 98 * FUNCTION: acpi_install_global_event_handler
388 * 99 *
389 * PARAMETERS: handler - Pointer to the global event handler function 100 * PARAMETERS: Handler - Pointer to the global event handler function
390 * context - Value passed to the handler on each event 101 * Context - Value passed to the handler on each event
391 * 102 *
392 * RETURN: Status 103 * RETURN: Status
393 * 104 *
@@ -398,7 +109,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_exception_handler)
398 * 109 *
399 ******************************************************************************/ 110 ******************************************************************************/
400acpi_status 111acpi_status
401acpi_install_global_event_handler(acpi_gbl_event_handler handler, void *context) 112acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context)
402{ 113{
403 acpi_status status; 114 acpi_status status;
404 115
@@ -436,10 +147,10 @@ ACPI_EXPORT_SYMBOL(acpi_install_global_event_handler)
436 * 147 *
437 * FUNCTION: acpi_install_fixed_event_handler 148 * FUNCTION: acpi_install_fixed_event_handler
438 * 149 *
439 * PARAMETERS: event - Event type to enable. 150 * PARAMETERS: Event - Event type to enable.
440 * handler - Pointer to the handler function for the 151 * Handler - Pointer to the handler function for the
441 * event 152 * event
442 * context - Value passed to the handler on each GPE 153 * Context - Value passed to the handler on each GPE
443 * 154 *
444 * RETURN: Status 155 * RETURN: Status
445 * 156 *
@@ -506,8 +217,8 @@ ACPI_EXPORT_SYMBOL(acpi_install_fixed_event_handler)
506 * 217 *
507 * FUNCTION: acpi_remove_fixed_event_handler 218 * FUNCTION: acpi_remove_fixed_event_handler
508 * 219 *
509 * PARAMETERS: event - Event type to disable. 220 * PARAMETERS: Event - Event type to disable.
510 * handler - Address of the handler 221 * Handler - Address of the handler
511 * 222 *
512 * RETURN: Status 223 * RETURN: Status
513 * 224 *
@@ -558,15 +269,450 @@ ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler)
558 269
559/******************************************************************************* 270/*******************************************************************************
560 * 271 *
272 * FUNCTION: acpi_populate_handler_object
273 *
274 * PARAMETERS: handler_obj - Handler object to populate
275 * handler_type - The type of handler:
276 * ACPI_SYSTEM_NOTIFY: system_handler (00-7f)
277 * ACPI_DEVICE_NOTIFY: driver_handler (80-ff)
278 * ACPI_ALL_NOTIFY: both system and device
279 * handler - Address of the handler
280 * context - Value passed to the handler on each GPE
281 * next - Address of a handler object to link to
282 *
283 * RETURN: None
284 *
285 * DESCRIPTION: Populate a handler object.
286 *
287 ******************************************************************************/
288static void
289acpi_populate_handler_object(struct acpi_object_notify_handler *handler_obj,
290 u32 handler_type,
291 acpi_notify_handler handler, void *context,
292 struct acpi_object_notify_handler *next)
293{
294 handler_obj->handler_type = handler_type;
295 handler_obj->handler = handler;
296 handler_obj->context = context;
297 handler_obj->next = next;
298}
299
300/*******************************************************************************
301 *
302 * FUNCTION: acpi_add_handler_object
303 *
304 * PARAMETERS: parent_obj - Parent of the new object
305 * handler - Address of the handler
306 * context - Value passed to the handler on each GPE
307 *
308 * RETURN: Status
309 *
310 * DESCRIPTION: Create a new handler object and populate it.
311 *
312 ******************************************************************************/
313static acpi_status
314acpi_add_handler_object(struct acpi_object_notify_handler *parent_obj,
315 acpi_notify_handler handler, void *context)
316{
317 struct acpi_object_notify_handler *handler_obj;
318
319 /* The parent must not be a defice notify handler object. */
320 if (parent_obj->handler_type & ACPI_DEVICE_NOTIFY)
321 return AE_BAD_PARAMETER;
322
323 handler_obj = ACPI_ALLOCATE_ZEROED(sizeof(*handler_obj));
324 if (!handler_obj)
325 return AE_NO_MEMORY;
326
327 acpi_populate_handler_object(handler_obj,
328 ACPI_SYSTEM_NOTIFY,
329 handler, context,
330 parent_obj->next);
331 parent_obj->next = handler_obj;
332
333 return AE_OK;
334}
335
336/*******************************************************************************
337 *
338 * FUNCTION: acpi_install_notify_handler
339 *
340 * PARAMETERS: Device - The device for which notifies will be handled
341 * handler_type - The type of handler:
342 * ACPI_SYSTEM_NOTIFY: system_handler (00-7f)
343 * ACPI_DEVICE_NOTIFY: driver_handler (80-ff)
344 * ACPI_ALL_NOTIFY: both system and device
345 * Handler - Address of the handler
346 * Context - Value passed to the handler on each GPE
347 *
348 * RETURN: Status
349 *
350 * DESCRIPTION: Install a handler for notifies on an ACPI device
351 *
352 ******************************************************************************/
353acpi_status
354acpi_install_notify_handler(acpi_handle device,
355 u32 handler_type,
356 acpi_notify_handler handler, void *context)
357{
358 union acpi_operand_object *obj_desc;
359 union acpi_operand_object *notify_obj;
360 struct acpi_namespace_node *node;
361 acpi_status status;
362
363 ACPI_FUNCTION_TRACE(acpi_install_notify_handler);
364
365 /* Parameter validation */
366
367 if ((!device) ||
368 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
369 return_ACPI_STATUS(AE_BAD_PARAMETER);
370 }
371
372 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
373 if (ACPI_FAILURE(status)) {
374 return_ACPI_STATUS(status);
375 }
376
377 /* Convert and validate the device handle */
378
379 node = acpi_ns_validate_handle(device);
380 if (!node) {
381 status = AE_BAD_PARAMETER;
382 goto unlock_and_exit;
383 }
384
385 /*
386 * Root Object:
387 * Registering a notify handler on the root object indicates that the
388 * caller wishes to receive notifications for all objects. Note that
389 * only one <external> global handler can be regsitered (per notify type).
390 */
391 if (device == ACPI_ROOT_OBJECT) {
392
393 /* Make sure the handler is not already installed */
394
395 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
396 acpi_gbl_system_notify.handler) ||
397 ((handler_type & ACPI_DEVICE_NOTIFY) &&
398 acpi_gbl_device_notify.handler)) {
399 status = AE_ALREADY_EXISTS;
400 goto unlock_and_exit;
401 }
402
403 if (handler_type & ACPI_SYSTEM_NOTIFY) {
404 acpi_gbl_system_notify.node = node;
405 acpi_gbl_system_notify.handler = handler;
406 acpi_gbl_system_notify.context = context;
407 }
408
409 if (handler_type & ACPI_DEVICE_NOTIFY) {
410 acpi_gbl_device_notify.node = node;
411 acpi_gbl_device_notify.handler = handler;
412 acpi_gbl_device_notify.context = context;
413 }
414
415 /* Global notify handler installed */
416 }
417
418 /*
419 * All Other Objects:
420 * Caller will only receive notifications specific to the target object.
421 * Note that only certain object types can receive notifications.
422 */
423 else {
424 /* Notifies allowed on this object? */
425
426 if (!acpi_ev_is_notify_object(node)) {
427 status = AE_TYPE;
428 goto unlock_and_exit;
429 }
430
431 /* Check for an existing internal object */
432
433 obj_desc = acpi_ns_get_attached_object(node);
434 if (obj_desc) {
435
436 /* Object exists. */
437
438 /* For a device notify, make sure there's no handler. */
439 if ((handler_type & ACPI_DEVICE_NOTIFY) &&
440 obj_desc->common_notify.device_notify) {
441 status = AE_ALREADY_EXISTS;
442 goto unlock_and_exit;
443 }
444
445 /* System notifies may have more handlers installed. */
446 notify_obj = obj_desc->common_notify.system_notify;
447
448 if ((handler_type & ACPI_SYSTEM_NOTIFY) && notify_obj) {
449 struct acpi_object_notify_handler *parent_obj;
450
451 if (handler_type & ACPI_DEVICE_NOTIFY) {
452 status = AE_ALREADY_EXISTS;
453 goto unlock_and_exit;
454 }
455
456 parent_obj = &notify_obj->notify;
457 status = acpi_add_handler_object(parent_obj,
458 handler,
459 context);
460 goto unlock_and_exit;
461 }
462 } else {
463 /* Create a new object */
464
465 obj_desc = acpi_ut_create_internal_object(node->type);
466 if (!obj_desc) {
467 status = AE_NO_MEMORY;
468 goto unlock_and_exit;
469 }
470
471 /* Attach new object to the Node */
472
473 status =
474 acpi_ns_attach_object(device, obj_desc, node->type);
475
476 /* Remove local reference to the object */
477
478 acpi_ut_remove_reference(obj_desc);
479 if (ACPI_FAILURE(status)) {
480 goto unlock_and_exit;
481 }
482 }
483
484 /* Install the handler */
485
486 notify_obj =
487 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_NOTIFY);
488 if (!notify_obj) {
489 status = AE_NO_MEMORY;
490 goto unlock_and_exit;
491 }
492
493 acpi_populate_handler_object(&notify_obj->notify,
494 handler_type,
495 handler, context,
496 NULL);
497
498 if (handler_type & ACPI_SYSTEM_NOTIFY) {
499 obj_desc->common_notify.system_notify = notify_obj;
500 }
501
502 if (handler_type & ACPI_DEVICE_NOTIFY) {
503 obj_desc->common_notify.device_notify = notify_obj;
504 }
505
506 if (handler_type == ACPI_ALL_NOTIFY) {
507
508 /* Extra ref if installed in both */
509
510 acpi_ut_add_reference(notify_obj);
511 }
512 }
513
514 unlock_and_exit:
515 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
516 return_ACPI_STATUS(status);
517}
518
519ACPI_EXPORT_SYMBOL(acpi_install_notify_handler)
520
521/*******************************************************************************
522 *
523 * FUNCTION: acpi_remove_notify_handler
524 *
525 * PARAMETERS: Device - The device for which notifies will be handled
526 * handler_type - The type of handler:
527 * ACPI_SYSTEM_NOTIFY: system_handler (00-7f)
528 * ACPI_DEVICE_NOTIFY: driver_handler (80-ff)
529 * ACPI_ALL_NOTIFY: both system and device
530 * Handler - Address of the handler
531 *
532 * RETURN: Status
533 *
534 * DESCRIPTION: Remove a handler for notifies on an ACPI device
535 *
536 ******************************************************************************/
537acpi_status
538acpi_remove_notify_handler(acpi_handle device,
539 u32 handler_type, acpi_notify_handler handler)
540{
541 union acpi_operand_object *notify_obj;
542 union acpi_operand_object *obj_desc;
543 struct acpi_namespace_node *node;
544 acpi_status status;
545
546 ACPI_FUNCTION_TRACE(acpi_remove_notify_handler);
547
548 /* Parameter validation */
549
550 if ((!device) ||
551 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
552 status = AE_BAD_PARAMETER;
553 goto exit;
554 }
555
556
557 /* Make sure all deferred tasks are completed */
558 acpi_os_wait_events_complete(NULL);
559
560 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
561 if (ACPI_FAILURE(status)) {
562 goto exit;
563 }
564
565 /* Convert and validate the device handle */
566
567 node = acpi_ns_validate_handle(device);
568 if (!node) {
569 status = AE_BAD_PARAMETER;
570 goto unlock_and_exit;
571 }
572
573 /* Root Object */
574
575 if (device == ACPI_ROOT_OBJECT) {
576 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
577 "Removing notify handler for namespace root object\n"));
578
579 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
580 !acpi_gbl_system_notify.handler) ||
581 ((handler_type & ACPI_DEVICE_NOTIFY) &&
582 !acpi_gbl_device_notify.handler)) {
583 status = AE_NOT_EXIST;
584 goto unlock_and_exit;
585 }
586
587 if (handler_type & ACPI_SYSTEM_NOTIFY) {
588 acpi_gbl_system_notify.node = NULL;
589 acpi_gbl_system_notify.handler = NULL;
590 acpi_gbl_system_notify.context = NULL;
591 }
592
593 if (handler_type & ACPI_DEVICE_NOTIFY) {
594 acpi_gbl_device_notify.node = NULL;
595 acpi_gbl_device_notify.handler = NULL;
596 acpi_gbl_device_notify.context = NULL;
597 }
598 }
599
600 /* All Other Objects */
601
602 else {
603 /* Notifies allowed on this object? */
604
605 if (!acpi_ev_is_notify_object(node)) {
606 status = AE_TYPE;
607 goto unlock_and_exit;
608 }
609
610 /* Check for an existing internal object */
611
612 obj_desc = acpi_ns_get_attached_object(node);
613 if (!obj_desc) {
614 status = AE_NOT_EXIST;
615 goto unlock_and_exit;
616 }
617
618 /* Object exists - make sure there's an existing handler */
619
620 if (handler_type & ACPI_SYSTEM_NOTIFY) {
621 struct acpi_object_notify_handler *handler_obj;
622 struct acpi_object_notify_handler *parent_obj;
623
624 notify_obj = obj_desc->common_notify.system_notify;
625 if (!notify_obj) {
626 status = AE_NOT_EXIST;
627 goto unlock_and_exit;
628 }
629
630 handler_obj = &notify_obj->notify;
631 parent_obj = NULL;
632 while (handler_obj->handler != handler) {
633 if (handler_obj->next) {
634 parent_obj = handler_obj;
635 handler_obj = handler_obj->next;
636 } else {
637 break;
638 }
639 }
640
641 if (handler_obj->handler != handler) {
642 status = AE_BAD_PARAMETER;
643 goto unlock_and_exit;
644 }
645
646 /*
647 * Remove the handler. There are three possible cases.
648 * First, we may need to remove a non-embedded object.
649 * Second, we may need to remove the embedded object's
650 * handler data, while non-embedded objects exist.
651 * Finally, we may need to remove the embedded object
652 * entirely along with its container.
653 */
654 if (parent_obj) {
655 /* Non-embedded object is being removed. */
656 parent_obj->next = handler_obj->next;
657 ACPI_FREE(handler_obj);
658 } else if (notify_obj->notify.next) {
659 /*
660 * The handler matches the embedded object, but
661 * there are more handler objects in the list.
662 * Replace the embedded object's data with the
663 * first next object's data and remove that
664 * object.
665 */
666 parent_obj = &notify_obj->notify;
667 handler_obj = notify_obj->notify.next;
668 *parent_obj = *handler_obj;
669 ACPI_FREE(handler_obj);
670 } else {
671 /* No more handler objects in the list. */
672 obj_desc->common_notify.system_notify = NULL;
673 acpi_ut_remove_reference(notify_obj);
674 }
675 }
676
677 if (handler_type & ACPI_DEVICE_NOTIFY) {
678 notify_obj = obj_desc->common_notify.device_notify;
679 if (!notify_obj) {
680 status = AE_NOT_EXIST;
681 goto unlock_and_exit;
682 }
683
684 if (notify_obj->notify.handler != handler) {
685 status = AE_BAD_PARAMETER;
686 goto unlock_and_exit;
687 }
688
689 /* Remove the handler */
690 obj_desc->common_notify.device_notify = NULL;
691 acpi_ut_remove_reference(notify_obj);
692 }
693 }
694
695 unlock_and_exit:
696 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
697 exit:
698 if (ACPI_FAILURE(status))
699 ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler"));
700 return_ACPI_STATUS(status);
701}
702
703ACPI_EXPORT_SYMBOL(acpi_remove_notify_handler)
704
705/*******************************************************************************
706 *
561 * FUNCTION: acpi_install_gpe_handler 707 * FUNCTION: acpi_install_gpe_handler
562 * 708 *
563 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT 709 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
564 * defined GPEs) 710 * defined GPEs)
565 * gpe_number - The GPE number within the GPE block 711 * gpe_number - The GPE number within the GPE block
566 * type - Whether this GPE should be treated as an 712 * Type - Whether this GPE should be treated as an
567 * edge- or level-triggered interrupt. 713 * edge- or level-triggered interrupt.
568 * address - Address of the handler 714 * Address - Address of the handler
569 * context - Value passed to the handler on each GPE 715 * Context - Value passed to the handler on each GPE
570 * 716 *
571 * RETURN: Status 717 * RETURN: Status
572 * 718 *
@@ -673,7 +819,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_gpe_handler)
673 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT 819 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
674 * defined GPEs) 820 * defined GPEs)
675 * gpe_number - The event to remove a handler 821 * gpe_number - The event to remove a handler
676 * address - Address of the handler 822 * Address - Address of the handler
677 * 823 *
678 * RETURN: Status 824 * RETURN: Status
679 * 825 *
@@ -699,7 +845,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
699 845
700 /* Make sure all deferred tasks are completed */ 846 /* Make sure all deferred tasks are completed */
701 847
702 acpi_os_wait_events_complete(); 848 acpi_os_wait_events_complete(NULL);
703 849
704 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 850 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
705 if (ACPI_FAILURE(status)) { 851 if (ACPI_FAILURE(status)) {
@@ -769,8 +915,8 @@ ACPI_EXPORT_SYMBOL(acpi_remove_gpe_handler)
769 * 915 *
770 * FUNCTION: acpi_acquire_global_lock 916 * FUNCTION: acpi_acquire_global_lock
771 * 917 *
772 * PARAMETERS: timeout - How long the caller is willing to wait 918 * PARAMETERS: Timeout - How long the caller is willing to wait
773 * handle - Where the handle to the lock is returned 919 * Handle - Where the handle to the lock is returned
774 * (if acquired) 920 * (if acquired)
775 * 921 *
776 * RETURN: Status 922 * RETURN: Status
@@ -817,7 +963,7 @@ ACPI_EXPORT_SYMBOL(acpi_acquire_global_lock)
817 * 963 *
818 * FUNCTION: acpi_release_global_lock 964 * FUNCTION: acpi_release_global_lock
819 * 965 *
820 * PARAMETERS: handle - Returned from acpi_acquire_global_lock 966 * PARAMETERS: Handle - Returned from acpi_acquire_global_lock
821 * 967 *
822 * RETURN: Status 968 * RETURN: Status
823 * 969 *
@@ -837,4 +983,3 @@ acpi_status acpi_release_global_lock(u32 handle)
837} 983}
838 984
839ACPI_EXPORT_SYMBOL(acpi_release_global_lock) 985ACPI_EXPORT_SYMBOL(acpi_release_global_lock)
840#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 35520c6eeef..c57b5c707a7 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include "accommon.h" 45#include "accommon.h"
47#include "actables.h" 46#include "actables.h"
@@ -49,7 +48,6 @@
49#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evxfevnt") 49ACPI_MODULE_NAME("evxfevnt")
51 50
52#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
53/******************************************************************************* 51/*******************************************************************************
54 * 52 *
55 * FUNCTION: acpi_enable 53 * FUNCTION: acpi_enable
@@ -153,8 +151,8 @@ ACPI_EXPORT_SYMBOL(acpi_disable)
153 * 151 *
154 * FUNCTION: acpi_enable_event 152 * FUNCTION: acpi_enable_event
155 * 153 *
156 * PARAMETERS: event - The fixed eventto be enabled 154 * PARAMETERS: Event - The fixed eventto be enabled
157 * flags - Reserved 155 * Flags - Reserved
158 * 156 *
159 * RETURN: Status 157 * RETURN: Status
160 * 158 *
@@ -265,7 +263,7 @@ ACPI_EXPORT_SYMBOL(acpi_disable_event)
265 * 263 *
266 * FUNCTION: acpi_clear_event 264 * FUNCTION: acpi_clear_event
267 * 265 *
268 * PARAMETERS: event - The fixed event to be cleared 266 * PARAMETERS: Event - The fixed event to be cleared
269 * 267 *
270 * RETURN: Status 268 * RETURN: Status
271 * 269 *
@@ -301,7 +299,7 @@ ACPI_EXPORT_SYMBOL(acpi_clear_event)
301 * 299 *
302 * FUNCTION: acpi_get_event_status 300 * FUNCTION: acpi_get_event_status
303 * 301 *
304 * PARAMETERS: event - The fixed event 302 * PARAMETERS: Event - The fixed event
305 * event_status - Where the current status of the event will 303 * event_status - Where the current status of the event will
306 * be returned 304 * be returned
307 * 305 *
@@ -353,4 +351,3 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
353} 351}
354 352
355ACPI_EXPORT_SYMBOL(acpi_get_event_status) 353ACPI_EXPORT_SYMBOL(acpi_get_event_status)
356#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index 3f30e753b65..52aaff3df56 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include "accommon.h" 45#include "accommon.h"
47#include "acevents.h" 46#include "acevents.h"
@@ -50,7 +49,6 @@
50#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
51ACPI_MODULE_NAME("evxfgpe") 50ACPI_MODULE_NAME("evxfgpe")
52 51
53#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
54/****************************************************************************** 52/******************************************************************************
55 * 53 *
56 * FUNCTION: acpi_update_all_gpes 54 * FUNCTION: acpi_update_all_gpes
@@ -197,12 +195,12 @@ acpi_status
197acpi_setup_gpe_for_wake(acpi_handle wake_device, 195acpi_setup_gpe_for_wake(acpi_handle wake_device,
198 acpi_handle gpe_device, u32 gpe_number) 196 acpi_handle gpe_device, u32 gpe_number)
199{ 197{
200 acpi_status status; 198 acpi_status status = AE_BAD_PARAMETER;
201 struct acpi_gpe_event_info *gpe_event_info; 199 struct acpi_gpe_event_info *gpe_event_info;
202 struct acpi_namespace_node *device_node; 200 struct acpi_namespace_node *device_node;
203 struct acpi_gpe_notify_info *notify; 201 struct acpi_gpe_notify_object *notify_object;
204 struct acpi_gpe_notify_info *new_notify;
205 acpi_cpu_flags flags; 202 acpi_cpu_flags flags;
203 u8 gpe_dispatch_mask;
206 204
207 ACPI_FUNCTION_TRACE(acpi_setup_gpe_for_wake); 205 ACPI_FUNCTION_TRACE(acpi_setup_gpe_for_wake);
208 206
@@ -216,96 +214,63 @@ acpi_setup_gpe_for_wake(acpi_handle wake_device,
216 return_ACPI_STATUS(AE_BAD_PARAMETER); 214 return_ACPI_STATUS(AE_BAD_PARAMETER);
217 } 215 }
218 216
219 /* Handle root object case */
220
221 if (wake_device == ACPI_ROOT_OBJECT) {
222 device_node = acpi_gbl_root_node;
223 } else {
224 device_node =
225 ACPI_CAST_PTR(struct acpi_namespace_node, wake_device);
226 }
227
228 /* Validate WakeDevice is of type Device */
229
230 if (device_node->type != ACPI_TYPE_DEVICE) {
231 return_ACPI_STATUS (AE_BAD_PARAMETER);
232 }
233
234 /*
235 * Allocate a new notify object up front, in case it is needed.
236 * Memory allocation while holding a spinlock is a big no-no
237 * on some hosts.
238 */
239 new_notify = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_notify_info));
240 if (!new_notify) {
241 return_ACPI_STATUS(AE_NO_MEMORY);
242 }
243
244 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 217 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
245 218
246 /* Ensure that we have a valid GPE number */ 219 /* Ensure that we have a valid GPE number */
247 220
248 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 221 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
249 if (!gpe_event_info) { 222 if (!gpe_event_info) {
250 status = AE_BAD_PARAMETER;
251 goto unlock_and_exit; 223 goto unlock_and_exit;
252 } 224 }
253 225
226 if (wake_device == ACPI_ROOT_OBJECT) {
227 goto out;
228 }
229
254 /* 230 /*
255 * If there is no method or handler for this GPE, then the 231 * If there is no method or handler for this GPE, then the
256 * wake_device will be notified whenever this GPE fires. This is 232 * wake_device will be notified whenever this GPE fires (aka
257 * known as an "implicit notify". Note: The GPE is assumed to be 233 * "implicit notify") Note: The GPE is assumed to be
258 * level-triggered (for windows compatibility). 234 * level-triggered (for windows compatibility).
259 */ 235 */
260 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 236 gpe_dispatch_mask = gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK;
261 ACPI_GPE_DISPATCH_NONE) { 237 if (gpe_dispatch_mask != ACPI_GPE_DISPATCH_NONE
262 /* 238 && gpe_dispatch_mask != ACPI_GPE_DISPATCH_NOTIFY) {
263 * This is the first device for implicit notify on this GPE. 239 goto out;
264 * Just set the flags here, and enter the NOTIFY block below.
265 */
266 gpe_event_info->flags =
267 (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
268 } 240 }
269 241
270 /* 242 /* Validate wake_device is of type Device */
271 * If we already have an implicit notify on this GPE, add
272 * this device to the notify list.
273 */
274 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
275 ACPI_GPE_DISPATCH_NOTIFY) {
276
277 /* Ensure that the device is not already in the list */
278
279 notify = gpe_event_info->dispatch.notify_list;
280 while (notify) {
281 if (notify->device_node == device_node) {
282 status = AE_ALREADY_EXISTS;
283 goto unlock_and_exit;
284 }
285 notify = notify->next;
286 }
287 243
288 /* Add this device to the notify list for this GPE */ 244 device_node = ACPI_CAST_PTR(struct acpi_namespace_node, wake_device);
289 245 if (device_node->type != ACPI_TYPE_DEVICE) {
290 new_notify->device_node = device_node; 246 goto unlock_and_exit;
291 new_notify->next = gpe_event_info->dispatch.notify_list;
292 gpe_event_info->dispatch.notify_list = new_notify;
293 new_notify = NULL;
294 } 247 }
295 248
296 /* Mark the GPE as a possible wake event */ 249 if (gpe_dispatch_mask == ACPI_GPE_DISPATCH_NONE) {
250 gpe_event_info->flags = (ACPI_GPE_DISPATCH_NOTIFY |
251 ACPI_GPE_LEVEL_TRIGGERED);
252 gpe_event_info->dispatch.device.node = device_node;
253 gpe_event_info->dispatch.device.next = NULL;
254 } else {
255 /* There are multiple devices to notify implicitly. */
256
257 notify_object = ACPI_ALLOCATE_ZEROED(sizeof(*notify_object));
258 if (!notify_object) {
259 status = AE_NO_MEMORY;
260 goto unlock_and_exit;
261 }
297 262
263 notify_object->node = device_node;
264 notify_object->next = gpe_event_info->dispatch.device.next;
265 gpe_event_info->dispatch.device.next = notify_object;
266 }
267
268 out:
298 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE; 269 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
299 status = AE_OK; 270 status = AE_OK;
300 271
301unlock_and_exit: 272 unlock_and_exit:
302 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 273 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
303
304 /* Delete the notify object if it was not used above */
305
306 if (new_notify) {
307 ACPI_FREE(new_notify);
308 }
309 return_ACPI_STATUS(status); 274 return_ACPI_STATUS(status);
310} 275}
311ACPI_EXPORT_SYMBOL(acpi_setup_gpe_for_wake) 276ACPI_EXPORT_SYMBOL(acpi_setup_gpe_for_wake)
@@ -316,7 +281,7 @@ ACPI_EXPORT_SYMBOL(acpi_setup_gpe_for_wake)
316 * 281 *
317 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 282 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
318 * gpe_number - GPE level within the GPE block 283 * gpe_number - GPE level within the GPE block
319 * action - Enable or Disable 284 * Action - Enable or Disable
320 * 285 *
321 * RETURN: Status 286 * RETURN: Status
322 * 287 *
@@ -325,8 +290,7 @@ ACPI_EXPORT_SYMBOL(acpi_setup_gpe_for_wake)
325 * 290 *
326 ******************************************************************************/ 291 ******************************************************************************/
327 292
328acpi_status 293acpi_status acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action)
329acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action)
330{ 294{
331 acpi_status status = AE_OK; 295 acpi_status status = AE_OK;
332 struct acpi_gpe_event_info *gpe_event_info; 296 struct acpi_gpe_event_info *gpe_event_info;
@@ -359,7 +323,8 @@ acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action)
359 goto unlock_and_exit; 323 goto unlock_and_exit;
360 } 324 }
361 325
362 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info); 326 register_bit =
327 acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
363 328
364 /* Perform the action */ 329 /* Perform the action */
365 330
@@ -541,7 +506,7 @@ ACPI_EXPORT_SYMBOL(acpi_enable_all_runtime_gpes)
541 * FUNCTION: acpi_install_gpe_block 506 * FUNCTION: acpi_install_gpe_block
542 * 507 *
543 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device 508 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
544 * gpe_block_address - Address and space_ID 509 * gpe_block_address - Address and space_iD
545 * register_count - Number of GPE register pairs in the block 510 * register_count - Number of GPE register pairs in the block
546 * interrupt_number - H/W interrupt for the block 511 * interrupt_number - H/W interrupt for the block
547 * 512 *
@@ -569,7 +534,7 @@ acpi_install_gpe_block(acpi_handle gpe_device,
569 534
570 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 535 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
571 if (ACPI_FAILURE(status)) { 536 if (ACPI_FAILURE(status)) {
572 return_ACPI_STATUS(status); 537 return (status);
573 } 538 }
574 539
575 node = acpi_ns_validate_handle(gpe_device); 540 node = acpi_ns_validate_handle(gpe_device);
@@ -652,7 +617,7 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
652 617
653 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 618 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
654 if (ACPI_FAILURE(status)) { 619 if (ACPI_FAILURE(status)) {
655 return_ACPI_STATUS(status); 620 return (status);
656 } 621 }
657 622
658 node = acpi_ns_validate_handle(gpe_device); 623 node = acpi_ns_validate_handle(gpe_device);
@@ -686,7 +651,7 @@ ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
686 * 651 *
687 * FUNCTION: acpi_get_gpe_device 652 * FUNCTION: acpi_get_gpe_device
688 * 653 *
689 * PARAMETERS: index - System GPE index (0-current_gpe_count) 654 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
690 * gpe_device - Where the parent GPE Device is returned 655 * gpe_device - Where the parent GPE Device is returned
691 * 656 *
692 * RETURN: Status 657 * RETURN: Status
@@ -696,7 +661,8 @@ ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
696 * the FADT-defined gpe blocks. Otherwise, the GPE block device. 661 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
697 * 662 *
698 ******************************************************************************/ 663 ******************************************************************************/
699acpi_status acpi_get_gpe_device(u32 index, acpi_handle * gpe_device) 664acpi_status
665acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
700{ 666{
701 struct acpi_gpe_device_info info; 667 struct acpi_gpe_device_info info;
702 acpi_status status; 668 acpi_status status;
@@ -728,4 +694,3 @@ acpi_status acpi_get_gpe_device(u32 index, acpi_handle * gpe_device)
728} 694}
729 695
730ACPI_EXPORT_SYMBOL(acpi_get_gpe_device) 696ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
731#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index 96b412d0395..00cd95692a9 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45#include <linux/export.h>
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include "accommon.h" 46#include "accommon.h"
48#include "acnamesp.h" 47#include "acnamesp.h"
@@ -55,11 +54,11 @@ ACPI_MODULE_NAME("evxfregn")
55 * 54 *
56 * FUNCTION: acpi_install_address_space_handler 55 * FUNCTION: acpi_install_address_space_handler
57 * 56 *
58 * PARAMETERS: device - Handle for the device 57 * PARAMETERS: Device - Handle for the device
59 * space_id - The address space ID 58 * space_id - The address space ID
60 * handler - Address of the handler 59 * Handler - Address of the handler
61 * setup - Address of the setup function 60 * Setup - Address of the setup function
62 * context - Value passed to the handler on each access 61 * Context - Value passed to the handler on each access
63 * 62 *
64 * RETURN: Status 63 * RETURN: Status
65 * 64 *
@@ -112,16 +111,16 @@ acpi_install_address_space_handler(acpi_handle device,
112 } 111 }
113 112
114 /* 113 /*
115 * For the default space_IDs, (the IDs for which there are default region handlers 114 * For the default space_iDs, (the IDs for which there are default region handlers
116 * installed) Only execute the _REG methods if the global initialization _REG 115 * installed) Only execute the _REG methods if the global initialization _REG
117 * methods have already been run (via acpi_initialize_objects). In other words, 116 * methods have already been run (via acpi_initialize_objects). In other words,
118 * we will defer the execution of the _REG methods for these space_IDs until 117 * we will defer the execution of the _REG methods for these space_iDs until
119 * execution of acpi_initialize_objects. This is done because we need the handlers 118 * execution of acpi_initialize_objects. This is done because we need the handlers
120 * for the default spaces (mem/io/pci/table) to be installed before we can run 119 * for the default spaces (mem/io/pci/table) to be installed before we can run
121 * any control methods (or _REG methods). There is known BIOS code that depends 120 * any control methods (or _REG methods). There is known BIOS code that depends
122 * on this. 121 * on this.
123 * 122 *
124 * For all other space_IDs, we can safely execute the _REG methods immediately. 123 * For all other space_iDs, we can safely execute the _REG methods immediately.
125 * This means that for IDs like embedded_controller, this function should be called 124 * This means that for IDs like embedded_controller, this function should be called
126 * only after acpi_enable_subsystem has been called. 125 * only after acpi_enable_subsystem has been called.
127 */ 126 */
@@ -157,9 +156,9 @@ ACPI_EXPORT_SYMBOL(acpi_install_address_space_handler)
157 * 156 *
158 * FUNCTION: acpi_remove_address_space_handler 157 * FUNCTION: acpi_remove_address_space_handler
159 * 158 *
160 * PARAMETERS: device - Handle for the device 159 * PARAMETERS: Device - Handle for the device
161 * space_id - The address space ID 160 * space_id - The address space ID
162 * handler - Address of the handler 161 * Handler - Address of the handler
163 * 162 *
164 * RETURN: Status 163 * RETURN: Status
165 * 164 *
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 16219bde48d..745a42b401f 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -66,7 +66,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc,
66 * 66 *
67 * FUNCTION: acpi_ex_add_table 67 * FUNCTION: acpi_ex_add_table
68 * 68 *
69 * PARAMETERS: table - Pointer to raw table 69 * PARAMETERS: Table - Pointer to raw table
70 * parent_node - Where to load the table (scope) 70 * parent_node - Where to load the table (scope)
71 * ddb_handle - Where to return the table handle. 71 * ddb_handle - Where to return the table handle.
72 * 72 *
@@ -276,8 +276,8 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
276 * FUNCTION: acpi_ex_region_read 276 * FUNCTION: acpi_ex_region_read
277 * 277 *
278 * PARAMETERS: obj_desc - Region descriptor 278 * PARAMETERS: obj_desc - Region descriptor
279 * length - Number of bytes to read 279 * Length - Number of bytes to read
280 * buffer - Pointer to where to put the data 280 * Buffer - Pointer to where to put the data
281 * 281 *
282 * RETURN: Status 282 * RETURN: Status
283 * 283 *
@@ -297,9 +297,9 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
297 /* Bytewise reads */ 297 /* Bytewise reads */
298 298
299 for (i = 0; i < length; i++) { 299 for (i = 0; i < length; i++) {
300 status = 300 status = acpi_ev_address_space_dispatch(obj_desc, ACPI_READ,
301 acpi_ev_address_space_dispatch(obj_desc, NULL, ACPI_READ, 301 region_offset, 8,
302 region_offset, 8, &value); 302 &value);
303 if (ACPI_FAILURE(status)) { 303 if (ACPI_FAILURE(status)) {
304 return status; 304 return status;
305 } 305 }
@@ -318,7 +318,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
318 * 318 *
319 * PARAMETERS: obj_desc - Region or Buffer/Field where the table will be 319 * PARAMETERS: obj_desc - Region or Buffer/Field where the table will be
320 * obtained 320 * obtained
321 * target - Where a handle to the table will be stored 321 * Target - Where a handle to the table will be stored
322 * walk_state - Current state 322 * walk_state - Current state
323 * 323 *
324 * RETURN: Status 324 * RETURN: Status
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 4492a4e0302..74162a11817 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -60,7 +60,7 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
60 * PARAMETERS: obj_desc - Object to be converted. Must be an 60 * PARAMETERS: obj_desc - Object to be converted. Must be an
61 * Integer, Buffer, or String 61 * Integer, Buffer, or String
62 * result_desc - Where the new Integer object is returned 62 * result_desc - Where the new Integer object is returned
63 * flags - Used for string conversion 63 * Flags - Used for string conversion
64 * 64 *
65 * RETURN: Status 65 * RETURN: Status
66 * 66 *
@@ -272,9 +272,9 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
272 * 272 *
273 * FUNCTION: acpi_ex_convert_to_ascii 273 * FUNCTION: acpi_ex_convert_to_ascii
274 * 274 *
275 * PARAMETERS: integer - Value to be converted 275 * PARAMETERS: Integer - Value to be converted
276 * base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX 276 * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
277 * string - Where the string is returned 277 * String - Where the string is returned
278 * data_width - Size of data item to be converted, in bytes 278 * data_width - Size of data item to be converted, in bytes
279 * 279 *
280 * RETURN: Actual string length 280 * RETURN: Actual string length
@@ -385,7 +385,7 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
385 * PARAMETERS: obj_desc - Object to be converted. Must be an 385 * PARAMETERS: obj_desc - Object to be converted. Must be an
386 * Integer, Buffer, or String 386 * Integer, Buffer, or String
387 * result_desc - Where the string object is returned 387 * result_desc - Where the string object is returned
388 * type - String flags (base and conversion type) 388 * Type - String flags (base and conversion type)
389 * 389 *
390 * RETURN: Status 390 * RETURN: Status
391 * 391 *
@@ -516,8 +516,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
516 string_length--; 516 string_length--;
517 } 517 }
518 518
519 return_desc = 519 return_desc = acpi_ut_create_string_object((acpi_size)
520 acpi_ut_create_string_object((acpi_size) string_length); 520 string_length);
521 if (!return_desc) { 521 if (!return_desc) {
522 return_ACPI_STATUS(AE_NO_MEMORY); 522 return_ACPI_STATUS(AE_NO_MEMORY);
523 } 523 }
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index 66554bc6f9a..110711afada 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -78,7 +78,7 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
78 (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { 78 (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
79 /* 79 /*
80 * Dereference an existing alias so that we don't create a chain 80 * Dereference an existing alias so that we don't create a chain
81 * of aliases. With this code, we guarantee that an alias is 81 * of aliases. With this code, we guarantee that an alias is
82 * always exactly one level of indirection away from the 82 * always exactly one level of indirection away from the
83 * actual aliased name. 83 * actual aliased name.
84 */ 84 */
@@ -90,7 +90,7 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
90 /* 90 /*
91 * For objects that can never change (i.e., the NS node will 91 * For objects that can never change (i.e., the NS node will
92 * permanently point to the same object), we can simply attach 92 * permanently point to the same object), we can simply attach
93 * the object to the new NS node. For other objects (such as 93 * the object to the new NS node. For other objects (such as
94 * Integers, buffers, etc.), we have to point the Alias node 94 * Integers, buffers, etc.), we have to point the Alias node
95 * to the original Node. 95 * to the original Node.
96 */ 96 */
@@ -139,7 +139,7 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
139 139
140 /* 140 /*
141 * The new alias assumes the type of the target, and it points 141 * The new alias assumes the type of the target, and it points
142 * to the same object. The reference count of the object has an 142 * to the same object. The reference count of the object has an
143 * additional reference to prevent deletion out from under either the 143 * additional reference to prevent deletion out from under either the
144 * target node or the alias Node 144 * target node or the alias Node
145 */ 145 */
@@ -243,7 +243,8 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
243 243
244 /* Init object and attach to NS node */ 244 /* Init object and attach to NS node */
245 245
246 obj_desc->mutex.sync_level = (u8)walk_state->operands[1]->integer.value; 246 obj_desc->mutex.sync_level =
247 (u8) walk_state->operands[1]->integer.value;
247 obj_desc->mutex.node = 248 obj_desc->mutex.node =
248 (struct acpi_namespace_node *)walk_state->operands[0]; 249 (struct acpi_namespace_node *)walk_state->operands[0];
249 250
@@ -266,7 +267,7 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
266 * 267 *
267 * PARAMETERS: aml_start - Pointer to the region declaration AML 268 * PARAMETERS: aml_start - Pointer to the region declaration AML
268 * aml_length - Max length of the declaration AML 269 * aml_length - Max length of the declaration AML
269 * space_id - Address space ID for the region 270 * region_space - space_iD for the region
270 * walk_state - Current state 271 * walk_state - Current state
271 * 272 *
272 * RETURN: Status 273 * RETURN: Status
@@ -278,7 +279,7 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
278acpi_status 279acpi_status
279acpi_ex_create_region(u8 * aml_start, 280acpi_ex_create_region(u8 * aml_start,
280 u32 aml_length, 281 u32 aml_length,
281 u8 space_id, struct acpi_walk_state *walk_state) 282 u8 region_space, struct acpi_walk_state *walk_state)
282{ 283{
283 acpi_status status; 284 acpi_status status;
284 union acpi_operand_object *obj_desc; 285 union acpi_operand_object *obj_desc;
@@ -303,19 +304,16 @@ acpi_ex_create_region(u8 * aml_start,
303 * Space ID must be one of the predefined IDs, or in the user-defined 304 * Space ID must be one of the predefined IDs, or in the user-defined
304 * range 305 * range
305 */ 306 */
306 if (!acpi_is_valid_space_id(space_id)) { 307 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) &&
307 /* 308 (region_space < ACPI_USER_REGION_BEGIN) &&
308 * Print an error message, but continue. We don't want to abort 309 (region_space != ACPI_ADR_SPACE_DATA_TABLE)) {
309 * a table load for this exception. Instead, if the region is 310 ACPI_ERROR((AE_INFO, "Invalid AddressSpace type 0x%X",
310 * actually used at runtime, abort the executing method. 311 region_space));
311 */ 312 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
312 ACPI_ERROR((AE_INFO,
313 "Invalid/unknown Address Space ID: 0x%2.2X",
314 space_id));
315 } 313 }
316 314
317 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n", 315 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
318 acpi_ut_get_region_name(space_id), space_id)); 316 acpi_ut_get_region_name(region_space), region_space));
319 317
320 /* Create the region descriptor */ 318 /* Create the region descriptor */
321 319
@@ -332,16 +330,10 @@ acpi_ex_create_region(u8 * aml_start,
332 region_obj2 = obj_desc->common.next_object; 330 region_obj2 = obj_desc->common.next_object;
333 region_obj2->extra.aml_start = aml_start; 331 region_obj2->extra.aml_start = aml_start;
334 region_obj2->extra.aml_length = aml_length; 332 region_obj2->extra.aml_length = aml_length;
335 if (walk_state->scope_info) {
336 region_obj2->extra.scope_node =
337 walk_state->scope_info->scope.node;
338 } else {
339 region_obj2->extra.scope_node = node;
340 }
341 333
342 /* Init the region from the operands */ 334 /* Init the region from the operands */
343 335
344 obj_desc->region.space_id = space_id; 336 obj_desc->region.space_id = region_space;
345 obj_desc->region.address = 0; 337 obj_desc->region.address = 0;
346 obj_desc->region.length = 0; 338 obj_desc->region.length = 0;
347 obj_desc->region.node = node; 339 obj_desc->region.node = node;
@@ -368,7 +360,7 @@ acpi_ex_create_region(u8 * aml_start,
368 * 360 *
369 * DESCRIPTION: Create a new processor object and populate the fields 361 * DESCRIPTION: Create a new processor object and populate the fields
370 * 362 *
371 * Processor (Name[0], cpu_ID[1], pblock_addr[2], pblock_length[3]) 363 * Processor (Name[0], cpu_iD[1], pblock_addr[2], pblock_length[3])
372 * 364 *
373 ******************************************************************************/ 365 ******************************************************************************/
374 366
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c
index d7c9f51608a..c7a2f1edd28 100644
--- a/drivers/acpi/acpica/exdebug.c
+++ b/drivers/acpi/acpica/exdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,8 +54,8 @@ ACPI_MODULE_NAME("exdebug")
54 * FUNCTION: acpi_ex_do_debug_object 54 * FUNCTION: acpi_ex_do_debug_object
55 * 55 *
56 * PARAMETERS: source_desc - Object to be output to "Debug Object" 56 * PARAMETERS: source_desc - Object to be output to "Debug Object"
57 * level - Indentation level (used for packages) 57 * Level - Indentation level (used for packages)
58 * index - Current package element, zero if not pkg 58 * Index - Current package element, zero if not pkg
59 * 59 *
60 * RETURN: None 60 * RETURN: None
61 * 61 *
@@ -145,10 +145,10 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
145 case ACPI_TYPE_BUFFER: 145 case ACPI_TYPE_BUFFER:
146 146
147 acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length); 147 acpi_os_printf("[0x%.2X]\n", (u32)source_desc->buffer.length);
148 acpi_ut_dump_buffer(source_desc->buffer.pointer, 148 acpi_ut_dump_buffer2(source_desc->buffer.pointer,
149 (source_desc->buffer.length < 256) ? 149 (source_desc->buffer.length < 256) ?
150 source_desc->buffer.length : 256, 150 source_desc->buffer.length : 256,
151 DB_BYTE_DISPLAY, 0); 151 DB_BYTE_DISPLAY);
152 break; 152 break;
153 153
154 case ACPI_TYPE_STRING: 154 case ACPI_TYPE_STRING:
@@ -190,7 +190,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
190 190
191 acpi_os_printf("Table Index 0x%X\n", 191 acpi_os_printf("Table Index 0x%X\n",
192 source_desc->reference.value); 192 source_desc->reference.value);
193 return_VOID; 193 return;
194 194
195 default: 195 default:
196 break; 196 break;
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index 858b43a7dcf..61b8c0e8b74 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -109,9 +109,9 @@ static struct acpi_exdump_info acpi_ex_dump_package[5] = {
109static struct acpi_exdump_info acpi_ex_dump_device[4] = { 109static struct acpi_exdump_info acpi_ex_dump_device[4] = {
110 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL}, 110 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL},
111 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"}, 111 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"},
112 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[0]), 112 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.system_notify),
113 "System Notify"}, 113 "System Notify"},
114 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[1]), 114 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.device_notify),
115 "Device Notify"} 115 "Device Notify"}
116}; 116};
117 117
@@ -158,9 +158,9 @@ static struct acpi_exdump_info acpi_ex_dump_power[5] = {
158 "System Level"}, 158 "System Level"},
159 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order), 159 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order),
160 "Resource Order"}, 160 "Resource Order"},
161 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[0]), 161 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.system_notify),
162 "System Notify"}, 162 "System Notify"},
163 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[1]), 163 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.device_notify),
164 "Device Notify"} 164 "Device Notify"}
165}; 165};
166 166
@@ -169,18 +169,18 @@ static struct acpi_exdump_info acpi_ex_dump_processor[7] = {
169 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"}, 169 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"},
170 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.length), "Length"}, 170 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.length), "Length"},
171 {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"}, 171 {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"},
172 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.notify_list[0]), 172 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.system_notify),
173 "System Notify"}, 173 "System Notify"},
174 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.notify_list[1]), 174 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.device_notify),
175 "Device Notify"}, 175 "Device Notify"},
176 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"} 176 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"}
177}; 177};
178 178
179static struct acpi_exdump_info acpi_ex_dump_thermal[4] = { 179static struct acpi_exdump_info acpi_ex_dump_thermal[4] = {
180 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL}, 180 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL},
181 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.notify_list[0]), 181 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.system_notify),
182 "System Notify"}, 182 "System Notify"},
183 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.notify_list[1]), 183 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.device_notify),
184 "Device Notify"}, 184 "Device Notify"},
185 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"} 185 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"}
186}; 186};
@@ -192,13 +192,10 @@ static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = {
192 "Buffer Object"} 192 "Buffer Object"}
193}; 193};
194 194
195static struct acpi_exdump_info acpi_ex_dump_region_field[5] = { 195static struct acpi_exdump_info acpi_ex_dump_region_field[3] = {
196 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL}, 196 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL},
197 {ACPI_EXD_FIELD, 0, NULL}, 197 {ACPI_EXD_FIELD, 0, NULL},
198 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(field.access_length), "AccessLength"}, 198 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"}
199 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"},
200 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.resource_buffer),
201 "ResourceBuffer"}
202}; 199};
203 200
204static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = { 201static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = {
@@ -241,15 +238,10 @@ static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = {
241 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"} 238 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"}
242}; 239};
243 240
244static struct acpi_exdump_info acpi_ex_dump_notify[7] = { 241static struct acpi_exdump_info acpi_ex_dump_notify[3] = {
245 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL}, 242 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL},
246 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.node), "Node"}, 243 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.node), "Node"},
247 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(notify.handler_type), "Handler Type"}, 244 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"}
248 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.handler), "Handler"},
249 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"},
250 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.next[0]),
251 "Next System Notify"},
252 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.next[1]), "Next Device Notify"}
253}; 245};
254 246
255/* Miscellaneous tables */ 247/* Miscellaneous tables */
@@ -323,7 +315,7 @@ static struct acpi_exdump_info *acpi_ex_dump_info[] = {
323 * FUNCTION: acpi_ex_dump_object 315 * FUNCTION: acpi_ex_dump_object
324 * 316 *
325 * PARAMETERS: obj_desc - Descriptor to dump 317 * PARAMETERS: obj_desc - Descriptor to dump
326 * info - Info table corresponding to this object 318 * Info - Info table corresponding to this object
327 * type 319 * type
328 * 320 *
329 * RETURN: None 321 * RETURN: None
@@ -449,7 +441,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
449 * FUNCTION: acpi_ex_dump_operand 441 * FUNCTION: acpi_ex_dump_operand
450 * 442 *
451 * PARAMETERS: *obj_desc - Pointer to entry to be dumped 443 * PARAMETERS: *obj_desc - Pointer to entry to be dumped
452 * depth - Current nesting depth 444 * Depth - Current nesting depth
453 * 445 *
454 * RETURN: None 446 * RETURN: None
455 * 447 *
@@ -464,8 +456,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
464 456
465 ACPI_FUNCTION_NAME(ex_dump_operand) 457 ACPI_FUNCTION_NAME(ex_dump_operand)
466 458
467 if (! 459 if (!((ACPI_LV_EXEC & acpi_dbg_level)
468 ((ACPI_LV_EXEC & acpi_dbg_level)
469 && (_COMPONENT & acpi_dbg_layer))) { 460 && (_COMPONENT & acpi_dbg_layer))) {
470 return; 461 return;
471 } 462 }
@@ -732,7 +723,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
732 * 723 *
733 * FUNCTION: acpi_ex_dump_operands 724 * FUNCTION: acpi_ex_dump_operands
734 * 725 *
735 * PARAMETERS: operands - A list of Operand objects 726 * PARAMETERS: Operands - A list of Operand objects
736 * opcode_name - AML opcode name 727 * opcode_name - AML opcode name
737 * num_operands - Operand count for this opcode 728 * num_operands - Operand count for this opcode
738 * 729 *
@@ -775,10 +766,10 @@ acpi_ex_dump_operands(union acpi_operand_object **operands,
775 * 766 *
776 * FUNCTION: acpi_ex_out* functions 767 * FUNCTION: acpi_ex_out* functions
777 * 768 *
778 * PARAMETERS: title - Descriptive text 769 * PARAMETERS: Title - Descriptive text
779 * value - Value to be displayed 770 * Value - Value to be displayed
780 * 771 *
781 * DESCRIPTION: Object dump output formatting functions. These functions 772 * DESCRIPTION: Object dump output formatting functions. These functions
782 * reduce the number of format strings required and keeps them 773 * reduce the number of format strings required and keeps them
783 * all in one place for easy modification. 774 * all in one place for easy modification.
784 * 775 *
@@ -798,8 +789,8 @@ static void acpi_ex_out_pointer(char *title, void *value)
798 * 789 *
799 * FUNCTION: acpi_ex_dump_namespace_node 790 * FUNCTION: acpi_ex_dump_namespace_node
800 * 791 *
801 * PARAMETERS: node - Descriptor to dump 792 * PARAMETERS: Node - Descriptor to dump
802 * flags - Force display if TRUE 793 * Flags - Force display if TRUE
803 * 794 *
804 * DESCRIPTION: Dumps the members of the given.Node 795 * DESCRIPTION: Dumps the members of the given.Node
805 * 796 *
@@ -811,8 +802,7 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
811 ACPI_FUNCTION_ENTRY(); 802 ACPI_FUNCTION_ENTRY();
812 803
813 if (!flags) { 804 if (!flags) {
814 if (! 805 if (!((ACPI_LV_OBJECTS & acpi_dbg_level)
815 ((ACPI_LV_OBJECTS & acpi_dbg_level)
816 && (_COMPONENT & acpi_dbg_layer))) { 806 && (_COMPONENT & acpi_dbg_layer))) {
817 return; 807 return;
818 } 808 }
@@ -832,7 +822,7 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
832 * 822 *
833 * FUNCTION: acpi_ex_dump_reference_obj 823 * FUNCTION: acpi_ex_dump_reference_obj
834 * 824 *
835 * PARAMETERS: object - Descriptor to dump 825 * PARAMETERS: Object - Descriptor to dump
836 * 826 *
837 * DESCRIPTION: Dumps a reference object 827 * DESCRIPTION: Dumps a reference object
838 * 828 *
@@ -889,8 +879,8 @@ static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
889 * FUNCTION: acpi_ex_dump_package_obj 879 * FUNCTION: acpi_ex_dump_package_obj
890 * 880 *
891 * PARAMETERS: obj_desc - Descriptor to dump 881 * PARAMETERS: obj_desc - Descriptor to dump
892 * level - Indentation Level 882 * Level - Indentation Level
893 * index - Package index for this object 883 * Index - Package index for this object
894 * 884 *
895 * DESCRIPTION: Dumps the elements of the package 885 * DESCRIPTION: Dumps the elements of the package
896 * 886 *
@@ -933,7 +923,9 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
933 case ACPI_TYPE_STRING: 923 case ACPI_TYPE_STRING:
934 924
935 acpi_os_printf("[String] Value: "); 925 acpi_os_printf("[String] Value: ");
936 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX); 926 for (i = 0; i < obj_desc->string.length; i++) {
927 acpi_os_printf("%c", obj_desc->string.pointer[i]);
928 }
937 acpi_os_printf("\n"); 929 acpi_os_printf("\n");
938 break; 930 break;
939 931
@@ -942,11 +934,10 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
942 acpi_os_printf("[Buffer] Length %.2X = ", 934 acpi_os_printf("[Buffer] Length %.2X = ",
943 obj_desc->buffer.length); 935 obj_desc->buffer.length);
944 if (obj_desc->buffer.length) { 936 if (obj_desc->buffer.length) {
945 acpi_ut_debug_dump_buffer(ACPI_CAST_PTR 937 acpi_ut_dump_buffer(ACPI_CAST_PTR
946 (u8, 938 (u8, obj_desc->buffer.pointer),
947 obj_desc->buffer.pointer), 939 obj_desc->buffer.length,
948 obj_desc->buffer.length, 940 DB_DWORD_DISPLAY, _COMPONENT);
949 DB_DWORD_DISPLAY, _COMPONENT);
950 } else { 941 } else {
951 acpi_os_printf("\n"); 942 acpi_os_printf("\n");
952 } 943 }
@@ -983,7 +974,7 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
983 * FUNCTION: acpi_ex_dump_object_descriptor 974 * FUNCTION: acpi_ex_dump_object_descriptor
984 * 975 *
985 * PARAMETERS: obj_desc - Descriptor to dump 976 * PARAMETERS: obj_desc - Descriptor to dump
986 * flags - Force display if TRUE 977 * Flags - Force display if TRUE
987 * 978 *
988 * DESCRIPTION: Dumps the members of the object descriptor given. 979 * DESCRIPTION: Dumps the members of the object descriptor given.
989 * 980 *
@@ -999,8 +990,7 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
999 } 990 }
1000 991
1001 if (!flags) { 992 if (!flags) {
1002 if (! 993 if (!((ACPI_LV_OBJECTS & acpi_dbg_level)
1003 ((ACPI_LV_OBJECTS & acpi_dbg_level)
1004 && (_COMPONENT & acpi_dbg_layer))) { 994 && (_COMPONENT & acpi_dbg_layer))) {
1005 return_VOID; 995 return_VOID;
1006 } 996 }
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index ebc55fbf3ff..0bde2230c02 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -59,7 +59,7 @@ ACPI_MODULE_NAME("exfield")
59 * 59 *
60 * RETURN: Status 60 * RETURN: Status
61 * 61 *
62 * DESCRIPTION: Read from a named field. Returns either an Integer or a 62 * DESCRIPTION: Read from a named field. Returns either an Integer or a
63 * Buffer, depending on the size of the field. 63 * Buffer, depending on the size of the field.
64 * 64 *
65 ******************************************************************************/ 65 ******************************************************************************/
@@ -100,25 +100,18 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
100 (obj_desc->field.region_obj->region.space_id == 100 (obj_desc->field.region_obj->region.space_id ==
101 ACPI_ADR_SPACE_SMBUS 101 ACPI_ADR_SPACE_SMBUS
102 || obj_desc->field.region_obj->region.space_id == 102 || obj_desc->field.region_obj->region.space_id ==
103 ACPI_ADR_SPACE_GSBUS
104 || obj_desc->field.region_obj->region.space_id ==
105 ACPI_ADR_SPACE_IPMI)) { 103 ACPI_ADR_SPACE_IPMI)) {
106 /* 104 /*
107 * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold 105 * This is an SMBus or IPMI read. We must create a buffer to hold
108 * the data and then directly access the region handler. 106 * the data and then directly access the region handler.
109 * 107 *
110 * Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function 108 * Note: Smbus protocol value is passed in upper 16-bits of Function
111 */ 109 */
112 if (obj_desc->field.region_obj->region.space_id == 110 if (obj_desc->field.region_obj->region.space_id ==
113 ACPI_ADR_SPACE_SMBUS) { 111 ACPI_ADR_SPACE_SMBUS) {
114 length = ACPI_SMBUS_BUFFER_SIZE; 112 length = ACPI_SMBUS_BUFFER_SIZE;
115 function = 113 function =
116 ACPI_READ | (obj_desc->field.attribute << 16); 114 ACPI_READ | (obj_desc->field.attribute << 16);
117 } else if (obj_desc->field.region_obj->region.space_id ==
118 ACPI_ADR_SPACE_GSBUS) {
119 length = ACPI_GSBUS_BUFFER_SIZE;
120 function =
121 ACPI_READ | (obj_desc->field.attribute << 16);
122 } else { /* IPMI */ 115 } else { /* IPMI */
123 116
124 length = ACPI_IPMI_BUFFER_SIZE; 117 length = ACPI_IPMI_BUFFER_SIZE;
@@ -149,7 +142,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
149 * Allocate a buffer for the contents of the field. 142 * Allocate a buffer for the contents of the field.
150 * 143 *
151 * If the field is larger than the current integer width, create 144 * If the field is larger than the current integer width, create
152 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows 145 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
153 * the use of arithmetic operators on the returned value if the 146 * the use of arithmetic operators on the returned value if the
154 * field size is equal or smaller than an Integer. 147 * field size is equal or smaller than an Integer.
155 * 148 *
@@ -255,23 +248,21 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
255 (obj_desc->field.region_obj->region.space_id == 248 (obj_desc->field.region_obj->region.space_id ==
256 ACPI_ADR_SPACE_SMBUS 249 ACPI_ADR_SPACE_SMBUS
257 || obj_desc->field.region_obj->region.space_id == 250 || obj_desc->field.region_obj->region.space_id ==
258 ACPI_ADR_SPACE_GSBUS
259 || obj_desc->field.region_obj->region.space_id ==
260 ACPI_ADR_SPACE_IPMI)) { 251 ACPI_ADR_SPACE_IPMI)) {
261 /* 252 /*
262 * This is an SMBus, GSBus or IPMI write. We will bypass the entire field 253 * This is an SMBus or IPMI write. We will bypass the entire field
263 * mechanism and handoff the buffer directly to the handler. For 254 * mechanism and handoff the buffer directly to the handler. For
264 * these address spaces, the buffer is bi-directional; on a write, 255 * these address spaces, the buffer is bi-directional; on a write,
265 * return data is returned in the same buffer. 256 * return data is returned in the same buffer.
266 * 257 *
267 * Source must be a buffer of sufficient size: 258 * Source must be a buffer of sufficient size:
268 * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE. 259 * ACPI_SMBUS_BUFFER_SIZE or ACPI_IPMI_BUFFER_SIZE.
269 * 260 *
270 * Note: SMBus and GSBus protocol type is passed in upper 16-bits of Function 261 * Note: SMBus protocol type is passed in upper 16-bits of Function
271 */ 262 */
272 if (source_desc->common.type != ACPI_TYPE_BUFFER) { 263 if (source_desc->common.type != ACPI_TYPE_BUFFER) {
273 ACPI_ERROR((AE_INFO, 264 ACPI_ERROR((AE_INFO,
274 "SMBus/IPMI/GenericSerialBus write requires Buffer, found type %s", 265 "SMBus or IPMI write requires Buffer, found type %s",
275 acpi_ut_get_object_type_name(source_desc))); 266 acpi_ut_get_object_type_name(source_desc)));
276 267
277 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 268 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
@@ -282,11 +273,6 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
282 length = ACPI_SMBUS_BUFFER_SIZE; 273 length = ACPI_SMBUS_BUFFER_SIZE;
283 function = 274 function =
284 ACPI_WRITE | (obj_desc->field.attribute << 16); 275 ACPI_WRITE | (obj_desc->field.attribute << 16);
285 } else if (obj_desc->field.region_obj->region.space_id ==
286 ACPI_ADR_SPACE_GSBUS) {
287 length = ACPI_GSBUS_BUFFER_SIZE;
288 function =
289 ACPI_WRITE | (obj_desc->field.attribute << 16);
290 } else { /* IPMI */ 276 } else { /* IPMI */
291 277
292 length = ACPI_IPMI_BUFFER_SIZE; 278 length = ACPI_IPMI_BUFFER_SIZE;
@@ -295,7 +281,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
295 281
296 if (source_desc->buffer.length < length) { 282 if (source_desc->buffer.length < length) {
297 ACPI_ERROR((AE_INFO, 283 ACPI_ERROR((AE_INFO,
298 "SMBus/IPMI/GenericSerialBus write requires Buffer of length %u, found length %u", 284 "SMBus or IPMI write requires Buffer of length %u, found length %u",
299 length, source_desc->buffer.length)); 285 length, source_desc->buffer.length));
300 286
301 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); 287 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index aa2ccfb7cb6..f915a7f3f92 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,7 +54,8 @@ ACPI_MODULE_NAME("exfldio")
54/* Local prototypes */ 54/* Local prototypes */
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, u64 *value, u32 read_write); 57 u32 field_datum_byte_offset,
58 u64 *value, u32 read_write);
58 59
59static u8 60static u8
60acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value); 61acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value);
@@ -85,7 +86,6 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
85{ 86{
86 acpi_status status = AE_OK; 87 acpi_status status = AE_OK;
87 union acpi_operand_object *rgn_desc; 88 union acpi_operand_object *rgn_desc;
88 u8 space_id;
89 89
90 ACPI_FUNCTION_TRACE_U32(ex_setup_region, field_datum_byte_offset); 90 ACPI_FUNCTION_TRACE_U32(ex_setup_region, field_datum_byte_offset);
91 91
@@ -101,17 +101,6 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
101 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 101 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
102 } 102 }
103 103
104 space_id = rgn_desc->region.space_id;
105
106 /* Validate the Space ID */
107
108 if (!acpi_is_valid_space_id(space_id)) {
109 ACPI_ERROR((AE_INFO,
110 "Invalid/unknown Address Space ID: 0x%2.2X",
111 space_id));
112 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
113 }
114
115 /* 104 /*
116 * If the Region Address and Length have not been previously evaluated, 105 * If the Region Address and Length have not been previously evaluated,
117 * evaluate them now and save the results. 106 * evaluate them now and save the results.
@@ -130,12 +119,11 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
130 } 119 }
131 120
132 /* 121 /*
133 * Exit now for SMBus, GSBus or IPMI address space, it has a non-linear 122 * Exit now for SMBus or IPMI address space, it has a non-linear
134 * address space and the request cannot be directly validated 123 * address space and the request cannot be directly validated
135 */ 124 */
136 if (space_id == ACPI_ADR_SPACE_SMBUS || 125 if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS ||
137 space_id == ACPI_ADR_SPACE_GSBUS || 126 rgn_desc->region.space_id == ACPI_ADR_SPACE_IPMI) {
138 space_id == ACPI_ADR_SPACE_IPMI) {
139 127
140 /* SMBus or IPMI has a non-linear address space */ 128 /* SMBus or IPMI has a non-linear address space */
141 129
@@ -154,7 +142,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
154#endif 142#endif
155 143
156 /* 144 /*
157 * Validate the request. The entire request from the byte offset for a 145 * Validate the request. The entire request from the byte offset for a
158 * length of one field datum (access width) must fit within the region. 146 * length of one field datum (access width) must fit within the region.
159 * (Region length is specified in bytes) 147 * (Region length is specified in bytes)
160 */ 148 */
@@ -182,7 +170,7 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
182 obj_desc->common_field.access_byte_width) { 170 obj_desc->common_field.access_byte_width) {
183 /* 171 /*
184 * This is the case where the access_type (acc_word, etc.) is wider 172 * This is the case where the access_type (acc_word, etc.) is wider
185 * than the region itself. For example, a region of length one 173 * than the region itself. For example, a region of length one
186 * byte, and a field with Dword access specified. 174 * byte, and a field with Dword access specified.
187 */ 175 */
188 ACPI_ERROR((AE_INFO, 176 ACPI_ERROR((AE_INFO,
@@ -221,9 +209,9 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
221 * PARAMETERS: obj_desc - Field to be read 209 * PARAMETERS: obj_desc - Field to be read
222 * field_datum_byte_offset - Byte offset of this datum within the 210 * field_datum_byte_offset - Byte offset of this datum within the
223 * parent field 211 * parent field
224 * value - Where to store value (must at least 212 * Value - Where to store value (must at least
225 * 64 bits) 213 * 64 bits)
226 * function - Read or Write flag plus other region- 214 * Function - Read or Write flag plus other region-
227 * dependent flags 215 * dependent flags
228 * 216 *
229 * RETURN: Status 217 * RETURN: Status
@@ -283,12 +271,11 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
283 271
284 /* Invoke the appropriate address_space/op_region handler */ 272 /* Invoke the appropriate address_space/op_region handler */
285 273
286 status = acpi_ev_address_space_dispatch(rgn_desc, obj_desc, 274 status =
287 function, region_offset, 275 acpi_ev_address_space_dispatch(rgn_desc, function, region_offset,
288 ACPI_MUL_8(obj_desc-> 276 ACPI_MUL_8(obj_desc->common_field.
289 common_field. 277 access_byte_width),
290 access_byte_width), 278 value);
291 value);
292 279
293 if (ACPI_FAILURE(status)) { 280 if (ACPI_FAILURE(status)) {
294 if (status == AE_NOT_IMPLEMENTED) { 281 if (status == AE_NOT_IMPLEMENTED) {
@@ -314,13 +301,13 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
314 * FUNCTION: acpi_ex_register_overflow 301 * FUNCTION: acpi_ex_register_overflow
315 * 302 *
316 * PARAMETERS: obj_desc - Register(Field) to be written 303 * PARAMETERS: obj_desc - Register(Field) to be written
317 * value - Value to be stored 304 * Value - Value to be stored
318 * 305 *
319 * RETURN: TRUE if value overflows the field, FALSE otherwise 306 * RETURN: TRUE if value overflows the field, FALSE otherwise
320 * 307 *
321 * DESCRIPTION: Check if a value is out of range of the field being written. 308 * DESCRIPTION: Check if a value is out of range of the field being written.
322 * Used to check if the values written to Index and Bank registers 309 * Used to check if the values written to Index and Bank registers
323 * are out of range. Normally, the value is simply truncated 310 * are out of range. Normally, the value is simply truncated
324 * to fit the field, but this case is most likely a serious 311 * to fit the field, but this case is most likely a serious
325 * coding error in the ASL. 312 * coding error in the ASL.
326 * 313 *
@@ -329,7 +316,6 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
329static u8 316static u8
330acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value) 317acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
331{ 318{
332 ACPI_FUNCTION_NAME(ex_register_overflow);
333 319
334 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) { 320 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
335 /* 321 /*
@@ -344,11 +330,6 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
344 * The Value is larger than the maximum value that can fit into 330 * The Value is larger than the maximum value that can fit into
345 * the register. 331 * the register.
346 */ 332 */
347 ACPI_ERROR((AE_INFO,
348 "Index value 0x%8.8X%8.8X overflows field width 0x%X",
349 ACPI_FORMAT_UINT64(value),
350 obj_desc->common_field.bit_length));
351
352 return (TRUE); 333 return (TRUE);
353 } 334 }
354 335
@@ -364,12 +345,12 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
364 * PARAMETERS: obj_desc - Field to be read 345 * PARAMETERS: obj_desc - Field to be read
365 * field_datum_byte_offset - Byte offset of this datum within the 346 * field_datum_byte_offset - Byte offset of this datum within the
366 * parent field 347 * parent field
367 * value - Where to store value (must be 64 bits) 348 * Value - Where to store value (must be 64 bits)
368 * read_write - Read or Write flag 349 * read_write - Read or Write flag
369 * 350 *
370 * RETURN: Status 351 * RETURN: Status
371 * 352 *
372 * DESCRIPTION: Read or Write a single datum of a field. The field_type is 353 * DESCRIPTION: Read or Write a single datum of a field. The field_type is
373 * demultiplexed here to handle the different types of fields 354 * demultiplexed here to handle the different types of fields
374 * (buffer_field, region_field, index_field, bank_field) 355 * (buffer_field, region_field, index_field, bank_field)
375 * 356 *
@@ -573,7 +554,7 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
573 * FUNCTION: acpi_ex_write_with_update_rule 554 * FUNCTION: acpi_ex_write_with_update_rule
574 * 555 *
575 * PARAMETERS: obj_desc - Field to be written 556 * PARAMETERS: obj_desc - Field to be written
576 * mask - bitmask within field datum 557 * Mask - bitmask within field datum
577 * field_value - Value to write 558 * field_value - Value to write
578 * field_datum_byte_offset - Offset of datum within field 559 * field_datum_byte_offset - Offset of datum within field
579 * 560 *
@@ -677,7 +658,7 @@ acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
677 * FUNCTION: acpi_ex_extract_from_field 658 * FUNCTION: acpi_ex_extract_from_field
678 * 659 *
679 * PARAMETERS: obj_desc - Field to be read 660 * PARAMETERS: obj_desc - Field to be read
680 * buffer - Where to store the field data 661 * Buffer - Where to store the field data
681 * buffer_length - Length of Buffer 662 * buffer_length - Length of Buffer
682 * 663 *
683 * RETURN: Status 664 * RETURN: Status
@@ -822,7 +803,7 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
822 * FUNCTION: acpi_ex_insert_into_field 803 * FUNCTION: acpi_ex_insert_into_field
823 * 804 *
824 * PARAMETERS: obj_desc - Field to be written 805 * PARAMETERS: obj_desc - Field to be written
825 * buffer - Data to be written 806 * Buffer - Data to be written
826 * buffer_length - Length of Buffer 807 * buffer_length - Length of Buffer
827 * 808 *
828 * RETURN: Status 809 * RETURN: Status
@@ -859,7 +840,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
859 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length); 840 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length);
860 /* 841 /*
861 * We must have a buffer that is at least as long as the field 842 * We must have a buffer that is at least as long as the field
862 * we are writing to. This is because individual fields are 843 * we are writing to. This is because individual fields are
863 * indivisible and partial writes are not supported -- as per 844 * indivisible and partial writes are not supported -- as per
864 * the ACPI specification. 845 * the ACPI specification.
865 */ 846 */
@@ -874,7 +855,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
874 855
875 /* 856 /*
876 * Copy the original data to the new buffer, starting 857 * Copy the original data to the new buffer, starting
877 * at Byte zero. All unused (upper) bytes of the 858 * at Byte zero. All unused (upper) bytes of the
878 * buffer will be 0. 859 * buffer will be 0.
879 */ 860 */
880 ACPI_MEMCPY((char *)new_buffer, (char *)buffer, buffer_length); 861 ACPI_MEMCPY((char *)new_buffer, (char *)buffer, buffer_length);
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 84058705ed1..703d88ed0b3 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes 4 * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -143,8 +144,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
143 * 144 *
144 * FUNCTION: acpi_ex_concat_template 145 * FUNCTION: acpi_ex_concat_template
145 * 146 *
146 * PARAMETERS: operand0 - First source object 147 * PARAMETERS: Operand0 - First source object
147 * operand1 - Second source object 148 * Operand1 - Second source object
148 * actual_return_desc - Where to place the return object 149 * actual_return_desc - Where to place the return object
149 * walk_state - Current walk state 150 * walk_state - Current walk state
150 * 151 *
@@ -228,8 +229,8 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
228 * 229 *
229 * FUNCTION: acpi_ex_do_concatenate 230 * FUNCTION: acpi_ex_do_concatenate
230 * 231 *
231 * PARAMETERS: operand0 - First source object 232 * PARAMETERS: Operand0 - First source object
232 * operand1 - Second source object 233 * Operand1 - Second source object
233 * actual_return_desc - Where to place the return object 234 * actual_return_desc - Where to place the return object
234 * walk_state - Current walk state 235 * walk_state - Current walk state
235 * 236 *
@@ -253,7 +254,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
253 ACPI_FUNCTION_TRACE(ex_do_concatenate); 254 ACPI_FUNCTION_TRACE(ex_do_concatenate);
254 255
255 /* 256 /*
256 * Convert the second operand if necessary. The first operand 257 * Convert the second operand if necessary. The first operand
257 * determines the type of the second operand, (See the Data Types 258 * determines the type of the second operand, (See the Data Types
258 * section of the ACPI specification.) Both object types are 259 * section of the ACPI specification.) Both object types are
259 * guaranteed to be either Integer/String/Buffer by the operand 260 * guaranteed to be either Integer/String/Buffer by the operand
@@ -396,9 +397,9 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
396 * 397 *
397 * FUNCTION: acpi_ex_do_math_op 398 * FUNCTION: acpi_ex_do_math_op
398 * 399 *
399 * PARAMETERS: opcode - AML opcode 400 * PARAMETERS: Opcode - AML opcode
400 * integer0 - Integer operand #0 401 * Integer0 - Integer operand #0
401 * integer1 - Integer operand #1 402 * Integer1 - Integer operand #1
402 * 403 *
403 * RETURN: Integer result of the operation 404 * RETURN: Integer result of the operation
404 * 405 *
@@ -478,9 +479,9 @@ u64 acpi_ex_do_math_op(u16 opcode, u64 integer0, u64 integer1)
478 * 479 *
479 * FUNCTION: acpi_ex_do_logical_numeric_op 480 * FUNCTION: acpi_ex_do_logical_numeric_op
480 * 481 *
481 * PARAMETERS: opcode - AML opcode 482 * PARAMETERS: Opcode - AML opcode
482 * integer0 - Integer operand #0 483 * Integer0 - Integer operand #0
483 * integer1 - Integer operand #1 484 * Integer1 - Integer operand #1
484 * logical_result - TRUE/FALSE result of the operation 485 * logical_result - TRUE/FALSE result of the operation
485 * 486 *
486 * RETURN: Status 487 * RETURN: Status
@@ -533,9 +534,9 @@ acpi_ex_do_logical_numeric_op(u16 opcode,
533 * 534 *
534 * FUNCTION: acpi_ex_do_logical_op 535 * FUNCTION: acpi_ex_do_logical_op
535 * 536 *
536 * PARAMETERS: opcode - AML opcode 537 * PARAMETERS: Opcode - AML opcode
537 * operand0 - operand #0 538 * Operand0 - operand #0
538 * operand1 - operand #1 539 * Operand1 - operand #1
539 * logical_result - TRUE/FALSE result of the operation 540 * logical_result - TRUE/FALSE result of the operation
540 * 541 *
541 * RETURN: Status 542 * RETURN: Status
@@ -572,7 +573,7 @@ acpi_ex_do_logical_op(u16 opcode,
572 ACPI_FUNCTION_TRACE(ex_do_logical_op); 573 ACPI_FUNCTION_TRACE(ex_do_logical_op);
573 574
574 /* 575 /*
575 * Convert the second operand if necessary. The first operand 576 * Convert the second operand if necessary. The first operand
576 * determines the type of the second operand, (See the Data Types 577 * determines the type of the second operand, (See the Data Types
577 * section of the ACPI 3.0+ specification.) Both object types are 578 * section of the ACPI 3.0+ specification.) Both object types are
578 * guaranteed to be either Integer/String/Buffer by the operand 579 * guaranteed to be either Integer/String/Buffer by the operand
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index d1f449d93dc..be1c56ead65 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exmutex - ASL Mutex Acquire/Release functions 4 * Module Name: exmutex - ASL Mutex Acquire/Release functions
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -101,7 +102,7 @@ void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
101 * FUNCTION: acpi_ex_link_mutex 102 * FUNCTION: acpi_ex_link_mutex
102 * 103 *
103 * PARAMETERS: obj_desc - The mutex to be linked 104 * PARAMETERS: obj_desc - The mutex to be linked
104 * thread - Current executing thread object 105 * Thread - Current executing thread object
105 * 106 *
106 * RETURN: None 107 * RETURN: None
107 * 108 *
@@ -137,7 +138,7 @@ acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
137 * 138 *
138 * FUNCTION: acpi_ex_acquire_mutex_object 139 * FUNCTION: acpi_ex_acquire_mutex_object
139 * 140 *
140 * PARAMETERS: timeout - Timeout in milliseconds 141 * PARAMETERS: Timeout - Timeout in milliseconds
141 * obj_desc - Mutex object 142 * obj_desc - Mutex object
142 * thread_id - Current thread state 143 * thread_id - Current thread state
143 * 144 *
@@ -304,7 +305,7 @@ acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc)
304 ACPI_FUNCTION_TRACE(ex_release_mutex_object); 305 ACPI_FUNCTION_TRACE(ex_release_mutex_object);
305 306
306 if (obj_desc->mutex.acquisition_depth == 0) { 307 if (obj_desc->mutex.acquisition_depth == 0) {
307 return_ACPI_STATUS(AE_NOT_ACQUIRED); 308 return (AE_NOT_ACQUIRED);
308 } 309 }
309 310
310 /* Match multiple Acquires with multiple Releases */ 311 /* Match multiple Acquires with multiple Releases */
@@ -442,7 +443,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
442 * 443 *
443 * FUNCTION: acpi_ex_release_all_mutexes 444 * FUNCTION: acpi_ex_release_all_mutexes
444 * 445 *
445 * PARAMETERS: thread - Current executing thread object 446 * PARAMETERS: Thread - Current executing thread object
446 * 447 *
447 * RETURN: Status 448 * RETURN: Status
448 * 449 *
@@ -461,7 +462,7 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
461 union acpi_operand_object *next = thread->acquired_mutex_list; 462 union acpi_operand_object *next = thread->acquired_mutex_list;
462 union acpi_operand_object *obj_desc; 463 union acpi_operand_object *obj_desc;
463 464
464 ACPI_FUNCTION_NAME(ex_release_all_mutexes); 465 ACPI_FUNCTION_ENTRY();
465 466
466 /* Traverse the list of owned mutexes, releasing each one */ 467 /* Traverse the list of owned mutexes, releasing each one */
467 468
@@ -473,10 +474,6 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
473 obj_desc->mutex.next = NULL; 474 obj_desc->mutex.next = NULL;
474 obj_desc->mutex.acquisition_depth = 0; 475 obj_desc->mutex.acquisition_depth = 0;
475 476
476 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
477 "Force-releasing held mutex: %p\n",
478 obj_desc));
479
480 /* Release the mutex, special case for Global Lock */ 477 /* Release the mutex, special case for Global Lock */
481 478
482 if (obj_desc == acpi_gbl_global_lock_mutex) { 479 if (obj_desc == acpi_gbl_global_lock_mutex) {
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c
index 2ff578a16ad..49ec049c157 100644
--- a/drivers/acpi/acpica/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exnames - interpreter/scanner name load/execute 4 * Module Name: exnames - interpreter/scanner name load/execute
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -52,7 +53,8 @@ ACPI_MODULE_NAME("exnames")
52/* Local prototypes */ 53/* Local prototypes */
53static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs); 54static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs);
54 55
55static acpi_status acpi_ex_name_segment(u8 **in_aml_address, char *name_string); 56static acpi_status
57acpi_ex_name_segment(u8 ** in_aml_address, char *name_string);
56 58
57/******************************************************************************* 59/*******************************************************************************
58 * 60 *
@@ -62,7 +64,7 @@ static acpi_status acpi_ex_name_segment(u8 **in_aml_address, char *name_string);
62 * (-1)==root, 0==none 64 * (-1)==root, 0==none
63 * num_name_segs - count of 4-character name segments 65 * num_name_segs - count of 4-character name segments
64 * 66 *
65 * RETURN: A pointer to the allocated string segment. This segment must 67 * RETURN: A pointer to the allocated string segment. This segment must
66 * be deleted by the caller. 68 * be deleted by the caller.
67 * 69 *
68 * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name 70 * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name
@@ -176,8 +178,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
176 178
177 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n")); 179 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n"));
178 180
179 for (index = 0; 181 for (index = 0; (index < ACPI_NAME_SIZE)
180 (index < ACPI_NAME_SIZE)
181 && (acpi_ut_valid_acpi_char(*aml_address, 0)); index++) { 182 && (acpi_ut_valid_acpi_char(*aml_address, 0)); index++) {
182 char_buf[index] = *aml_address++; 183 char_buf[index] = *aml_address++;
183 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index])); 184 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index]));
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index bbf01e9bf05..236ead14b7f 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exoparg1 - AML execution - opcodes with 1 argument 4 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -605,7 +606,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
605 } 606 }
606 607
607 /* 608 /*
608 * Set result to ONES (TRUE) if Value == 0. Note: 609 * Set result to ONES (TRUE) if Value == 0. Note:
609 * return_desc->Integer.Value is initially == 0 (FALSE) from above. 610 * return_desc->Integer.Value is initially == 0 (FALSE) from above.
610 */ 611 */
611 if (!operand[0]->integer.value) { 612 if (!operand[0]->integer.value) {
@@ -617,7 +618,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
617 case AML_INCREMENT_OP: /* Increment (Operand) */ 618 case AML_INCREMENT_OP: /* Increment (Operand) */
618 619
619 /* 620 /*
620 * Create a new integer. Can't just get the base integer and 621 * Create a new integer. Can't just get the base integer and
621 * increment it because it may be an Arg or Field. 622 * increment it because it may be an Arg or Field.
622 */ 623 */
623 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 624 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
@@ -685,7 +686,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
685 686
686 /* 687 /*
687 * Note: The operand is not resolved at this point because we want to 688 * Note: The operand is not resolved at this point because we want to
688 * get the associated object, not its value. For example, we don't 689 * get the associated object, not its value. For example, we don't
689 * want to resolve a field_unit to its value, we want the actual 690 * want to resolve a field_unit to its value, we want the actual
690 * field_unit object. 691 * field_unit object.
691 */ 692 */
@@ -726,7 +727,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
726 727
727 /* 728 /*
728 * The type of the base object must be integer, buffer, string, or 729 * The type of the base object must be integer, buffer, string, or
729 * package. All others are not supported. 730 * package. All others are not supported.
730 * 731 *
731 * NOTE: Integer is not specifically supported by the ACPI spec, 732 * NOTE: Integer is not specifically supported by the ACPI spec,
732 * but is supported implicitly via implicit operand conversion. 733 * but is supported implicitly via implicit operand conversion.
@@ -964,7 +965,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
964 case ACPI_TYPE_PACKAGE: 965 case ACPI_TYPE_PACKAGE:
965 966
966 /* 967 /*
967 * Return the referenced element of the package. We must 968 * Return the referenced element of the package. We must
968 * add another reference to the referenced object, however. 969 * add another reference to the referenced object, however.
969 */ 970 */
970 return_desc = 971 return_desc =
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index ee5634a074c..2571b4a310f 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -123,7 +123,7 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state)
123 /* 123 /*
124 * Dispatch the notify to the appropriate handler 124 * Dispatch the notify to the appropriate handler
125 * NOTE: the request is queued for execution after this method 125 * NOTE: the request is queued for execution after this method
126 * completes. The notify handlers are NOT invoked synchronously 126 * completes. The notify handlers are NOT invoked synchronously
127 * from this thread -- because handlers may in turn run other 127 * from this thread -- because handlers may in turn run other
128 * control methods. 128 * control methods.
129 */ 129 */
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 2c89b4651f0..1b48d9d28c9 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exoparg3 - AML execution - opcodes with 3 arguments 4 * Module Name: exoparg3 - AML execution - opcodes with 3 arguments
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -157,7 +158,7 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
157 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ 158 case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
158 159
159 /* 160 /*
160 * Create the return object. The Source operand is guaranteed to be 161 * Create the return object. The Source operand is guaranteed to be
161 * either a String or a Buffer, so just use its type. 162 * either a String or a Buffer, so just use its type.
162 */ 163 */
163 return_desc = acpi_ut_create_internal_object((operand[0])-> 164 return_desc = acpi_ut_create_internal_object((operand[0])->
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index 3e08695c3b3..f4a2787e8e9 100644
--- a/drivers/acpi/acpica/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exoparg6 - AML execution - opcodes with 6 arguments 4 * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -197,7 +198,7 @@ acpi_ex_do_match(u32 match_op,
197 return (FALSE); 198 return (FALSE);
198 } 199 }
199 200
200 return (logical_result); 201 return logical_result;
201} 202}
202 203
203/******************************************************************************* 204/*******************************************************************************
@@ -268,7 +269,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
268 * and the next should be examined. 269 * and the next should be examined.
269 * 270 *
270 * Upon finding a match, the loop will terminate via "break" at 271 * Upon finding a match, the loop will terminate via "break" at
271 * the bottom. If it terminates "normally", match_value will be 272 * the bottom. If it terminates "normally", match_value will be
272 * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no 273 * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
273 * match was found. 274 * match was found.
274 */ 275 */
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index ba9db4de7c8..cc95e200040 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities 4 * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -46,7 +47,6 @@
46#include "acinterp.h" 47#include "acinterp.h"
47#include "amlcode.h" 48#include "amlcode.h"
48#include "acnamesp.h" 49#include "acnamesp.h"
49#include "acdispat.h"
50 50
51#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
52ACPI_MODULE_NAME("exprep") 52ACPI_MODULE_NAME("exprep")
@@ -77,8 +77,8 @@ acpi_ex_generate_access(u32 field_bit_offset,
77 * any_acc keyword. 77 * any_acc keyword.
78 * 78 *
79 * NOTE: Need to have the region_length in order to check for boundary 79 * NOTE: Need to have the region_length in order to check for boundary
80 * conditions (end-of-region). However, the region_length is a deferred 80 * conditions (end-of-region). However, the region_length is a deferred
81 * operation. Therefore, to complete this implementation, the generation 81 * operation. Therefore, to complete this implementation, the generation
82 * of this access width must be deferred until the region length has 82 * of this access width must be deferred until the region length has
83 * been evaluated. 83 * been evaluated.
84 * 84 *
@@ -307,7 +307,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
307 * RETURN: Status 307 * RETURN: Status
308 * 308 *
309 * DESCRIPTION: Initialize the areas of the field object that are common 309 * DESCRIPTION: Initialize the areas of the field object that are common
310 * to the various types of fields. Note: This is very "sensitive" 310 * to the various types of fields. Note: This is very "sensitive"
311 * code because we are solving the general case for field 311 * code because we are solving the general case for field
312 * alignment. 312 * alignment.
313 * 313 *
@@ -335,13 +335,13 @@ acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
335 obj_desc->common_field.bit_length = field_bit_length; 335 obj_desc->common_field.bit_length = field_bit_length;
336 336
337 /* 337 /*
338 * Decode the access type so we can compute offsets. The access type gives 338 * Decode the access type so we can compute offsets. The access type gives
339 * two pieces of information - the width of each field access and the 339 * two pieces of information - the width of each field access and the
340 * necessary byte_alignment (address granularity) of the access. 340 * necessary byte_alignment (address granularity) of the access.
341 * 341 *
342 * For any_acc, the access_bit_width is the largest width that is both 342 * For any_acc, the access_bit_width is the largest width that is both
343 * necessary and possible in an attempt to access the whole field in one 343 * necessary and possible in an attempt to access the whole field in one
344 * I/O operation. However, for any_acc, the byte_alignment is always one 344 * I/O operation. However, for any_acc, the byte_alignment is always one
345 * byte. 345 * byte.
346 * 346 *
347 * For all Buffer Fields, the byte_alignment is always one byte. 347 * For all Buffer Fields, the byte_alignment is always one byte.
@@ -362,7 +362,7 @@ acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
362 362
363 /* 363 /*
364 * base_byte_offset is the address of the start of the field within the 364 * base_byte_offset is the address of the start of the field within the
365 * region. It is the byte address of the first *datum* (field-width data 365 * region. It is the byte address of the first *datum* (field-width data
366 * unit) of the field. (i.e., the first datum that contains at least the 366 * unit) of the field. (i.e., the first datum that contains at least the
367 * first *bit* of the field.) 367 * first *bit* of the field.)
368 * 368 *
@@ -390,12 +390,12 @@ acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
390 * 390 *
391 * FUNCTION: acpi_ex_prep_field_value 391 * FUNCTION: acpi_ex_prep_field_value
392 * 392 *
393 * PARAMETERS: info - Contains all field creation info 393 * PARAMETERS: Info - Contains all field creation info
394 * 394 *
395 * RETURN: Status 395 * RETURN: Status
396 * 396 *
397 * DESCRIPTION: Construct an object of type union acpi_operand_object with a 397 * DESCRIPTION: Construct a union acpi_operand_object of type def_field and
398 * subtype of def_field and connect it to the parent Node. 398 * connect it to the parent Node.
399 * 399 *
400 ******************************************************************************/ 400 ******************************************************************************/
401 401
@@ -455,30 +455,6 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
455 obj_desc->field.region_obj = 455 obj_desc->field.region_obj =
456 acpi_ns_get_attached_object(info->region_node); 456 acpi_ns_get_attached_object(info->region_node);
457 457
458 /* Fields specific to generic_serial_bus fields */
459
460 obj_desc->field.access_length = info->access_length;
461
462 if (info->connection_node) {
463 second_desc = info->connection_node->object;
464 if (!(second_desc->common.flags & AOPOBJ_DATA_VALID)) {
465 status =
466 acpi_ds_get_buffer_arguments(second_desc);
467 if (ACPI_FAILURE(status)) {
468 acpi_ut_delete_object_desc(obj_desc);
469 return_ACPI_STATUS(status);
470 }
471 }
472
473 obj_desc->field.resource_buffer =
474 second_desc->buffer.pointer;
475 obj_desc->field.resource_length =
476 (u16)second_desc->buffer.length;
477 } else if (info->resource_buffer) {
478 obj_desc->field.resource_buffer = info->resource_buffer;
479 obj_desc->field.resource_length = info->resource_length;
480 }
481
482 /* Allow full data read from EC address space */ 458 /* Allow full data read from EC address space */
483 459
484 if ((obj_desc->field.region_obj->region.space_id == 460 if ((obj_desc->field.region_obj->region.space_id ==
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 1db2c0bfde0..f0d5e14f1f2 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exregion - ACPI default op_region (address space) handlers 4 * Module Name: exregion - ACPI default op_region (address space) handlers
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -52,10 +53,10 @@ ACPI_MODULE_NAME("exregion")
52 * 53 *
53 * FUNCTION: acpi_ex_system_memory_space_handler 54 * FUNCTION: acpi_ex_system_memory_space_handler
54 * 55 *
55 * PARAMETERS: function - Read or Write operation 56 * PARAMETERS: Function - Read or Write operation
56 * address - Where in the space to read or write 57 * Address - Where in the space to read or write
57 * bit_width - Field width in bits (8, 16, or 32) 58 * bit_width - Field width in bits (8, 16, or 32)
58 * value - Pointer to in or out value 59 * Value - Pointer to in or out value
59 * handler_context - Pointer to Handler's context 60 * handler_context - Pointer to Handler's context
60 * region_context - Pointer to context specific to the 61 * region_context - Pointer to context specific to the
61 * accessed region 62 * accessed region
@@ -201,7 +202,7 @@ acpi_ex_system_memory_space_handler(u32 function,
201 * Perform the memory read or write 202 * Perform the memory read or write
202 * 203 *
203 * Note: For machines that do not support non-aligned transfers, the target 204 * Note: For machines that do not support non-aligned transfers, the target
204 * address was checked for alignment above. We do not attempt to break the 205 * address was checked for alignment above. We do not attempt to break the
205 * transfer up into smaller (byte-size) chunks because the AML specifically 206 * transfer up into smaller (byte-size) chunks because the AML specifically
206 * asked for a transfer width that the hardware may require. 207 * asked for a transfer width that the hardware may require.
207 */ 208 */
@@ -269,10 +270,10 @@ acpi_ex_system_memory_space_handler(u32 function,
269 * 270 *
270 * FUNCTION: acpi_ex_system_io_space_handler 271 * FUNCTION: acpi_ex_system_io_space_handler
271 * 272 *
272 * PARAMETERS: function - Read or Write operation 273 * PARAMETERS: Function - Read or Write operation
273 * address - Where in the space to read or write 274 * Address - Where in the space to read or write
274 * bit_width - Field width in bits (8, 16, or 32) 275 * bit_width - Field width in bits (8, 16, or 32)
275 * value - Pointer to in or out value 276 * Value - Pointer to in or out value
276 * handler_context - Pointer to Handler's context 277 * handler_context - Pointer to Handler's context
277 * region_context - Pointer to context specific to the 278 * region_context - Pointer to context specific to the
278 * accessed region 279 * accessed region
@@ -328,10 +329,10 @@ acpi_ex_system_io_space_handler(u32 function,
328 * 329 *
329 * FUNCTION: acpi_ex_pci_config_space_handler 330 * FUNCTION: acpi_ex_pci_config_space_handler
330 * 331 *
331 * PARAMETERS: function - Read or Write operation 332 * PARAMETERS: Function - Read or Write operation
332 * address - Where in the space to read or write 333 * Address - Where in the space to read or write
333 * bit_width - Field width in bits (8, 16, or 32) 334 * bit_width - Field width in bits (8, 16, or 32)
334 * value - Pointer to in or out value 335 * Value - Pointer to in or out value
335 * handler_context - Pointer to Handler's context 336 * handler_context - Pointer to Handler's context
336 * region_context - Pointer to context specific to the 337 * region_context - Pointer to context specific to the
337 * accessed region 338 * accessed region
@@ -364,7 +365,7 @@ acpi_ex_pci_config_space_handler(u32 function,
364 * pci_function is the PCI device function number 365 * pci_function is the PCI device function number
365 * pci_register is the Config space register range 0-255 bytes 366 * pci_register is the Config space register range 0-255 bytes
366 * 367 *
367 * value - input value for write, output address for read 368 * Value - input value for write, output address for read
368 * 369 *
369 */ 370 */
370 pci_id = (struct acpi_pci_id *)region_context; 371 pci_id = (struct acpi_pci_id *)region_context;
@@ -401,10 +402,10 @@ acpi_ex_pci_config_space_handler(u32 function,
401 * 402 *
402 * FUNCTION: acpi_ex_cmos_space_handler 403 * FUNCTION: acpi_ex_cmos_space_handler
403 * 404 *
404 * PARAMETERS: function - Read or Write operation 405 * PARAMETERS: Function - Read or Write operation
405 * address - Where in the space to read or write 406 * Address - Where in the space to read or write
406 * bit_width - Field width in bits (8, 16, or 32) 407 * bit_width - Field width in bits (8, 16, or 32)
407 * value - Pointer to in or out value 408 * Value - Pointer to in or out value
408 * handler_context - Pointer to Handler's context 409 * handler_context - Pointer to Handler's context
409 * region_context - Pointer to context specific to the 410 * region_context - Pointer to context specific to the
410 * accessed region 411 * accessed region
@@ -433,10 +434,10 @@ acpi_ex_cmos_space_handler(u32 function,
433 * 434 *
434 * FUNCTION: acpi_ex_pci_bar_space_handler 435 * FUNCTION: acpi_ex_pci_bar_space_handler
435 * 436 *
436 * PARAMETERS: function - Read or Write operation 437 * PARAMETERS: Function - Read or Write operation
437 * address - Where in the space to read or write 438 * Address - Where in the space to read or write
438 * bit_width - Field width in bits (8, 16, or 32) 439 * bit_width - Field width in bits (8, 16, or 32)
439 * value - Pointer to in or out value 440 * Value - Pointer to in or out value
440 * handler_context - Pointer to Handler's context 441 * handler_context - Pointer to Handler's context
441 * region_context - Pointer to context specific to the 442 * region_context - Pointer to context specific to the
442 * accessed region 443 * accessed region
@@ -465,10 +466,10 @@ acpi_ex_pci_bar_space_handler(u32 function,
465 * 466 *
466 * FUNCTION: acpi_ex_data_table_space_handler 467 * FUNCTION: acpi_ex_data_table_space_handler
467 * 468 *
468 * PARAMETERS: function - Read or Write operation 469 * PARAMETERS: Function - Read or Write operation
469 * address - Where in the space to read or write 470 * Address - Where in the space to read or write
470 * bit_width - Field width in bits (8, 16, or 32) 471 * bit_width - Field width in bits (8, 16, or 32)
471 * value - Pointer to in or out value 472 * Value - Pointer to in or out value
472 * handler_context - Pointer to Handler's context 473 * handler_context - Pointer to Handler's context
473 * region_context - Pointer to context specific to the 474 * region_context - Pointer to context specific to the
474 * accessed region 475 * accessed region
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 6239956786e..55997e46948 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exresnte - AML Interpreter object resolution 4 * Module Name: exresnte - AML Interpreter object resolution
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -57,8 +58,8 @@ ACPI_MODULE_NAME("exresnte")
57 * PARAMETERS: object_ptr - Pointer to a location that contains 58 * PARAMETERS: object_ptr - Pointer to a location that contains
58 * a pointer to a NS node, and will receive a 59 * a pointer to a NS node, and will receive a
59 * pointer to the resolved object. 60 * pointer to the resolved object.
60 * walk_state - Current state. Valid only if executing AML 61 * walk_state - Current state. Valid only if executing AML
61 * code. NULL if simply resolving an object 62 * code. NULL if simply resolving an object
62 * 63 *
63 * RETURN: Status 64 * RETURN: Status
64 * 65 *
@@ -66,7 +67,7 @@ ACPI_MODULE_NAME("exresnte")
66 * 67 *
67 * Note: for some of the data types, the pointer attached to the Node 68 * Note: for some of the data types, the pointer attached to the Node
68 * can be either a pointer to an actual internal object or a pointer into the 69 * can be either a pointer to an actual internal object or a pointer into the
69 * AML stream itself. These types are currently: 70 * AML stream itself. These types are currently:
70 * 71 *
71 * ACPI_TYPE_INTEGER 72 * ACPI_TYPE_INTEGER
72 * ACPI_TYPE_STRING 73 * ACPI_TYPE_STRING
@@ -88,7 +89,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
88 ACPI_FUNCTION_TRACE(ex_resolve_node_to_value); 89 ACPI_FUNCTION_TRACE(ex_resolve_node_to_value);
89 90
90 /* 91 /*
91 * The stack pointer points to a struct acpi_namespace_node (Node). Get the 92 * The stack pointer points to a struct acpi_namespace_node (Node). Get the
92 * object that is attached to the Node. 93 * object that is attached to the Node.
93 */ 94 */
94 node = *object_ptr; 95 node = *object_ptr;
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index cc176b245e2..db502cd7d93 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exresolv - AML Interpreter object resolution 4 * Module Name: exresolv - AML Interpreter object resolution
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -146,7 +147,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
146 147
147 stack_desc = *stack_ptr; 148 stack_desc = *stack_ptr;
148 149
149 /* This is an object of type union acpi_operand_object */ 150 /* This is a union acpi_operand_object */
150 151
151 switch (stack_desc->common.type) { 152 switch (stack_desc->common.type) {
152 case ACPI_TYPE_LOCAL_REFERENCE: 153 case ACPI_TYPE_LOCAL_REFERENCE:
@@ -320,13 +321,13 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
320 * FUNCTION: acpi_ex_resolve_multiple 321 * FUNCTION: acpi_ex_resolve_multiple
321 * 322 *
322 * PARAMETERS: walk_state - Current state (contains AML opcode) 323 * PARAMETERS: walk_state - Current state (contains AML opcode)
323 * operand - Starting point for resolution 324 * Operand - Starting point for resolution
324 * return_type - Where the object type is returned 325 * return_type - Where the object type is returned
325 * return_desc - Where the resolved object is returned 326 * return_desc - Where the resolved object is returned
326 * 327 *
327 * RETURN: Status 328 * RETURN: Status
328 * 329 *
329 * DESCRIPTION: Return the base object and type. Traverse a reference list if 330 * DESCRIPTION: Return the base object and type. Traverse a reference list if
330 * necessary to get to the base object. 331 * necessary to get to the base object.
331 * 332 *
332 ******************************************************************************/ 333 ******************************************************************************/
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index b9ebff2f6a0..e3bb00ccdff 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exresop - AML Interpreter operand/object resolution 4 * Module Name: exresop - AML Interpreter operand/object resolution
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -86,7 +87,7 @@ acpi_ex_check_object_type(acpi_object_type type_needed,
86 if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) { 87 if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) {
87 /* 88 /*
88 * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference 89 * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
89 * objects and thus allow them to be targets. (As per the ACPI 90 * objects and thus allow them to be targets. (As per the ACPI
90 * specification, a store to a constant is a noop.) 91 * specification, a store to a constant is a noop.)
91 */ 92 */
92 if ((this_type == ACPI_TYPE_INTEGER) && 93 if ((this_type == ACPI_TYPE_INTEGER) &&
@@ -112,7 +113,7 @@ acpi_ex_check_object_type(acpi_object_type type_needed,
112 * 113 *
113 * FUNCTION: acpi_ex_resolve_operands 114 * FUNCTION: acpi_ex_resolve_operands
114 * 115 *
115 * PARAMETERS: opcode - Opcode being interpreted 116 * PARAMETERS: Opcode - Opcode being interpreted
116 * stack_ptr - Pointer to the operand stack to be 117 * stack_ptr - Pointer to the operand stack to be
117 * resolved 118 * resolved
118 * walk_state - Current state 119 * walk_state - Current state
@@ -306,7 +307,7 @@ acpi_ex_resolve_operands(u16 opcode,
306 case ARGI_DEVICE_REF: 307 case ARGI_DEVICE_REF:
307 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ 308 case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
308 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ 309 case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
309 case ARGI_SIMPLE_TARGET: /* Name, Local, or arg - no implicit conversion */ 310 case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
310 311
311 /* 312 /*
312 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE 313 * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
@@ -336,8 +337,7 @@ acpi_ex_resolve_operands(u16 opcode,
336 if ((opcode == AML_STORE_OP) && 337 if ((opcode == AML_STORE_OP) &&
337 ((*stack_ptr)->common.type == 338 ((*stack_ptr)->common.type ==
338 ACPI_TYPE_LOCAL_REFERENCE) 339 ACPI_TYPE_LOCAL_REFERENCE)
339 && ((*stack_ptr)->reference.class == 340 && ((*stack_ptr)->reference.class == ACPI_REFCLASS_INDEX)) {
340 ACPI_REFCLASS_INDEX)) {
341 goto next_operand; 341 goto next_operand;
342 } 342 }
343 break; 343 break;
@@ -410,7 +410,7 @@ acpi_ex_resolve_operands(u16 opcode,
410 /* 410 /*
411 * Need an operand of type ACPI_TYPE_INTEGER, 411 * Need an operand of type ACPI_TYPE_INTEGER,
412 * But we can implicitly convert from a STRING or BUFFER 412 * But we can implicitly convert from a STRING or BUFFER
413 * aka - "Implicit Source Operand Conversion" 413 * Aka - "Implicit Source Operand Conversion"
414 */ 414 */
415 status = 415 status =
416 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); 416 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16);
@@ -437,7 +437,7 @@ acpi_ex_resolve_operands(u16 opcode,
437 /* 437 /*
438 * Need an operand of type ACPI_TYPE_BUFFER, 438 * Need an operand of type ACPI_TYPE_BUFFER,
439 * But we can implicitly convert from a STRING or INTEGER 439 * But we can implicitly convert from a STRING or INTEGER
440 * aka - "Implicit Source Operand Conversion" 440 * Aka - "Implicit Source Operand Conversion"
441 */ 441 */
442 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); 442 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr);
443 if (ACPI_FAILURE(status)) { 443 if (ACPI_FAILURE(status)) {
@@ -463,7 +463,7 @@ acpi_ex_resolve_operands(u16 opcode,
463 /* 463 /*
464 * Need an operand of type ACPI_TYPE_STRING, 464 * Need an operand of type ACPI_TYPE_STRING,
465 * But we can implicitly convert from a BUFFER or INTEGER 465 * But we can implicitly convert from a BUFFER or INTEGER
466 * aka - "Implicit Source Operand Conversion" 466 * Aka - "Implicit Source Operand Conversion"
467 */ 467 */
468 status = acpi_ex_convert_to_string(obj_desc, stack_ptr, 468 status = acpi_ex_convert_to_string(obj_desc, stack_ptr,
469 ACPI_IMPLICIT_CONVERT_HEX); 469 ACPI_IMPLICIT_CONVERT_HEX);
@@ -638,7 +638,7 @@ acpi_ex_resolve_operands(u16 opcode,
638 if (acpi_gbl_enable_interpreter_slack) { 638 if (acpi_gbl_enable_interpreter_slack) {
639 /* 639 /*
640 * Enable original behavior of Store(), allowing any and all 640 * Enable original behavior of Store(), allowing any and all
641 * objects as the source operand. The ACPI spec does not 641 * objects as the source operand. The ACPI spec does not
642 * allow this, however. 642 * allow this, however.
643 */ 643 */
644 break; 644 break;
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 90431f12f83..c0c8842dd34 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -62,8 +62,8 @@ acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
62 * FUNCTION: acpi_ex_store 62 * FUNCTION: acpi_ex_store
63 * 63 *
64 * PARAMETERS: *source_desc - Value to be stored 64 * PARAMETERS: *source_desc - Value to be stored
65 * *dest_desc - Where to store it. Must be an NS node 65 * *dest_desc - Where to store it. Must be an NS node
66 * or union acpi_operand_object of type 66 * or a union acpi_operand_object of type
67 * Reference; 67 * Reference;
68 * walk_state - Current walk state 68 * walk_state - Current walk state
69 * 69 *
@@ -361,7 +361,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
361 * FUNCTION: acpi_ex_store_object_to_node 361 * FUNCTION: acpi_ex_store_object_to_node
362 * 362 *
363 * PARAMETERS: source_desc - Value to be stored 363 * PARAMETERS: source_desc - Value to be stored
364 * node - Named object to receive the value 364 * Node - Named object to receive the value
365 * walk_state - Current walk state 365 * walk_state - Current walk state
366 * implicit_conversion - Perform implicit conversion (yes/no) 366 * implicit_conversion - Perform implicit conversion (yes/no)
367 * 367 *
@@ -374,7 +374,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
374 * with the input value. 374 * with the input value.
375 * 375 *
376 * When storing into an object the data is converted to the 376 * When storing into an object the data is converted to the
377 * target object type then stored in the object. This means 377 * target object type then stored in the object. This means
378 * that the target object type (for an initialized target) will 378 * that the target object type (for an initialized target) will
379 * not be changed by a store operation. 379 * not be changed by a store operation.
380 * 380 *
@@ -491,7 +491,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
491 acpi_ut_get_object_type_name(source_desc), 491 acpi_ut_get_object_type_name(source_desc),
492 source_desc, node)); 492 source_desc, node));
493 493
494 /* No conversions for all other types. Just attach the source object */ 494 /* No conversions for all other types. Just attach the source object */
495 495
496 status = acpi_ns_attach_object(node, source_desc, 496 status = acpi_ns_attach_object(node, source_desc,
497 source_desc->common.type); 497 source_desc->common.type);
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index 87153bbc4b4..a979017d56b 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exstoren - AML Interpreter object store support, 4 * Module Name: exstoren - AML Interpreter object store support,
@@ -6,7 +7,7 @@
6 *****************************************************************************/ 7 *****************************************************************************/
7 8
8/* 9/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 10 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 11 * All rights reserved.
11 * 12 *
12 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -60,7 +61,7 @@ ACPI_MODULE_NAME("exstoren")
60 * 61 *
61 * RETURN: Status, resolved object in source_desc_ptr. 62 * RETURN: Status, resolved object in source_desc_ptr.
62 * 63 *
63 * DESCRIPTION: Resolve an object. If the object is a reference, dereference 64 * DESCRIPTION: Resolve an object. If the object is a reference, dereference
64 * it and return the actual object in the source_desc_ptr. 65 * it and return the actual object in the source_desc_ptr.
65 * 66 *
66 ******************************************************************************/ 67 ******************************************************************************/
@@ -92,7 +93,7 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
92 93
93 /* 94 /*
94 * Stores into a Field/Region or into a Integer/Buffer/String 95 * Stores into a Field/Region or into a Integer/Buffer/String
95 * are all essentially the same. This case handles the 96 * are all essentially the same. This case handles the
96 * "interchangeable" types Integer, String, and Buffer. 97 * "interchangeable" types Integer, String, and Buffer.
97 */ 98 */
98 if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) { 99 if (source_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
@@ -166,7 +167,7 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
166 * 167 *
167 * RETURN: Status 168 * RETURN: Status
168 * 169 *
169 * DESCRIPTION: "Store" an object to another object. This may include 170 * DESCRIPTION: "Store" an object to another object. This may include
170 * converting the source type to the target type (implicit 171 * converting the source type to the target type (implicit
171 * conversion), and a copy of the value of the source to 172 * conversion), and a copy of the value of the source to
172 * the target. 173 * the target.
@@ -177,14 +178,14 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
177 * with the input value. 178 * with the input value.
178 * 179 *
179 * When storing into an object the data is converted to the 180 * When storing into an object the data is converted to the
180 * target object type then stored in the object. This means 181 * target object type then stored in the object. This means
181 * that the target object type (for an initialized target) will 182 * that the target object type (for an initialized target) will
182 * not be changed by a store operation. 183 * not be changed by a store operation.
183 * 184 *
184 * This module allows destination types of Number, String, 185 * This module allows destination types of Number, String,
185 * Buffer, and Package. 186 * Buffer, and Package.
186 * 187 *
187 * Assumes parameters are already validated. NOTE: source_desc 188 * Assumes parameters are already validated. NOTE: source_desc
188 * resolution (from a reference object) must be performed by 189 * resolution (from a reference object) must be performed by
189 * the caller if necessary. 190 * the caller if necessary.
190 * 191 *
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c
index b5f339cb130..dc665cc554d 100644
--- a/drivers/acpi/acpica/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exstorob - AML Interpreter object store support, store to object 4 * Module Name: exstorob - AML Interpreter object store support, store to object
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -107,16 +108,16 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
107#ifdef ACPI_OBSOLETE_BEHAVIOR 108#ifdef ACPI_OBSOLETE_BEHAVIOR
108 /* 109 /*
109 * NOTE: ACPI versions up to 3.0 specified that the buffer must be 110 * NOTE: ACPI versions up to 3.0 specified that the buffer must be
110 * truncated if the string is smaller than the buffer. However, "other" 111 * truncated if the string is smaller than the buffer. However, "other"
111 * implementations of ACPI never did this and thus became the defacto 112 * implementations of ACPI never did this and thus became the defacto
112 * standard. ACPI 3.0A changes this behavior such that the buffer 113 * standard. ACPI 3.0_a changes this behavior such that the buffer
113 * is no longer truncated. 114 * is no longer truncated.
114 */ 115 */
115 116
116 /* 117 /*
117 * OBSOLETE BEHAVIOR: 118 * OBSOLETE BEHAVIOR:
118 * If the original source was a string, we must truncate the buffer, 119 * If the original source was a string, we must truncate the buffer,
119 * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer 120 * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer
120 * copy must not truncate the original buffer. 121 * copy must not truncate the original buffer.
121 */ 122 */
122 if (original_src_type == ACPI_TYPE_STRING) { 123 if (original_src_type == ACPI_TYPE_STRING) {
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c
index c8a0ad5c1f5..df66e7b686b 100644
--- a/drivers/acpi/acpica/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exsystem - Interface to OS services 4 * Module Name: exsystem - Interface to OS services
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -52,13 +53,13 @@ ACPI_MODULE_NAME("exsystem")
52 * 53 *
53 * FUNCTION: acpi_ex_system_wait_semaphore 54 * FUNCTION: acpi_ex_system_wait_semaphore
54 * 55 *
55 * PARAMETERS: semaphore - Semaphore to wait on 56 * PARAMETERS: Semaphore - Semaphore to wait on
56 * timeout - Max time to wait 57 * Timeout - Max time to wait
57 * 58 *
58 * RETURN: Status 59 * RETURN: Status
59 * 60 *
60 * DESCRIPTION: Implements a semaphore wait with a check to see if the 61 * DESCRIPTION: Implements a semaphore wait with a check to see if the
61 * semaphore is available immediately. If it is not, the 62 * semaphore is available immediately. If it is not, the
62 * interpreter is released before waiting. 63 * interpreter is released before waiting.
63 * 64 *
64 ******************************************************************************/ 65 ******************************************************************************/
@@ -97,13 +98,13 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
97 * 98 *
98 * FUNCTION: acpi_ex_system_wait_mutex 99 * FUNCTION: acpi_ex_system_wait_mutex
99 * 100 *
100 * PARAMETERS: mutex - Mutex to wait on 101 * PARAMETERS: Mutex - Mutex to wait on
101 * timeout - Max time to wait 102 * Timeout - Max time to wait
102 * 103 *
103 * RETURN: Status 104 * RETURN: Status
104 * 105 *
105 * DESCRIPTION: Implements a mutex wait with a check to see if the 106 * DESCRIPTION: Implements a mutex wait with a check to see if the
106 * mutex is available immediately. If it is not, the 107 * mutex is available immediately. If it is not, the
107 * interpreter is released before waiting. 108 * interpreter is released before waiting.
108 * 109 *
109 ******************************************************************************/ 110 ******************************************************************************/
@@ -151,7 +152,7 @@ acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout)
151 * DESCRIPTION: Suspend running thread for specified amount of time. 152 * DESCRIPTION: Suspend running thread for specified amount of time.
152 * Note: ACPI specification requires that Stall() does not 153 * Note: ACPI specification requires that Stall() does not
153 * relinquish the processor, and delays longer than 100 usec 154 * relinquish the processor, and delays longer than 100 usec
154 * should use Sleep() instead. We allow stalls up to 255 usec 155 * should use Sleep() instead. We allow stalls up to 255 usec
155 * for compatibility with other interpreters and existing BIOSs. 156 * for compatibility with other interpreters and existing BIOSs.
156 * 157 *
157 ******************************************************************************/ 158 ******************************************************************************/
@@ -253,7 +254,7 @@ acpi_status acpi_ex_system_signal_event(union acpi_operand_object * obj_desc)
253 * RETURN: Status 254 * RETURN: Status
254 * 255 *
255 * DESCRIPTION: Provides an access point to perform synchronization operations 256 * DESCRIPTION: Provides an access point to perform synchronization operations
256 * within the AML. This operation is a request to wait for an 257 * within the AML. This operation is a request to wait for an
257 * event. 258 * event.
258 * 259 *
259 ******************************************************************************/ 260 ******************************************************************************/
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 264d22d8018..8ad93146dd3 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: exutils - interpreter/scanner utilities 4 * Module Name: exutils - interpreter/scanner utilities
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -44,12 +45,12 @@
44/* 45/*
45 * DEFINE_AML_GLOBALS is tested in amlcode.h 46 * DEFINE_AML_GLOBALS is tested in amlcode.h
46 * to determine whether certain global names should be "defined" or only 47 * to determine whether certain global names should be "defined" or only
47 * "declared" in the current compilation. This enhances maintainability 48 * "declared" in the current compilation. This enhances maintainability
48 * by enabling a single header file to embody all knowledge of the names 49 * by enabling a single header file to embody all knowledge of the names
49 * in question. 50 * in question.
50 * 51 *
51 * Exactly one module of any executable should #define DEFINE_GLOBALS 52 * Exactly one module of any executable should #define DEFINE_GLOBALS
52 * before #including the header files which use this convention. The 53 * before #including the header files which use this convention. The
53 * names in question will be defined and initialized in that module, 54 * names in question will be defined and initialized in that module,
54 * and declared as extern in all other modules which #include those 55 * and declared as extern in all other modules which #include those
55 * header files. 56 * header files.
@@ -108,7 +109,7 @@ void acpi_ex_enter_interpreter(void)
108 * 109 *
109 * DESCRIPTION: Reacquire the interpreter execution region from within the 110 * DESCRIPTION: Reacquire the interpreter execution region from within the
110 * interpreter code. Failure to enter the interpreter region is a 111 * interpreter code. Failure to enter the interpreter region is a
111 * fatal system error. Used in conjunction with 112 * fatal system error. Used in conjunction with
112 * relinquish_interpreter 113 * relinquish_interpreter
113 * 114 *
114 ******************************************************************************/ 115 ******************************************************************************/
@@ -316,8 +317,8 @@ void acpi_ex_release_global_lock(u32 field_flags)
316 * 317 *
317 * FUNCTION: acpi_ex_digits_needed 318 * FUNCTION: acpi_ex_digits_needed
318 * 319 *
319 * PARAMETERS: value - Value to be represented 320 * PARAMETERS: Value - Value to be represented
320 * base - Base of representation 321 * Base - Base of representation
321 * 322 *
322 * RETURN: The number of digits. 323 * RETURN: The number of digits.
323 * 324 *
@@ -407,7 +408,7 @@ void acpi_ex_eisa_id_to_string(char *out_string, u64 compressed_id)
407 * PARAMETERS: out_string - Where to put the converted string. At least 408 * PARAMETERS: out_string - Where to put the converted string. At least
408 * 21 bytes are needed to hold the largest 409 * 21 bytes are needed to hold the largest
409 * possible 64-bit integer. 410 * possible 64-bit integer.
410 * value - Value to be converted 411 * Value - Value to be converted
411 * 412 *
412 * RETURN: None, string 413 * RETURN: None, string
413 * 414 *
@@ -434,29 +435,4 @@ void acpi_ex_integer_to_string(char *out_string, u64 value)
434 } 435 }
435} 436}
436 437
437/*******************************************************************************
438 *
439 * FUNCTION: acpi_is_valid_space_id
440 *
441 * PARAMETERS: space_id - ID to be validated
442 *
443 * RETURN: TRUE if valid/supported ID.
444 *
445 * DESCRIPTION: Validate an operation region space_ID.
446 *
447 ******************************************************************************/
448
449u8 acpi_is_valid_space_id(u8 space_id)
450{
451
452 if ((space_id >= ACPI_NUM_PREDEFINED_REGIONS) &&
453 (space_id < ACPI_USER_REGION_BEGIN) &&
454 (space_id != ACPI_ADR_SPACE_DATA_TABLE) &&
455 (space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) {
456 return (FALSE);
457 }
458
459 return (TRUE);
460}
461
462#endif 438#endif
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 90a9aea1cee..fc380d3d45a 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface 4 * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -47,12 +48,11 @@
47#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
48ACPI_MODULE_NAME("hwacpi") 49ACPI_MODULE_NAME("hwacpi")
49 50
50#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
51/****************************************************************************** 51/******************************************************************************
52 * 52 *
53 * FUNCTION: acpi_hw_set_mode 53 * FUNCTION: acpi_hw_set_mode
54 * 54 *
55 * PARAMETERS: mode - SYS_MODE_ACPI or SYS_MODE_LEGACY 55 * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY
56 * 56 *
57 * RETURN: Status 57 * RETURN: Status
58 * 58 *
@@ -135,7 +135,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
135 * 135 *
136 * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY 136 * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY
137 * 137 *
138 * DESCRIPTION: Return current operating state of system. Determined by 138 * DESCRIPTION: Return current operating state of system. Determined by
139 * querying the SCI_EN bit. 139 * querying the SCI_EN bit.
140 * 140 *
141 ******************************************************************************/ 141 ******************************************************************************/
@@ -166,5 +166,3 @@ u32 acpi_hw_get_mode(void)
166 return_UINT32(ACPI_SYS_MODE_LEGACY); 166 return_UINT32(ACPI_SYS_MODE_LEGACY);
167 } 167 }
168} 168}
169
170#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
deleted file mode 100644
index 94996f9ae3a..00000000000
--- a/drivers/acpi/acpica/hwesleep.c
+++ /dev/null
@@ -1,235 +0,0 @@
1/******************************************************************************
2 *
3 * Name: hwesleep.c - ACPI Hardware Sleep/Wake Support functions for the
4 * extended FADT-V5 sleep registers.
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2012, 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
48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwesleep")
50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_hw_execute_sleep_method
54 *
55 * PARAMETERS: method_pathname - Pathname of method to execute
56 * integer_argument - Argument to pass to the method
57 *
58 * RETURN: None
59 *
60 * DESCRIPTION: Execute a sleep/wake related method with one integer argument
61 * and no return value.
62 *
63 ******************************************************************************/
64void acpi_hw_execute_sleep_method(char *method_pathname, u32 integer_argument)
65{
66 struct acpi_object_list arg_list;
67 union acpi_object arg;
68 acpi_status status;
69
70 ACPI_FUNCTION_TRACE(hw_execute_sleep_method);
71
72 /* One argument, integer_argument; No return value expected */
73
74 arg_list.count = 1;
75 arg_list.pointer = &arg;
76 arg.type = ACPI_TYPE_INTEGER;
77 arg.integer.value = (u64)integer_argument;
78
79 status = acpi_evaluate_object(NULL, method_pathname, &arg_list, NULL);
80 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
81 ACPI_EXCEPTION((AE_INFO, status, "While executing method %s",
82 method_pathname));
83 }
84
85 return_VOID;
86}
87
88/*******************************************************************************
89 *
90 * FUNCTION: acpi_hw_extended_sleep
91 *
92 * PARAMETERS: sleep_state - Which sleep state to enter
93 *
94 * RETURN: Status
95 *
96 * DESCRIPTION: Enter a system sleep state via the extended FADT sleep
97 * registers (V5 FADT).
98 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
99 *
100 ******************************************************************************/
101
102acpi_status acpi_hw_extended_sleep(u8 sleep_state)
103{
104 acpi_status status;
105 u8 sleep_type_value;
106 u64 sleep_status;
107
108 ACPI_FUNCTION_TRACE(hw_extended_sleep);
109
110 /* Extended sleep registers must be valid */
111
112 if (!acpi_gbl_FADT.sleep_control.address ||
113 !acpi_gbl_FADT.sleep_status.address) {
114 return_ACPI_STATUS(AE_NOT_EXIST);
115 }
116
117 /* Clear wake status (WAK_STS) */
118
119 status =
120 acpi_write((u64)ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status);
121 if (ACPI_FAILURE(status)) {
122 return_ACPI_STATUS(status);
123 }
124
125 acpi_gbl_system_awake_and_running = FALSE;
126
127 /* Flush caches, as per ACPI specification */
128
129 ACPI_FLUSH_CPU_CACHE();
130
131 /*
132 * Set the SLP_TYP and SLP_EN bits.
133 *
134 * Note: We only use the first value returned by the \_Sx method
135 * (acpi_gbl_sleep_type_a) - As per ACPI specification.
136 */
137 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
138 "Entering sleep state [S%u]\n", sleep_state));
139
140 sleep_type_value =
141 ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
142 ACPI_X_SLEEP_TYPE_MASK);
143
144 status = acpi_write((u64)(sleep_type_value | ACPI_X_SLEEP_ENABLE),
145 &acpi_gbl_FADT.sleep_control);
146 if (ACPI_FAILURE(status)) {
147 return_ACPI_STATUS(status);
148 }
149
150 /* Wait for transition back to Working State */
151
152 do {
153 status = acpi_read(&sleep_status, &acpi_gbl_FADT.sleep_status);
154 if (ACPI_FAILURE(status)) {
155 return_ACPI_STATUS(status);
156 }
157
158 } while (!(((u8)sleep_status) & ACPI_X_WAKE_STATUS));
159
160 return_ACPI_STATUS(AE_OK);
161}
162
163/*******************************************************************************
164 *
165 * FUNCTION: acpi_hw_extended_wake_prep
166 *
167 * PARAMETERS: sleep_state - Which sleep state we just exited
168 *
169 * RETURN: Status
170 *
171 * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after
172 * a sleep. Called with interrupts ENABLED.
173 *
174 ******************************************************************************/
175
176acpi_status acpi_hw_extended_wake_prep(u8 sleep_state)
177{
178 acpi_status status;
179 u8 sleep_type_value;
180
181 ACPI_FUNCTION_TRACE(hw_extended_wake_prep);
182
183 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
184 &acpi_gbl_sleep_type_a,
185 &acpi_gbl_sleep_type_b);
186 if (ACPI_SUCCESS(status)) {
187 sleep_type_value =
188 ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
189 ACPI_X_SLEEP_TYPE_MASK);
190
191 (void)acpi_write((u64)(sleep_type_value | ACPI_X_SLEEP_ENABLE),
192 &acpi_gbl_FADT.sleep_control);
193 }
194
195 return_ACPI_STATUS(AE_OK);
196}
197
198/*******************************************************************************
199 *
200 * FUNCTION: acpi_hw_extended_wake
201 *
202 * PARAMETERS: sleep_state - Which sleep state we just exited
203 * flags - Reserved, set to zero
204 *
205 * RETURN: Status
206 *
207 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
208 * Called with interrupts ENABLED.
209 *
210 ******************************************************************************/
211
212acpi_status acpi_hw_extended_wake(u8 sleep_state)
213{
214 ACPI_FUNCTION_TRACE(hw_extended_wake);
215
216 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
217
218 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
219
220 /* Execute the wake methods */
221
222 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
223 acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
224
225 /*
226 * Some BIOS code assumes that WAK_STS will be cleared on resume
227 * and use it to determine whether the system is rebooting or
228 * resuming. Clear WAK_STS for compatibility.
229 */
230 (void)acpi_write((u64)ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status);
231 acpi_gbl_system_awake_and_running = TRUE;
232
233 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
234 return_ACPI_STATUS(AE_OK);
235}
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 64560045052..f610d88a66b 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: hwgpe - Low level GPE enable/disable/clear functions 4 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -47,7 +48,7 @@
47 48
48#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwgpe") 50ACPI_MODULE_NAME("hwgpe")
50#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51
51/* Local prototypes */ 52/* Local prototypes */
52static acpi_status 53static acpi_status
53acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 54acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
@@ -59,6 +60,7 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
59 * FUNCTION: acpi_hw_get_gpe_register_bit 60 * FUNCTION: acpi_hw_get_gpe_register_bit
60 * 61 *
61 * PARAMETERS: gpe_event_info - Info block for the GPE 62 * PARAMETERS: gpe_event_info - Info block for the GPE
63 * gpe_register_info - Info block for the GPE register
62 * 64 *
63 * RETURN: Register mask with a one in the GPE bit position 65 * RETURN: Register mask with a one in the GPE bit position
64 * 66 *
@@ -67,10 +69,11 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
67 * 69 *
68 ******************************************************************************/ 70 ******************************************************************************/
69 71
70u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info) 72u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info,
73 struct acpi_gpe_register_info *gpe_register_info)
71{ 74{
72 return (u32)1 << (gpe_event_info->gpe_number - 75 return (u32)1 << (gpe_event_info->gpe_number -
73 gpe_event_info->register_info->base_gpe_number); 76 gpe_register_info->base_gpe_number);
74} 77}
75 78
76/****************************************************************************** 79/******************************************************************************
@@ -112,7 +115,8 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
112 115
113 /* Set or clear just the bit that corresponds to this GPE */ 116 /* Set or clear just the bit that corresponds to this GPE */
114 117
115 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info); 118 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
119 gpe_register_info);
116 switch (action) { 120 switch (action) {
117 case ACPI_GPE_CONDITIONAL_ENABLE: 121 case ACPI_GPE_CONDITIONAL_ENABLE:
118 122
@@ -174,7 +178,8 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
174 * Write a one to the appropriate bit in the status register to 178 * Write a one to the appropriate bit in the status register to
175 * clear this GPE. 179 * clear this GPE.
176 */ 180 */
177 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info); 181 register_bit =
182 acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
178 183
179 status = acpi_hw_write(register_bit, 184 status = acpi_hw_write(register_bit,
180 &gpe_register_info->status_address); 185 &gpe_register_info->status_address);
@@ -217,7 +222,8 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
217 222
218 /* Get the register bitmask for this GPE */ 223 /* Get the register bitmask for this GPE */
219 224
220 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info); 225 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info,
226 gpe_register_info);
221 227
222 /* GPE currently enabled? (enabled for runtime?) */ 228 /* GPE currently enabled? (enabled for runtime?) */
223 229
@@ -338,8 +344,7 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
338 344
339acpi_status 345acpi_status
340acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 346acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
341 struct acpi_gpe_block_info * gpe_block, 347 struct acpi_gpe_block_info *gpe_block, void *context)
342 void *context)
343{ 348{
344 u32 i; 349 u32 i;
345 acpi_status status; 350 acpi_status status;
@@ -474,5 +479,3 @@ acpi_status acpi_hw_enable_all_wakeup_gpes(void)
474 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL); 479 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
475 return_ACPI_STATUS(status); 480 return_ACPI_STATUS(status);
476} 481}
477
478#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwpci.c b/drivers/acpi/acpica/hwpci.c
index 65bc3453a29..050fd227951 100644
--- a/drivers/acpi/acpica/hwpci.c
+++ b/drivers/acpi/acpica/hwpci.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,7 +259,7 @@ acpi_hw_process_pci_list(struct acpi_pci_id *pci_id,
259 status = acpi_hw_get_pci_device_info(pci_id, info->device, 259 status = acpi_hw_get_pci_device_info(pci_id, info->device,
260 &bus_number, &is_bridge); 260 &bus_number, &is_bridge);
261 if (ACPI_FAILURE(status)) { 261 if (ACPI_FAILURE(status)) {
262 return (status); 262 return_ACPI_STATUS(status);
263 } 263 }
264 264
265 info = info->next; 265 info = info->next;
@@ -271,7 +271,7 @@ acpi_hw_process_pci_list(struct acpi_pci_id *pci_id,
271 pci_id->segment, pci_id->bus, pci_id->device, 271 pci_id->segment, pci_id->bus, pci_id->device,
272 pci_id->function, status, bus_number, is_bridge)); 272 pci_id->function, status, bus_number, is_bridge));
273 273
274 return (AE_OK); 274 return_ACPI_STATUS(AE_OK);
275} 275}
276 276
277/******************************************************************************* 277/*******************************************************************************
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index f4e57503576..55accb7018b 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -1,3 +1,4 @@
1
1/******************************************************************************* 2/*******************************************************************************
2 * 3 *
3 * Module Name: hwregs - Read/write access functions for the various ACPI 4 * Module Name: hwregs - Read/write access functions for the various ACPI
@@ -6,7 +7,7 @@
6 ******************************************************************************/ 7 ******************************************************************************/
7 8
8/* 9/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 10 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 11 * All rights reserved.
11 * 12 *
12 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -50,7 +51,6 @@
50#define _COMPONENT ACPI_HARDWARE 51#define _COMPONENT ACPI_HARDWARE
51ACPI_MODULE_NAME("hwregs") 52ACPI_MODULE_NAME("hwregs")
52 53
53#if (!ACPI_REDUCED_HARDWARE)
54/* Local Prototypes */ 54/* Local Prototypes */
55static acpi_status 55static acpi_status
56acpi_hw_read_multiple(u32 *value, 56acpi_hw_read_multiple(u32 *value,
@@ -62,15 +62,13 @@ acpi_hw_write_multiple(u32 value,
62 struct acpi_generic_address *register_a, 62 struct acpi_generic_address *register_a,
63 struct acpi_generic_address *register_b); 63 struct acpi_generic_address *register_b);
64 64
65#endif /* !ACPI_REDUCED_HARDWARE */
66
67/****************************************************************************** 65/******************************************************************************
68 * 66 *
69 * FUNCTION: acpi_hw_validate_register 67 * FUNCTION: acpi_hw_validate_register
70 * 68 *
71 * PARAMETERS: reg - GAS register structure 69 * PARAMETERS: Reg - GAS register structure
72 * max_bit_width - Max bit_width supported (32 or 64) 70 * max_bit_width - Max bit_width supported (32 or 64)
73 * address - Pointer to where the gas->address 71 * Address - Pointer to where the gas->address
74 * is returned 72 * is returned
75 * 73 *
76 * RETURN: Status 74 * RETURN: Status
@@ -101,7 +99,7 @@ acpi_hw_validate_register(struct acpi_generic_address *reg,
101 return (AE_BAD_ADDRESS); 99 return (AE_BAD_ADDRESS);
102 } 100 }
103 101
104 /* Validate the space_ID */ 102 /* Validate the space_iD */
105 103
106 if ((reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) && 104 if ((reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
107 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { 105 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
@@ -136,8 +134,8 @@ acpi_hw_validate_register(struct acpi_generic_address *reg,
136 * 134 *
137 * FUNCTION: acpi_hw_read 135 * FUNCTION: acpi_hw_read
138 * 136 *
139 * PARAMETERS: value - Where the value is returned 137 * PARAMETERS: Value - Where the value is returned
140 * reg - GAS register structure 138 * Reg - GAS register structure
141 * 139 *
142 * RETURN: Status 140 * RETURN: Status
143 * 141 *
@@ -147,7 +145,7 @@ acpi_hw_validate_register(struct acpi_generic_address *reg,
147 * 145 *
148 * LIMITATIONS: <These limitations also apply to acpi_hw_write> 146 * LIMITATIONS: <These limitations also apply to acpi_hw_write>
149 * bit_width must be exactly 8, 16, or 32. 147 * bit_width must be exactly 8, 16, or 32.
150 * space_ID must be system_memory or system_IO. 148 * space_iD must be system_memory or system_iO.
151 * bit_offset and access_width are currently ignored, as there has 149 * bit_offset and access_width are currently ignored, as there has
152 * not been a need to implement these. 150 * not been a need to implement these.
153 * 151 *
@@ -156,7 +154,6 @@ acpi_hw_validate_register(struct acpi_generic_address *reg,
156acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg) 154acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg)
157{ 155{
158 u64 address; 156 u64 address;
159 u64 value64;
160 acpi_status status; 157 acpi_status status;
161 158
162 ACPI_FUNCTION_NAME(hw_read); 159 ACPI_FUNCTION_NAME(hw_read);
@@ -178,9 +175,7 @@ acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg)
178 */ 175 */
179 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 176 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
180 status = acpi_os_read_memory((acpi_physical_address) 177 status = acpi_os_read_memory((acpi_physical_address)
181 address, &value64, reg->bit_width); 178 address, value, reg->bit_width);
182
183 *value = (u32)value64;
184 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 179 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
185 180
186 status = acpi_hw_read_port((acpi_io_address) 181 status = acpi_hw_read_port((acpi_io_address)
@@ -199,8 +194,8 @@ acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg)
199 * 194 *
200 * FUNCTION: acpi_hw_write 195 * FUNCTION: acpi_hw_write
201 * 196 *
202 * PARAMETERS: value - Value to be written 197 * PARAMETERS: Value - Value to be written
203 * reg - GAS register structure 198 * Reg - GAS register structure
204 * 199 *
205 * RETURN: Status 200 * RETURN: Status
206 * 201 *
@@ -230,8 +225,7 @@ acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg)
230 */ 225 */
231 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 226 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
232 status = acpi_os_write_memory((acpi_physical_address) 227 status = acpi_os_write_memory((acpi_physical_address)
233 address, (u64)value, 228 address, value, reg->bit_width);
234 reg->bit_width);
235 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 229 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
236 230
237 status = acpi_hw_write_port((acpi_io_address) 231 status = acpi_hw_write_port((acpi_io_address)
@@ -246,7 +240,6 @@ acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg)
246 return (status); 240 return (status);
247} 241}
248 242
249#if (!ACPI_REDUCED_HARDWARE)
250/******************************************************************************* 243/*******************************************************************************
251 * 244 *
252 * FUNCTION: acpi_hw_clear_acpi_status 245 * FUNCTION: acpi_hw_clear_acpi_status
@@ -276,23 +269,22 @@ acpi_status acpi_hw_clear_acpi_status(void)
276 269
277 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, 270 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
278 ACPI_BITMASK_ALL_FIXED_STATUS); 271 ACPI_BITMASK_ALL_FIXED_STATUS);
279 272 if (ACPI_FAILURE(status)) {
280 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); 273 goto unlock_and_exit;
281 274 }
282 if (ACPI_FAILURE(status))
283 goto exit;
284 275
285 /* Clear the GPE Bits in all GPE registers in all GPE blocks */ 276 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
286 277
287 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); 278 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
288 279
289exit: 280 unlock_and_exit:
281 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
290 return_ACPI_STATUS(status); 282 return_ACPI_STATUS(status);
291} 283}
292 284
293/******************************************************************************* 285/*******************************************************************************
294 * 286 *
295 * FUNCTION: acpi_hw_get_bit_register_info 287 * FUNCTION: acpi_hw_get_register_bit_mask
296 * 288 *
297 * PARAMETERS: register_id - Index of ACPI Register to access 289 * PARAMETERS: register_id - Index of ACPI Register to access
298 * 290 *
@@ -438,7 +430,7 @@ acpi_hw_register_read(u32 register_id, u32 * return_value)
438 * FUNCTION: acpi_hw_register_write 430 * FUNCTION: acpi_hw_register_write
439 * 431 *
440 * PARAMETERS: register_id - ACPI Register ID 432 * PARAMETERS: register_id - ACPI Register ID
441 * value - The value to write 433 * Value - The value to write
442 * 434 *
443 * RETURN: Status 435 * RETURN: Status
444 * 436 *
@@ -570,7 +562,7 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
570 * 562 *
571 * FUNCTION: acpi_hw_read_multiple 563 * FUNCTION: acpi_hw_read_multiple
572 * 564 *
573 * PARAMETERS: value - Where the register value is returned 565 * PARAMETERS: Value - Where the register value is returned
574 * register_a - First ACPI register (required) 566 * register_a - First ACPI register (required)
575 * register_b - Second ACPI register (optional) 567 * register_b - Second ACPI register (optional)
576 * 568 *
@@ -623,7 +615,7 @@ acpi_hw_read_multiple(u32 *value,
623 * 615 *
624 * FUNCTION: acpi_hw_write_multiple 616 * FUNCTION: acpi_hw_write_multiple
625 * 617 *
626 * PARAMETERS: value - The value to write 618 * PARAMETERS: Value - The value to write
627 * register_a - First ACPI register (required) 619 * register_a - First ACPI register (required)
628 * register_b - Second ACPI register (optional) 620 * register_b - Second ACPI register (optional)
629 * 621 *
@@ -665,5 +657,3 @@ acpi_hw_write_multiple(u32 value,
665 657
666 return (status); 658 return (status);
667} 659}
668
669#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 3fddde056a5..2ac28bbe882 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -1,12 +1,12 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the 4 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
4 * original/legacy sleep/PM registers.
5 * 5 *
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -43,36 +43,212 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <linux/acpi.h>
47#include "accommon.h" 46#include "accommon.h"
48#include <linux/module.h> 47#include "actables.h"
48#include <linux/tboot.h>
49 49
50#define _COMPONENT ACPI_HARDWARE 50#define _COMPONENT ACPI_HARDWARE
51ACPI_MODULE_NAME("hwsleep") 51ACPI_MODULE_NAME("hwsleep")
52 52
53#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
54/******************************************************************************* 53/*******************************************************************************
55 * 54 *
56 * FUNCTION: acpi_hw_legacy_sleep 55 * FUNCTION: acpi_set_firmware_waking_vector
56 *
57 * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode
58 * entry point.
59 *
60 * RETURN: Status
61 *
62 * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
63 *
64 ******************************************************************************/
65acpi_status
66acpi_set_firmware_waking_vector(u32 physical_address)
67{
68 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
69
70
71 /*
72 * According to the ACPI specification 2.0c and later, the 64-bit
73 * waking vector should be cleared and the 32-bit waking vector should
74 * be used, unless we want the wake-up code to be called by the BIOS in
75 * Protected Mode. Some systems (for example HP dv5-1004nr) are known
76 * to fail to resume if the 64-bit vector is used.
77 */
78
79 /* Set the 32-bit vector */
80
81 acpi_gbl_FACS->firmware_waking_vector = physical_address;
82
83 /* Clear the 64-bit vector if it exists */
84
85 if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
86 acpi_gbl_FACS->xfirmware_waking_vector = 0;
87 }
88
89 return_ACPI_STATUS(AE_OK);
90}
91
92ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
93
94#if ACPI_MACHINE_WIDTH == 64
95/*******************************************************************************
96 *
97 * FUNCTION: acpi_set_firmware_waking_vector64
98 *
99 * PARAMETERS: physical_address - 64-bit physical address of ACPI protected
100 * mode entry point.
101 *
102 * RETURN: Status
103 *
104 * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
105 * it exists in the table. This function is intended for use with
106 * 64-bit host operating systems.
107 *
108 ******************************************************************************/
109acpi_status
110acpi_set_firmware_waking_vector64(u64 physical_address)
111{
112 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
113
114
115 /* Determine if the 64-bit vector actually exists */
116
117 if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
118 return_ACPI_STATUS(AE_NOT_EXIST);
119 }
120
121 /* Clear 32-bit vector, set the 64-bit X_ vector */
122
123 acpi_gbl_FACS->firmware_waking_vector = 0;
124 acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
125
126 return_ACPI_STATUS(AE_OK);
127}
128
129ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
130#endif
131
132/*******************************************************************************
133 *
134 * FUNCTION: acpi_enter_sleep_state_prep
57 * 135 *
58 * PARAMETERS: sleep_state - Which sleep state to enter 136 * PARAMETERS: sleep_state - Which sleep state to enter
59 * 137 *
60 * RETURN: Status 138 * RETURN: Status
61 * 139 *
62 * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers 140 * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
141 * This function must execute with interrupts enabled.
142 * We break sleeping into 2 stages so that OSPM can handle
143 * various OS-specific tasks between the two steps.
144 *
145 ******************************************************************************/
146acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
147{
148 acpi_status status;
149 struct acpi_object_list arg_list;
150 union acpi_object arg;
151
152 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep);
153
154 /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */
155
156 status = acpi_get_sleep_type_data(sleep_state,
157 &acpi_gbl_sleep_type_a,
158 &acpi_gbl_sleep_type_b);
159 if (ACPI_FAILURE(status)) {
160 return_ACPI_STATUS(status);
161 }
162
163 /* Setup parameter object */
164
165 arg_list.count = 1;
166 arg_list.pointer = &arg;
167
168 arg.type = ACPI_TYPE_INTEGER;
169 arg.integer.value = sleep_state;
170
171 /* Run the _PTS method */
172
173 status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL);
174 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
175 return_ACPI_STATUS(status);
176 }
177
178 /* Setup the argument to _SST */
179
180 switch (sleep_state) {
181 case ACPI_STATE_S0:
182 arg.integer.value = ACPI_SST_WORKING;
183 break;
184
185 case ACPI_STATE_S1:
186 case ACPI_STATE_S2:
187 case ACPI_STATE_S3:
188 arg.integer.value = ACPI_SST_SLEEPING;
189 break;
190
191 case ACPI_STATE_S4:
192 arg.integer.value = ACPI_SST_SLEEP_CONTEXT;
193 break;
194
195 default:
196 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
197 break;
198 }
199
200 /*
201 * Set the system indicators to show the desired sleep state.
202 * _SST is an optional method (return no error if not found)
203 */
204 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
205 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
206 ACPI_EXCEPTION((AE_INFO, status,
207 "While executing method _SST"));
208 }
209
210 return_ACPI_STATUS(AE_OK);
211}
212
213ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
214
215static unsigned int gts, bfs;
216module_param(gts, uint, 0644);
217module_param(bfs, uint, 0644);
218MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
219MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
220
221/*******************************************************************************
222 *
223 * FUNCTION: acpi_enter_sleep_state
224 *
225 * PARAMETERS: sleep_state - Which sleep state to enter
226 *
227 * RETURN: Status
228 *
229 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
63 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 230 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
64 * 231 *
65 ******************************************************************************/ 232 ******************************************************************************/
66acpi_status acpi_hw_legacy_sleep(u8 sleep_state) 233acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
67{ 234{
68 struct acpi_bit_register_info *sleep_type_reg_info;
69 struct acpi_bit_register_info *sleep_enable_reg_info;
70 u32 pm1a_control; 235 u32 pm1a_control;
71 u32 pm1b_control; 236 u32 pm1b_control;
237 struct acpi_bit_register_info *sleep_type_reg_info;
238 struct acpi_bit_register_info *sleep_enable_reg_info;
72 u32 in_value; 239 u32 in_value;
240 struct acpi_object_list arg_list;
241 union acpi_object arg;
73 acpi_status status; 242 acpi_status status;
74 243
75 ACPI_FUNCTION_TRACE(hw_legacy_sleep); 244 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state);
245
246 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
247 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
248 ACPI_ERROR((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X",
249 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
250 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
251 }
76 252
77 sleep_type_reg_info = 253 sleep_type_reg_info =
78 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE); 254 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
@@ -109,6 +285,20 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
109 return_ACPI_STATUS(status); 285 return_ACPI_STATUS(status);
110 } 286 }
111 287
288 if (gts) {
289 /* Execute the _GTS method */
290
291 arg_list.count = 1;
292 arg_list.pointer = &arg;
293 arg.type = ACPI_TYPE_INTEGER;
294 arg.integer.value = sleep_state;
295
296 status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
297 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
298 return_ACPI_STATUS(status);
299 }
300 }
301
112 /* Get current value of PM1A control */ 302 /* Get current value of PM1A control */
113 303
114 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, 304 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
@@ -153,12 +343,8 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
153 343
154 ACPI_FLUSH_CPU_CACHE(); 344 ACPI_FLUSH_CPU_CACHE();
155 345
156 status = acpi_os_prepare_sleep(sleep_state, pm1a_control, 346 tboot_sleep(sleep_state, pm1a_control, pm1b_control);
157 pm1b_control); 347
158 if (ACPI_SKIP(status))
159 return_ACPI_STATUS(AE_OK);
160 if (ACPI_FAILURE(status))
161 return_ACPI_STATUS(status);
162 /* Write #2: Write both SLP_TYP + SLP_EN */ 348 /* Write #2: Write both SLP_TYP + SLP_EN */
163 349
164 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control); 350 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
@@ -188,43 +374,114 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
188 } 374 }
189 } 375 }
190 376
191 /* Wait for transition back to Working State */ 377 /* Wait until we enter sleep state */
192 378
193 do { 379 do {
380 status = acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS,
381 &in_value);
382 if (ACPI_FAILURE(status)) {
383 return_ACPI_STATUS(status);
384 }
385
386 /* Spin until we wake */
387
388 } while (!in_value);
389
390 return_ACPI_STATUS(AE_OK);
391}
392
393ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
394
395/*******************************************************************************
396 *
397 * FUNCTION: acpi_enter_sleep_state_s4bios
398 *
399 * PARAMETERS: None
400 *
401 * RETURN: Status
402 *
403 * DESCRIPTION: Perform a S4 bios request.
404 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
405 *
406 ******************************************************************************/
407acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
408{
409 u32 in_value;
410 acpi_status status;
411
412 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
413
414 /* Clear the wake status bit (PM1) */
415
416 status =
417 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
418 if (ACPI_FAILURE(status)) {
419 return_ACPI_STATUS(status);
420 }
421
422 status = acpi_hw_clear_acpi_status();
423 if (ACPI_FAILURE(status)) {
424 return_ACPI_STATUS(status);
425 }
426
427 /*
428 * 1) Disable/Clear all GPEs
429 * 2) Enable all wakeup GPEs
430 */
431 status = acpi_hw_disable_all_gpes();
432 if (ACPI_FAILURE(status)) {
433 return_ACPI_STATUS(status);
434 }
435 acpi_gbl_system_awake_and_running = FALSE;
436
437 status = acpi_hw_enable_all_wakeup_gpes();
438 if (ACPI_FAILURE(status)) {
439 return_ACPI_STATUS(status);
440 }
441
442 ACPI_FLUSH_CPU_CACHE();
443
444 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
445 (u32) acpi_gbl_FADT.S4bios_request, 8);
446
447 do {
448 acpi_os_stall(1000);
194 status = 449 status =
195 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); 450 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
196 if (ACPI_FAILURE(status)) { 451 if (ACPI_FAILURE(status)) {
197 return_ACPI_STATUS(status); 452 return_ACPI_STATUS(status);
198 } 453 }
199
200 } while (!in_value); 454 } while (!in_value);
201 455
202 return_ACPI_STATUS(AE_OK); 456 return_ACPI_STATUS(AE_OK);
203} 457}
204 458
459ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
460
205/******************************************************************************* 461/*******************************************************************************
206 * 462 *
207 * FUNCTION: acpi_hw_legacy_wake_prep 463 * FUNCTION: acpi_leave_sleep_state_prep
208 * 464 *
209 * PARAMETERS: sleep_state - Which sleep state we just exited 465 * PARAMETERS: sleep_state - Which sleep state we are exiting
210 * 466 *
211 * RETURN: Status 467 * RETURN: Status
212 * 468 *
213 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a 469 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
214 * sleep. 470 * sleep.
215 * Called with interrupts ENABLED. 471 * Called with interrupts DISABLED.
216 * 472 *
217 ******************************************************************************/ 473 ******************************************************************************/
218 474acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
219acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
220{ 475{
476 struct acpi_object_list arg_list;
477 union acpi_object arg;
221 acpi_status status; 478 acpi_status status;
222 struct acpi_bit_register_info *sleep_type_reg_info; 479 struct acpi_bit_register_info *sleep_type_reg_info;
223 struct acpi_bit_register_info *sleep_enable_reg_info; 480 struct acpi_bit_register_info *sleep_enable_reg_info;
224 u32 pm1a_control; 481 u32 pm1a_control;
225 u32 pm1b_control; 482 u32 pm1b_control;
226 483
227 ACPI_FUNCTION_TRACE(hw_legacy_wake_prep); 484 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
228 485
229 /* 486 /*
230 * Set SLP_TYPE and SLP_EN to state S0. 487 * Set SLP_TYPE and SLP_EN to state S0.
@@ -267,12 +524,25 @@ acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
267 } 524 }
268 } 525 }
269 526
527 if (bfs) {
528 /* Execute the _BFS method */
529
530 arg_list.count = 1;
531 arg_list.pointer = &arg;
532 arg.type = ACPI_TYPE_INTEGER;
533 arg.integer.value = sleep_state;
534
535 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
536 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
537 ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
538 }
539 }
270 return_ACPI_STATUS(status); 540 return_ACPI_STATUS(status);
271} 541}
272 542
273/******************************************************************************* 543/*******************************************************************************
274 * 544 *
275 * FUNCTION: acpi_hw_legacy_wake 545 * FUNCTION: acpi_leave_sleep_state
276 * 546 *
277 * PARAMETERS: sleep_state - Which sleep state we just exited 547 * PARAMETERS: sleep_state - Which sleep state we just exited
278 * 548 *
@@ -282,17 +552,31 @@ acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
282 * Called with interrupts ENABLED. 552 * Called with interrupts ENABLED.
283 * 553 *
284 ******************************************************************************/ 554 ******************************************************************************/
285 555acpi_status acpi_leave_sleep_state(u8 sleep_state)
286acpi_status acpi_hw_legacy_wake(u8 sleep_state)
287{ 556{
557 struct acpi_object_list arg_list;
558 union acpi_object arg;
288 acpi_status status; 559 acpi_status status;
289 560
290 ACPI_FUNCTION_TRACE(hw_legacy_wake); 561 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
291 562
292 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ 563 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
293 564
294 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; 565 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
295 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING); 566
567 /* Setup parameter object */
568
569 arg_list.count = 1;
570 arg_list.pointer = &arg;
571 arg.type = ACPI_TYPE_INTEGER;
572
573 /* Ignore any errors from these methods */
574
575 arg.integer.value = ACPI_SST_WAKING;
576 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
577 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
578 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
579 }
296 580
297 /* 581 /*
298 * GPEs must be enabled before _WAK is called as GPEs 582 * GPEs must be enabled before _WAK is called as GPEs
@@ -306,40 +590,46 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state)
306 if (ACPI_FAILURE(status)) { 590 if (ACPI_FAILURE(status)) {
307 return_ACPI_STATUS(status); 591 return_ACPI_STATUS(status);
308 } 592 }
309
310 status = acpi_hw_enable_all_runtime_gpes(); 593 status = acpi_hw_enable_all_runtime_gpes();
311 if (ACPI_FAILURE(status)) { 594 if (ACPI_FAILURE(status)) {
312 return_ACPI_STATUS(status); 595 return_ACPI_STATUS(status);
313 } 596 }
314 597
315 /* 598 arg.integer.value = sleep_state;
316 * Now we can execute _WAK, etc. Some machines require that the GPEs 599 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
317 * are enabled before the wake methods are executed. 600 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
318 */ 601 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
319 acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state); 602 }
603 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
320 604
321 /* 605 /*
322 * Some BIOS code assumes that WAK_STS will be cleared on resume 606 * Some BIOSes assume that WAK_STS will be cleared on resume and use
323 * and use it to determine whether the system is rebooting or 607 * it to determine whether the system is rebooting or resuming. Clear
324 * resuming. Clear WAK_STS for compatibility. 608 * it for compatibility.
325 */ 609 */
326 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); 610 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1);
611
327 acpi_gbl_system_awake_and_running = TRUE; 612 acpi_gbl_system_awake_and_running = TRUE;
328 613
329 /* Enable power button */ 614 /* Enable power button */
330 615
331 (void) 616 (void)
332 acpi_write_bit_register(acpi_gbl_fixed_event_info 617 acpi_write_bit_register(acpi_gbl_fixed_event_info
333 [ACPI_EVENT_POWER_BUTTON]. 618 [ACPI_EVENT_POWER_BUTTON].
334 enable_register_id, ACPI_ENABLE_EVENT); 619 enable_register_id, ACPI_ENABLE_EVENT);
335 620
336 (void) 621 (void)
337 acpi_write_bit_register(acpi_gbl_fixed_event_info 622 acpi_write_bit_register(acpi_gbl_fixed_event_info
338 [ACPI_EVENT_POWER_BUTTON]. 623 [ACPI_EVENT_POWER_BUTTON].
339 status_register_id, ACPI_CLEAR_STATUS); 624 status_register_id, ACPI_CLEAR_STATUS);
625
626 arg.integer.value = ACPI_SST_WORKING;
627 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
628 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
629 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
630 }
340 631
341 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
342 return_ACPI_STATUS(status); 632 return_ACPI_STATUS(status);
343} 633}
344 634
345#endif /* !ACPI_REDUCED_HARDWARE */ 635ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state)
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index bfdce22f379..9c8eb71a12f 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Name: hwtimer.c - ACPI Power Management Timer Interface 4 * Name: hwtimer.c - ACPI Power Management Timer Interface
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -41,19 +42,17 @@
41 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
42 */ 43 */
43 44
44#include <linux/export.h>
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwtimer") 49ACPI_MODULE_NAME("hwtimer")
50 50
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/****************************************************************************** 51/******************************************************************************
53 * 52 *
54 * FUNCTION: acpi_get_timer_resolution 53 * FUNCTION: acpi_get_timer_resolution
55 * 54 *
56 * PARAMETERS: resolution - Where the resolution is returned 55 * PARAMETERS: Resolution - Where the resolution is returned
57 * 56 *
58 * RETURN: Status and timer resolution 57 * RETURN: Status and timer resolution
59 * 58 *
@@ -83,7 +82,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_timer_resolution)
83 * 82 *
84 * FUNCTION: acpi_get_timer 83 * FUNCTION: acpi_get_timer
85 * 84 *
86 * PARAMETERS: ticks - Where the timer value is returned 85 * PARAMETERS: Ticks - Where the timer value is returned
87 * 86 *
88 * RETURN: Status and current timer value (ticks) 87 * RETURN: Status and current timer value (ticks)
89 * 88 *
@@ -100,7 +99,8 @@ acpi_status acpi_get_timer(u32 * ticks)
100 return_ACPI_STATUS(AE_BAD_PARAMETER); 99 return_ACPI_STATUS(AE_BAD_PARAMETER);
101 } 100 }
102 101
103 status = acpi_hw_read(ticks, &acpi_gbl_FADT.xpm_timer_block); 102 status =
103 acpi_hw_read(ticks, &acpi_gbl_FADT.xpm_timer_block);
104 104
105 return_ACPI_STATUS(status); 105 return_ACPI_STATUS(status);
106} 106}
@@ -127,7 +127,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_timer)
127 * a versatile and accurate timer. 127 * a versatile and accurate timer.
128 * 128 *
129 * Note that this function accommodates only a single timer 129 * Note that this function accommodates only a single timer
130 * rollover. Thus for 24-bit timers, this function should only 130 * rollover. Thus for 24-bit timers, this function should only
131 * be used for calculating durations less than ~4.6 seconds 131 * be used for calculating durations less than ~4.6 seconds
132 * (~20 minutes for 32-bit timers) -- calculations below: 132 * (~20 minutes for 32-bit timers) -- calculations below:
133 * 133 *
@@ -186,4 +186,3 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
186} 186}
187 187
188ACPI_EXPORT_SYMBOL(acpi_get_timer_duration) 188ACPI_EXPORT_SYMBOL(acpi_get_timer_duration)
189#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
index b6aae58299d..5f160587465 100644
--- a/drivers/acpi/acpica/hwvalid.c
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: hwvalid - I/O request validation 4 * Module Name: hwvalid - I/O request validation
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -57,7 +58,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width);
57 * 58 *
58 * The table is used to implement the Microsoft port access rules that 59 * The table is used to implement the Microsoft port access rules that
59 * first appeared in Windows XP. Some ports are always illegal, and some 60 * first appeared in Windows XP. Some ports are always illegal, and some
60 * ports are only illegal if the BIOS calls _OSI with a win_XP string or 61 * ports are only illegal if the BIOS calls _OSI with a win_xP string or
61 * later (meaning that the BIOS itelf is post-XP.) 62 * later (meaning that the BIOS itelf is post-XP.)
62 * 63 *
63 * This provides ACPICA with the desired port protections and 64 * This provides ACPICA with the desired port protections and
@@ -65,7 +66,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width);
65 * 66 *
66 * Description of port entries: 67 * Description of port entries:
67 * DMA: DMA controller 68 * DMA: DMA controller
68 * PIC0: Programmable Interrupt Controller (8259A) 69 * PIC0: Programmable Interrupt Controller (8259_a)
69 * PIT1: System Timer 1 70 * PIT1: System Timer 1
70 * PIT2: System Timer 2 failsafe 71 * PIT2: System Timer 2 failsafe
71 * RTC: Real-time clock 72 * RTC: Real-time clock
@@ -133,8 +134,6 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width)
133 /* Supported widths are 8/16/32 */ 134 /* Supported widths are 8/16/32 */
134 135
135 if ((bit_width != 8) && (bit_width != 16) && (bit_width != 32)) { 136 if ((bit_width != 8) && (bit_width != 16) && (bit_width != 32)) {
136 ACPI_ERROR((AE_INFO,
137 "Bad BitWidth parameter: %8.8X", bit_width));
138 return AE_BAD_PARAMETER; 137 return AE_BAD_PARAMETER;
139 } 138 }
140 139
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 05a154c3c9a..f75f81ad15c 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -1,3 +1,4 @@
1
1/****************************************************************************** 2/******************************************************************************
2 * 3 *
3 * Module Name: hwxface - Public ACPICA hardware interfaces 4 * Module Name: hwxface - Public ACPICA hardware interfaces
@@ -5,7 +6,7 @@
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -41,7 +42,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
42 */ 43 */
43 44
44#include <linux/export.h>
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
@@ -103,8 +103,8 @@ ACPI_EXPORT_SYMBOL(acpi_reset)
103 * 103 *
104 * FUNCTION: acpi_read 104 * FUNCTION: acpi_read
105 * 105 *
106 * PARAMETERS: value - Where the value is returned 106 * PARAMETERS: Value - Where the value is returned
107 * reg - GAS register structure 107 * Reg - GAS register structure
108 * 108 *
109 * RETURN: Status 109 * RETURN: Status
110 * 110 *
@@ -112,7 +112,7 @@ ACPI_EXPORT_SYMBOL(acpi_reset)
112 * 112 *
113 * LIMITATIONS: <These limitations also apply to acpi_write> 113 * LIMITATIONS: <These limitations also apply to acpi_write>
114 * bit_width must be exactly 8, 16, 32, or 64. 114 * bit_width must be exactly 8, 16, 32, or 64.
115 * space_ID must be system_memory or system_IO. 115 * space_iD must be system_memory or system_iO.
116 * bit_offset and access_width are currently ignored, as there has 116 * bit_offset and access_width are currently ignored, as there has
117 * not been a need to implement these. 117 * not been a need to implement these.
118 * 118 *
@@ -137,6 +137,11 @@ acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg)
137 return (status); 137 return (status);
138 } 138 }
139 139
140 width = reg->bit_width;
141 if (width == 64) {
142 width = 32; /* Break into two 32-bit transfers */
143 }
144
140 /* Initialize entire 64-bit return value to zero */ 145 /* Initialize entire 64-bit return value to zero */
141 146
142 *return_value = 0; 147 *return_value = 0;
@@ -148,17 +153,24 @@ acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg)
148 */ 153 */
149 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 154 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
150 status = acpi_os_read_memory((acpi_physical_address) 155 status = acpi_os_read_memory((acpi_physical_address)
151 address, return_value, 156 address, &value, width);
152 reg->bit_width);
153 if (ACPI_FAILURE(status)) { 157 if (ACPI_FAILURE(status)) {
154 return (status); 158 return (status);
155 } 159 }
156 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 160 *return_value = value;
161
162 if (reg->bit_width == 64) {
163
164 /* Read the top 32 bits */
157 165
158 width = reg->bit_width; 166 status = acpi_os_read_memory((acpi_physical_address)
159 if (width == 64) { 167 (address + 4), &value, 32);
160 width = 32; /* Break into two 32-bit transfers */ 168 if (ACPI_FAILURE(status)) {
169 return (status);
170 }
171 *return_value |= ((u64)value << 32);
161 } 172 }
173 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
162 174
163 status = acpi_hw_read_port((acpi_io_address) 175 status = acpi_hw_read_port((acpi_io_address)
164 address, &value, width); 176 address, &value, width);
@@ -195,8 +207,8 @@ ACPI_EXPORT_SYMBOL(acpi_read)
195 * 207 *
196 * FUNCTION: acpi_write 208 * FUNCTION: acpi_write
197 * 209 *
198 * PARAMETERS: value - Value to be written 210 * PARAMETERS: Value - Value to be written
199 * reg - GAS register structure 211 * Reg - GAS register structure
200 * 212 *
201 * RETURN: Status 213 * RETURN: Status
202 * 214 *
@@ -218,22 +230,32 @@ acpi_status acpi_write(u64 value, struct acpi_generic_address *reg)
218 return (status); 230 return (status);
219 } 231 }
220 232
233 width = reg->bit_width;
234 if (width == 64) {
235 width = 32; /* Break into two 32-bit transfers */
236 }
237
221 /* 238 /*
222 * Two address spaces supported: Memory or IO. PCI_Config is 239 * Two address spaces supported: Memory or IO. PCI_Config is
223 * not supported here because the GAS structure is insufficient 240 * not supported here because the GAS structure is insufficient
224 */ 241 */
225 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 242 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
226 status = acpi_os_write_memory((acpi_physical_address) 243 status = acpi_os_write_memory((acpi_physical_address)
227 address, value, reg->bit_width); 244 address, ACPI_LODWORD(value),
245 width);
228 if (ACPI_FAILURE(status)) { 246 if (ACPI_FAILURE(status)) {
229 return (status); 247 return (status);
230 } 248 }
231 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
232 249
233 width = reg->bit_width; 250 if (reg->bit_width == 64) {
234 if (width == 64) { 251 status = acpi_os_write_memory((acpi_physical_address)
235 width = 32; /* Break into two 32-bit transfers */ 252 (address + 4),
253 ACPI_HIDWORD(value), 32);
254 if (ACPI_FAILURE(status)) {
255 return (status);
256 }
236 } 257 }
258 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
237 259
238 status = acpi_hw_write_port((acpi_io_address) 260 status = acpi_hw_write_port((acpi_io_address)
239 address, ACPI_LODWORD(value), 261 address, ACPI_LODWORD(value),
@@ -263,7 +285,6 @@ acpi_status acpi_write(u64 value, struct acpi_generic_address *reg)
263 285
264ACPI_EXPORT_SYMBOL(acpi_write) 286ACPI_EXPORT_SYMBOL(acpi_write)
265 287
266#if (!ACPI_REDUCED_HARDWARE)
267/******************************************************************************* 288/*******************************************************************************
268 * 289 *
269 * FUNCTION: acpi_read_bit_register 290 * FUNCTION: acpi_read_bit_register
@@ -334,7 +355,7 @@ ACPI_EXPORT_SYMBOL(acpi_read_bit_register)
334 * 355 *
335 * PARAMETERS: register_id - ID of ACPI Bit Register to access 356 * PARAMETERS: register_id - ID of ACPI Bit Register to access
336 * Value - Value to write to the register, in bit 357 * Value - Value to write to the register, in bit
337 * position zero. The bit is automatically 358 * position zero. The bit is automaticallly
338 * shifted to the correct position. 359 * shifted to the correct position.
339 * 360 *
340 * RETURN: Status 361 * RETURN: Status
@@ -431,7 +452,7 @@ unlock_and_exit:
431} 452}
432 453
433ACPI_EXPORT_SYMBOL(acpi_write_bit_register) 454ACPI_EXPORT_SYMBOL(acpi_write_bit_register)
434#endif /* !ACPI_REDUCED_HARDWARE */ 455
435/******************************************************************************* 456/*******************************************************************************
436 * 457 *
437 * FUNCTION: acpi_get_sleep_type_data 458 * FUNCTION: acpi_get_sleep_type_data
@@ -440,7 +461,7 @@ ACPI_EXPORT_SYMBOL(acpi_write_bit_register)
440 * *sleep_type_a - Where SLP_TYPa is returned 461 * *sleep_type_a - Where SLP_TYPa is returned
441 * *sleep_type_b - Where SLP_TYPb is returned 462 * *sleep_type_b - Where SLP_TYPb is returned
442 * 463 *
443 * RETURN: status - ACPI status 464 * RETURN: Status - ACPI status
444 * 465 *
445 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep 466 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
446 * state. 467 * state.
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
deleted file mode 100644
index ae443fe2ebf..00000000000
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ /dev/null
@@ -1,424 +0,0 @@
1/******************************************************************************
2 *
3 * Name: hwxfsleep.c - ACPI Hardware Sleep/Wake External Interfaces
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include <linux/module.h>
47
48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwxfsleep")
50
51/* Local prototypes */
52static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
53
54/*
55 * Dispatch table used to efficiently branch to the various sleep
56 * functions.
57 */
58#define ACPI_SLEEP_FUNCTION_ID 0
59#define ACPI_WAKE_PREP_FUNCTION_ID 1
60#define ACPI_WAKE_FUNCTION_ID 2
61
62/* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
63
64static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
65 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
66 acpi_hw_extended_sleep},
67 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
68 acpi_hw_extended_wake_prep},
69 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
70};
71
72/*
73 * These functions are removed for the ACPI_REDUCED_HARDWARE case:
74 * acpi_set_firmware_waking_vector
75 * acpi_set_firmware_waking_vector64
76 * acpi_enter_sleep_state_s4bios
77 */
78
79#if (!ACPI_REDUCED_HARDWARE)
80/*******************************************************************************
81 *
82 * FUNCTION: acpi_set_firmware_waking_vector
83 *
84 * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode
85 * entry point.
86 *
87 * RETURN: Status
88 *
89 * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
90 *
91 ******************************************************************************/
92
93acpi_status acpi_set_firmware_waking_vector(u32 physical_address)
94{
95 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
96
97
98 /*
99 * According to the ACPI specification 2.0c and later, the 64-bit
100 * waking vector should be cleared and the 32-bit waking vector should
101 * be used, unless we want the wake-up code to be called by the BIOS in
102 * Protected Mode. Some systems (for example HP dv5-1004nr) are known
103 * to fail to resume if the 64-bit vector is used.
104 */
105
106 /* Set the 32-bit vector */
107
108 acpi_gbl_FACS->firmware_waking_vector = physical_address;
109
110 /* Clear the 64-bit vector if it exists */
111
112 if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
113 acpi_gbl_FACS->xfirmware_waking_vector = 0;
114 }
115
116 return_ACPI_STATUS(AE_OK);
117}
118
119ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
120
121#if ACPI_MACHINE_WIDTH == 64
122/*******************************************************************************
123 *
124 * FUNCTION: acpi_set_firmware_waking_vector64
125 *
126 * PARAMETERS: physical_address - 64-bit physical address of ACPI protected
127 * mode entry point.
128 *
129 * RETURN: Status
130 *
131 * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
132 * it exists in the table. This function is intended for use with
133 * 64-bit host operating systems.
134 *
135 ******************************************************************************/
136acpi_status acpi_set_firmware_waking_vector64(u64 physical_address)
137{
138 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
139
140
141 /* Determine if the 64-bit vector actually exists */
142
143 if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
144 return_ACPI_STATUS(AE_NOT_EXIST);
145 }
146
147 /* Clear 32-bit vector, set the 64-bit X_ vector */
148
149 acpi_gbl_FACS->firmware_waking_vector = 0;
150 acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
151 return_ACPI_STATUS(AE_OK);
152}
153
154ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
155#endif
156
157/*******************************************************************************
158 *
159 * FUNCTION: acpi_enter_sleep_state_s4bios
160 *
161 * PARAMETERS: None
162 *
163 * RETURN: Status
164 *
165 * DESCRIPTION: Perform a S4 bios request.
166 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
167 *
168 ******************************************************************************/
169acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
170{
171 u32 in_value;
172 acpi_status status;
173
174 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
175
176 /* Clear the wake status bit (PM1) */
177
178 status =
179 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
180 if (ACPI_FAILURE(status)) {
181 return_ACPI_STATUS(status);
182 }
183
184 status = acpi_hw_clear_acpi_status();
185 if (ACPI_FAILURE(status)) {
186 return_ACPI_STATUS(status);
187 }
188
189 /*
190 * 1) Disable/Clear all GPEs
191 * 2) Enable all wakeup GPEs
192 */
193 status = acpi_hw_disable_all_gpes();
194 if (ACPI_FAILURE(status)) {
195 return_ACPI_STATUS(status);
196 }
197 acpi_gbl_system_awake_and_running = FALSE;
198
199 status = acpi_hw_enable_all_wakeup_gpes();
200 if (ACPI_FAILURE(status)) {
201 return_ACPI_STATUS(status);
202 }
203
204 ACPI_FLUSH_CPU_CACHE();
205
206 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
207 (u32)acpi_gbl_FADT.s4_bios_request, 8);
208
209 do {
210 acpi_os_stall(1000);
211 status =
212 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
213 if (ACPI_FAILURE(status)) {
214 return_ACPI_STATUS(status);
215 }
216 } while (!in_value);
217
218 return_ACPI_STATUS(AE_OK);
219}
220
221ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
222#endif /* !ACPI_REDUCED_HARDWARE */
223/*******************************************************************************
224 *
225 * FUNCTION: acpi_hw_sleep_dispatch
226 *
227 * PARAMETERS: sleep_state - Which sleep state to enter/exit
228 * function_id - Sleep, wake_prep, or Wake
229 *
230 * RETURN: Status from the invoked sleep handling function.
231 *
232 * DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling
233 * function.
234 *
235 ******************************************************************************/
236static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id)
237{
238 acpi_status status;
239 struct acpi_sleep_functions *sleep_functions =
240 &acpi_sleep_dispatch[function_id];
241
242#if (!ACPI_REDUCED_HARDWARE)
243
244 /*
245 * If the Hardware Reduced flag is set (from the FADT), we must
246 * use the extended sleep registers
247 */
248 if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) {
249 status = sleep_functions->extended_function(sleep_state);
250 } else {
251 /* Legacy sleep */
252
253 status = sleep_functions->legacy_function(sleep_state);
254 }
255
256 return (status);
257
258#else
259 /*
260 * For the case where reduced-hardware-only code is being generated,
261 * we know that only the extended sleep registers are available
262 */
263 status = sleep_functions->extended_function(sleep_state);
264 return (status);
265
266#endif /* !ACPI_REDUCED_HARDWARE */
267}
268
269/*******************************************************************************
270 *
271 * FUNCTION: acpi_enter_sleep_state_prep
272 *
273 * PARAMETERS: sleep_state - Which sleep state to enter
274 *
275 * RETURN: Status
276 *
277 * DESCRIPTION: Prepare to enter a system sleep state.
278 * This function must execute with interrupts enabled.
279 * We break sleeping into 2 stages so that OSPM can handle
280 * various OS-specific tasks between the two steps.
281 *
282 ******************************************************************************/
283
284acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
285{
286 acpi_status status;
287 struct acpi_object_list arg_list;
288 union acpi_object arg;
289 u32 sst_value;
290
291 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep);
292
293 status = acpi_get_sleep_type_data(sleep_state,
294 &acpi_gbl_sleep_type_a,
295 &acpi_gbl_sleep_type_b);
296 if (ACPI_FAILURE(status)) {
297 return_ACPI_STATUS(status);
298 }
299
300 /* Execute the _PTS method (Prepare To Sleep) */
301
302 arg_list.count = 1;
303 arg_list.pointer = &arg;
304 arg.type = ACPI_TYPE_INTEGER;
305 arg.integer.value = sleep_state;
306
307 status =
308 acpi_evaluate_object(NULL, METHOD_PATHNAME__PTS, &arg_list, NULL);
309 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
310 return_ACPI_STATUS(status);
311 }
312
313 /* Setup the argument to the _SST method (System STatus) */
314
315 switch (sleep_state) {
316 case ACPI_STATE_S0:
317 sst_value = ACPI_SST_WORKING;
318 break;
319
320 case ACPI_STATE_S1:
321 case ACPI_STATE_S2:
322 case ACPI_STATE_S3:
323 sst_value = ACPI_SST_SLEEPING;
324 break;
325
326 case ACPI_STATE_S4:
327 sst_value = ACPI_SST_SLEEP_CONTEXT;
328 break;
329
330 default:
331 sst_value = ACPI_SST_INDICATOR_OFF; /* Default is off */
332 break;
333 }
334
335 /*
336 * Set the system indicators to show the desired sleep state.
337 * _SST is an optional method (return no error if not found)
338 */
339 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, sst_value);
340 return_ACPI_STATUS(AE_OK);
341}
342
343ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
344
345/*******************************************************************************
346 *
347 * FUNCTION: acpi_enter_sleep_state
348 *
349 * PARAMETERS: sleep_state - Which sleep state to enter
350 *
351 * RETURN: Status
352 *
353 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
354 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
355 *
356 ******************************************************************************/
357acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
358{
359 acpi_status status;
360
361 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state);
362
363 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
364 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
365 ACPI_ERROR((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X",
366 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
367 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
368 }
369
370 status = acpi_hw_sleep_dispatch(sleep_state, ACPI_SLEEP_FUNCTION_ID);
371 return_ACPI_STATUS(status);
372}
373
374ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
375
376/*******************************************************************************
377 *
378 * FUNCTION: acpi_leave_sleep_state_prep
379 *
380 * PARAMETERS: sleep_state - Which sleep state we are exiting
381 *
382 * RETURN: Status
383 *
384 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
385 * sleep.
386 * Called with interrupts DISABLED.
387 *
388 ******************************************************************************/
389acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
390{
391 acpi_status status;
392
393 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
394
395 status =
396 acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_PREP_FUNCTION_ID);
397 return_ACPI_STATUS(status);
398}
399
400ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state_prep)
401
402/*******************************************************************************
403 *
404 * FUNCTION: acpi_leave_sleep_state
405 *
406 * PARAMETERS: sleep_state - Which sleep state we are exiting
407 *
408 * RETURN: Status
409 *
410 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
411 * Called with interrupts ENABLED.
412 *
413 ******************************************************************************/
414acpi_status acpi_leave_sleep_state(u8 sleep_state)
415{
416 acpi_status status;
417
418 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
419
420 status = acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_FUNCTION_ID);
421 return_ACPI_STATUS(status);
422}
423
424ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state)
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index d70eaf39dfd..d93172fd15a 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -110,11 +110,11 @@ acpi_status acpi_ns_root_initialize(void)
110 status = acpi_ns_lookup(NULL, init_val->name, init_val->type, 110 status = acpi_ns_lookup(NULL, init_val->name, init_val->type,
111 ACPI_IMODE_LOAD_PASS2, 111 ACPI_IMODE_LOAD_PASS2,
112 ACPI_NS_NO_UPSEARCH, NULL, &new_node); 112 ACPI_NS_NO_UPSEARCH, NULL, &new_node);
113 if (ACPI_FAILURE(status)) { 113
114 if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */
114 ACPI_EXCEPTION((AE_INFO, status, 115 ACPI_EXCEPTION((AE_INFO, status,
115 "Could not create predefined name %s", 116 "Could not create predefined name %s",
116 init_val->name)); 117 init_val->name));
117 continue;
118 } 118 }
119 119
120 /* 120 /*
@@ -157,7 +157,7 @@ acpi_status acpi_ns_root_initialize(void)
157 157
158#if defined (ACPI_ASL_COMPILER) 158#if defined (ACPI_ASL_COMPILER)
159 159
160 /* Save the parameter count for the iASL compiler */ 160 /* Save the parameter count for the i_aSL compiler */
161 161
162 new_node->value = obj_desc->method.param_count; 162 new_node->value = obj_desc->method.param_count;
163#else 163#else
@@ -179,7 +179,8 @@ acpi_status acpi_ns_root_initialize(void)
179 179
180 /* Build an object around the static string */ 180 /* Build an object around the static string */
181 181
182 obj_desc->string.length = (u32)ACPI_STRLEN(val); 182 obj_desc->string.length =
183 (u32) ACPI_STRLEN(val);
183 obj_desc->string.pointer = val; 184 obj_desc->string.pointer = val;
184 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; 185 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
185 break; 186 break;
@@ -257,11 +258,11 @@ acpi_status acpi_ns_root_initialize(void)
257 * FUNCTION: acpi_ns_lookup 258 * FUNCTION: acpi_ns_lookup
258 * 259 *
259 * PARAMETERS: scope_info - Current scope info block 260 * PARAMETERS: scope_info - Current scope info block
260 * pathname - Search pathname, in internal format 261 * Pathname - Search pathname, in internal format
261 * (as represented in the AML stream) 262 * (as represented in the AML stream)
262 * type - Type associated with name 263 * Type - Type associated with name
263 * interpreter_mode - IMODE_LOAD_PASS2 => add name if not found 264 * interpreter_mode - IMODE_LOAD_PASS2 => add name if not found
264 * flags - Flags describing the search restrictions 265 * Flags - Flags describing the search restrictions
265 * walk_state - Current state of the walk 266 * walk_state - Current state of the walk
266 * return_node - Where the Node is placed (if found 267 * return_node - Where the Node is placed (if found
267 * or created successfully) 268 * or created successfully)
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 15143c44f5e..1d0ef15d158 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -52,7 +52,7 @@ ACPI_MODULE_NAME("nsalloc")
52 * 52 *
53 * FUNCTION: acpi_ns_create_node 53 * FUNCTION: acpi_ns_create_node
54 * 54 *
55 * PARAMETERS: name - Name of the new node (4 char ACPI name) 55 * PARAMETERS: Name - Name of the new node (4 char ACPI name)
56 * 56 *
57 * RETURN: New namespace node (Null on failure) 57 * RETURN: New namespace node (Null on failure)
58 * 58 *
@@ -92,7 +92,7 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name)
92 * 92 *
93 * FUNCTION: acpi_ns_delete_node 93 * FUNCTION: acpi_ns_delete_node
94 * 94 *
95 * PARAMETERS: node - Node to be deleted 95 * PARAMETERS: Node - Node to be deleted
96 * 96 *
97 * RETURN: None 97 * RETURN: None
98 * 98 *
@@ -143,7 +143,7 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node)
143 * 143 *
144 * FUNCTION: acpi_ns_remove_node 144 * FUNCTION: acpi_ns_remove_node
145 * 145 *
146 * PARAMETERS: node - Node to be removed/deleted 146 * PARAMETERS: Node - Node to be removed/deleted
147 * 147 *
148 * RETURN: None 148 * RETURN: None
149 * 149 *
@@ -196,8 +196,8 @@ void acpi_ns_remove_node(struct acpi_namespace_node *node)
196 * 196 *
197 * PARAMETERS: walk_state - Current state of the walk 197 * PARAMETERS: walk_state - Current state of the walk
198 * parent_node - The parent of the new Node 198 * parent_node - The parent of the new Node
199 * node - The new Node to install 199 * Node - The new Node to install
200 * type - ACPI object type of the new Node 200 * Type - ACPI object type of the new Node
201 * 201 *
202 * RETURN: None 202 * RETURN: None
203 * 203 *
@@ -332,7 +332,7 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
332 * 332 *
333 * RETURN: None. 333 * RETURN: None.
334 * 334 *
335 * DESCRIPTION: Delete a subtree of the namespace. This includes all objects 335 * DESCRIPTION: Delete a subtree of the namespace. This includes all objects
336 * stored within the subtree. 336 * stored within the subtree.
337 * 337 *
338 ******************************************************************************/ 338 ******************************************************************************/
@@ -418,7 +418,7 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
418 * RETURN: Status 418 * RETURN: Status
419 * 419 *
420 * DESCRIPTION: Delete entries within the namespace that are owned by a 420 * DESCRIPTION: Delete entries within the namespace that are owned by a
421 * specific ID. Used to delete entire ACPI tables. All 421 * specific ID. Used to delete entire ACPI tables. All
422 * reference counts are updated. 422 * reference counts are updated.
423 * 423 *
424 * MUTEX: Locks namespace during deletion walk. 424 * MUTEX: Locks namespace during deletion walk.
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 924b3c71473..b683cc2ff9d 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -63,7 +63,7 @@ acpi_ns_dump_one_device(acpi_handle obj_handle,
63 * FUNCTION: acpi_ns_print_pathname 63 * FUNCTION: acpi_ns_print_pathname
64 * 64 *
65 * PARAMETERS: num_segments - Number of ACPI name segments 65 * PARAMETERS: num_segments - Number of ACPI name segments
66 * pathname - The compressed (internal) path 66 * Pathname - The compressed (internal) path
67 * 67 *
68 * RETURN: None 68 * RETURN: None
69 * 69 *
@@ -107,10 +107,10 @@ void acpi_ns_print_pathname(u32 num_segments, char *pathname)
107 * 107 *
108 * FUNCTION: acpi_ns_dump_pathname 108 * FUNCTION: acpi_ns_dump_pathname
109 * 109 *
110 * PARAMETERS: handle - Object 110 * PARAMETERS: Handle - Object
111 * msg - Prefix message 111 * Msg - Prefix message
112 * level - Desired debug level 112 * Level - Desired debug level
113 * component - Caller's component ID 113 * Component - Caller's component ID
114 * 114 *
115 * RETURN: None 115 * RETURN: None
116 * 116 *
@@ -143,8 +143,8 @@ acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
143 * FUNCTION: acpi_ns_dump_one_object 143 * FUNCTION: acpi_ns_dump_one_object
144 * 144 *
145 * PARAMETERS: obj_handle - Node to be dumped 145 * PARAMETERS: obj_handle - Node to be dumped
146 * level - Nesting level of the handle 146 * Level - Nesting level of the handle
147 * context - Passed into walk_namespace 147 * Context - Passed into walk_namespace
148 * return_value - Not used 148 * return_value - Not used
149 * 149 *
150 * RETURN: Status 150 * RETURN: Status
@@ -209,6 +209,14 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
209 "Invalid ACPI Object Type 0x%08X", type)); 209 "Invalid ACPI Object Type 0x%08X", type));
210 } 210 }
211 211
212 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
213 this_node->name.integer =
214 acpi_ut_repair_name(this_node->name.ascii);
215
216 ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
217 this_node->name.integer));
218 }
219
212 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); 220 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
213 } 221 }
214 222
@@ -234,20 +242,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
234 242
235 if (!obj_desc) { 243 if (!obj_desc) {
236 244
237 /* No attached object. Some types should always have an object */ 245 /* No attached object, we are done */
238
239 switch (type) {
240 case ACPI_TYPE_INTEGER:
241 case ACPI_TYPE_PACKAGE:
242 case ACPI_TYPE_BUFFER:
243 case ACPI_TYPE_STRING:
244 case ACPI_TYPE_METHOD:
245 acpi_os_printf("<No attached object>");
246 break;
247
248 default:
249 break;
250 }
251 246
252 acpi_os_printf("\n"); 247 acpi_os_printf("\n");
253 return (AE_OK); 248 return (AE_OK);
@@ -256,7 +251,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
256 switch (type) { 251 switch (type) {
257 case ACPI_TYPE_PROCESSOR: 252 case ACPI_TYPE_PROCESSOR:
258 253
259 acpi_os_printf("ID %02X Len %02X Addr %p\n", 254 acpi_os_printf("ID %X Len %.4X Addr %p\n",
260 obj_desc->processor.proc_id, 255 obj_desc->processor.proc_id,
261 obj_desc->processor.length, 256 obj_desc->processor.length,
262 ACPI_CAST_PTR(void, 257 ACPI_CAST_PTR(void,
@@ -607,7 +602,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
607 * 602 *
608 * FUNCTION: acpi_ns_dump_objects 603 * FUNCTION: acpi_ns_dump_objects
609 * 604 *
610 * PARAMETERS: type - Object type to be dumped 605 * PARAMETERS: Type - Object type to be dumped
611 * display_type - 0 or ACPI_DISPLAY_SUMMARY 606 * display_type - 0 or ACPI_DISPLAY_SUMMARY
612 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX 607 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
613 * for an effectively unlimited depth. 608 * for an effectively unlimited depth.
@@ -663,7 +658,7 @@ acpi_ns_dump_objects(acpi_object_type type,
663 * 658 *
664 * FUNCTION: acpi_ns_dump_entry 659 * FUNCTION: acpi_ns_dump_entry
665 * 660 *
666 * PARAMETERS: handle - Node to be dumped 661 * PARAMETERS: Handle - Node to be dumped
667 * debug_level - Output level 662 * debug_level - Output level
668 * 663 *
669 * RETURN: None 664 * RETURN: None
@@ -692,7 +687,7 @@ void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
692 * 687 *
693 * PARAMETERS: search_base - Root of subtree to be dumped, or 688 * PARAMETERS: search_base - Root of subtree to be dumped, or
694 * NS_ALL to dump the entire namespace 689 * NS_ALL to dump the entire namespace
695 * max_depth - Maximum depth of dump. Use INT_MAX 690 * max_depth - Maximum depth of dump. Use INT_MAX
696 * for an effectively unlimited depth. 691 * for an effectively unlimited depth.
697 * 692 *
698 * RETURN: None 693 * RETURN: None
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 944d4c8d943..2ed294b7a4d 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,9 +55,9 @@ ACPI_MODULE_NAME("nsdumpdv")
55 * 55 *
56 * FUNCTION: acpi_ns_dump_one_device 56 * FUNCTION: acpi_ns_dump_one_device
57 * 57 *
58 * PARAMETERS: handle - Node to be dumped 58 * PARAMETERS: Handle - Node to be dumped
59 * level - Nesting level of the handle 59 * Level - Nesting level of the handle
60 * context - Passed into walk_namespace 60 * Context - Passed into walk_namespace
61 * return_value - Not used 61 * return_value - Not used
62 * 62 *
63 * RETURN: Status 63 * RETURN: Status
@@ -121,7 +121,7 @@ void acpi_ns_dump_root_devices(void)
121 return; 121 return;
122 } 122 }
123 123
124 status = acpi_get_handle(NULL, METHOD_NAME__SB_, &sys_bus_handle); 124 status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle);
125 if (ACPI_FAILURE(status)) { 125 if (ACPI_FAILURE(status)) {
126 return; 126 return;
127 } 127 }
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 69074be498e..c1bd02b1a05 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -59,11 +59,11 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
59 * 59 *
60 * FUNCTION: acpi_ns_evaluate 60 * FUNCTION: acpi_ns_evaluate
61 * 61 *
62 * PARAMETERS: info - Evaluation info block, contains: 62 * PARAMETERS: Info - Evaluation info block, contains:
63 * prefix_node - Prefix or Method/Object Node to execute 63 * prefix_node - Prefix or Method/Object Node to execute
64 * pathname - Name of method to execute, If NULL, the 64 * Pathname - Name of method to execute, If NULL, the
65 * Node is the object to execute 65 * Node is the object to execute
66 * parameters - List of parameters to pass to the method, 66 * Parameters - List of parameters to pass to the method,
67 * terminated by NULL. Params itself may be 67 * terminated by NULL. Params itself may be
68 * NULL if no parameters are being passed. 68 * NULL if no parameters are being passed.
69 * return_object - Where to put method's return value (if 69 * return_object - Where to put method's return value (if
@@ -71,7 +71,7 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
71 * parameter_type - Type of Parameter list 71 * parameter_type - Type of Parameter list
72 * return_object - Where to put method's return value (if 72 * return_object - Where to put method's return value (if
73 * any). If NULL, no value is returned. 73 * any). If NULL, no value is returned.
74 * flags - ACPI_IGNORE_RETURN_VALUE to delete return 74 * Flags - ACPI_IGNORE_RETURN_VALUE to delete return
75 * 75 *
76 * RETURN: Status 76 * RETURN: Status
77 * 77 *
@@ -351,7 +351,7 @@ void acpi_ns_exec_module_code_list(void)
351 * FUNCTION: acpi_ns_exec_module_code 351 * FUNCTION: acpi_ns_exec_module_code
352 * 352 *
353 * PARAMETERS: method_obj - Object container for the module-level code 353 * PARAMETERS: method_obj - Object container for the module-level code
354 * info - Info block for method evaluation 354 * Info - Info block for method evaluation
355 * 355 *
356 * RETURN: None. Exceptions during method execution are ignored, since 356 * RETURN: None. Exceptions during method execution are ignored, since
357 * we cannot abort a table load. 357 * we cannot abort a table load.
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 4328e2adfeb..fd7c6380e29 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,8 +96,8 @@ 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 NULL, &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"));
103 } 103 }
@@ -224,8 +224,8 @@ acpi_status acpi_ns_initialize_devices(void)
224 * FUNCTION: acpi_ns_init_one_object 224 * FUNCTION: acpi_ns_init_one_object
225 * 225 *
226 * PARAMETERS: obj_handle - Node 226 * PARAMETERS: obj_handle - Node
227 * level - Current nesting level 227 * Level - Current nesting level
228 * context - Points to a init info struct 228 * Context - Points to a init info struct
229 * return_value - Not used 229 * return_value - Not used
230 * 230 *
231 * RETURN: Status 231 * RETURN: Status
@@ -530,7 +530,7 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
530 * we will not run _INI, but we continue to examine the children 530 * we will not run _INI, but we continue to examine the children
531 * of this device. 531 * of this device.
532 * 532 *
533 * From the ACPI spec, description of _STA: (note - no mention 533 * From the ACPI spec, description of _STA: (Note - no mention
534 * of whether to run _INI or not on the device in question) 534 * of whether to run _INI or not on the device in question)
535 * 535 *
536 * "_STA may return bit 0 clear (not present) with bit 3 set 536 * "_STA may return bit 0 clear (not present) with bit 3 set
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index 911f99127b9..5f7dc691c18 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -63,7 +63,7 @@ static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle);
63 * FUNCTION: acpi_ns_load_table 63 * FUNCTION: acpi_ns_load_table
64 * 64 *
65 * PARAMETERS: table_index - Index for table to be loaded 65 * PARAMETERS: table_index - Index for table to be loaded
66 * node - Owning NS node 66 * Node - Owning NS node
67 * 67 *
68 * RETURN: Status 68 * RETURN: Status
69 * 69 *
@@ -80,8 +80,8 @@ acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node)
80 80
81 /* 81 /*
82 * Parse the table and load the namespace with all named 82 * Parse the table and load the namespace with all named
83 * objects found within. Control methods are NOT parsed 83 * objects found within. Control methods are NOT parsed
84 * at this time. In fact, the control methods cannot be 84 * at this time. In fact, the control methods cannot be
85 * parsed until the entire namespace is loaded, because 85 * parsed until the entire namespace is loaded, because
86 * if a control method makes a forward reference (call) 86 * if a control method makes a forward reference (call)
87 * to another control method, we can't continue parsing 87 * to another control method, we can't continue parsing
@@ -122,7 +122,7 @@ acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node)
122 } 122 }
123 123
124 /* 124 /*
125 * Now we can parse the control methods. We always parse 125 * Now we can parse the control methods. We always parse
126 * them here for a sanity check, and if configured for 126 * them here for a sanity check, and if configured for
127 * just-in-time parsing, we delete the control method 127 * just-in-time parsing, we delete the control method
128 * parse trees. 128 * parse trees.
@@ -166,7 +166,7 @@ acpi_status acpi_ns_load_namespace(void)
166 } 166 }
167 167
168 /* 168 /*
169 * Load the namespace. The DSDT is required, 169 * Load the namespace. The DSDT is required,
170 * but the SSDT and PSDT tables are optional. 170 * but the SSDT and PSDT tables are optional.
171 */ 171 */
172 status = acpi_ns_load_table_by_type(ACPI_TABLE_ID_DSDT); 172 status = acpi_ns_load_table_by_type(ACPI_TABLE_ID_DSDT);
@@ -278,12 +278,12 @@ static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle)
278 * 278 *
279 * FUNCTION: acpi_ns_unload_name_space 279 * FUNCTION: acpi_ns_unload_name_space
280 * 280 *
281 * PARAMETERS: handle - Root of namespace subtree to be deleted 281 * PARAMETERS: Handle - Root of namespace subtree to be deleted
282 * 282 *
283 * RETURN: Status 283 * RETURN: Status
284 * 284 *
285 * DESCRIPTION: Shrinks the namespace, typically in response to an undocking 285 * DESCRIPTION: Shrinks the namespace, typically in response to an undocking
286 * event. Deletes an entire subtree starting from (and 286 * event. Deletes an entire subtree starting from (and
287 * including) the given handle. 287 * including) the given handle.
288 * 288 *
289 ******************************************************************************/ 289 ******************************************************************************/
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index 55a175eadcc..d5fa520c3de 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -53,8 +53,8 @@ ACPI_MODULE_NAME("nsnames")
53 * 53 *
54 * FUNCTION: acpi_ns_build_external_path 54 * FUNCTION: acpi_ns_build_external_path
55 * 55 *
56 * PARAMETERS: node - NS node whose pathname is needed 56 * PARAMETERS: Node - NS node whose pathname is needed
57 * size - Size of the pathname 57 * Size - Size of the pathname
58 * *name_buffer - Where to return the pathname 58 * *name_buffer - Where to return the pathname
59 * 59 *
60 * RETURN: Status 60 * RETURN: Status
@@ -120,7 +120,7 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
120 * 120 *
121 * FUNCTION: acpi_ns_get_external_pathname 121 * FUNCTION: acpi_ns_get_external_pathname
122 * 122 *
123 * PARAMETERS: node - Namespace node whose pathname is needed 123 * PARAMETERS: Node - Namespace node whose pathname is needed
124 * 124 *
125 * RETURN: Pointer to storage containing the fully qualified name of 125 * RETURN: Pointer to storage containing the fully qualified name of
126 * the node, In external format (name segments separated by path 126 * the node, In external format (name segments separated by path
@@ -168,7 +168,7 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
168 * 168 *
169 * FUNCTION: acpi_ns_get_pathname_length 169 * FUNCTION: acpi_ns_get_pathname_length
170 * 170 *
171 * PARAMETERS: node - Namespace node 171 * PARAMETERS: Node - Namespace node
172 * 172 *
173 * RETURN: Length of path, including prefix 173 * RETURN: Length of path, including prefix
174 * 174 *
@@ -195,7 +195,7 @@ acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
195 ACPI_ERROR((AE_INFO, 195 ACPI_ERROR((AE_INFO,
196 "Invalid Namespace Node (%p) while traversing namespace", 196 "Invalid Namespace Node (%p) while traversing namespace",
197 next_node)); 197 next_node));
198 return (0); 198 return 0;
199 } 199 }
200 size += ACPI_PATH_SEGMENT_LENGTH; 200 size += ACPI_PATH_SEGMENT_LENGTH;
201 next_node = next_node->parent; 201 next_node = next_node->parent;
@@ -214,7 +214,7 @@ acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
214 * 214 *
215 * PARAMETERS: target_handle - Handle of named object whose name is 215 * PARAMETERS: target_handle - Handle of named object whose name is
216 * to be found 216 * to be found
217 * buffer - Where the pathname is returned 217 * Buffer - Where the pathname is returned
218 * 218 *
219 * RETURN: Status, Buffer is filled with pathname if status is AE_OK 219 * RETURN: Status, Buffer is filled with pathname if status is AE_OK
220 * 220 *
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index e69f7fa2579..3bb8bf105ea 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -53,15 +53,15 @@ ACPI_MODULE_NAME("nsobject")
53 * 53 *
54 * FUNCTION: acpi_ns_attach_object 54 * FUNCTION: acpi_ns_attach_object
55 * 55 *
56 * PARAMETERS: node - Parent Node 56 * PARAMETERS: Node - Parent Node
57 * object - Object to be attached 57 * Object - Object to be attached
58 * type - Type of object, or ACPI_TYPE_ANY if not 58 * Type - Type of object, or ACPI_TYPE_ANY if not
59 * known 59 * known
60 * 60 *
61 * RETURN: Status 61 * RETURN: Status
62 * 62 *
63 * DESCRIPTION: Record the given object as the value associated with the 63 * DESCRIPTION: Record the given object as the value associated with the
64 * name whose acpi_handle is passed. If Object is NULL 64 * name whose acpi_handle is passed. If Object is NULL
65 * and Type is ACPI_TYPE_ANY, set the name as having no value. 65 * and Type is ACPI_TYPE_ANY, set the name as having no value.
66 * Note: Future may require that the Node->Flags field be passed 66 * Note: Future may require that the Node->Flags field be passed
67 * as a parameter. 67 * as a parameter.
@@ -133,7 +133,7 @@ acpi_ns_attach_object(struct acpi_namespace_node *node,
133 ((struct acpi_namespace_node *)object)->object) { 133 ((struct acpi_namespace_node *)object)->object) {
134 /* 134 /*
135 * Value passed is a name handle and that name has a 135 * Value passed is a name handle and that name has a
136 * non-null value. Use that name's value and type. 136 * non-null value. Use that name's value and type.
137 */ 137 */
138 obj_desc = ((struct acpi_namespace_node *)object)->object; 138 obj_desc = ((struct acpi_namespace_node *)object)->object;
139 object_type = ((struct acpi_namespace_node *)object)->type; 139 object_type = ((struct acpi_namespace_node *)object)->type;
@@ -191,7 +191,7 @@ acpi_ns_attach_object(struct acpi_namespace_node *node,
191 * 191 *
192 * FUNCTION: acpi_ns_detach_object 192 * FUNCTION: acpi_ns_detach_object
193 * 193 *
194 * PARAMETERS: node - A Namespace node whose object will be detached 194 * PARAMETERS: Node - A Namespace node whose object will be detached
195 * 195 *
196 * RETURN: None. 196 * RETURN: None.
197 * 197 *
@@ -250,7 +250,7 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
250 * 250 *
251 * FUNCTION: acpi_ns_get_attached_object 251 * FUNCTION: acpi_ns_get_attached_object
252 * 252 *
253 * PARAMETERS: node - Namespace node 253 * PARAMETERS: Node - Namespace node
254 * 254 *
255 * RETURN: Current value of the object field from the Node whose 255 * RETURN: Current value of the object field from the Node whose
256 * handle is passed 256 * handle is passed
@@ -285,7 +285,7 @@ union acpi_operand_object *acpi_ns_get_attached_object(struct
285 * 285 *
286 * FUNCTION: acpi_ns_get_secondary_object 286 * FUNCTION: acpi_ns_get_secondary_object
287 * 287 *
288 * PARAMETERS: node - Namespace node 288 * PARAMETERS: Node - Namespace node
289 * 289 *
290 * RETURN: Current value of the object field from the Node whose 290 * RETURN: Current value of the object field from the Node whose
291 * handle is passed. 291 * handle is passed.
@@ -315,13 +315,13 @@ union acpi_operand_object *acpi_ns_get_secondary_object(union
315 * 315 *
316 * FUNCTION: acpi_ns_attach_data 316 * FUNCTION: acpi_ns_attach_data
317 * 317 *
318 * PARAMETERS: node - Namespace node 318 * PARAMETERS: Node - Namespace node
319 * handler - Handler to be associated with the data 319 * Handler - Handler to be associated with the data
320 * data - Data to be attached 320 * Data - Data to be attached
321 * 321 *
322 * RETURN: Status 322 * RETURN: Status
323 * 323 *
324 * DESCRIPTION: Low-level attach data. Create and attach a Data object. 324 * DESCRIPTION: Low-level attach data. Create and attach a Data object.
325 * 325 *
326 ******************************************************************************/ 326 ******************************************************************************/
327 327
@@ -372,12 +372,12 @@ acpi_ns_attach_data(struct acpi_namespace_node *node,
372 * 372 *
373 * FUNCTION: acpi_ns_detach_data 373 * FUNCTION: acpi_ns_detach_data
374 * 374 *
375 * PARAMETERS: node - Namespace node 375 * PARAMETERS: Node - Namespace node
376 * handler - Handler associated with the data 376 * Handler - Handler associated with the data
377 * 377 *
378 * RETURN: Status 378 * RETURN: Status
379 * 379 *
380 * DESCRIPTION: Low-level detach data. Delete the data node, but the caller 380 * DESCRIPTION: Low-level detach data. Delete the data node, but the caller
381 * is responsible for the actual data. 381 * is responsible for the actual data.
382 * 382 *
383 ******************************************************************************/ 383 ******************************************************************************/
@@ -416,9 +416,9 @@ acpi_ns_detach_data(struct acpi_namespace_node * node,
416 * 416 *
417 * FUNCTION: acpi_ns_get_attached_data 417 * FUNCTION: acpi_ns_get_attached_data
418 * 418 *
419 * PARAMETERS: node - Namespace node 419 * PARAMETERS: Node - Namespace node
420 * handler - Handler associated with the data 420 * Handler - Handler associated with the data
421 * data - Where the data is returned 421 * Data - Where the data is returned
422 * 422 *
423 * RETURN: Status 423 * RETURN: Status
424 * 424 *
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 233f756d5cf..b3234fa795b 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,11 +168,11 @@ acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node)
168 /* 168 /*
169 * AML Parse, pass 1 169 * AML Parse, pass 1
170 * 170 *
171 * In this pass, we load most of the namespace. Control methods 171 * In this pass, we load most of the namespace. Control methods
172 * are not parsed until later. A parse tree is not created. Instead, 172 * are not parsed until later. A parse tree is not created. Instead,
173 * each Parser Op subtree is deleted when it is finished. This saves 173 * each Parser Op subtree is deleted when it is finished. This saves
174 * a great deal of memory, and allows a small cache of parse objects 174 * a great deal of memory, and allows a small cache of parse objects
175 * to service the entire parse. The second pass of the parse then 175 * to service the entire parse. The second pass of the parse then
176 * performs another complete parse of the AML. 176 * performs another complete parse of the AML.
177 */ 177 */
178 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n")); 178 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n"));
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 2419f417ea3..c845c8089f3 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -116,7 +116,7 @@ static const char *acpi_rtype_names[] = {
116 * 116 *
117 * FUNCTION: acpi_ns_check_predefined_names 117 * FUNCTION: acpi_ns_check_predefined_names
118 * 118 *
119 * PARAMETERS: node - Namespace node for the method/object 119 * PARAMETERS: Node - Namespace node for the method/object
120 * user_param_count - Number of parameters actually passed 120 * user_param_count - Number of parameters actually passed
121 * return_status - Status from the object evaluation 121 * return_status - Status from the object evaluation
122 * return_object_ptr - Pointer to the object returned from the 122 * return_object_ptr - Pointer to the object returned from the
@@ -275,10 +275,10 @@ cleanup:
275 * 275 *
276 * FUNCTION: acpi_ns_check_parameter_count 276 * FUNCTION: acpi_ns_check_parameter_count
277 * 277 *
278 * PARAMETERS: pathname - Full pathname to the node (for error msgs) 278 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
279 * node - Namespace node for the method/object 279 * Node - Namespace node for the method/object
280 * user_param_count - Number of args passed in by the caller 280 * user_param_count - Number of args passed in by the caller
281 * predefined - Pointer to entry in predefined name table 281 * Predefined - Pointer to entry in predefined name table
282 * 282 *
283 * RETURN: None 283 * RETURN: None
284 * 284 *
@@ -364,7 +364,7 @@ acpi_ns_check_parameter_count(char *pathname,
364 * 364 *
365 * FUNCTION: acpi_ns_check_for_predefined_name 365 * FUNCTION: acpi_ns_check_for_predefined_name
366 * 366 *
367 * PARAMETERS: node - Namespace node for the method/object 367 * PARAMETERS: Node - Namespace node for the method/object
368 * 368 *
369 * RETURN: Pointer to entry in predefined table. NULL indicates not found. 369 * RETURN: Pointer to entry in predefined table. NULL indicates not found.
370 * 370 *
@@ -410,7 +410,7 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
410 * 410 *
411 * FUNCTION: acpi_ns_check_package 411 * FUNCTION: acpi_ns_check_package
412 * 412 *
413 * PARAMETERS: data - Pointer to validation data structure 413 * PARAMETERS: Data - Pointer to validation data structure
414 * return_object_ptr - Pointer to the object returned from the 414 * return_object_ptr - Pointer to the object returned from the
415 * evaluation of a method or object 415 * evaluation of a method or object
416 * 416 *
@@ -620,7 +620,6 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
620 case ACPI_PTYPE2_FIXED: 620 case ACPI_PTYPE2_FIXED:
621 case ACPI_PTYPE2_MIN: 621 case ACPI_PTYPE2_MIN:
622 case ACPI_PTYPE2_COUNT: 622 case ACPI_PTYPE2_COUNT:
623 case ACPI_PTYPE2_FIX_VAR:
624 623
625 /* 624 /*
626 * These types all return a single Package that consists of a 625 * These types all return a single Package that consists of a
@@ -638,8 +637,8 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
638 /* Create the new outer package and populate it */ 637 /* Create the new outer package and populate it */
639 638
640 status = 639 status =
641 acpi_ns_wrap_with_package(data, return_object, 640 acpi_ns_repair_package_list(data,
642 return_object_ptr); 641 return_object_ptr);
643 if (ACPI_FAILURE(status)) { 642 if (ACPI_FAILURE(status)) {
644 return (status); 643 return (status);
645 } 644 }
@@ -685,11 +684,11 @@ package_too_small:
685 * 684 *
686 * FUNCTION: acpi_ns_check_package_list 685 * FUNCTION: acpi_ns_check_package_list
687 * 686 *
688 * PARAMETERS: data - Pointer to validation data structure 687 * PARAMETERS: Data - Pointer to validation data structure
689 * package - Pointer to package-specific info for method 688 * Package - Pointer to package-specific info for method
690 * elements - Element list of parent package. All elements 689 * Elements - Element list of parent package. All elements
691 * of this list should be of type Package. 690 * of this list should be of type Package.
692 * count - Count of subpackages 691 * Count - Count of subpackages
693 * 692 *
694 * RETURN: Status 693 * RETURN: Status
695 * 694 *
@@ -760,34 +759,6 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
760 } 759 }
761 break; 760 break;
762 761
763 case ACPI_PTYPE2_FIX_VAR:
764 /*
765 * Each subpackage has a fixed number of elements and an
766 * optional element
767 */
768 expected_count =
769 package->ret_info.count1 + package->ret_info.count2;
770 if (sub_package->package.count < expected_count) {
771 goto package_too_small;
772 }
773
774 status =
775 acpi_ns_check_package_elements(data, sub_elements,
776 package->ret_info.
777 object_type1,
778 package->ret_info.
779 count1,
780 package->ret_info.
781 object_type2,
782 sub_package->package.
783 count -
784 package->ret_info.
785 count1, 0);
786 if (ACPI_FAILURE(status)) {
787 return (status);
788 }
789 break;
790
791 case ACPI_PTYPE2_FIXED: 762 case ACPI_PTYPE2_FIXED:
792 763
793 /* Each sub-package has a fixed length */ 764 /* Each sub-package has a fixed length */
@@ -911,12 +882,12 @@ package_too_small:
911 * 882 *
912 * FUNCTION: acpi_ns_check_package_elements 883 * FUNCTION: acpi_ns_check_package_elements
913 * 884 *
914 * PARAMETERS: data - Pointer to validation data structure 885 * PARAMETERS: Data - Pointer to validation data structure
915 * elements - Pointer to the package elements array 886 * Elements - Pointer to the package elements array
916 * type1 - Object type for first group 887 * Type1 - Object type for first group
917 * count1 - Count for first group 888 * Count1 - Count for first group
918 * type2 - Object type for second group 889 * Type2 - Object type for second group
919 * count2 - Count for second group 890 * Count2 - Count for second group
920 * start_index - Start of the first group of elements 891 * start_index - Start of the first group of elements
921 * 892 *
922 * RETURN: Status 893 * RETURN: Status
@@ -968,7 +939,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data,
968 * 939 *
969 * FUNCTION: acpi_ns_check_object_type 940 * FUNCTION: acpi_ns_check_object_type
970 * 941 *
971 * PARAMETERS: data - Pointer to validation data structure 942 * PARAMETERS: Data - Pointer to validation data structure
972 * return_object_ptr - Pointer to the object returned from the 943 * return_object_ptr - Pointer to the object returned from the
973 * evaluation of a method or object 944 * evaluation of a method or object
974 * expected_btypes - Bitmap of expected return type(s) 945 * expected_btypes - Bitmap of expected return type(s)
@@ -1102,7 +1073,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
1102 * 1073 *
1103 * FUNCTION: acpi_ns_check_reference 1074 * FUNCTION: acpi_ns_check_reference
1104 * 1075 *
1105 * PARAMETERS: data - Pointer to validation data structure 1076 * PARAMETERS: Data - Pointer to validation data structure
1106 * return_object - Object returned from the evaluation of a 1077 * return_object - Object returned from the evaluation of a
1107 * method or object 1078 * method or object
1108 * 1079 *
@@ -1140,7 +1111,7 @@ acpi_ns_check_reference(struct acpi_predefined_data *data,
1140 * 1111 *
1141 * FUNCTION: acpi_ns_get_expected_types 1112 * FUNCTION: acpi_ns_get_expected_types
1142 * 1113 *
1143 * PARAMETERS: buffer - Pointer to where the string is returned 1114 * PARAMETERS: Buffer - Pointer to where the string is returned
1144 * expected_btypes - Bitmap of expected return type(s) 1115 * expected_btypes - Bitmap of expected return type(s)
1145 * 1116 *
1146 * RETURN: Buffer is populated with type names. 1117 * RETURN: Buffer is populated with type names.
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index 8c5f292860f..ac7b854b0bd 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -71,10 +71,11 @@ ACPI_MODULE_NAME("nsrepair")
71 * Buffer -> String 71 * Buffer -> String
72 * Buffer -> Package of Integers 72 * Buffer -> Package of Integers
73 * Package -> Package of one Package 73 * Package -> Package of one Package
74 * An incorrect standalone object is wrapped with required outer package
75 * 74 *
76 * Additional possible repairs: 75 * Additional possible repairs:
76 *
77 * Required package elements that are NULL replaced by Integer/String/Buffer 77 * Required package elements that are NULL replaced by Integer/String/Buffer
78 * Incorrect standalone package wrapped with required outer package
78 * 79 *
79 ******************************************************************************/ 80 ******************************************************************************/
80/* Local prototypes */ 81/* Local prototypes */
@@ -90,11 +91,15 @@ static acpi_status
90acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, 91acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
91 union acpi_operand_object **return_object); 92 union acpi_operand_object **return_object);
92 93
94static acpi_status
95acpi_ns_convert_to_package(union acpi_operand_object *original_object,
96 union acpi_operand_object **return_object);
97
93/******************************************************************************* 98/*******************************************************************************
94 * 99 *
95 * FUNCTION: acpi_ns_repair_object 100 * FUNCTION: acpi_ns_repair_object
96 * 101 *
97 * PARAMETERS: data - Pointer to validation data structure 102 * PARAMETERS: Data - Pointer to validation data structure
98 * expected_btypes - Object types expected 103 * expected_btypes - Object types expected
99 * package_index - Index of object within parent package (if 104 * package_index - Index of object within parent package (if
100 * applicable - ACPI_NOT_PACKAGE_ELEMENT 105 * applicable - ACPI_NOT_PACKAGE_ELEMENT
@@ -146,24 +151,9 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
146 } 151 }
147 } 152 }
148 if (expected_btypes & ACPI_RTYPE_PACKAGE) { 153 if (expected_btypes & ACPI_RTYPE_PACKAGE) {
149 /* 154 status = acpi_ns_convert_to_package(return_object, &new_object);
150 * A package is expected. We will wrap the existing object with a
151 * new package object. It is often the case that if a variable-length
152 * package is required, but there is only a single object needed, the
153 * BIOS will return that object instead of wrapping it with a Package
154 * object. Note: after the wrapping, the package will be validated
155 * for correct contents (expected object type or types).
156 */
157 status =
158 acpi_ns_wrap_with_package(data, return_object, &new_object);
159 if (ACPI_SUCCESS(status)) { 155 if (ACPI_SUCCESS(status)) {
160 /* 156 goto object_repaired;
161 * The original object just had its reference count
162 * incremented for being inserted into the new package.
163 */
164 *return_object_ptr = new_object; /* New Package object */
165 data->flags |= ACPI_OBJECT_REPAIRED;
166 return (AE_OK);
167 } 157 }
168 } 158 }
169 159
@@ -175,27 +165,22 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
175 165
176 /* Object was successfully repaired */ 166 /* Object was successfully repaired */
177 167
168 /*
169 * If the original object is a package element, we need to:
170 * 1. Set the reference count of the new object to match the
171 * reference count of the old object.
172 * 2. Decrement the reference count of the original object.
173 */
178 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { 174 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
179 /* 175 new_object->common.reference_count =
180 * The original object is a package element. We need to 176 return_object->common.reference_count;
181 * decrement the reference count of the original object,
182 * for removing it from the package.
183 *
184 * However, if the original object was just wrapped with a
185 * package object as part of the repair, we don't need to
186 * change the reference count.
187 */
188 if (!(data->flags & ACPI_OBJECT_WRAPPED)) {
189 new_object->common.reference_count =
190 return_object->common.reference_count;
191 177
192 if (return_object->common.reference_count > 1) { 178 if (return_object->common.reference_count > 1) {
193 return_object->common.reference_count--; 179 return_object->common.reference_count--;
194 }
195 } 180 }
196 181
197 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 182 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
198 "%s: Converted %s to expected %s at Package index %u\n", 183 "%s: Converted %s to expected %s at index %u\n",
199 data->pathname, 184 data->pathname,
200 acpi_ut_get_object_type_name(return_object), 185 acpi_ut_get_object_type_name(return_object),
201 acpi_ut_get_object_type_name(new_object), 186 acpi_ut_get_object_type_name(new_object),
@@ -468,9 +453,68 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
468 453
469/******************************************************************************* 454/*******************************************************************************
470 * 455 *
456 * FUNCTION: acpi_ns_convert_to_package
457 *
458 * PARAMETERS: original_object - Object to be converted
459 * return_object - Where the new converted object is returned
460 *
461 * RETURN: Status. AE_OK if conversion was successful.
462 *
463 * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of
464 * the buffer is converted to a single integer package element.
465 *
466 ******************************************************************************/
467
468static acpi_status
469acpi_ns_convert_to_package(union acpi_operand_object *original_object,
470 union acpi_operand_object **return_object)
471{
472 union acpi_operand_object *new_object;
473 union acpi_operand_object **elements;
474 u32 length;
475 u8 *buffer;
476
477 switch (original_object->common.type) {
478 case ACPI_TYPE_BUFFER:
479
480 /* Buffer-to-Package conversion */
481
482 length = original_object->buffer.length;
483 new_object = acpi_ut_create_package_object(length);
484 if (!new_object) {
485 return (AE_NO_MEMORY);
486 }
487
488 /* Convert each buffer byte to an integer package element */
489
490 elements = new_object->package.elements;
491 buffer = original_object->buffer.pointer;
492
493 while (length--) {
494 *elements =
495 acpi_ut_create_integer_object((u64) *buffer);
496 if (!*elements) {
497 acpi_ut_remove_reference(new_object);
498 return (AE_NO_MEMORY);
499 }
500 elements++;
501 buffer++;
502 }
503 break;
504
505 default:
506 return (AE_AML_OPERAND_TYPE);
507 }
508
509 *return_object = new_object;
510 return (AE_OK);
511}
512
513/*******************************************************************************
514 *
471 * FUNCTION: acpi_ns_repair_null_element 515 * FUNCTION: acpi_ns_repair_null_element
472 * 516 *
473 * PARAMETERS: data - Pointer to validation data structure 517 * PARAMETERS: Data - Pointer to validation data structure
474 * expected_btypes - Object types expected 518 * expected_btypes - Object types expected
475 * package_index - Index of object within parent package (if 519 * package_index - Index of object within parent package (if
476 * applicable - ACPI_NOT_PACKAGE_ELEMENT 520 * applicable - ACPI_NOT_PACKAGE_ELEMENT
@@ -509,17 +553,17 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data,
509 */ 553 */
510 if (expected_btypes & ACPI_RTYPE_INTEGER) { 554 if (expected_btypes & ACPI_RTYPE_INTEGER) {
511 555
512 /* Need an integer - create a zero-value integer */ 556 /* Need an Integer - create a zero-value integer */
513 557
514 new_object = acpi_ut_create_integer_object((u64)0); 558 new_object = acpi_ut_create_integer_object((u64)0);
515 } else if (expected_btypes & ACPI_RTYPE_STRING) { 559 } else if (expected_btypes & ACPI_RTYPE_STRING) {
516 560
517 /* Need a string - create a NULL string */ 561 /* Need a String - create a NULL string */
518 562
519 new_object = acpi_ut_create_string_object(0); 563 new_object = acpi_ut_create_string_object(0);
520 } else if (expected_btypes & ACPI_RTYPE_BUFFER) { 564 } else if (expected_btypes & ACPI_RTYPE_BUFFER) {
521 565
522 /* Need a buffer - create a zero-length buffer */ 566 /* Need a Buffer - create a zero-length buffer */
523 567
524 new_object = acpi_ut_create_buffer_object(0); 568 new_object = acpi_ut_create_buffer_object(0);
525 } else { 569 } else {
@@ -552,7 +596,7 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data,
552 * 596 *
553 * FUNCTION: acpi_ns_remove_null_elements 597 * FUNCTION: acpi_ns_remove_null_elements
554 * 598 *
555 * PARAMETERS: data - Pointer to validation data structure 599 * PARAMETERS: Data - Pointer to validation data structure
556 * package_type - An acpi_return_package_types value 600 * package_type - An acpi_return_package_types value
557 * obj_desc - A Package object 601 * obj_desc - A Package object
558 * 602 *
@@ -590,7 +634,6 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
590 case ACPI_PTYPE2_FIXED: 634 case ACPI_PTYPE2_FIXED:
591 case ACPI_PTYPE2_MIN: 635 case ACPI_PTYPE2_MIN:
592 case ACPI_PTYPE2_REV_FIXED: 636 case ACPI_PTYPE2_REV_FIXED:
593 case ACPI_PTYPE2_FIX_VAR:
594 break; 637 break;
595 638
596 default: 639 default:
@@ -633,56 +676,55 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
633 676
634/******************************************************************************* 677/*******************************************************************************
635 * 678 *
636 * FUNCTION: acpi_ns_wrap_with_package 679 * FUNCTION: acpi_ns_repair_package_list
637 * 680 *
638 * PARAMETERS: data - Pointer to validation data structure 681 * PARAMETERS: Data - Pointer to validation data structure
639 * original_object - Pointer to the object to repair. 682 * obj_desc_ptr - Pointer to the object to repair. The new
640 * obj_desc_ptr - The new package object is returned here 683 * package object is returned here,
684 * overwriting the old object.
641 * 685 *
642 * RETURN: Status, new object in *obj_desc_ptr 686 * RETURN: Status, new object in *obj_desc_ptr
643 * 687 *
644 * DESCRIPTION: Repair a common problem with objects that are defined to 688 * DESCRIPTION: Repair a common problem with objects that are defined to return
645 * return a variable-length Package of sub-objects. If there is 689 * a variable-length Package of Packages. If the variable-length
646 * only one sub-object, some BIOS code mistakenly simply declares 690 * is one, some BIOS code mistakenly simply declares a single
647 * the single object instead of a Package with one sub-object. 691 * Package instead of a Package with one sub-Package. This
648 * This function attempts to repair this error by wrapping a 692 * function attempts to repair this error by wrapping a Package
649 * Package object around the original object, creating the 693 * object around the original Package, creating the correct
650 * correct and expected Package with one sub-object. 694 * Package with one sub-Package.
651 * 695 *
652 * Names that can be repaired in this manner include: 696 * Names that can be repaired in this manner include:
653 * _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS, 697 * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS
654 * _BCL, _DOD, _FIX, _Sx
655 * 698 *
656 ******************************************************************************/ 699 ******************************************************************************/
657 700
658acpi_status 701acpi_status
659acpi_ns_wrap_with_package(struct acpi_predefined_data *data, 702acpi_ns_repair_package_list(struct acpi_predefined_data *data,
660 union acpi_operand_object *original_object, 703 union acpi_operand_object **obj_desc_ptr)
661 union acpi_operand_object **obj_desc_ptr)
662{ 704{
663 union acpi_operand_object *pkg_obj_desc; 705 union acpi_operand_object *pkg_obj_desc;
664 706
665 ACPI_FUNCTION_NAME(ns_wrap_with_package); 707 ACPI_FUNCTION_NAME(ns_repair_package_list);
666 708
667 /* 709 /*
668 * Create the new outer package and populate it. The new package will 710 * Create the new outer package and populate it. The new package will
669 * have a single element, the lone sub-object. 711 * have a single element, the lone subpackage.
670 */ 712 */
671 pkg_obj_desc = acpi_ut_create_package_object(1); 713 pkg_obj_desc = acpi_ut_create_package_object(1);
672 if (!pkg_obj_desc) { 714 if (!pkg_obj_desc) {
673 return (AE_NO_MEMORY); 715 return (AE_NO_MEMORY);
674 } 716 }
675 717
676 pkg_obj_desc->package.elements[0] = original_object; 718 pkg_obj_desc->package.elements[0] = *obj_desc_ptr;
677
678 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
679 "%s: Wrapped %s with expected Package object\n",
680 data->pathname,
681 acpi_ut_get_object_type_name(original_object)));
682 719
683 /* Return the new object in the object pointer */ 720 /* Return the new object in the object pointer */
684 721
685 *obj_desc_ptr = pkg_obj_desc; 722 *obj_desc_ptr = pkg_obj_desc;
686 data->flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED; 723 data->flags |= ACPI_OBJECT_REPAIRED;
724
725 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
726 "%s: Repaired incorrectly formed Package\n",
727 data->pathname));
728
687 return (AE_OK); 729 return (AE_OK);
688} 730}
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 90189251cdf..024c4f263f8 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -149,8 +149,8 @@ static const struct acpi_repair_info acpi_ns_repairable_names[] = {
149 * 149 *
150 * FUNCTION: acpi_ns_complex_repairs 150 * FUNCTION: acpi_ns_complex_repairs
151 * 151 *
152 * PARAMETERS: data - Pointer to validation data structure 152 * PARAMETERS: Data - Pointer to validation data structure
153 * node - Namespace node for the method/object 153 * Node - Namespace node for the method/object
154 * validate_status - Original status of earlier validation 154 * validate_status - Original status of earlier validation
155 * return_object_ptr - Pointer to the object returned from the 155 * return_object_ptr - Pointer to the object returned from the
156 * evaluation of a method or object 156 * evaluation of a method or object
@@ -187,7 +187,7 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
187 * 187 *
188 * FUNCTION: acpi_ns_match_repairable_name 188 * FUNCTION: acpi_ns_match_repairable_name
189 * 189 *
190 * PARAMETERS: node - Namespace node for the method/object 190 * PARAMETERS: Node - Namespace node for the method/object
191 * 191 *
192 * RETURN: Pointer to entry in repair table. NULL indicates not found. 192 * RETURN: Pointer to entry in repair table. NULL indicates not found.
193 * 193 *
@@ -218,7 +218,7 @@ static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct
218 * 218 *
219 * FUNCTION: acpi_ns_repair_ALR 219 * FUNCTION: acpi_ns_repair_ALR
220 * 220 *
221 * PARAMETERS: data - Pointer to validation data structure 221 * PARAMETERS: Data - Pointer to validation data structure
222 * return_object_ptr - Pointer to the object returned from the 222 * return_object_ptr - Pointer to the object returned from the
223 * evaluation of a method or object 223 * evaluation of a method or object
224 * 224 *
@@ -247,7 +247,7 @@ acpi_ns_repair_ALR(struct acpi_predefined_data *data,
247 * 247 *
248 * FUNCTION: acpi_ns_repair_FDE 248 * FUNCTION: acpi_ns_repair_FDE
249 * 249 *
250 * PARAMETERS: data - Pointer to validation data structure 250 * PARAMETERS: Data - Pointer to validation data structure
251 * return_object_ptr - Pointer to the object returned from the 251 * return_object_ptr - Pointer to the object returned from the
252 * evaluation of a method or object 252 * evaluation of a method or object
253 * 253 *
@@ -335,7 +335,7 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data,
335 * 335 *
336 * FUNCTION: acpi_ns_repair_CID 336 * FUNCTION: acpi_ns_repair_CID
337 * 337 *
338 * PARAMETERS: data - Pointer to validation data structure 338 * PARAMETERS: Data - Pointer to validation data structure
339 * return_object_ptr - Pointer to the object returned from the 339 * return_object_ptr - Pointer to the object returned from the
340 * evaluation of a method or object 340 * evaluation of a method or object
341 * 341 *
@@ -405,7 +405,7 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data,
405 * 405 *
406 * FUNCTION: acpi_ns_repair_HID 406 * FUNCTION: acpi_ns_repair_HID
407 * 407 *
408 * PARAMETERS: data - Pointer to validation data structure 408 * PARAMETERS: Data - Pointer to validation data structure
409 * return_object_ptr - Pointer to the object returned from the 409 * return_object_ptr - Pointer to the object returned from the
410 * evaluation of a method or object 410 * evaluation of a method or object
411 * 411 *
@@ -467,12 +467,11 @@ acpi_ns_repair_HID(struct acpi_predefined_data *data,
467 } 467 }
468 468
469 /* 469 /*
470 * Copy and uppercase the string. From the ACPI 5.0 specification: 470 * Copy and uppercase the string. From the ACPI specification:
471 * 471 *
472 * A valid PNP ID must be of the form "AAA####" where A is an uppercase 472 * A valid PNP ID must be of the form "AAA####" where A is an uppercase
473 * letter and # is a hex digit. A valid ACPI ID must be of the form 473 * letter and # is a hex digit. A valid ACPI ID must be of the form
474 * "NNNN####" where N is an uppercase letter or decimal digit, and 474 * "ACPI####" where # is a hex digit.
475 * # is a hex digit.
476 */ 475 */
477 for (dest = new_string->string.pointer; *source; dest++, source++) { 476 for (dest = new_string->string.pointer; *source; dest++, source++) {
478 *dest = (char)ACPI_TOUPPER(*source); 477 *dest = (char)ACPI_TOUPPER(*source);
@@ -487,7 +486,7 @@ acpi_ns_repair_HID(struct acpi_predefined_data *data,
487 * 486 *
488 * FUNCTION: acpi_ns_repair_TSS 487 * FUNCTION: acpi_ns_repair_TSS
489 * 488 *
490 * PARAMETERS: data - Pointer to validation data structure 489 * PARAMETERS: Data - Pointer to validation data structure
491 * return_object_ptr - Pointer to the object returned from the 490 * return_object_ptr - Pointer to the object returned from the
492 * evaluation of a method or object 491 * evaluation of a method or object
493 * 492 *
@@ -531,7 +530,7 @@ acpi_ns_repair_TSS(struct acpi_predefined_data *data,
531 * 530 *
532 * FUNCTION: acpi_ns_repair_PSS 531 * FUNCTION: acpi_ns_repair_PSS
533 * 532 *
534 * PARAMETERS: data - Pointer to validation data structure 533 * PARAMETERS: Data - Pointer to validation data structure
535 * return_object_ptr - Pointer to the object returned from the 534 * return_object_ptr - Pointer to the object returned from the
536 * evaluation of a method or object 535 * evaluation of a method or object
537 * 536 *
@@ -600,7 +599,7 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data,
600 * 599 *
601 * FUNCTION: acpi_ns_check_sorted_list 600 * FUNCTION: acpi_ns_check_sorted_list
602 * 601 *
603 * PARAMETERS: data - Pointer to validation data structure 602 * PARAMETERS: Data - Pointer to validation data structure
604 * return_object - Pointer to the top-level returned object 603 * return_object - Pointer to the top-level returned object
605 * expected_count - Minimum length of each sub-package 604 * expected_count - Minimum length of each sub-package
606 * sort_index - Sub-package entry to sort on 605 * sort_index - Sub-package entry to sort on
@@ -707,9 +706,9 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
707 * 706 *
708 * FUNCTION: acpi_ns_sort_list 707 * FUNCTION: acpi_ns_sort_list
709 * 708 *
710 * PARAMETERS: elements - Package object element list 709 * PARAMETERS: Elements - Package object element list
711 * count - Element count for above 710 * Count - Element count for above
712 * index - Sort by which package element 711 * Index - Sort by which package element
713 * sort_direction - Ascending or Descending sort 712 * sort_direction - Ascending or Descending sort
714 * 713 *
715 * RETURN: None 714 * RETURN: None
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index 1d2d8ffc1bc..28b0d7a62b9 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -65,7 +65,7 @@ acpi_ns_search_parent_tree(u32 target_name,
65 * 65 *
66 * PARAMETERS: target_name - Ascii ACPI name to search for 66 * PARAMETERS: target_name - Ascii ACPI name to search for
67 * parent_node - Starting node where search will begin 67 * parent_node - Starting node where search will begin
68 * type - Object type to match 68 * Type - Object type to match
69 * return_node - Where the matched Named obj is returned 69 * return_node - Where the matched Named obj is returned
70 * 70 *
71 * RETURN: Status 71 * RETURN: Status
@@ -175,8 +175,8 @@ acpi_ns_search_one_scope(u32 target_name,
175 * FUNCTION: acpi_ns_search_parent_tree 175 * FUNCTION: acpi_ns_search_parent_tree
176 * 176 *
177 * PARAMETERS: target_name - Ascii ACPI name to search for 177 * PARAMETERS: target_name - Ascii ACPI name to search for
178 * node - Starting node where search will begin 178 * Node - Starting node where search will begin
179 * type - Object type to match 179 * Type - Object type to match
180 * return_node - Where the matched Node is returned 180 * return_node - Where the matched Node is returned
181 * 181 *
182 * RETURN: Status 182 * RETURN: Status
@@ -264,11 +264,11 @@ acpi_ns_search_parent_tree(u32 target_name,
264 * 264 *
265 * PARAMETERS: target_name - Ascii ACPI name to search for (4 chars) 265 * PARAMETERS: target_name - Ascii ACPI name to search for (4 chars)
266 * walk_state - Current state of the walk 266 * walk_state - Current state of the walk
267 * node - Starting node where search will begin 267 * Node - Starting node where search will begin
268 * interpreter_mode - Add names only in ACPI_MODE_LOAD_PASS_x. 268 * interpreter_mode - Add names only in ACPI_MODE_LOAD_PASS_x.
269 * Otherwise,search only. 269 * Otherwise,search only.
270 * type - Object type to match 270 * Type - Object type to match
271 * flags - Flags describing the search restrictions 271 * Flags - Flags describing the search restrictions
272 * return_node - Where the Node is returned 272 * return_node - Where the Node is returned
273 * 273 *
274 * RETURN: Status 274 * RETURN: Status
@@ -314,7 +314,22 @@ acpi_ns_search_and_enter(u32 target_name,
314 * this problem, and we want to be able to enable ACPI support for them, 314 * this problem, and we want to be able to enable ACPI support for them,
315 * even though there are a few bad names. 315 * even though there are a few bad names.
316 */ 316 */
317 acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name)); 317 if (!acpi_ut_valid_acpi_name(target_name)) {
318 target_name =
319 acpi_ut_repair_name(ACPI_CAST_PTR(char, &target_name));
320
321 /* Report warning only if in strict mode or debug mode */
322
323 if (!acpi_gbl_enable_interpreter_slack) {
324 ACPI_WARNING((AE_INFO,
325 "Found bad character(s) in name, repaired: [%4.4s]\n",
326 ACPI_CAST_PTR(char, &target_name)));
327 } else {
328 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
329 "Found bad character(s) in name, repaired: [%4.4s]\n",
330 ACPI_CAST_PTR(char, &target_name)));
331 }
332 }
318 333
319 /* Try to find the name in the namespace level specified by the caller */ 334 /* Try to find the name in the namespace level specified by the caller */
320 335
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index b5b4cb72a8a..cb1b104a69a 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -62,8 +62,8 @@ acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
62 * 62 *
63 * FUNCTION: acpi_ns_print_node_pathname 63 * FUNCTION: acpi_ns_print_node_pathname
64 * 64 *
65 * PARAMETERS: node - Object 65 * PARAMETERS: Node - Object
66 * message - Prefix message 66 * Message - Prefix message
67 * 67 *
68 * DESCRIPTION: Print an object's full namespace pathname 68 * DESCRIPTION: Print an object's full namespace pathname
69 * Manages allocation/freeing of a pathname buffer 69 * Manages allocation/freeing of a pathname buffer
@@ -101,7 +101,7 @@ acpi_ns_print_node_pathname(struct acpi_namespace_node *node,
101 * 101 *
102 * FUNCTION: acpi_ns_valid_root_prefix 102 * FUNCTION: acpi_ns_valid_root_prefix
103 * 103 *
104 * PARAMETERS: prefix - Character to be checked 104 * PARAMETERS: Prefix - Character to be checked
105 * 105 *
106 * RETURN: TRUE if a valid prefix 106 * RETURN: TRUE if a valid prefix
107 * 107 *
@@ -119,7 +119,7 @@ u8 acpi_ns_valid_root_prefix(char prefix)
119 * 119 *
120 * FUNCTION: acpi_ns_valid_path_separator 120 * FUNCTION: acpi_ns_valid_path_separator
121 * 121 *
122 * PARAMETERS: sep - Character to be checked 122 * PARAMETERS: Sep - Character to be checked
123 * 123 *
124 * RETURN: TRUE if a valid path separator 124 * RETURN: TRUE if a valid path separator
125 * 125 *
@@ -137,7 +137,7 @@ static u8 acpi_ns_valid_path_separator(char sep)
137 * 137 *
138 * FUNCTION: acpi_ns_get_type 138 * FUNCTION: acpi_ns_get_type
139 * 139 *
140 * PARAMETERS: node - Parent Node to be examined 140 * PARAMETERS: Node - Parent Node to be examined
141 * 141 *
142 * RETURN: Type field from Node whose handle is passed 142 * RETURN: Type field from Node whose handle is passed
143 * 143 *
@@ -161,7 +161,7 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
161 * 161 *
162 * FUNCTION: acpi_ns_local 162 * FUNCTION: acpi_ns_local
163 * 163 *
164 * PARAMETERS: type - A namespace object type 164 * PARAMETERS: Type - A namespace object type
165 * 165 *
166 * RETURN: LOCAL if names must be found locally in objects of the 166 * RETURN: LOCAL if names must be found locally in objects of the
167 * passed type, 0 if enclosing scopes should be searched 167 * passed type, 0 if enclosing scopes should be searched
@@ -189,7 +189,7 @@ u32 acpi_ns_local(acpi_object_type type)
189 * 189 *
190 * FUNCTION: acpi_ns_get_internal_name_length 190 * FUNCTION: acpi_ns_get_internal_name_length
191 * 191 *
192 * PARAMETERS: info - Info struct initialized with the 192 * PARAMETERS: Info - Info struct initialized with the
193 * external name pointer. 193 * external name pointer.
194 * 194 *
195 * RETURN: None 195 * RETURN: None
@@ -260,7 +260,7 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
260 * 260 *
261 * FUNCTION: acpi_ns_build_internal_name 261 * FUNCTION: acpi_ns_build_internal_name
262 * 262 *
263 * PARAMETERS: info - Info struct fully initialized 263 * PARAMETERS: Info - Info struct fully initialized
264 * 264 *
265 * RETURN: Status 265 * RETURN: Status
266 * 266 *
@@ -341,7 +341,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
341 341
342 if (!acpi_ns_valid_path_separator(*external_name) && 342 if (!acpi_ns_valid_path_separator(*external_name) &&
343 (*external_name != 0)) { 343 (*external_name != 0)) {
344 return_ACPI_STATUS(AE_BAD_PATHNAME); 344 return_ACPI_STATUS(AE_BAD_PARAMETER);
345 } 345 }
346 346
347 /* Move on the next segment */ 347 /* Move on the next segment */
@@ -371,7 +371,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
371 * FUNCTION: acpi_ns_internalize_name 371 * FUNCTION: acpi_ns_internalize_name
372 * 372 *
373 * PARAMETERS: *external_name - External representation of name 373 * PARAMETERS: *external_name - External representation of name
374 * **Converted name - Where to return the resulting 374 * **Converted Name - Where to return the resulting
375 * internal represention of the name 375 * internal represention of the name
376 * 376 *
377 * RETURN: Status 377 * RETURN: Status
@@ -530,7 +530,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
530 ((num_segments > 0) ? (num_segments - 1) : 0) + 1; 530 ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
531 531
532 /* 532 /*
533 * Check to see if we're still in bounds. If not, there's a problem 533 * Check to see if we're still in bounds. If not, there's a problem
534 * with internal_name (invalid format). 534 * with internal_name (invalid format).
535 */ 535 */
536 if (required_length > internal_name_length) { 536 if (required_length > internal_name_length) {
@@ -557,14 +557,10 @@ acpi_ns_externalize_name(u32 internal_name_length,
557 (*converted_name)[j++] = '.'; 557 (*converted_name)[j++] = '.';
558 } 558 }
559 559
560 /* Copy and validate the 4-char name segment */ 560 (*converted_name)[j++] = internal_name[names_index++];
561 561 (*converted_name)[j++] = internal_name[names_index++];
562 ACPI_MOVE_NAME(&(*converted_name)[j], 562 (*converted_name)[j++] = internal_name[names_index++];
563 &internal_name[names_index]); 563 (*converted_name)[j++] = internal_name[names_index++];
564 acpi_ut_repair_name(&(*converted_name)[j]);
565
566 j += ACPI_NAME_SIZE;
567 names_index += ACPI_NAME_SIZE;
568 } 564 }
569 } 565 }
570 566
@@ -579,7 +575,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
579 * 575 *
580 * FUNCTION: acpi_ns_validate_handle 576 * FUNCTION: acpi_ns_validate_handle
581 * 577 *
582 * PARAMETERS: handle - Handle to be validated and typecast to a 578 * PARAMETERS: Handle - Handle to be validated and typecast to a
583 * namespace node. 579 * namespace node.
584 * 580 *
585 * RETURN: A pointer to a namespace node 581 * RETURN: A pointer to a namespace node
@@ -655,7 +651,7 @@ void acpi_ns_terminate(void)
655 * 651 *
656 * FUNCTION: acpi_ns_opens_scope 652 * FUNCTION: acpi_ns_opens_scope
657 * 653 *
658 * PARAMETERS: type - A valid namespace type 654 * PARAMETERS: Type - A valid namespace type
659 * 655 *
660 * RETURN: NEWSCOPE if the passed type "opens a name scope" according 656 * RETURN: NEWSCOPE if the passed type "opens a name scope" according
661 * to the ACPI specification, else 0 657 * to the ACPI specification, else 0
@@ -681,19 +677,19 @@ u32 acpi_ns_opens_scope(acpi_object_type type)
681 * 677 *
682 * FUNCTION: acpi_ns_get_node 678 * FUNCTION: acpi_ns_get_node
683 * 679 *
684 * PARAMETERS: *pathname - Name to be found, in external (ASL) format. The 680 * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
685 * \ (backslash) and ^ (carat) prefixes, and the 681 * \ (backslash) and ^ (carat) prefixes, and the
686 * . (period) to separate segments are supported. 682 * . (period) to separate segments are supported.
687 * prefix_node - Root of subtree to be searched, or NS_ALL for the 683 * prefix_node - Root of subtree to be searched, or NS_ALL for the
688 * root of the name space. If Name is fully 684 * root of the name space. If Name is fully
689 * qualified (first s8 is '\'), the passed value 685 * qualified (first s8 is '\'), the passed value
690 * of Scope will not be accessed. 686 * of Scope will not be accessed.
691 * flags - Used to indicate whether to perform upsearch or 687 * Flags - Used to indicate whether to perform upsearch or
692 * not. 688 * not.
693 * return_node - Where the Node is returned 689 * return_node - Where the Node is returned
694 * 690 *
695 * DESCRIPTION: Look up a name relative to a given scope and return the 691 * DESCRIPTION: Look up a name relative to a given scope and return the
696 * corresponding Node. NOTE: Scope can be null. 692 * corresponding Node. NOTE: Scope can be null.
697 * 693 *
698 * MUTEX: Locks namespace 694 * MUTEX: Locks namespace
699 * 695 *
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 0483877f26b..345f0c3c6ad 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -60,8 +60,8 @@ ACPI_MODULE_NAME("nswalk")
60 * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if 60 * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if
61 * none is found. 61 * none is found.
62 * 62 *
63 * DESCRIPTION: Return the next peer node within the namespace. If Handle 63 * DESCRIPTION: Return the next peer node within the namespace. If Handle
64 * is valid, Scope is ignored. Otherwise, the first node 64 * is valid, Scope is ignored. Otherwise, the first node
65 * within Scope is returned. 65 * within Scope is returned.
66 * 66 *
67 ******************************************************************************/ 67 ******************************************************************************/
@@ -88,7 +88,7 @@ struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
88 * 88 *
89 * FUNCTION: acpi_ns_get_next_node_typed 89 * FUNCTION: acpi_ns_get_next_node_typed
90 * 90 *
91 * PARAMETERS: type - Type of node to be searched for 91 * PARAMETERS: Type - Type of node to be searched for
92 * parent_node - Parent node whose children we are 92 * parent_node - Parent node whose children we are
93 * getting 93 * getting
94 * child_node - Previous child that was found. 94 * child_node - Previous child that was found.
@@ -97,8 +97,8 @@ struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
97 * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if 97 * RETURN: struct acpi_namespace_node - Pointer to the NEXT child or NULL if
98 * none is found. 98 * none is found.
99 * 99 *
100 * DESCRIPTION: Return the next peer node within the namespace. If Handle 100 * DESCRIPTION: Return the next peer node within the namespace. If Handle
101 * is valid, Scope is ignored. Otherwise, the first node 101 * is valid, Scope is ignored. Otherwise, the first node
102 * within Scope is returned. 102 * within Scope is returned.
103 * 103 *
104 ******************************************************************************/ 104 ******************************************************************************/
@@ -151,16 +151,16 @@ struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type,
151 * 151 *
152 * FUNCTION: acpi_ns_walk_namespace 152 * FUNCTION: acpi_ns_walk_namespace
153 * 153 *
154 * PARAMETERS: type - acpi_object_type to search for 154 * PARAMETERS: Type - acpi_object_type to search for
155 * start_node - Handle in namespace where search begins 155 * start_node - Handle in namespace where search begins
156 * max_depth - Depth to which search is to reach 156 * max_depth - Depth to which search is to reach
157 * flags - Whether to unlock the NS before invoking 157 * Flags - Whether to unlock the NS before invoking
158 * the callback routine 158 * the callback routine
159 * pre_order_visit - Called during tree pre-order visit 159 * pre_order_visit - Called during tree pre-order visit
160 * when an object of "Type" is found 160 * when an object of "Type" is found
161 * post_order_visit - Called during tree post-order visit 161 * post_order_visit - Called during tree post-order visit
162 * when an object of "Type" is found 162 * when an object of "Type" is found
163 * context - Passed to user function(s) above 163 * Context - Passed to user function(s) above
164 * return_value - from the user_function if terminated 164 * return_value - from the user_function if terminated
165 * early. Otherwise, returns NULL. 165 * early. Otherwise, returns NULL.
166 * RETURNS: Status 166 * RETURNS: Status
@@ -305,7 +305,7 @@ acpi_ns_walk_namespace(acpi_object_type type,
305 305
306 /* 306 /*
307 * Depth first search: Attempt to go down another level in the 307 * Depth first search: Attempt to go down another level in the
308 * namespace if we are allowed to. Don't go any further if we have 308 * namespace if we are allowed to. Don't go any further if we have
309 * reached the caller specified maximum depth or if the user 309 * reached the caller specified maximum depth or if the user
310 * function has specified that the maximum depth has been reached. 310 * function has specified that the maximum depth has been reached.
311 */ 311 */
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index d6a9f77972b..c53f0040e49 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45#include <linux/export.h>
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include "accommon.h" 46#include "accommon.h"
48#include "acnamesp.h" 47#include "acnamesp.h"
@@ -58,19 +57,19 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info);
58 * 57 *
59 * FUNCTION: acpi_evaluate_object_typed 58 * FUNCTION: acpi_evaluate_object_typed
60 * 59 *
61 * PARAMETERS: handle - Object handle (optional) 60 * PARAMETERS: Handle - Object handle (optional)
62 * pathname - Object pathname (optional) 61 * Pathname - Object pathname (optional)
63 * external_params - List of parameters to pass to method, 62 * external_params - List of parameters to pass to method,
64 * terminated by NULL. May be NULL 63 * terminated by NULL. May be NULL
65 * if no parameters are being passed. 64 * if no parameters are being passed.
66 * return_buffer - Where to put method's return value (if 65 * return_buffer - Where to put method's return value (if
67 * any). If NULL, no value is returned. 66 * any). If NULL, no value is returned.
68 * return_type - Expected type of return object 67 * return_type - Expected type of return object
69 * 68 *
70 * RETURN: Status 69 * RETURN: Status
71 * 70 *
72 * DESCRIPTION: Find and evaluate the given object, passing the given 71 * DESCRIPTION: Find and evaluate the given object, passing the given
73 * parameters if necessary. One of "Handle" or "Pathname" must 72 * parameters if necessary. One of "Handle" or "Pathname" must
74 * be valid (non-null) 73 * be valid (non-null)
75 * 74 *
76 ******************************************************************************/ 75 ******************************************************************************/
@@ -152,18 +151,18 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed)
152 * 151 *
153 * FUNCTION: acpi_evaluate_object 152 * FUNCTION: acpi_evaluate_object
154 * 153 *
155 * PARAMETERS: handle - Object handle (optional) 154 * PARAMETERS: Handle - Object handle (optional)
156 * pathname - Object pathname (optional) 155 * Pathname - Object pathname (optional)
157 * external_params - List of parameters to pass to method, 156 * external_params - List of parameters to pass to method,
158 * terminated by NULL. May be NULL 157 * terminated by NULL. May be NULL
159 * if no parameters are being passed. 158 * if no parameters are being passed.
160 * return_buffer - Where to put method's return value (if 159 * return_buffer - Where to put method's return value (if
161 * any). If NULL, no value is returned. 160 * any). If NULL, no value is returned.
162 * 161 *
163 * RETURN: Status 162 * RETURN: Status
164 * 163 *
165 * DESCRIPTION: Find and evaluate the given object, passing the given 164 * DESCRIPTION: Find and evaluate the given object, passing the given
166 * parameters if necessary. One of "Handle" or "Pathname" must 165 * parameters if necessary. One of "Handle" or "Pathname" must
167 * be valid (non-null) 166 * be valid (non-null)
168 * 167 *
169 ******************************************************************************/ 168 ******************************************************************************/
@@ -364,7 +363,7 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object)
364 * 363 *
365 * FUNCTION: acpi_ns_resolve_references 364 * FUNCTION: acpi_ns_resolve_references
366 * 365 *
367 * PARAMETERS: info - Evaluation info block 366 * PARAMETERS: Info - Evaluation info block
368 * 367 *
369 * RETURN: Info->return_object is replaced with the dereferenced object 368 * RETURN: Info->return_object is replaced with the dereferenced object
370 * 369 *
@@ -431,14 +430,14 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
431 * 430 *
432 * FUNCTION: acpi_walk_namespace 431 * FUNCTION: acpi_walk_namespace
433 * 432 *
434 * PARAMETERS: type - acpi_object_type to search for 433 * PARAMETERS: Type - acpi_object_type to search for
435 * start_object - Handle in namespace where search begins 434 * start_object - Handle in namespace where search begins
436 * max_depth - Depth to which search is to reach 435 * max_depth - Depth to which search is to reach
437 * pre_order_visit - Called during tree pre-order visit 436 * pre_order_visit - Called during tree pre-order visit
438 * when an object of "Type" is found 437 * when an object of "Type" is found
439 * post_order_visit - Called during tree post-order visit 438 * post_order_visit - Called during tree post-order visit
440 * when an object of "Type" is found 439 * when an object of "Type" is found
441 * context - Passed to user function(s) above 440 * Context - Passed to user function(s) above
442 * return_value - Location where return value of 441 * return_value - Location where return value of
443 * user_function is put if terminated early 442 * user_function is put if terminated early
444 * 443 *
@@ -542,15 +541,15 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
542 acpi_status status; 541 acpi_status status;
543 struct acpi_namespace_node *node; 542 struct acpi_namespace_node *node;
544 u32 flags; 543 u32 flags;
545 struct acpi_pnp_device_id *hid; 544 struct acpica_device_id *hid;
546 struct acpi_pnp_device_id_list *cid; 545 struct acpica_device_id_list *cid;
547 u32 i; 546 u32 i;
548 u8 found; 547 u8 found;
549 int no_match; 548 int no_match;
550 549
551 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 550 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
552 if (ACPI_FAILURE(status)) { 551 if (ACPI_FAILURE(status)) {
553 return_ACPI_STATUS(status); 552 return (status);
554 } 553 }
555 554
556 node = acpi_ns_validate_handle(obj_handle); 555 node = acpi_ns_validate_handle(obj_handle);
@@ -646,7 +645,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
646 * 645 *
647 * PARAMETERS: HID - HID to search for. Can be NULL. 646 * PARAMETERS: HID - HID to search for. Can be NULL.
648 * user_function - Called when a matching object is found 647 * user_function - Called when a matching object is found
649 * context - Passed to user function 648 * Context - Passed to user function
650 * return_value - Location where return value of 649 * return_value - Location where return value of
651 * user_function is put if terminated early 650 * user_function is put if terminated early
652 * 651 *
@@ -656,7 +655,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
656 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, 655 * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
657 * starting (and ending) at the object specified by start_handle. 656 * starting (and ending) at the object specified by start_handle.
658 * The user_function is called whenever an object of type 657 * The user_function is called whenever an object of type
659 * Device is found. If the user function returns 658 * Device is found. If the user function returns
660 * a non-zero value, the search is terminated immediately and this 659 * a non-zero value, the search is terminated immediately and this
661 * value is returned to the caller. 660 * value is returned to the caller.
662 * 661 *
@@ -716,8 +715,8 @@ ACPI_EXPORT_SYMBOL(acpi_get_devices)
716 * FUNCTION: acpi_attach_data 715 * FUNCTION: acpi_attach_data
717 * 716 *
718 * PARAMETERS: obj_handle - Namespace node 717 * PARAMETERS: obj_handle - Namespace node
719 * handler - Handler for this attachment 718 * Handler - Handler for this attachment
720 * data - Pointer to data to be attached 719 * Data - Pointer to data to be attached
721 * 720 *
722 * RETURN: Status 721 * RETURN: Status
723 * 722 *
@@ -764,7 +763,7 @@ ACPI_EXPORT_SYMBOL(acpi_attach_data)
764 * FUNCTION: acpi_detach_data 763 * FUNCTION: acpi_detach_data
765 * 764 *
766 * PARAMETERS: obj_handle - Namespace node handle 765 * PARAMETERS: obj_handle - Namespace node handle
767 * handler - Handler used in call to acpi_attach_data 766 * Handler - Handler used in call to acpi_attach_data
768 * 767 *
769 * RETURN: Status 768 * RETURN: Status
770 * 769 *
@@ -810,8 +809,8 @@ ACPI_EXPORT_SYMBOL(acpi_detach_data)
810 * FUNCTION: acpi_get_data 809 * FUNCTION: acpi_get_data
811 * 810 *
812 * PARAMETERS: obj_handle - Namespace node 811 * PARAMETERS: obj_handle - Namespace node
813 * handler - Handler used in call to attach_data 812 * Handler - Handler used in call to attach_data
814 * data - Where the data is returned 813 * Data - Where the data is returned
815 * 814 *
816 * RETURN: Status 815 * RETURN: Status
817 * 816 *
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index 811c6f13f47..3fd4526f3db 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45#include <linux/export.h>
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include "accommon.h" 46#include "accommon.h"
48#include "acnamesp.h" 47#include "acnamesp.h"
@@ -53,24 +52,24 @@
53ACPI_MODULE_NAME("nsxfname") 52ACPI_MODULE_NAME("nsxfname")
54 53
55/* Local prototypes */ 54/* Local prototypes */
56static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, 55static char *acpi_ns_copy_device_id(struct acpica_device_id *dest,
57 struct acpi_pnp_device_id *source, 56 struct acpica_device_id *source,
58 char *string_area); 57 char *string_area);
59 58
60/****************************************************************************** 59/******************************************************************************
61 * 60 *
62 * FUNCTION: acpi_get_handle 61 * FUNCTION: acpi_get_handle
63 * 62 *
64 * PARAMETERS: parent - Object to search under (search scope). 63 * PARAMETERS: Parent - Object to search under (search scope).
65 * pathname - Pointer to an asciiz string containing the 64 * Pathname - Pointer to an asciiz string containing the
66 * name 65 * name
67 * ret_handle - Where the return handle is returned 66 * ret_handle - Where the return handle is returned
68 * 67 *
69 * RETURN: Status 68 * RETURN: Status
70 * 69 *
71 * DESCRIPTION: This routine will search for a caller specified name in the 70 * DESCRIPTION: This routine will search for a caller specified name in the
72 * name space. The caller can restrict the search region by 71 * name space. The caller can restrict the search region by
73 * specifying a non NULL parent. The parent value is itself a 72 * specifying a non NULL parent. The parent value is itself a
74 * namespace handle. 73 * namespace handle.
75 * 74 *
76 ******************************************************************************/ 75 ******************************************************************************/
@@ -142,14 +141,14 @@ ACPI_EXPORT_SYMBOL(acpi_get_handle)
142 * 141 *
143 * FUNCTION: acpi_get_name 142 * FUNCTION: acpi_get_name
144 * 143 *
145 * PARAMETERS: handle - Handle to be converted to a pathname 144 * PARAMETERS: Handle - Handle to be converted to a pathname
146 * name_type - Full pathname or single segment 145 * name_type - Full pathname or single segment
147 * buffer - Buffer for returned path 146 * Buffer - Buffer for returned path
148 * 147 *
149 * RETURN: Pointer to a string containing the fully qualified Name. 148 * RETURN: Pointer to a string containing the fully qualified Name.
150 * 149 *
151 * DESCRIPTION: This routine returns the fully qualified name associated with 150 * DESCRIPTION: This routine returns the fully qualified name associated with
152 * the Handle parameter. This and the acpi_pathname_to_handle are 151 * the Handle parameter. This and the acpi_pathname_to_handle are
153 * complementary functions. 152 * complementary functions.
154 * 153 *
155 ******************************************************************************/ 154 ******************************************************************************/
@@ -202,7 +201,8 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
202 201
203 /* Just copy the ACPI name from the Node and zero terminate it */ 202 /* Just copy the ACPI name from the Node and zero terminate it */
204 203
205 ACPI_MOVE_NAME(buffer->pointer, acpi_ut_get_node_name(node)); 204 ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node),
205 ACPI_NAME_SIZE);
206 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0; 206 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
207 status = AE_OK; 207 status = AE_OK;
208 208
@@ -218,21 +218,20 @@ ACPI_EXPORT_SYMBOL(acpi_get_name)
218 * 218 *
219 * FUNCTION: acpi_ns_copy_device_id 219 * FUNCTION: acpi_ns_copy_device_id
220 * 220 *
221 * PARAMETERS: dest - Pointer to the destination PNP_DEVICE_ID 221 * PARAMETERS: Dest - Pointer to the destination DEVICE_ID
222 * source - Pointer to the source PNP_DEVICE_ID 222 * Source - Pointer to the source DEVICE_ID
223 * string_area - Pointer to where to copy the dest string 223 * string_area - Pointer to where to copy the dest string
224 * 224 *
225 * RETURN: Pointer to the next string area 225 * RETURN: Pointer to the next string area
226 * 226 *
227 * DESCRIPTION: Copy a single PNP_DEVICE_ID, including the string data. 227 * DESCRIPTION: Copy a single DEVICE_ID, including the string data.
228 * 228 *
229 ******************************************************************************/ 229 ******************************************************************************/
230static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, 230static char *acpi_ns_copy_device_id(struct acpica_device_id *dest,
231 struct acpi_pnp_device_id *source, 231 struct acpica_device_id *source,
232 char *string_area) 232 char *string_area)
233{ 233{
234 234 /* Create the destination DEVICE_ID */
235 /* Create the destination PNP_DEVICE_ID */
236 235
237 dest->string = string_area; 236 dest->string = string_area;
238 dest->length = source->length; 237 dest->length = source->length;
@@ -247,7 +246,7 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest,
247 * 246 *
248 * FUNCTION: acpi_get_object_info 247 * FUNCTION: acpi_get_object_info
249 * 248 *
250 * PARAMETERS: handle - Object Handle 249 * PARAMETERS: Handle - Object Handle
251 * return_buffer - Where the info is returned 250 * return_buffer - Where the info is returned
252 * 251 *
253 * RETURN: Status 252 * RETURN: Status
@@ -256,8 +255,8 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest,
256 * namespace node and possibly by running several standard 255 * namespace node and possibly by running several standard
257 * control methods (Such as in the case of a device.) 256 * control methods (Such as in the case of a device.)
258 * 257 *
259 * For Device and Processor objects, run the Device _HID, _UID, _CID, _SUB, 258 * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA,
260 * _STA, _ADR, _sx_w, and _sx_d methods. 259 * _ADR, _sx_w, and _sx_d methods.
261 * 260 *
262 * Note: Allocates the return buffer, must be freed by the caller. 261 * Note: Allocates the return buffer, must be freed by the caller.
263 * 262 *
@@ -269,10 +268,9 @@ acpi_get_object_info(acpi_handle handle,
269{ 268{
270 struct acpi_namespace_node *node; 269 struct acpi_namespace_node *node;
271 struct acpi_device_info *info; 270 struct acpi_device_info *info;
272 struct acpi_pnp_device_id_list *cid_list = NULL; 271 struct acpica_device_id_list *cid_list = NULL;
273 struct acpi_pnp_device_id *hid = NULL; 272 struct acpica_device_id *hid = NULL;
274 struct acpi_pnp_device_id *uid = NULL; 273 struct acpica_device_id *uid = NULL;
275 struct acpi_pnp_device_id *sub = NULL;
276 char *next_id_string; 274 char *next_id_string;
277 acpi_object_type type; 275 acpi_object_type type;
278 acpi_name name; 276 acpi_name name;
@@ -317,7 +315,7 @@ acpi_get_object_info(acpi_handle handle,
317 if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) { 315 if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) {
318 /* 316 /*
319 * Get extra info for ACPI Device/Processor objects only: 317 * Get extra info for ACPI Device/Processor objects only:
320 * Run the Device _HID, _UID, _SUB, and _CID methods. 318 * Run the Device _HID, _UID, and _CID methods.
321 * 319 *
322 * Note: none of these methods are required, so they may or may 320 * Note: none of these methods are required, so they may or may
323 * not be present for this device. The Info->Valid bitfield is used 321 * not be present for this device. The Info->Valid bitfield is used
@@ -340,14 +338,6 @@ acpi_get_object_info(acpi_handle handle,
340 valid |= ACPI_VALID_UID; 338 valid |= ACPI_VALID_UID;
341 } 339 }
342 340
343 /* Execute the Device._SUB method */
344
345 status = acpi_ut_execute_SUB(node, &sub);
346 if (ACPI_SUCCESS(status)) {
347 info_size += sub->length;
348 valid |= ACPI_VALID_SUB;
349 }
350
351 /* Execute the Device._CID method */ 341 /* Execute the Device._CID method */
352 342
353 status = acpi_ut_execute_CID(node, &cid_list); 343 status = acpi_ut_execute_CID(node, &cid_list);
@@ -357,7 +347,7 @@ acpi_get_object_info(acpi_handle handle,
357 347
358 info_size += 348 info_size +=
359 (cid_list->list_size - 349 (cid_list->list_size -
360 sizeof(struct acpi_pnp_device_id_list)); 350 sizeof(struct acpica_device_id_list));
361 valid |= ACPI_VALID_CID; 351 valid |= ACPI_VALID_CID;
362 } 352 }
363 } 353 }
@@ -427,17 +417,16 @@ acpi_get_object_info(acpi_handle handle,
427 next_id_string = ACPI_CAST_PTR(char, info->compatible_id_list.ids); 417 next_id_string = ACPI_CAST_PTR(char, info->compatible_id_list.ids);
428 if (cid_list) { 418 if (cid_list) {
429 419
430 /* Point past the CID PNP_DEVICE_ID array */ 420 /* Point past the CID DEVICE_ID array */
431 421
432 next_id_string += 422 next_id_string +=
433 ((acpi_size) cid_list->count * 423 ((acpi_size) cid_list->count *
434 sizeof(struct acpi_pnp_device_id)); 424 sizeof(struct acpica_device_id));
435 } 425 }
436 426
437 /* 427 /*
438 * Copy the HID, UID, SUB, and CIDs to the return buffer. 428 * Copy the HID, UID, and CIDs to the return buffer. The variable-length
439 * The variable-length strings are copied to the reserved area 429 * strings are copied to the reserved area at the end of the buffer.
440 * at the end of the buffer.
441 * 430 *
442 * For HID and CID, check if the ID is a PCI Root Bridge. 431 * For HID and CID, check if the ID is a PCI Root Bridge.
443 */ 432 */
@@ -455,11 +444,6 @@ acpi_get_object_info(acpi_handle handle,
455 uid, next_id_string); 444 uid, next_id_string);
456 } 445 }
457 446
458 if (sub) {
459 next_id_string = acpi_ns_copy_device_id(&info->subsystem_id,
460 sub, next_id_string);
461 }
462
463 if (cid_list) { 447 if (cid_list) {
464 info->compatible_id_list.count = cid_list->count; 448 info->compatible_id_list.count = cid_list->count;
465 info->compatible_id_list.list_size = cid_list->list_size; 449 info->compatible_id_list.list_size = cid_list->list_size;
@@ -496,9 +480,6 @@ acpi_get_object_info(acpi_handle handle,
496 if (uid) { 480 if (uid) {
497 ACPI_FREE(uid); 481 ACPI_FREE(uid);
498 } 482 }
499 if (sub) {
500 ACPI_FREE(sub);
501 }
502 if (cid_list) { 483 if (cid_list) {
503 ACPI_FREE(cid_list); 484 ACPI_FREE(cid_list);
504 } 485 }
@@ -511,7 +492,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_object_info)
511 * 492 *
512 * FUNCTION: acpi_install_method 493 * FUNCTION: acpi_install_method
513 * 494 *
514 * PARAMETERS: buffer - An ACPI table containing one control method 495 * PARAMETERS: Buffer - An ACPI table containing one control method
515 * 496 *
516 * RETURN: Status 497 * RETURN: Status
517 * 498 *
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 9d029dac6b6..db7660f8b86 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 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, 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
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45#include <linux/export.h>
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include "accommon.h" 46#include "accommon.h"
48#include "acnamesp.h" 47#include "acnamesp.h"
@@ -98,7 +97,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_id)
98 * 97 *
99 * FUNCTION: acpi_get_type 98 * FUNCTION: acpi_get_type
100 * 99 *
101 * PARAMETERS: handle - Handle of object whose type is desired 100 * PARAMETERS: Handle - Handle of object whose type is desired
102 * ret_type - Where the type will be placed 101 * ret_type - Where the type will be placed
103 * 102 *
104 * RETURN: Status 103 * RETURN: Status
@@ -151,7 +150,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_type)
151 * 150 *
152 * FUNCTION: acpi_get_parent 151 * FUNCTION: acpi_get_parent
153 * 152 *
154 * PARAMETERS: handle - Handle of object whose parent is desired 153 * PARAMETERS: Handle - Handle of object whose parent is desired
155 * ret_handle - Where the parent handle will be placed 154 * ret_handle - Where the parent handle will be placed
156 * 155 *
157 * RETURN: Status 156 * RETURN: Status
@@ -212,16 +211,16 @@ ACPI_EXPORT_SYMBOL(acpi_get_parent)
212 * 211 *
213 * FUNCTION: acpi_get_next_object 212 * FUNCTION: acpi_get_next_object
214 * 213 *
215 * PARAMETERS: type - Type of object to be searched for 214 * PARAMETERS: Type - Type of object to be searched for
216 * parent - Parent object whose children we are getting 215 * Parent - Parent object whose children we are getting
217 * last_child - Previous child that was found. 216 * last_child - Previous child that was found.
218 * The NEXT child will be returned 217 * The NEXT child will be returned
219 * ret_handle - Where handle to the next object is placed 218 * ret_handle - Where handle to the next object is placed
220 * 219 *
221 * RETURN: Status 220 * RETURN: Status
222 * 221 *
223 * DESCRIPTION: Return the next peer object within the namespace. If Handle is 222 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
224 * valid, Scope is ignored. Otherwise, the first object within 223 * valid, Scope is ignored. Otherwise, the first object within
225 * Scope is returned. 224 * Scope is returned.
226 * 225 *
227 ******************************************************************************/ 226 ******************************************************************************/
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index cb79e2d4d74..e1fad0ee013 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -120,7 +120,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
120 * RETURN: Pointer to end-of-package +1 120 * RETURN: Pointer to end-of-package +1
121 * 121 *
122 * DESCRIPTION: Get next package length and return a pointer past the end of 122 * DESCRIPTION: Get next package length and return a pointer past the end of
123 * the package. Consumes the package length field 123 * the package. Consumes the package length field
124 * 124 *
125 ******************************************************************************/ 125 ******************************************************************************/
126 126
@@ -147,8 +147,8 @@ u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state)
147 * RETURN: Pointer to the start of the name string (pointer points into 147 * RETURN: Pointer to the start of the name string (pointer points into
148 * the AML. 148 * the AML.
149 * 149 *
150 * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name 150 * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
151 * prefix characters. Set parser state to point past the string. 151 * prefix characters. Set parser state to point past the string.
152 * (Name is consumed from the AML.) 152 * (Name is consumed from the AML.)
153 * 153 *
154 ******************************************************************************/ 154 ******************************************************************************/
@@ -210,7 +210,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
210 * FUNCTION: acpi_ps_get_next_namepath 210 * FUNCTION: acpi_ps_get_next_namepath
211 * 211 *
212 * PARAMETERS: parser_state - Current parser state object 212 * PARAMETERS: parser_state - Current parser state object
213 * arg - Where the namepath will be stored 213 * Arg - Where the namepath will be stored
214 * arg_count - If the namepath points to a control method 214 * arg_count - If the namepath points to a control method
215 * the method's argument is returned here. 215 * the method's argument is returned here.
216 * possible_method_call - Whether the namepath can possibly be the 216 * possible_method_call - Whether the namepath can possibly be the
@@ -220,7 +220,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
220 * 220 *
221 * DESCRIPTION: Get next name (if method call, return # of required args). 221 * DESCRIPTION: Get next name (if method call, return # of required args).
222 * Names are looked up in the internal namespace to determine 222 * Names are looked up in the internal namespace to determine
223 * if the name represents a control method. If a method 223 * if the name represents a control method. If a method
224 * is found, the number of arguments to the method is returned. 224 * is found, the number of arguments to the method is returned.
225 * This information is critical for parsing to continue correctly. 225 * This information is critical for parsing to continue correctly.
226 * 226 *
@@ -379,7 +379,7 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
379 * 379 *
380 * PARAMETERS: parser_state - Current parser state object 380 * PARAMETERS: parser_state - Current parser state object
381 * arg_type - The argument type (AML_*_ARG) 381 * arg_type - The argument type (AML_*_ARG)
382 * arg - Where the argument is returned 382 * Arg - Where the argument is returned
383 * 383 *
384 * RETURN: None 384 * RETURN: None
385 * 385 *
@@ -484,54 +484,34 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
484static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state 484static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
485 *parser_state) 485 *parser_state)
486{ 486{
487 u32 aml_offset; 487 u32 aml_offset = (u32)
488 ACPI_PTR_DIFF(parser_state->aml,
489 parser_state->aml_start);
488 union acpi_parse_object *field; 490 union acpi_parse_object *field;
489 union acpi_parse_object *arg = NULL;
490 u16 opcode; 491 u16 opcode;
491 u32 name; 492 u32 name;
492 u8 access_type;
493 u8 access_attribute;
494 u8 access_length;
495 u32 pkg_length;
496 u8 *pkg_end;
497 u32 buffer_length;
498 493
499 ACPI_FUNCTION_TRACE(ps_get_next_field); 494 ACPI_FUNCTION_TRACE(ps_get_next_field);
500 495
501 aml_offset =
502 (u32)ACPI_PTR_DIFF(parser_state->aml, parser_state->aml_start);
503
504 /* Determine field type */ 496 /* Determine field type */
505 497
506 switch (ACPI_GET8(parser_state->aml)) { 498 switch (ACPI_GET8(parser_state->aml)) {
507 case AML_FIELD_OFFSET_OP: 499 default:
508
509 opcode = AML_INT_RESERVEDFIELD_OP;
510 parser_state->aml++;
511 break;
512
513 case AML_FIELD_ACCESS_OP:
514 500
515 opcode = AML_INT_ACCESSFIELD_OP; 501 opcode = AML_INT_NAMEDFIELD_OP;
516 parser_state->aml++;
517 break; 502 break;
518 503
519 case AML_FIELD_CONNECTION_OP: 504 case 0x00:
520 505
521 opcode = AML_INT_CONNECTION_OP; 506 opcode = AML_INT_RESERVEDFIELD_OP;
522 parser_state->aml++; 507 parser_state->aml++;
523 break; 508 break;
524 509
525 case AML_FIELD_EXT_ACCESS_OP: 510 case 0x01:
526 511
527 opcode = AML_INT_EXTACCESSFIELD_OP; 512 opcode = AML_INT_ACCESSFIELD_OP;
528 parser_state->aml++; 513 parser_state->aml++;
529 break; 514 break;
530
531 default:
532
533 opcode = AML_INT_NAMEDFIELD_OP;
534 break;
535 } 515 }
536 516
537 /* Allocate a new field op */ 517 /* Allocate a new field op */
@@ -569,113 +549,16 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
569 break; 549 break;
570 550
571 case AML_INT_ACCESSFIELD_OP: 551 case AML_INT_ACCESSFIELD_OP:
572 case AML_INT_EXTACCESSFIELD_OP:
573 552
574 /* 553 /*
575 * Get access_type and access_attrib and merge into the field Op 554 * Get access_type and access_attrib and merge into the field Op
576 * access_type is first operand, access_attribute is second. stuff 555 * access_type is first operand, access_attribute is second
577 * these bytes into the node integer value for convenience.
578 */ 556 */
579 557 field->common.value.integer =
580 /* Get the two bytes (Type/Attribute) */ 558 (((u32) ACPI_GET8(parser_state->aml) << 8));
581
582 access_type = ACPI_GET8(parser_state->aml);
583 parser_state->aml++; 559 parser_state->aml++;
584 access_attribute = ACPI_GET8(parser_state->aml); 560 field->common.value.integer |= ACPI_GET8(parser_state->aml);
585 parser_state->aml++; 561 parser_state->aml++;
586
587 field->common.value.integer = (u8)access_type;
588 field->common.value.integer |= (u16)(access_attribute << 8);
589
590 /* This opcode has a third byte, access_length */
591
592 if (opcode == AML_INT_EXTACCESSFIELD_OP) {
593 access_length = ACPI_GET8(parser_state->aml);
594 parser_state->aml++;
595
596 field->common.value.integer |=
597 (u32)(access_length << 16);
598 }
599 break;
600
601 case AML_INT_CONNECTION_OP:
602
603 /*
604 * Argument for Connection operator can be either a Buffer
605 * (resource descriptor), or a name_string.
606 */
607 if (ACPI_GET8(parser_state->aml) == AML_BUFFER_OP) {
608 parser_state->aml++;
609
610 pkg_end = parser_state->aml;
611 pkg_length =
612 acpi_ps_get_next_package_length(parser_state);
613 pkg_end += pkg_length;
614
615 if (parser_state->aml < pkg_end) {
616
617 /* Non-empty list */
618
619 arg = acpi_ps_alloc_op(AML_INT_BYTELIST_OP);
620 if (!arg) {
621 acpi_ps_free_op(field);
622 return_PTR(NULL);
623 }
624
625 /* Get the actual buffer length argument */
626
627 opcode = ACPI_GET8(parser_state->aml);
628 parser_state->aml++;
629
630 switch (opcode) {
631 case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
632 buffer_length =
633 ACPI_GET8(parser_state->aml);
634 parser_state->aml += 1;
635 break;
636
637 case AML_WORD_OP: /* AML_WORDDATA_ARG */
638 buffer_length =
639 ACPI_GET16(parser_state->aml);
640 parser_state->aml += 2;
641 break;
642
643 case AML_DWORD_OP: /* AML_DWORDATA_ARG */
644 buffer_length =
645 ACPI_GET32(parser_state->aml);
646 parser_state->aml += 4;
647 break;
648
649 default:
650 buffer_length = 0;
651 break;
652 }
653
654 /* Fill in bytelist data */
655
656 arg->named.value.size = buffer_length;
657 arg->named.data = parser_state->aml;
658 }
659
660 /* Skip to End of byte data */
661
662 parser_state->aml = pkg_end;
663 } else {
664 arg = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
665 if (!arg) {
666 acpi_ps_free_op(field);
667 return_PTR(NULL);
668 }
669
670 /* Get the Namestring argument */
671
672 arg->common.value.name =
673 acpi_ps_get_next_namestring(parser_state);
674 }
675
676 /* Link the buffer/namestring to parent (CONNECTION_OP) */
677
678 acpi_ps_append_arg(field, arg);
679 break; 562 break;
680 563
681 default: 564 default:
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index 5607805aab2..01dd70d1de5 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -133,46 +133,18 @@ static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
133 133
134 case AML_CLASS_UNKNOWN: 134 case AML_CLASS_UNKNOWN:
135 135
136 /* The opcode is unrecognized. Complain and skip unknown opcodes */ 136 /* The opcode is unrecognized. Just skip unknown opcodes */
137 137
138 if (walk_state->pass_number == 2) { 138 ACPI_ERROR((AE_INFO,
139 ACPI_ERROR((AE_INFO, 139 "Found unknown opcode 0x%X at AML address %p offset 0x%X, ignoring",
140 "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring", 140 walk_state->opcode, walk_state->parser_state.aml,
141 walk_state->opcode, 141 walk_state->aml_offset));
142 (u32)(walk_state->aml_offset +
143 sizeof(struct acpi_table_header))));
144 142
145 ACPI_DUMP_BUFFER(walk_state->parser_state.aml - 16, 48); 143 ACPI_DUMP_BUFFER(walk_state->parser_state.aml, 128);
146 144
147#ifdef ACPI_ASL_COMPILER 145 /* Assume one-byte bad opcode */
148 /*
149 * This is executed for the disassembler only. Output goes
150 * to the disassembled ASL output file.
151 */
152 acpi_os_printf
153 ("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
154 walk_state->opcode,
155 (u32)(walk_state->aml_offset +
156 sizeof(struct acpi_table_header)));
157
158 /* Dump the context surrounding the invalid opcode */
159
160 acpi_ut_dump_buffer(((u8 *)walk_state->parser_state.
161 aml - 16), 48, DB_BYTE_DISPLAY,
162 walk_state->aml_offset +
163 sizeof(struct acpi_table_header) -
164 16);
165 acpi_os_printf(" */\n");
166#endif
167 }
168
169 /* Increment past one-byte or two-byte opcode */
170 146
171 walk_state->parser_state.aml++; 147 walk_state->parser_state.aml++;
172 if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */
173 walk_state->parser_state.aml++;
174 }
175
176 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); 148 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
177 149
178 default: 150 default:
@@ -195,7 +167,7 @@ static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
195 * PARAMETERS: walk_state - Current state 167 * PARAMETERS: walk_state - Current state
196 * aml_op_start - Begin of named Op in AML 168 * aml_op_start - Begin of named Op in AML
197 * unnamed_op - Early Op (not a named Op) 169 * unnamed_op - Early Op (not a named Op)
198 * op - Returned Op 170 * Op - Returned Op
199 * 171 *
200 * RETURN: Status 172 * RETURN: Status
201 * 173 *
@@ -351,7 +323,7 @@ acpi_ps_create_op(struct acpi_walk_state *walk_state,
351 323
352 if (walk_state->op_info->flags & AML_CREATE) { 324 if (walk_state->op_info->flags & AML_CREATE) {
353 /* 325 /*
354 * Backup to beginning of create_XXXfield declaration 326 * Backup to beginning of create_xXXfield declaration
355 * body_length is unknown until we parse the body 327 * body_length is unknown until we parse the body
356 */ 328 */
357 op->named.data = aml_op_start; 329 op->named.data = aml_op_start;
@@ -408,7 +380,7 @@ acpi_ps_create_op(struct acpi_walk_state *walk_state,
408 * 380 *
409 * PARAMETERS: walk_state - Current state 381 * PARAMETERS: walk_state - Current state
410 * aml_op_start - Op start in AML 382 * aml_op_start - Op start in AML
411 * op - Current Op 383 * Op - Current Op
412 * 384 *
413 * RETURN: Status 385 * RETURN: Status
414 * 386 *
@@ -547,18 +519,11 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
547 if ((op_info->class == 519 if ((op_info->class ==
548 AML_CLASS_EXECUTE) && (!arg)) { 520 AML_CLASS_EXECUTE) && (!arg)) {
549 ACPI_WARNING((AE_INFO, 521 ACPI_WARNING((AE_INFO,
550 "Unsupported module-level executable opcode " 522 "Detected an unsupported executable opcode "
551 "0x%.2X at table offset 0x%.4X", 523 "at module-level: [0x%.4X] at table offset 0x%.4X",
552 op->common. 524 op->common.aml_opcode,
553 aml_opcode, 525 (u32)((aml_op_start - walk_state->parser_state.aml_start)
554 (u32) 526 + sizeof(struct acpi_table_header))));
555 (ACPI_PTR_DIFF
556 (aml_op_start,
557 walk_state->
558 parser_state.
559 aml_start) +
560 sizeof(struct
561 acpi_table_header))));
562 } 527 }
563 } 528 }
564 break; 529 break;
@@ -714,8 +679,8 @@ acpi_ps_link_module_code(union acpi_parse_object *parent_op,
714 * FUNCTION: acpi_ps_complete_op 679 * FUNCTION: acpi_ps_complete_op
715 * 680 *
716 * PARAMETERS: walk_state - Current state 681 * PARAMETERS: walk_state - Current state
717 * op - Returned Op 682 * Op - Returned Op
718 * status - Parse status before complete Op 683 * Status - Parse status before complete Op
719 * 684 *
720 * RETURN: Status 685 * RETURN: Status
721 * 686 *
@@ -878,6 +843,8 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state,
878 *op = NULL; 843 *op = NULL;
879 } 844 }
880 845
846 ACPI_PREEMPTION_POINT();
847
881 return_ACPI_STATUS(AE_OK); 848 return_ACPI_STATUS(AE_OK);
882} 849}
883 850
@@ -886,8 +853,8 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state,
886 * FUNCTION: acpi_ps_complete_final_op 853 * FUNCTION: acpi_ps_complete_final_op
887 * 854 *
888 * PARAMETERS: walk_state - Current state 855 * PARAMETERS: walk_state - Current state
889 * op - Current Op 856 * Op - Current Op
890 * status - Current parse status before complete last 857 * Status - Current parse status before complete last
891 * Op 858 * Op
892 * 859 *
893 * RETURN: Status 860 * RETURN: Status
@@ -1198,7 +1165,7 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
1198 1165
1199 if (walk_state->op_info->flags & AML_CREATE) { 1166 if (walk_state->op_info->flags & AML_CREATE) {
1200 /* 1167 /*
1201 * Backup to beginning of create_XXXfield declaration (1 for 1168 * Backup to beginning of create_xXXfield declaration (1 for
1202 * Opcode) 1169 * Opcode)
1203 * 1170 *
1204 * body_length is unknown until we parse the body 1171 * body_length is unknown until we parse the body
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c
index 1793d934aa3..bed08de7528 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -59,7 +59,7 @@ static const u8 acpi_gbl_argument_count[] =
59 * 59 *
60 * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands> 60 * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands>
61 * The name is a simple ascii string, the operand specifier is an 61 * The name is a simple ascii string, the operand specifier is an
62 * ascii string with one letter per operand. The letter specifies 62 * ascii string with one letter per operand. The letter specifies
63 * the operand type. 63 * the operand type.
64 * 64 *
65 ******************************************************************************/ 65 ******************************************************************************/
@@ -183,7 +183,7 @@ static const u8 acpi_gbl_argument_count[] =
183 ******************************************************************************/ 183 ******************************************************************************/
184 184
185/* 185/*
186 * Master Opcode information table. A summary of everything we know about each 186 * Master Opcode information table. A summary of everything we know about each
187 * opcode, all in one place. 187 * opcode, all in one place.
188 */ 188 */
189const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { 189const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
@@ -392,12 +392,10 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
392 AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), 392 AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
393/* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, 393/* 38 */ ACPI_OP("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY,
394 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, 394 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R,
395 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | 395 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
396 AML_CONSTANT),
397/* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, 396/* 39 */ ACPI_OP("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY,
398 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, 397 AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R,
399 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | 398 AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
400 AML_CONSTANT),
401/* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, 399/* 3A */ ACPI_OP("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY,
402 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, 400 AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R,
403 AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), 401 AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
@@ -497,8 +495,7 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
497 AML_NSNODE | AML_NAMED | AML_DEFER), 495 AML_NSNODE | AML_NAMED | AML_DEFER),
498/* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, 496/* 59 */ ACPI_OP("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY,
499 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, 497 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD,
500 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | 498 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
501 AML_FIELD),
502/* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, 499/* 5A */ ACPI_OP("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP,
503 ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, 500 ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT,
504 AML_TYPE_NAMED_NO_OBJ, 501 AML_TYPE_NAMED_NO_OBJ,
@@ -522,13 +519,12 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
522/* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, 519/* 5E */ ACPI_OP("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP,
523 ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, 520 ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT,
524 AML_TYPE_NAMED_FIELD, 521 AML_TYPE_NAMED_FIELD,
525 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | 522 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
526 AML_FIELD),
527/* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, 523/* 5F */ ACPI_OP("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP,
528 ACPI_TYPE_LOCAL_BANK_FIELD, 524 ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT,
529 AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, 525 AML_TYPE_NAMED_FIELD,
530 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | 526 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD |
531 AML_FIELD | AML_DEFER), 527 AML_DEFER),
532 528
533/* Internal opcodes that map to invalid AML opcodes */ 529/* Internal opcodes that map to invalid AML opcodes */
534 530
@@ -636,23 +632,13 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
636/* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, 632/* 7D */ ACPI_OP("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP,
637 ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, 633 ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT,
638 AML_TYPE_NAMED_NO_OBJ, 634 AML_TYPE_NAMED_NO_OBJ,
639 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | 635 AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE),
640 AML_NSNODE),
641 636
642/* ACPI 3.0 opcodes */ 637/* ACPI 3.0 opcodes */
643 638
644/* 7E */ ACPI_OP("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, 639/* 7E */ ACPI_OP("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY,
645 AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, 640 AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R,
646 AML_FLAGS_EXEC_0A_0T_1R), 641 AML_FLAGS_EXEC_0A_0T_1R)
647
648/* ACPI 5.0 opcodes */
649
650/* 7F */ ACPI_OP("-ConnectField-", ARGP_CONNECTFIELD_OP,
651 ARGI_CONNECTFIELD_OP, ACPI_TYPE_ANY,
652 AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS),
653/* 80 */ ACPI_OP("-ExtAccessField-", ARGP_CONNECTFIELD_OP,
654 ARGI_CONNECTFIELD_OP, ACPI_TYPE_ANY,
655 AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0)
656 642
657/*! [End] no source code translation !*/ 643/*! [End] no source code translation !*/
658}; 644};
@@ -671,7 +657,7 @@ static const u8 acpi_gbl_short_op_index[256] = {
671/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 657/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
672/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, 658/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
673/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, 659/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
674/* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 660/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
675/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 661/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
676/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 662/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
677/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, 663/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
@@ -700,7 +686,7 @@ static const u8 acpi_gbl_short_op_index[256] = {
700 686
701/* 687/*
702 * This table is indexed by the second opcode of the extended opcode 688 * This table is indexed by the second opcode of the extended opcode
703 * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info) 689 * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info)
704 */ 690 */
705static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = { 691static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = {
706/* 0 1 2 3 4 5 6 7 */ 692/* 0 1 2 3 4 5 6 7 */
@@ -729,7 +715,7 @@ static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = {
729 * 715 *
730 * FUNCTION: acpi_ps_get_opcode_info 716 * FUNCTION: acpi_ps_get_opcode_info
731 * 717 *
732 * PARAMETERS: opcode - The AML opcode 718 * PARAMETERS: Opcode - The AML opcode
733 * 719 *
734 * RETURN: A pointer to the info about the opcode. 720 * RETURN: A pointer to the info about the opcode.
735 * 721 *
@@ -774,7 +760,7 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
774 * 760 *
775 * FUNCTION: acpi_ps_get_opcode_name 761 * FUNCTION: acpi_ps_get_opcode_name
776 * 762 *
777 * PARAMETERS: opcode - The AML opcode 763 * PARAMETERS: Opcode - The AML opcode
778 * 764 *
779 * RETURN: A pointer to the name of the opcode (ASCII String) 765 * RETURN: A pointer to the name of the opcode (ASCII String)
780 * Note: Never returns NULL. 766 * Note: Never returns NULL.
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c
index 2494caf4775..9bb0cbd37b5 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -43,9 +43,9 @@
43 43
44/* 44/*
45 * Parse the AML and build an operation tree as most interpreters, 45 * Parse the AML and build an operation tree as most interpreters,
46 * like Perl, do. Parsing is done by hand rather than with a YACC 46 * like Perl, do. Parsing is done by hand rather than with a YACC
47 * generated parser to tightly constrain stack and dynamic memory 47 * generated parser to tightly constrain stack and dynamic memory
48 * usage. At the same time, parsing is kept flexible and the code 48 * usage. At the same time, parsing is kept flexible and the code
49 * fairly compact by parsing based on a list of AML opcode 49 * fairly compact by parsing based on a list of AML opcode
50 * templates in aml_op_info[] 50 * templates in aml_op_info[]
51 */ 51 */
@@ -64,7 +64,7 @@ ACPI_MODULE_NAME("psparse")
64 * 64 *
65 * FUNCTION: acpi_ps_get_opcode_size 65 * FUNCTION: acpi_ps_get_opcode_size
66 * 66 *
67 * PARAMETERS: opcode - An AML opcode 67 * PARAMETERS: Opcode - An AML opcode
68 * 68 *
69 * RETURN: Size of the opcode, in bytes (1 or 2) 69 * RETURN: Size of the opcode, in bytes (1 or 2)
70 * 70 *
@@ -121,7 +121,7 @@ u16 acpi_ps_peek_opcode(struct acpi_parse_state * parser_state)
121 * FUNCTION: acpi_ps_complete_this_op 121 * FUNCTION: acpi_ps_complete_this_op
122 * 122 *
123 * PARAMETERS: walk_state - Current State 123 * PARAMETERS: walk_state - Current State
124 * op - Op to complete 124 * Op - Op to complete
125 * 125 *
126 * RETURN: Status 126 * RETURN: Status
127 * 127 *
@@ -311,7 +311,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
311 * FUNCTION: acpi_ps_next_parse_state 311 * FUNCTION: acpi_ps_next_parse_state
312 * 312 *
313 * PARAMETERS: walk_state - Current state 313 * PARAMETERS: walk_state - Current state
314 * op - Current parse op 314 * Op - Current parse op
315 * callback_status - Status from previous operation 315 * callback_status - Status from previous operation
316 * 316 *
317 * RETURN: Status 317 * RETURN: Status
@@ -379,7 +379,7 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
379 case AE_CTRL_FALSE: 379 case AE_CTRL_FALSE:
380 /* 380 /*
381 * Either an IF/WHILE Predicate was false or we encountered a BREAK 381 * Either an IF/WHILE Predicate was false or we encountered a BREAK
382 * opcode. In both cases, we do not execute the rest of the 382 * opcode. In both cases, we do not execute the rest of the
383 * package; We simply close out the parent (finishing the walk of 383 * package; We simply close out the parent (finishing the walk of
384 * this branch of the tree) and continue execution at the parent 384 * this branch of the tree) and continue execution at the parent
385 * level. 385 * level.
@@ -459,9 +459,8 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
459 459
460 /* Executing a control method - additional cleanup */ 460 /* Executing a control method - additional cleanup */
461 461
462 acpi_ds_terminate_control_method(walk_state-> 462 acpi_ds_terminate_control_method(
463 method_desc, 463 walk_state->method_desc, walk_state);
464 walk_state);
465 } 464 }
466 465
467 acpi_ds_delete_walk_state(walk_state); 466 acpi_ds_delete_walk_state(walk_state);
@@ -488,7 +487,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
488 acpi_gbl_current_walk_list = thread; 487 acpi_gbl_current_walk_list = thread;
489 488
490 /* 489 /*
491 * Execute the walk loop as long as there is a valid Walk State. This 490 * Execute the walk loop as long as there is a valid Walk State. This
492 * handles nested control method invocations without recursion. 491 * handles nested control method invocations without recursion.
493 */ 492 */
494 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "State=%p\n", walk_state)); 493 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "State=%p\n", walk_state));
diff --git a/drivers/acpi/acpica/psscope.c b/drivers/acpi/acpica/psscope.c
index 608dc20dc17..a5faa1323a0 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -93,7 +93,7 @@ u8 acpi_ps_has_completed_scope(struct acpi_parse_state * parser_state)
93 * FUNCTION: acpi_ps_init_scope 93 * FUNCTION: acpi_ps_init_scope
94 * 94 *
95 * PARAMETERS: parser_state - Current parser state object 95 * PARAMETERS: parser_state - Current parser state object
96 * root - the Root Node of this new scope 96 * Root - the Root Node of this new scope
97 * 97 *
98 * RETURN: Status 98 * RETURN: Status
99 * 99 *
@@ -131,7 +131,7 @@ acpi_ps_init_scope(struct acpi_parse_state * parser_state,
131 * FUNCTION: acpi_ps_push_scope 131 * FUNCTION: acpi_ps_push_scope
132 * 132 *
133 * PARAMETERS: parser_state - Current parser state object 133 * PARAMETERS: parser_state - Current parser state object
134 * op - Current op to be pushed 134 * Op - Current op to be pushed
135 * remaining_args - List of args remaining 135 * remaining_args - List of args remaining
136 * arg_count - Fixed or variable number of args 136 * arg_count - Fixed or variable number of args
137 * 137 *
@@ -184,7 +184,7 @@ acpi_ps_push_scope(struct acpi_parse_state *parser_state,
184 * FUNCTION: acpi_ps_pop_scope 184 * FUNCTION: acpi_ps_pop_scope
185 * 185 *
186 * PARAMETERS: parser_state - Current parser state object 186 * PARAMETERS: parser_state - Current parser state object
187 * op - Where the popped op is returned 187 * Op - Where the popped op is returned
188 * arg_list - Where the popped "next argument" is 188 * arg_list - Where the popped "next argument" is
189 * returned 189 * returned
190 * arg_count - Count of objects in arg_list 190 * arg_count - Count of objects in arg_list
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c
index fdb2e71f304..f1464c03aa4 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -58,8 +58,8 @@ union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op);
58 * 58 *
59 * FUNCTION: acpi_ps_get_arg 59 * FUNCTION: acpi_ps_get_arg
60 * 60 *
61 * PARAMETERS: op - Get an argument for this op 61 * PARAMETERS: Op - Get an argument for this op
62 * argn - Nth argument to get 62 * Argn - Nth argument to get
63 * 63 *
64 * RETURN: The argument (as an Op object). NULL if argument does not exist 64 * RETURN: The argument (as an Op object). NULL if argument does not exist
65 * 65 *
@@ -74,12 +74,6 @@ union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn)
74 74
75 ACPI_FUNCTION_ENTRY(); 75 ACPI_FUNCTION_ENTRY();
76 76
77/*
78 if (Op->Common.aml_opcode == AML_INT_CONNECTION_OP)
79 {
80 return (Op->Common.Value.Arg);
81 }
82*/
83 /* Get the info structure for this opcode */ 77 /* Get the info structure for this opcode */
84 78
85 op_info = acpi_ps_get_opcode_info(op->common.aml_opcode); 79 op_info = acpi_ps_get_opcode_info(op->common.aml_opcode);
@@ -114,8 +108,8 @@ union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn)
114 * 108 *
115 * FUNCTION: acpi_ps_append_arg 109 * FUNCTION: acpi_ps_append_arg
116 * 110 *
117 * PARAMETERS: op - Append an argument to this Op. 111 * PARAMETERS: Op - Append an argument to this Op.
118 * arg - Argument Op to append 112 * Arg - Argument Op to append
119 * 113 *
120 * RETURN: None. 114 * RETURN: None.
121 * 115 *
@@ -188,8 +182,8 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg)
188 * 182 *
189 * FUNCTION: acpi_ps_get_depth_next 183 * FUNCTION: acpi_ps_get_depth_next
190 * 184 *
191 * PARAMETERS: origin - Root of subtree to search 185 * PARAMETERS: Origin - Root of subtree to search
192 * op - Last (previous) Op that was found 186 * Op - Last (previous) Op that was found
193 * 187 *
194 * RETURN: Next Op found in the search. 188 * RETURN: Next Op found in the search.
195 * 189 *
@@ -261,7 +255,7 @@ union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin,
261 * 255 *
262 * FUNCTION: acpi_ps_get_child 256 * FUNCTION: acpi_ps_get_child
263 * 257 *
264 * PARAMETERS: op - Get the child of this Op 258 * PARAMETERS: Op - Get the child of this Op
265 * 259 *
266 * RETURN: Child Op, Null if none is found. 260 * RETURN: Child Op, Null if none is found.
267 * 261 *
diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c
index 4137dcb352d..7eda7850342 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -77,8 +77,8 @@ union acpi_parse_object *acpi_ps_create_scope_op(void)
77 * 77 *
78 * FUNCTION: acpi_ps_init_op 78 * FUNCTION: acpi_ps_init_op
79 * 79 *
80 * PARAMETERS: op - A newly allocated Op object 80 * PARAMETERS: Op - A newly allocated Op object
81 * opcode - Opcode to store in the Op 81 * Opcode - Opcode to store in the Op
82 * 82 *
83 * RETURN: None 83 * RETURN: None
84 * 84 *
@@ -103,12 +103,12 @@ void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode)
103 * 103 *
104 * FUNCTION: acpi_ps_alloc_op 104 * FUNCTION: acpi_ps_alloc_op
105 * 105 *
106 * PARAMETERS: opcode - Opcode that will be stored in the new Op 106 * PARAMETERS: Opcode - Opcode that will be stored in the new Op
107 * 107 *
108 * RETURN: Pointer to the new Op, null on failure 108 * RETURN: Pointer to the new Op, null on failure
109 * 109 *
110 * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on 110 * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
111 * opcode. A cache of opcodes is available for the pure 111 * opcode. A cache of opcodes is available for the pure
112 * GENERIC_OP, since this is by far the most commonly used. 112 * GENERIC_OP, since this is by far the most commonly used.
113 * 113 *
114 ******************************************************************************/ 114 ******************************************************************************/
@@ -160,11 +160,11 @@ union acpi_parse_object *acpi_ps_alloc_op(u16 opcode)
160 * 160 *
161 * FUNCTION: acpi_ps_free_op 161 * FUNCTION: acpi_ps_free_op
162 * 162 *
163 * PARAMETERS: op - Op to be freed 163 * PARAMETERS: Op - Op to be freed
164 * 164 *
165 * RETURN: None. 165 * RETURN: None.
166 * 166 *
167 * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list 167 * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list
168 * or actually free it. 168 * or actually free it.
169 * 169 *
170 ******************************************************************************/ 170 ******************************************************************************/
diff --git a/drivers/acpi/acpica/pswalk.c b/drivers/acpi/acpica/pswalk.c
index ab96cf47896..3312d6368bf 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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 963e1622579..8086805d449 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -66,7 +66,7 @@ acpi_ps_update_parameter_list(struct acpi_evaluate_info *info, u16 action);
66 * PARAMETERS: method_name - Valid ACPI name string 66 * PARAMETERS: method_name - Valid ACPI name string
67 * debug_level - Optional level mask. 0 to use default 67 * debug_level - Optional level mask. 0 to use default
68 * debug_layer - Optional layer mask. 0 to use default 68 * debug_layer - Optional layer mask. 0 to use default
69 * flags - bit 1: one shot(1) or persistent(0) 69 * Flags - bit 1: one shot(1) or persistent(0)
70 * 70 *
71 * RETURN: Status 71 * RETURN: Status
72 * 72 *
@@ -105,7 +105,7 @@ acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags)
105 * 105 *
106 * FUNCTION: acpi_ps_start_trace 106 * FUNCTION: acpi_ps_start_trace
107 * 107 *
108 * PARAMETERS: info - Method info struct 108 * PARAMETERS: Info - Method info struct
109 * 109 *
110 * RETURN: None 110 * RETURN: None
111 * 111 *
@@ -150,7 +150,7 @@ static void acpi_ps_start_trace(struct acpi_evaluate_info *info)
150 * 150 *
151 * FUNCTION: acpi_ps_stop_trace 151 * FUNCTION: acpi_ps_stop_trace
152 * 152 *
153 * PARAMETERS: info - Method info struct 153 * PARAMETERS: Info - Method info struct
154 * 154 *
155 * RETURN: None 155 * RETURN: None
156 * 156 *
@@ -193,10 +193,10 @@ static void acpi_ps_stop_trace(struct acpi_evaluate_info *info)
193 * 193 *
194 * FUNCTION: acpi_ps_execute_method 194 * FUNCTION: acpi_ps_execute_method
195 * 195 *
196 * PARAMETERS: info - Method info block, contains: 196 * PARAMETERS: Info - Method info block, contains:
197 * node - Method Node to execute 197 * Node - Method Node to execute
198 * obj_desc - Method object 198 * obj_desc - Method object
199 * parameters - List of parameters to pass to the method, 199 * Parameters - List of parameters to pass to the method,
200 * terminated by NULL. Params itself may be 200 * terminated by NULL. Params itself may be
201 * NULL if no parameters are being passed. 201 * NULL if no parameters are being passed.
202 * return_object - Where to put method's return value (if 202 * return_object - Where to put method's return value (if
@@ -361,9 +361,9 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
361 * 361 *
362 * FUNCTION: acpi_ps_update_parameter_list 362 * FUNCTION: acpi_ps_update_parameter_list
363 * 363 *
364 * PARAMETERS: info - See struct acpi_evaluate_info 364 * PARAMETERS: Info - See struct acpi_evaluate_info
365 * (Used: parameter_type and Parameters) 365 * (Used: parameter_type and Parameters)
366 * action - Add or Remove reference 366 * Action - Add or Remove reference
367 * 367 *
368 * RETURN: Status 368 * RETURN: Status
369 * 369 *
diff --git a/drivers/acpi/acpica/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index 856ff075b6a..9e66f907842 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,8 +182,8 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {
182 182
183 /* Revision ID */ 183 /* Revision ID */
184 184
185 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_ID), 185 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_iD),
186 AML_OFFSET(ext_address64.revision_ID), 186 AML_OFFSET(ext_address64.revision_iD),
187 1}, 187 1},
188 /* 188 /*
189 * These fields are contiguous in both the source and destination: 189 * These fields are contiguous in both the source and destination:
@@ -215,7 +215,7 @@ static struct acpi_rsconvert_info acpi_rs_convert_general_flags[6] = {
215 AML_OFFSET(address.resource_type), 215 AML_OFFSET(address.resource_type),
216 1}, 216 1},
217 217
218 /* General flags - Consume, Decode, min_fixed, max_fixed */ 218 /* General Flags - Consume, Decode, min_fixed, max_fixed */
219 219
220 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer), 220 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer),
221 AML_OFFSET(address.flags), 221 AML_OFFSET(address.flags),
@@ -293,8 +293,8 @@ static struct acpi_rsconvert_info acpi_rs_convert_io_flags[4] = {
293 * 293 *
294 * FUNCTION: acpi_rs_get_address_common 294 * FUNCTION: acpi_rs_get_address_common
295 * 295 *
296 * PARAMETERS: resource - Pointer to the internal resource struct 296 * PARAMETERS: Resource - Pointer to the internal resource struct
297 * aml - Pointer to the AML resource descriptor 297 * Aml - Pointer to the AML resource descriptor
298 * 298 *
299 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise 299 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
300 * 300 *
@@ -343,8 +343,8 @@ acpi_rs_get_address_common(struct acpi_resource *resource,
343 * 343 *
344 * FUNCTION: acpi_rs_set_address_common 344 * FUNCTION: acpi_rs_set_address_common
345 * 345 *
346 * PARAMETERS: aml - Pointer to the AML resource descriptor 346 * PARAMETERS: Aml - Pointer to the AML resource descriptor
347 * resource - Pointer to the internal resource struct 347 * Resource - Pointer to the internal resource struct
348 * 348 *
349 * RETURN: None 349 * RETURN: None
350 * 350 *
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 147feb6aa2a..3a8a89ec2ca 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -173,7 +173,7 @@ acpi_rs_stream_option_length(u32 resource_length,
173 * 173 *
174 * FUNCTION: acpi_rs_get_aml_length 174 * FUNCTION: acpi_rs_get_aml_length
175 * 175 *
176 * PARAMETERS: resource - Pointer to the resource linked list 176 * PARAMETERS: Resource - Pointer to the resource linked list
177 * size_needed - Where the required size is returned 177 * size_needed - Where the required size is returned
178 * 178 *
179 * RETURN: Status 179 * RETURN: Status
@@ -313,38 +313,6 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
313 resource_source)); 313 resource_source));
314 break; 314 break;
315 315
316 case ACPI_RESOURCE_TYPE_GPIO:
317
318 total_size =
319 (acpi_rs_length) (total_size +
320 (resource->data.gpio.
321 pin_table_length * 2) +
322 resource->data.gpio.
323 resource_source.string_length +
324 resource->data.gpio.
325 vendor_length);
326
327 break;
328
329 case ACPI_RESOURCE_TYPE_SERIAL_BUS:
330
331 total_size =
332 acpi_gbl_aml_resource_serial_bus_sizes[resource->
333 data.
334 common_serial_bus.
335 type];
336
337 total_size = (acpi_rs_length) (total_size +
338 resource->data.
339 i2c_serial_bus.
340 resource_source.
341 string_length +
342 resource->data.
343 i2c_serial_bus.
344 vendor_length);
345
346 break;
347
348 default: 316 default:
349 break; 317 break;
350 } 318 }
@@ -394,11 +362,10 @@ acpi_rs_get_list_length(u8 * aml_buffer,
394 u32 extra_struct_bytes; 362 u32 extra_struct_bytes;
395 u8 resource_index; 363 u8 resource_index;
396 u8 minimum_aml_resource_length; 364 u8 minimum_aml_resource_length;
397 union aml_resource *aml_resource;
398 365
399 ACPI_FUNCTION_TRACE(rs_get_list_length); 366 ACPI_FUNCTION_TRACE(rs_get_list_length);
400 367
401 *size_needed = ACPI_RS_SIZE_MIN; /* Minimum size is one end_tag */ 368 *size_needed = 0;
402 end_aml = aml_buffer + aml_buffer_length; 369 end_aml = aml_buffer + aml_buffer_length;
403 370
404 /* Walk the list of AML resource descriptors */ 371 /* Walk the list of AML resource descriptors */
@@ -409,15 +376,9 @@ acpi_rs_get_list_length(u8 * aml_buffer,
409 376
410 status = acpi_ut_validate_resource(aml_buffer, &resource_index); 377 status = acpi_ut_validate_resource(aml_buffer, &resource_index);
411 if (ACPI_FAILURE(status)) { 378 if (ACPI_FAILURE(status)) {
412 /*
413 * Exit on failure. Cannot continue because the descriptor length
414 * may be bogus also.
415 */
416 return_ACPI_STATUS(status); 379 return_ACPI_STATUS(status);
417 } 380 }
418 381
419 aml_resource = (void *)aml_buffer;
420
421 /* Get the resource length and base (minimum) AML size */ 382 /* Get the resource length and base (minimum) AML size */
422 383
423 resource_length = acpi_ut_get_resource_length(aml_buffer); 384 resource_length = acpi_ut_get_resource_length(aml_buffer);
@@ -457,21 +418,14 @@ acpi_rs_get_list_length(u8 * aml_buffer,
457 * Get the number of vendor data bytes 418 * Get the number of vendor data bytes
458 */ 419 */
459 extra_struct_bytes = resource_length; 420 extra_struct_bytes = resource_length;
460
461 /*
462 * There is already one byte included in the minimum
463 * descriptor size. If there are extra struct bytes,
464 * subtract one from the count.
465 */
466 if (extra_struct_bytes) {
467 extra_struct_bytes--;
468 }
469 break; 421 break;
470 422
471 case ACPI_RESOURCE_NAME_END_TAG: 423 case ACPI_RESOURCE_NAME_END_TAG:
472 /* 424 /*
473 * End Tag: This is the normal exit 425 * End Tag:
426 * This is the normal exit, add size of end_tag
474 */ 427 */
428 *size_needed += ACPI_RS_SIZE_MIN;
475 return_ACPI_STATUS(AE_OK); 429 return_ACPI_STATUS(AE_OK);
476 430
477 case ACPI_RESOURCE_NAME_ADDRESS32: 431 case ACPI_RESOURCE_NAME_ADDRESS32:
@@ -503,33 +457,6 @@ acpi_rs_get_list_length(u8 * aml_buffer,
503 minimum_aml_resource_length); 457 minimum_aml_resource_length);
504 break; 458 break;
505 459
506 case ACPI_RESOURCE_NAME_GPIO:
507
508 /* Vendor data is optional */
509
510 if (aml_resource->gpio.vendor_length) {
511 extra_struct_bytes +=
512 aml_resource->gpio.vendor_offset -
513 aml_resource->gpio.pin_table_offset +
514 aml_resource->gpio.vendor_length;
515 } else {
516 extra_struct_bytes +=
517 aml_resource->large_header.resource_length +
518 sizeof(struct aml_resource_large_header) -
519 aml_resource->gpio.pin_table_offset;
520 }
521 break;
522
523 case ACPI_RESOURCE_NAME_SERIAL_BUS:
524
525 minimum_aml_resource_length =
526 acpi_gbl_resource_aml_serial_bus_sizes
527 [aml_resource->common_serial_bus.type];
528 extra_struct_bytes +=
529 aml_resource->common_serial_bus.resource_length -
530 minimum_aml_resource_length;
531 break;
532
533 default: 460 default:
534 break; 461 break;
535 } 462 }
@@ -540,18 +467,9 @@ acpi_rs_get_list_length(u8 * aml_buffer,
540 * Important: Round the size up for the appropriate alignment. This 467 * Important: Round the size up for the appropriate alignment. This
541 * is a requirement on IA64. 468 * is a requirement on IA64.
542 */ 469 */
543 if (acpi_ut_get_resource_type(aml_buffer) == 470 buffer_size = acpi_gbl_resource_struct_sizes[resource_index] +
544 ACPI_RESOURCE_NAME_SERIAL_BUS) { 471 extra_struct_bytes;
545 buffer_size = 472 buffer_size = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(buffer_size);
546 acpi_gbl_resource_struct_serial_bus_sizes
547 [aml_resource->common_serial_bus.type] +
548 extra_struct_bytes;
549 } else {
550 buffer_size =
551 acpi_gbl_resource_struct_sizes[resource_index] +
552 extra_struct_bytes;
553 }
554 buffer_size = (u32)ACPI_ROUND_UP_TO_NATIVE_WORD(buffer_size);
555 473
556 *size_needed += buffer_size; 474 *size_needed += buffer_size;
557 475
@@ -610,7 +528,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
610 /* 528 /*
611 * Calculate the size of the return buffer. 529 * Calculate the size of the return buffer.
612 * The base size is the number of elements * the sizes of the 530 * The base size is the number of elements * the sizes of the
613 * structures. Additional space for the strings is added below. 531 * structures. Additional space for the strings is added below.
614 * The minus one is to subtract the size of the u8 Source[1] 532 * The minus one is to subtract the size of the u8 Source[1]
615 * member because it is added below. 533 * member because it is added below.
616 * 534 *
@@ -673,7 +591,8 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
673 (*sub_object_list)->string. 591 (*sub_object_list)->string.
674 length + 1); 592 length + 1);
675 } else { 593 } else {
676 temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node); 594 temp_size_needed +=
595 acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
677 } 596 }
678 } else { 597 } else {
679 /* 598 /*
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index 311cbc4f05f..4ce6e1147e8 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,70 +51,6 @@ ACPI_MODULE_NAME("rscreate")
51 51
52/******************************************************************************* 52/*******************************************************************************
53 * 53 *
54 * FUNCTION: acpi_buffer_to_resource
55 *
56 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
57 * aml_buffer_length - Length of the aml_buffer
58 * resource_ptr - Where the converted resource is returned
59 *
60 * RETURN: Status
61 *
62 * DESCRIPTION: Convert a raw AML buffer to a resource list
63 *
64 ******************************************************************************/
65acpi_status
66acpi_buffer_to_resource(u8 *aml_buffer,
67 u16 aml_buffer_length,
68 struct acpi_resource **resource_ptr)
69{
70 acpi_status status;
71 acpi_size list_size_needed;
72 void *resource;
73 void *current_resource_ptr;
74
75 /*
76 * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag
77 * is not required here.
78 */
79
80 /* Get the required length for the converted resource */
81
82 status = acpi_rs_get_list_length(aml_buffer, aml_buffer_length,
83 &list_size_needed);
84 if (status == AE_AML_NO_RESOURCE_END_TAG) {
85 status = AE_OK;
86 }
87 if (ACPI_FAILURE(status)) {
88 return (status);
89 }
90
91 /* Allocate a buffer for the converted resource */
92
93 resource = ACPI_ALLOCATE_ZEROED(list_size_needed);
94 current_resource_ptr = resource;
95 if (!resource) {
96 return (AE_NO_MEMORY);
97 }
98
99 /* Perform the AML-to-Resource conversion */
100
101 status = acpi_ut_walk_aml_resources(aml_buffer, aml_buffer_length,
102 acpi_rs_convert_aml_to_resources,
103 &current_resource_ptr);
104 if (status == AE_AML_NO_RESOURCE_END_TAG) {
105 status = AE_OK;
106 }
107 if (ACPI_FAILURE(status)) {
108 ACPI_FREE(resource);
109 } else {
110 *resource_ptr = resource;
111 }
112
113 return (status);
114}
115
116/*******************************************************************************
117 *
118 * FUNCTION: acpi_rs_create_resource_list 54 * FUNCTION: acpi_rs_create_resource_list
119 * 55 *
120 * PARAMETERS: aml_buffer - Pointer to the resource byte stream 56 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
@@ -130,10 +66,9 @@ acpi_buffer_to_resource(u8 *aml_buffer,
130 * of device resources. 66 * of device resources.
131 * 67 *
132 ******************************************************************************/ 68 ******************************************************************************/
133
134acpi_status 69acpi_status
135acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, 70acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
136 struct acpi_buffer * output_buffer) 71 struct acpi_buffer *output_buffer)
137{ 72{
138 73
139 acpi_status status; 74 acpi_status status;
@@ -190,8 +125,8 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
190 * 125 *
191 * FUNCTION: acpi_rs_create_pci_routing_table 126 * FUNCTION: acpi_rs_create_pci_routing_table
192 * 127 *
193 * PARAMETERS: package_object - Pointer to a package containing one 128 * PARAMETERS: package_object - Pointer to a union acpi_operand_object
194 * of more ACPI_OPERAND_OBJECTs 129 * package
195 * output_buffer - Pointer to the user's buffer 130 * output_buffer - Pointer to the user's buffer
196 * 131 *
197 * RETURN: Status AE_OK if okay, else a valid acpi_status code. 132 * RETURN: Status AE_OK if okay, else a valid acpi_status code.
@@ -199,7 +134,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
199 * AE_BUFFER_OVERFLOW and output_buffer->Length will point 134 * AE_BUFFER_OVERFLOW and output_buffer->Length will point
200 * to the size buffer needed. 135 * to the size buffer needed.
201 * 136 *
202 * DESCRIPTION: Takes the union acpi_operand_object package and creates a 137 * DESCRIPTION: Takes the union acpi_operand_object package and creates a
203 * linked list of PCI interrupt descriptions 138 * linked list of PCI interrupt descriptions
204 * 139 *
205 * NOTE: It is the caller's responsibility to ensure that the start of the 140 * NOTE: It is the caller's responsibility to ensure that the start of the
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 4d11b072388..33db7520c74 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -61,13 +61,11 @@ static void acpi_rs_out_integer64(char *title, u64 value);
61 61
62static void acpi_rs_out_title(char *title); 62static void acpi_rs_out_title(char *title);
63 63
64static void acpi_rs_dump_byte_list(u16 length, u8 *data); 64static void acpi_rs_dump_byte_list(u16 length, u8 * data);
65 65
66static void acpi_rs_dump_word_list(u16 length, u16 *data); 66static void acpi_rs_dump_dword_list(u8 length, u32 * data);
67 67
68static void acpi_rs_dump_dword_list(u8 length, u32 *data); 68static void acpi_rs_dump_short_byte_list(u8 length, u8 * data);
69
70static void acpi_rs_dump_short_byte_list(u8 length, u8 *data);
71 69
72static void 70static void
73acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source); 71acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
@@ -311,125 +309,6 @@ struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
311 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL} 309 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
312}; 310};
313 311
314struct acpi_rsdump_info acpi_rs_dump_gpio[16] = {
315 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL},
316 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL},
317 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type),
318 "ConnectionType", acpi_gbl_ct_decode},
319 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer),
320 "ProducerConsumer", acpi_gbl_consume_decode},
321 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig",
322 acpi_gbl_ppc_decode},
323 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharable",
324 acpi_gbl_shr_decode},
325 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction),
326 "IoRestriction", acpi_gbl_ior_decode},
327 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering",
328 acpi_gbl_he_decode},
329 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity",
330 acpi_gbl_ll_decode},
331 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength",
332 NULL},
333 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout),
334 "DebounceTimeout", NULL},
335 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source),
336 "ResourceSource", NULL},
337 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length),
338 "PinTableLength", NULL},
339 {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL},
340 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength",
341 NULL},
342 {ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData",
343 NULL},
344};
345
346struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = {
347 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma),
348 "FixedDma", NULL},
349 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines),
350 "RequestLines", NULL},
351 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels",
352 NULL},
353 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth",
354 acpi_gbl_dts_decode},
355};
356
357#define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
358 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \
359 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \
360 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \
361 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \
362 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \
363 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \
364 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \
365 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \
366 {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL},
367
368struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = {
369 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus),
370 "Common Serial Bus", NULL},
371 ACPI_RS_DUMP_COMMON_SERIAL_BUS
372};
373
374struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = {
375 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus),
376 "I2C Serial Bus", NULL},
377 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
378 ACPI_RSD_OFFSET(i2c_serial_bus.
379 access_mode),
380 "AccessMode", acpi_gbl_am_decode},
381 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed),
382 "ConnectionSpeed", NULL},
383 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address),
384 "SlaveAddress", NULL},
385};
386
387struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = {
388 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus),
389 "Spi Serial Bus", NULL},
390 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
391 ACPI_RSD_OFFSET(spi_serial_bus.
392 wire_mode), "WireMode",
393 acpi_gbl_wm_decode},
394 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity),
395 "DevicePolarity", acpi_gbl_dp_decode},
396 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length),
397 "DataBitLength", NULL},
398 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase),
399 "ClockPhase", acpi_gbl_cph_decode},
400 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity),
401 "ClockPolarity", acpi_gbl_cpo_decode},
402 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection),
403 "DeviceSelection", NULL},
404 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed),
405 "ConnectionSpeed", NULL},
406};
407
408struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = {
409 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus),
410 "Uart Serial Bus", NULL},
411 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG,
412 ACPI_RSD_OFFSET(uart_serial_bus.
413 flow_control),
414 "FlowControl", acpi_gbl_fc_decode},
415 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits),
416 "StopBits", acpi_gbl_sb_decode},
417 {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits),
418 "DataBits", acpi_gbl_bpb_decode},
419 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian",
420 acpi_gbl_ed_decode},
421 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity",
422 acpi_gbl_pt_decode},
423 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled),
424 "LinesEnabled", NULL},
425 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size),
426 "RxFifoSize", NULL},
427 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size),
428 "TxFifoSize", NULL},
429 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate),
430 "ConnectionSpeed", NULL},
431};
432
433/* 312/*
434 * Tables used for common address descriptor flag fields 313 * Tables used for common address descriptor flag fields
435 */ 314 */
@@ -534,14 +413,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
534 /* Data items, 8/16/32/64 bit */ 413 /* Data items, 8/16/32/64 bit */
535 414
536 case ACPI_RSD_UINT8: 415 case ACPI_RSD_UINT8:
537 if (table->pointer) { 416 acpi_rs_out_integer8(name, ACPI_GET8(target));
538 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
539 table->
540 pointer
541 [*target]));
542 } else {
543 acpi_rs_out_integer8(name, ACPI_GET8(target));
544 }
545 break; 417 break;
546 418
547 case ACPI_RSD_UINT16: 419 case ACPI_RSD_UINT16:
@@ -572,13 +444,6 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
572 0x03])); 444 0x03]));
573 break; 445 break;
574 446
575 case ACPI_RSD_3BITFLAG:
576 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
577 table->
578 pointer[*target &
579 0x07]));
580 break;
581
582 case ACPI_RSD_SHORTLIST: 447 case ACPI_RSD_SHORTLIST:
583 /* 448 /*
584 * Short byte list (single line output) for DMA and IRQ resources 449 * Short byte list (single line output) for DMA and IRQ resources
@@ -591,20 +456,6 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
591 } 456 }
592 break; 457 break;
593 458
594 case ACPI_RSD_SHORTLISTX:
595 /*
596 * Short byte list (single line output) for GPIO vendor data
597 * Note: The list length is obtained from the previous table entry
598 */
599 if (previous_target) {
600 acpi_rs_out_title(name);
601 acpi_rs_dump_short_byte_list(*previous_target,
602 *
603 (ACPI_CAST_INDIRECT_PTR
604 (u8, target)));
605 }
606 break;
607
608 case ACPI_RSD_LONGLIST: 459 case ACPI_RSD_LONGLIST:
609 /* 460 /*
610 * Long byte list for Vendor resource data 461 * Long byte list for Vendor resource data
@@ -629,18 +480,6 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
629 } 480 }
630 break; 481 break;
631 482
632 case ACPI_RSD_WORDLIST:
633 /*
634 * Word list for GPIO Pin Table
635 * Note: The list length is obtained from the previous table entry
636 */
637 if (previous_target) {
638 acpi_rs_dump_word_list(*previous_target,
639 *(ACPI_CAST_INDIRECT_PTR
640 (u16, target)));
641 }
642 break;
643
644 case ACPI_RSD_ADDRESS: 483 case ACPI_RSD_ADDRESS:
645 /* 484 /*
646 * Common flags for all Address resources 485 * Common flags for all Address resources
@@ -703,7 +542,7 @@ acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
703 * 542 *
704 * FUNCTION: acpi_rs_dump_address_common 543 * FUNCTION: acpi_rs_dump_address_common
705 * 544 *
706 * PARAMETERS: resource - Pointer to an internal resource descriptor 545 * PARAMETERS: Resource - Pointer to an internal resource descriptor
707 * 546 *
708 * RETURN: None 547 * RETURN: None
709 * 548 *
@@ -788,20 +627,14 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
788 627
789 /* Dump the resource descriptor */ 628 /* Dump the resource descriptor */
790 629
791 if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { 630 acpi_rs_dump_descriptor(&resource_list->data,
792 acpi_rs_dump_descriptor(&resource_list->data, 631 acpi_gbl_dump_resource_dispatch[type]);
793 acpi_gbl_dump_serial_bus_dispatch
794 [resource_list->data.
795 common_serial_bus.type]);
796 } else {
797 acpi_rs_dump_descriptor(&resource_list->data,
798 acpi_gbl_dump_resource_dispatch
799 [type]);
800 }
801 632
802 /* Point to the next resource structure */ 633 /* Point to the next resource structure */
803 634
804 resource_list = ACPI_NEXT_RESOURCE(resource_list); 635 resource_list =
636 ACPI_ADD_PTR(struct acpi_resource, resource_list,
637 resource_list->length);
805 638
806 /* Exit when END_TAG descriptor is reached */ 639 /* Exit when END_TAG descriptor is reached */
807 640
@@ -850,8 +683,8 @@ void acpi_rs_dump_irq_list(u8 * route_table)
850 * 683 *
851 * FUNCTION: acpi_rs_out* 684 * FUNCTION: acpi_rs_out*
852 * 685 *
853 * PARAMETERS: title - Name of the resource field 686 * PARAMETERS: Title - Name of the resource field
854 * value - Value of the resource field 687 * Value - Value of the resource field
855 * 688 *
856 * RETURN: None 689 * RETURN: None
857 * 690 *
@@ -898,8 +731,8 @@ static void acpi_rs_out_title(char *title)
898 * 731 *
899 * FUNCTION: acpi_rs_dump*List 732 * FUNCTION: acpi_rs_dump*List
900 * 733 *
901 * PARAMETERS: length - Number of elements in the list 734 * PARAMETERS: Length - Number of elements in the list
902 * data - Start of the list 735 * Data - Start of the list
903 * 736 *
904 * RETURN: None 737 * RETURN: None
905 * 738 *
@@ -935,13 +768,4 @@ static void acpi_rs_dump_dword_list(u8 length, u32 * data)
935 } 768 }
936} 769}
937 770
938static void acpi_rs_dump_word_list(u16 length, u16 *data)
939{
940 u16 i;
941
942 for (i = 0; i < length; i++) {
943 acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);
944 }
945}
946
947#endif 771#endif
diff --git a/drivers/acpi/acpica/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index a9fa5158200..f9ea60872aa 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,10 +76,7 @@ struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = {
76 acpi_rs_convert_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ 76 acpi_rs_convert_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
77 acpi_rs_convert_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ 77 acpi_rs_convert_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
78 acpi_rs_convert_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 78 acpi_rs_convert_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
79 acpi_rs_convert_generic_reg, /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 79 acpi_rs_convert_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
80 acpi_rs_convert_gpio, /* 0x11, ACPI_RESOURCE_TYPE_GPIO */
81 acpi_rs_convert_fixed_dma, /* 0x12, ACPI_RESOURCE_TYPE_FIXED_DMA */
82 NULL, /* 0x13, ACPI_RESOURCE_TYPE_SERIAL_BUS - Use subtype table below */
83}; 80};
84 81
85/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ 82/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
@@ -97,7 +94,7 @@ struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
97 acpi_rs_convert_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ 94 acpi_rs_convert_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
98 acpi_rs_convert_io, /* 0x08, ACPI_RESOURCE_NAME_IO */ 95 acpi_rs_convert_io, /* 0x08, ACPI_RESOURCE_NAME_IO */
99 acpi_rs_convert_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ 96 acpi_rs_convert_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
100 acpi_rs_convert_fixed_dma, /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */ 97 NULL, /* 0x0A, Reserved */
101 NULL, /* 0x0B, Reserved */ 98 NULL, /* 0x0B, Reserved */
102 NULL, /* 0x0C, Reserved */ 99 NULL, /* 0x0C, Reserved */
103 NULL, /* 0x0D, Reserved */ 100 NULL, /* 0x0D, Reserved */
@@ -117,19 +114,7 @@ struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
117 acpi_rs_convert_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ 114 acpi_rs_convert_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
118 acpi_rs_convert_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ 115 acpi_rs_convert_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
119 acpi_rs_convert_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ 116 acpi_rs_convert_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
120 acpi_rs_convert_ext_address64, /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ 117 acpi_rs_convert_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
121 acpi_rs_convert_gpio, /* 0x0C, ACPI_RESOURCE_NAME_GPIO */
122 NULL, /* 0x0D, Reserved */
123 NULL, /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use subtype table below */
124};
125
126/* Subtype table for serial_bus -- I2C, SPI, and UART */
127
128struct acpi_rsconvert_info *acpi_gbl_convert_resource_serial_bus_dispatch[] = {
129 NULL,
130 acpi_rs_convert_i2c_serial_bus,
131 acpi_rs_convert_spi_serial_bus,
132 acpi_rs_convert_uart_serial_bus,
133}; 118};
134 119
135#ifdef ACPI_FUTURE_USAGE 120#ifdef ACPI_FUTURE_USAGE
@@ -155,16 +140,6 @@ struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = {
155 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ 140 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
156 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 141 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
157 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 142 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
158 acpi_rs_dump_gpio, /* ACPI_RESOURCE_TYPE_GPIO */
159 acpi_rs_dump_fixed_dma, /* ACPI_RESOURCE_TYPE_FIXED_DMA */
160 NULL, /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
161};
162
163struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[] = {
164 NULL,
165 acpi_rs_dump_i2c_serial_bus, /* AML_RESOURCE_I2C_BUS_TYPE */
166 acpi_rs_dump_spi_serial_bus, /* AML_RESOURCE_SPI_BUS_TYPE */
167 acpi_rs_dump_uart_serial_bus, /* AML_RESOURCE_UART_BUS_TYPE */
168}; 143};
169#endif 144#endif
170 145
@@ -191,10 +166,7 @@ const u8 acpi_gbl_aml_resource_sizes[] = {
191 sizeof(struct aml_resource_address64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */ 166 sizeof(struct aml_resource_address64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
192 sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ 167 sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
193 sizeof(struct aml_resource_extended_irq), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ 168 sizeof(struct aml_resource_extended_irq), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
194 sizeof(struct aml_resource_generic_register), /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ 169 sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
195 sizeof(struct aml_resource_gpio), /* ACPI_RESOURCE_TYPE_GPIO */
196 sizeof(struct aml_resource_fixed_dma), /* ACPI_RESOURCE_TYPE_FIXED_DMA */
197 sizeof(struct aml_resource_common_serialbus), /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
198}; 170};
199 171
200const u8 acpi_gbl_resource_struct_sizes[] = { 172const u8 acpi_gbl_resource_struct_sizes[] = {
@@ -210,7 +182,7 @@ const u8 acpi_gbl_resource_struct_sizes[] = {
210 ACPI_RS_SIZE_MIN, 182 ACPI_RS_SIZE_MIN,
211 ACPI_RS_SIZE(struct acpi_resource_io), 183 ACPI_RS_SIZE(struct acpi_resource_io),
212 ACPI_RS_SIZE(struct acpi_resource_fixed_io), 184 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
213 ACPI_RS_SIZE(struct acpi_resource_fixed_dma), 185 0,
214 0, 186 0,
215 0, 187 0,
216 0, 188 0,
@@ -230,21 +202,5 @@ const u8 acpi_gbl_resource_struct_sizes[] = {
230 ACPI_RS_SIZE(struct acpi_resource_address16), 202 ACPI_RS_SIZE(struct acpi_resource_address16),
231 ACPI_RS_SIZE(struct acpi_resource_extended_irq), 203 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
232 ACPI_RS_SIZE(struct acpi_resource_address64), 204 ACPI_RS_SIZE(struct acpi_resource_address64),
233 ACPI_RS_SIZE(struct acpi_resource_extended_address64), 205 ACPI_RS_SIZE(struct acpi_resource_extended_address64)
234 ACPI_RS_SIZE(struct acpi_resource_gpio),
235 ACPI_RS_SIZE(struct acpi_resource_common_serialbus)
236};
237
238const u8 acpi_gbl_aml_resource_serial_bus_sizes[] = {
239 0,
240 sizeof(struct aml_resource_i2c_serialbus),
241 sizeof(struct aml_resource_spi_serialbus),
242 sizeof(struct aml_resource_uart_serialbus),
243};
244
245const u8 acpi_gbl_resource_struct_serial_bus_sizes[] = {
246 0,
247 ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus),
248 ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),
249 ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),
250}; 206};
diff --git a/drivers/acpi/acpica/rsio.c b/drivers/acpi/acpica/rsio.c
index f6a081057a2..0c7efef008b 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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 e23a9ec248c..50b8ad21116 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -264,34 +264,3 @@ struct acpi_rsconvert_info acpi_rs_convert_dma[6] = {
264 AML_OFFSET(dma.dma_channel_mask), 264 AML_OFFSET(dma.dma_channel_mask),
265 ACPI_RS_OFFSET(data.dma.channel_count)} 265 ACPI_RS_OFFSET(data.dma.channel_count)}
266}; 266};
267
268/*******************************************************************************
269 *
270 * acpi_rs_convert_fixed_dma
271 *
272 ******************************************************************************/
273
274struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = {
275 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_DMA,
276 ACPI_RS_SIZE(struct acpi_resource_fixed_dma),
277 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_dma)},
278
279 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_DMA,
280 sizeof(struct aml_resource_fixed_dma),
281 0},
282
283 /*
284 * These fields are contiguous in both the source and destination:
285 * request_lines
286 * Channels
287 */
288
289 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_dma.request_lines),
290 AML_OFFSET(fixed_dma.request_lines),
291 2},
292
293 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_dma.width),
294 AML_OFFSET(fixed_dma.width),
295 1},
296
297};
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index 8b64db9a3fd..1bfcef736c5 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,8 +70,6 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
70 struct acpi_resource **resource_ptr = 70 struct acpi_resource **resource_ptr =
71 ACPI_CAST_INDIRECT_PTR(struct acpi_resource, context); 71 ACPI_CAST_INDIRECT_PTR(struct acpi_resource, context);
72 struct acpi_resource *resource; 72 struct acpi_resource *resource;
73 union aml_resource *aml_resource;
74 struct acpi_rsconvert_info *conversion_table;
75 acpi_status status; 73 acpi_status status;
76 74
77 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resources); 75 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resources);
@@ -86,37 +84,14 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
86 "Misaligned resource pointer %p", resource)); 84 "Misaligned resource pointer %p", resource));
87 } 85 }
88 86
89 /* Get the appropriate conversion info table */
90
91 aml_resource = ACPI_CAST_PTR(union aml_resource, aml);
92 if (acpi_ut_get_resource_type(aml) == ACPI_RESOURCE_NAME_SERIAL_BUS) {
93 if (aml_resource->common_serial_bus.type >
94 AML_RESOURCE_MAX_SERIALBUSTYPE) {
95 conversion_table = NULL;
96 } else {
97 /* This is an I2C, SPI, or UART serial_bus descriptor */
98
99 conversion_table =
100 acpi_gbl_convert_resource_serial_bus_dispatch
101 [aml_resource->common_serial_bus.type];
102 }
103 } else {
104 conversion_table =
105 acpi_gbl_get_resource_dispatch[resource_index];
106 }
107
108 if (!conversion_table) {
109 ACPI_ERROR((AE_INFO,
110 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
111 resource_index));
112 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
113 }
114
115 /* Convert the AML byte stream resource to a local resource struct */ 87 /* Convert the AML byte stream resource to a local resource struct */
116 88
117 status = 89 status =
118 acpi_rs_convert_aml_to_resource(resource, aml_resource, 90 acpi_rs_convert_aml_to_resource(resource,
119 conversion_table); 91 ACPI_CAST_PTR(union aml_resource,
92 aml),
93 acpi_gbl_get_resource_dispatch
94 [resource_index]);
120 if (ACPI_FAILURE(status)) { 95 if (ACPI_FAILURE(status)) {
121 ACPI_EXCEPTION((AE_INFO, status, 96 ACPI_EXCEPTION((AE_INFO, status,
122 "Could not convert AML resource (Type 0x%X)", 97 "Could not convert AML resource (Type 0x%X)",
@@ -131,7 +106,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
131 106
132 /* Point to the next structure in the output buffer */ 107 /* Point to the next structure in the output buffer */
133 108
134 *resource_ptr = ACPI_NEXT_RESOURCE(resource); 109 *resource_ptr = ACPI_ADD_PTR(void, resource, resource->length);
135 return_ACPI_STATUS(AE_OK); 110 return_ACPI_STATUS(AE_OK);
136} 111}
137 112
@@ -139,7 +114,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml,
139 * 114 *
140 * FUNCTION: acpi_rs_convert_resources_to_aml 115 * FUNCTION: acpi_rs_convert_resources_to_aml
141 * 116 *
142 * PARAMETERS: resource - Pointer to the resource linked list 117 * PARAMETERS: Resource - Pointer to the resource linked list
143 * aml_size_needed - Calculated size of the byte stream 118 * aml_size_needed - Calculated size of the byte stream
144 * needed from calling acpi_rs_get_aml_length() 119 * needed from calling acpi_rs_get_aml_length()
145 * The size of the output_buffer is 120 * The size of the output_buffer is
@@ -160,7 +135,6 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
160{ 135{
161 u8 *aml = output_buffer; 136 u8 *aml = output_buffer;
162 u8 *end_aml = output_buffer + aml_size_needed; 137 u8 *end_aml = output_buffer + aml_size_needed;
163 struct acpi_rsconvert_info *conversion_table;
164 acpi_status status; 138 acpi_status status;
165 139
166 ACPI_FUNCTION_TRACE(rs_convert_resources_to_aml); 140 ACPI_FUNCTION_TRACE(rs_convert_resources_to_aml);
@@ -180,34 +154,11 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
180 154
181 /* Perform the conversion */ 155 /* Perform the conversion */
182 156
183 if (resource->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { 157 status = acpi_rs_convert_resource_to_aml(resource, ACPI_CAST_PTR(union
184 if (resource->data.common_serial_bus.type > 158 aml_resource,
185 AML_RESOURCE_MAX_SERIALBUSTYPE) { 159 aml),
186 conversion_table = NULL; 160 acpi_gbl_set_resource_dispatch
187 } else { 161 [resource->type]);
188 /* This is an I2C, SPI, or UART serial_bus descriptor */
189
190 conversion_table =
191 acpi_gbl_convert_resource_serial_bus_dispatch
192 [resource->data.common_serial_bus.type];
193 }
194 } else {
195 conversion_table =
196 acpi_gbl_set_resource_dispatch[resource->type];
197 }
198
199 if (!conversion_table) {
200 ACPI_ERROR((AE_INFO,
201 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
202 resource->type));
203 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
204 }
205
206 status = acpi_rs_convert_resource_to_aml(resource,
207 ACPI_CAST_PTR(union
208 aml_resource,
209 aml),
210 conversion_table);
211 if (ACPI_FAILURE(status)) { 162 if (ACPI_FAILURE(status)) {
212 ACPI_EXCEPTION((AE_INFO, status, 163 ACPI_EXCEPTION((AE_INFO, status,
213 "Could not convert resource (type 0x%X) to AML", 164 "Could not convert resource (type 0x%X) to AML",
@@ -241,7 +192,9 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
241 192
242 /* Point to the next input resource descriptor */ 193 /* Point to the next input resource descriptor */
243 194
244 resource = ACPI_NEXT_RESOURCE(resource); 195 resource =
196 ACPI_ADD_PTR(struct acpi_resource, resource,
197 resource->length);
245 } 198 }
246 199
247 /* Completed buffer, but did not find an end_tag resource descriptor */ 200 /* Completed buffer, but did not find an end_tag resource descriptor */
diff --git a/drivers/acpi/acpica/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index 4fd611ad02b..7cc6d8625f1 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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 c6f291c2bc8..410264b22a2 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -57,9 +57,9 @@ ACPI_MODULE_NAME("rsmisc")
57 * 57 *
58 * FUNCTION: acpi_rs_convert_aml_to_resource 58 * FUNCTION: acpi_rs_convert_aml_to_resource
59 * 59 *
60 * PARAMETERS: resource - Pointer to the resource descriptor 60 * PARAMETERS: Resource - Pointer to the resource descriptor
61 * aml - Where the AML descriptor is returned 61 * Aml - Where the AML descriptor is returned
62 * info - Pointer to appropriate conversion table 62 * Info - Pointer to appropriate conversion table
63 * 63 *
64 * RETURN: Status 64 * RETURN: Status
65 * 65 *
@@ -83,10 +83,6 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
83 83
84 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource); 84 ACPI_FUNCTION_TRACE(rs_convert_aml_to_resource);
85 85
86 if (!info) {
87 return_ACPI_STATUS(AE_BAD_PARAMETER);
88 }
89
90 if (((acpi_size) resource) & 0x3) { 86 if (((acpi_size) resource) & 0x3) {
91 87
92 /* Each internal resource struct is expected to be 32-bit aligned */ 88 /* Each internal resource struct is expected to be 32-bit aligned */
@@ -105,6 +101,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
105 * table length (# of table entries) 101 * table length (# of table entries)
106 */ 102 */
107 count = INIT_TABLE_LENGTH(info); 103 count = INIT_TABLE_LENGTH(info);
104
108 while (count) { 105 while (count) {
109 /* 106 /*
110 * Source is the external AML byte stream buffer, 107 * Source is the external AML byte stream buffer,
@@ -148,14 +145,6 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
148 ((ACPI_GET8(source) >> info->value) & 0x03); 145 ((ACPI_GET8(source) >> info->value) & 0x03);
149 break; 146 break;
150 147
151 case ACPI_RSC_3BITFLAG:
152 /*
153 * Mask and shift the flag bits
154 */
155 ACPI_SET8(destination) = (u8)
156 ((ACPI_GET8(source) >> info->value) & 0x07);
157 break;
158
159 case ACPI_RSC_COUNT: 148 case ACPI_RSC_COUNT:
160 149
161 item_count = ACPI_GET8(source); 150 item_count = ACPI_GET8(source);
@@ -174,69 +163,6 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
174 (info->value * (item_count - 1)); 163 (info->value * (item_count - 1));
175 break; 164 break;
176 165
177 case ACPI_RSC_COUNT_GPIO_PIN:
178
179 target = ACPI_ADD_PTR(void, aml, info->value);
180 item_count = ACPI_GET16(target) - ACPI_GET16(source);
181
182 resource->length = resource->length + item_count;
183 item_count = item_count / 2;
184 ACPI_SET16(destination) = item_count;
185 break;
186
187 case ACPI_RSC_COUNT_GPIO_VEN:
188
189 item_count = ACPI_GET8(source);
190 ACPI_SET8(destination) = (u8)item_count;
191
192 resource->length = resource->length +
193 (info->value * item_count);
194 break;
195
196 case ACPI_RSC_COUNT_GPIO_RES:
197
198 /*
199 * Vendor data is optional (length/offset may both be zero)
200 * Examine vendor data length field first
201 */
202 target = ACPI_ADD_PTR(void, aml, (info->value + 2));
203 if (ACPI_GET16(target)) {
204
205 /* Use vendor offset to get resource source length */
206
207 target = ACPI_ADD_PTR(void, aml, info->value);
208 item_count =
209 ACPI_GET16(target) - ACPI_GET16(source);
210 } else {
211 /* No vendor data to worry about */
212
213 item_count = aml->large_header.resource_length +
214 sizeof(struct aml_resource_large_header) -
215 ACPI_GET16(source);
216 }
217
218 resource->length = resource->length + item_count;
219 ACPI_SET16(destination) = item_count;
220 break;
221
222 case ACPI_RSC_COUNT_SERIAL_VEN:
223
224 item_count = ACPI_GET16(source) - info->value;
225
226 resource->length = resource->length + item_count;
227 ACPI_SET16(destination) = item_count;
228 break;
229
230 case ACPI_RSC_COUNT_SERIAL_RES:
231
232 item_count = (aml_resource_length +
233 sizeof(struct aml_resource_large_header))
234 - ACPI_GET16(source) - info->value;
235
236 resource->length = resource->length + item_count;
237 ACPI_SET16(destination) = item_count;
238 break;
239
240 case ACPI_RSC_LENGTH: 166 case ACPI_RSC_LENGTH:
241 167
242 resource->length = resource->length + info->value; 168 resource->length = resource->length + info->value;
@@ -257,72 +183,6 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
257 info->opcode); 183 info->opcode);
258 break; 184 break;
259 185
260 case ACPI_RSC_MOVE_GPIO_PIN:
261
262 /* Generate and set the PIN data pointer */
263
264 target = (char *)ACPI_ADD_PTR(void, resource,
265 (resource->length -
266 item_count * 2));
267 *(u16 **)destination = ACPI_CAST_PTR(u16, target);
268
269 /* Copy the PIN data */
270
271 source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
272 acpi_rs_move_data(target, source, item_count,
273 info->opcode);
274 break;
275
276 case ACPI_RSC_MOVE_GPIO_RES:
277
278 /* Generate and set the resource_source string pointer */
279
280 target = (char *)ACPI_ADD_PTR(void, resource,
281 (resource->length -
282 item_count));
283 *(u8 **)destination = ACPI_CAST_PTR(u8, target);
284
285 /* Copy the resource_source string */
286
287 source = ACPI_ADD_PTR(void, aml, ACPI_GET16(source));
288 acpi_rs_move_data(target, source, item_count,
289 info->opcode);
290 break;
291
292 case ACPI_RSC_MOVE_SERIAL_VEN:
293
294 /* Generate and set the Vendor Data pointer */
295
296 target = (char *)ACPI_ADD_PTR(void, resource,
297 (resource->length -
298 item_count));
299 *(u8 **)destination = ACPI_CAST_PTR(u8, target);
300
301 /* Copy the Vendor Data */
302
303 source = ACPI_ADD_PTR(void, aml, info->value);
304 acpi_rs_move_data(target, source, item_count,
305 info->opcode);
306 break;
307
308 case ACPI_RSC_MOVE_SERIAL_RES:
309
310 /* Generate and set the resource_source string pointer */
311
312 target = (char *)ACPI_ADD_PTR(void, resource,
313 (resource->length -
314 item_count));
315 *(u8 **)destination = ACPI_CAST_PTR(u8, target);
316
317 /* Copy the resource_source string */
318
319 source =
320 ACPI_ADD_PTR(void, aml,
321 (ACPI_GET16(source) + info->value));
322 acpi_rs_move_data(target, source, item_count,
323 info->opcode);
324 break;
325
326 case ACPI_RSC_SET8: 186 case ACPI_RSC_SET8:
327 187
328 ACPI_MEMSET(destination, info->aml_offset, info->value); 188 ACPI_MEMSET(destination, info->aml_offset, info->value);
@@ -359,18 +219,13 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
359 * Optional resource_source (Index and String). This is the more 219 * Optional resource_source (Index and String). This is the more
360 * complicated case used by the Interrupt() macro 220 * complicated case used by the Interrupt() macro
361 */ 221 */
362 target = ACPI_ADD_PTR(char, resource, 222 target =
363 info->aml_offset + 223 ACPI_ADD_PTR(char, resource,
364 (item_count * 4)); 224 info->aml_offset + (item_count * 4));
365 225
366 resource->length += 226 resource->length +=
367 acpi_rs_get_resource_source(aml_resource_length, 227 acpi_rs_get_resource_source(aml_resource_length,
368 (acpi_rs_length) 228 (acpi_rs_length) (((item_count - 1) * sizeof(u32)) + info->value), destination, aml, target);
369 (((item_count -
370 1) * sizeof(u32)) +
371 info->value),
372 destination, aml,
373 target);
374 break; 229 break;
375 230
376 case ACPI_RSC_BITMASK: 231 case ACPI_RSC_BITMASK:
@@ -406,7 +261,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
406 261
407 case ACPI_RSC_EXIT_NE: 262 case ACPI_RSC_EXIT_NE:
408 /* 263 /*
409 * control - Exit conversion if not equal 264 * Control - Exit conversion if not equal
410 */ 265 */
411 switch (info->resource_offset) { 266 switch (info->resource_offset) {
412 case ACPI_RSC_COMPARE_AML_LENGTH: 267 case ACPI_RSC_COMPARE_AML_LENGTH:
@@ -454,9 +309,9 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
454 * 309 *
455 * FUNCTION: acpi_rs_convert_resource_to_aml 310 * FUNCTION: acpi_rs_convert_resource_to_aml
456 * 311 *
457 * PARAMETERS: resource - Pointer to the resource descriptor 312 * PARAMETERS: Resource - Pointer to the resource descriptor
458 * aml - Where the AML descriptor is returned 313 * Aml - Where the AML descriptor is returned
459 * info - Pointer to appropriate conversion table 314 * Info - Pointer to appropriate conversion table
460 * 315 *
461 * RETURN: Status 316 * RETURN: Status
462 * 317 *
@@ -472,7 +327,6 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
472{ 327{
473 void *source = NULL; 328 void *source = NULL;
474 void *destination; 329 void *destination;
475 char *target;
476 acpi_rsdesc_size aml_length = 0; 330 acpi_rsdesc_size aml_length = 0;
477 u8 count; 331 u8 count;
478 u16 temp16 = 0; 332 u16 temp16 = 0;
@@ -480,10 +334,6 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
480 334
481 ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml); 335 ACPI_FUNCTION_TRACE(rs_convert_resource_to_aml);
482 336
483 if (!info) {
484 return_ACPI_STATUS(AE_BAD_PARAMETER);
485 }
486
487 /* 337 /*
488 * First table entry must be ACPI_RSC_INITxxx and must contain the 338 * First table entry must be ACPI_RSC_INITxxx and must contain the
489 * table length (# of table entries) 339 * table length (# of table entries)
@@ -533,14 +383,6 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
533 ((ACPI_GET8(source) & 0x03) << info->value); 383 ((ACPI_GET8(source) & 0x03) << info->value);
534 break; 384 break;
535 385
536 case ACPI_RSC_3BITFLAG:
537 /*
538 * Mask and shift the flag bits
539 */
540 ACPI_SET8(destination) |= (u8)
541 ((ACPI_GET8(source) & 0x07) << info->value);
542 break;
543
544 case ACPI_RSC_COUNT: 386 case ACPI_RSC_COUNT:
545 387
546 item_count = ACPI_GET8(source); 388 item_count = ACPI_GET8(source);
@@ -558,63 +400,6 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
558 acpi_rs_set_resource_length(aml_length, aml); 400 acpi_rs_set_resource_length(aml_length, aml);
559 break; 401 break;
560 402
561 case ACPI_RSC_COUNT_GPIO_PIN:
562
563 item_count = ACPI_GET16(source);
564 ACPI_SET16(destination) = (u16)aml_length;
565
566 aml_length = (u16)(aml_length + item_count * 2);
567 target = ACPI_ADD_PTR(void, aml, info->value);
568 ACPI_SET16(target) = (u16)aml_length;
569 acpi_rs_set_resource_length(aml_length, aml);
570 break;
571
572 case ACPI_RSC_COUNT_GPIO_VEN:
573
574 item_count = ACPI_GET16(source);
575 ACPI_SET16(destination) = (u16)item_count;
576
577 aml_length =
578 (u16)(aml_length + (info->value * item_count));
579 acpi_rs_set_resource_length(aml_length, aml);
580 break;
581
582 case ACPI_RSC_COUNT_GPIO_RES:
583
584 /* Set resource source string length */
585
586 item_count = ACPI_GET16(source);
587 ACPI_SET16(destination) = (u16)aml_length;
588
589 /* Compute offset for the Vendor Data */
590
591 aml_length = (u16)(aml_length + item_count);
592 target = ACPI_ADD_PTR(void, aml, info->value);
593
594 /* Set vendor offset only if there is vendor data */
595
596 if (resource->data.gpio.vendor_length) {
597 ACPI_SET16(target) = (u16)aml_length;
598 }
599
600 acpi_rs_set_resource_length(aml_length, aml);
601 break;
602
603 case ACPI_RSC_COUNT_SERIAL_VEN:
604
605 item_count = ACPI_GET16(source);
606 ACPI_SET16(destination) = item_count + info->value;
607 aml_length = (u16)(aml_length + item_count);
608 acpi_rs_set_resource_length(aml_length, aml);
609 break;
610
611 case ACPI_RSC_COUNT_SERIAL_RES:
612
613 item_count = ACPI_GET16(source);
614 aml_length = (u16)(aml_length + item_count);
615 acpi_rs_set_resource_length(aml_length, aml);
616 break;
617
618 case ACPI_RSC_LENGTH: 403 case ACPI_RSC_LENGTH:
619 404
620 acpi_rs_set_resource_length(info->value, aml); 405 acpi_rs_set_resource_length(info->value, aml);
@@ -632,48 +417,6 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
632 info->opcode); 417 info->opcode);
633 break; 418 break;
634 419
635 case ACPI_RSC_MOVE_GPIO_PIN:
636
637 destination = (char *)ACPI_ADD_PTR(void, aml,
638 ACPI_GET16
639 (destination));
640 source = *(u16 **)source;
641 acpi_rs_move_data(destination, source, item_count,
642 info->opcode);
643 break;
644
645 case ACPI_RSC_MOVE_GPIO_RES:
646
647 /* Used for both resource_source string and vendor_data */
648
649 destination = (char *)ACPI_ADD_PTR(void, aml,
650 ACPI_GET16
651 (destination));
652 source = *(u8 **)source;
653 acpi_rs_move_data(destination, source, item_count,
654 info->opcode);
655 break;
656
657 case ACPI_RSC_MOVE_SERIAL_VEN:
658
659 destination = (char *)ACPI_ADD_PTR(void, aml,
660 (aml_length -
661 item_count));
662 source = *(u8 **)source;
663 acpi_rs_move_data(destination, source, item_count,
664 info->opcode);
665 break;
666
667 case ACPI_RSC_MOVE_SERIAL_RES:
668
669 destination = (char *)ACPI_ADD_PTR(void, aml,
670 (aml_length -
671 item_count));
672 source = *(u8 **)source;
673 acpi_rs_move_data(destination, source, item_count,
674 info->opcode);
675 break;
676
677 case ACPI_RSC_ADDRESS: 420 case ACPI_RSC_ADDRESS:
678 421
679 /* Set the Resource Type, General Flags, and Type-Specific Flags */ 422 /* Set the Resource Type, General Flags, and Type-Specific Flags */
@@ -726,7 +469,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
726 469
727 case ACPI_RSC_EXIT_LE: 470 case ACPI_RSC_EXIT_LE:
728 /* 471 /*
729 * control - Exit conversion if less than or equal 472 * Control - Exit conversion if less than or equal
730 */ 473 */
731 if (item_count <= info->value) { 474 if (item_count <= info->value) {
732 goto exit; 475 goto exit;
@@ -735,7 +478,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
735 478
736 case ACPI_RSC_EXIT_NE: 479 case ACPI_RSC_EXIT_NE:
737 /* 480 /*
738 * control - Exit conversion if not equal 481 * Control - Exit conversion if not equal
739 */ 482 */
740 switch (COMPARE_OPCODE(info)) { 483 switch (COMPARE_OPCODE(info)) {
741 case ACPI_RSC_COMPARE_VALUE: 484 case ACPI_RSC_COMPARE_VALUE:
@@ -757,7 +500,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
757 500
758 case ACPI_RSC_EXIT_EQ: 501 case ACPI_RSC_EXIT_EQ:
759 /* 502 /*
760 * control - Exit conversion if equal 503 * Control - Exit conversion if equal
761 */ 504 */
762 if (*ACPI_ADD_PTR(u8, resource, 505 if (*ACPI_ADD_PTR(u8, resource,
763 COMPARE_TARGET(info)) == 506 COMPARE_TARGET(info)) ==
@@ -783,7 +526,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
783#if 0 526#if 0
784/* Previous resource validations */ 527/* Previous resource validations */
785 528
786if (aml->ext_address64.revision_ID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) { 529if (aml->ext_address64.revision_iD != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
787 return_ACPI_STATUS(AE_SUPPORT); 530 return_ACPI_STATUS(AE_SUPPORT);
788} 531}
789 532
diff --git a/drivers/acpi/acpica/rsserial.c b/drivers/acpi/acpica/rsserial.c
deleted file mode 100644
index 9aa5e689b44..00000000000
--- a/drivers/acpi/acpica/rsserial.c
+++ /dev/null
@@ -1,441 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: rsserial - GPIO/serial_bus resource descriptors
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acresrc.h"
47
48#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsserial")
50
51/*******************************************************************************
52 *
53 * acpi_rs_convert_gpio
54 *
55 ******************************************************************************/
56struct acpi_rsconvert_info acpi_rs_convert_gpio[17] = {
57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO,
58 ACPI_RS_SIZE(struct acpi_resource_gpio),
59 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_gpio)},
60
61 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO,
62 sizeof(struct aml_resource_gpio),
63 0},
64
65 /*
66 * These fields are contiguous in both the source and destination:
67 * revision_id
68 * connection_type
69 */
70 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.revision_id),
71 AML_OFFSET(gpio.revision_id),
72 2},
73
74 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.producer_consumer),
75 AML_OFFSET(gpio.flags),
76 0},
77
78 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.sharable),
79 AML_OFFSET(gpio.int_flags),
80 3},
81
82 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.io_restriction),
83 AML_OFFSET(gpio.int_flags),
84 0},
85
86 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.triggering),
87 AML_OFFSET(gpio.int_flags),
88 0},
89
90 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.polarity),
91 AML_OFFSET(gpio.int_flags),
92 1},
93
94 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.pin_config),
95 AML_OFFSET(gpio.pin_config),
96 1},
97
98 /*
99 * These fields are contiguous in both the source and destination:
100 * drive_strength
101 * debounce_timeout
102 */
103 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.gpio.drive_strength),
104 AML_OFFSET(gpio.drive_strength),
105 2},
106
107 /* Pin Table */
108
109 {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET(data.gpio.pin_table_length),
110 AML_OFFSET(gpio.pin_table_offset),
111 AML_OFFSET(gpio.res_source_offset)},
112
113 {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET(data.gpio.pin_table),
114 AML_OFFSET(gpio.pin_table_offset),
115 0},
116
117 /* Resource Source */
118
119 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.resource_source.index),
120 AML_OFFSET(gpio.res_source_index),
121 1},
122
123 {ACPI_RSC_COUNT_GPIO_RES,
124 ACPI_RS_OFFSET(data.gpio.resource_source.string_length),
125 AML_OFFSET(gpio.res_source_offset),
126 AML_OFFSET(gpio.vendor_offset)},
127
128 {ACPI_RSC_MOVE_GPIO_RES,
129 ACPI_RS_OFFSET(data.gpio.resource_source.string_ptr),
130 AML_OFFSET(gpio.res_source_offset),
131 0},
132
133 /* Vendor Data */
134
135 {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET(data.gpio.vendor_length),
136 AML_OFFSET(gpio.vendor_length),
137 1},
138
139 {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET(data.gpio.vendor_data),
140 AML_OFFSET(gpio.vendor_offset),
141 0},
142};
143
144/*******************************************************************************
145 *
146 * acpi_rs_convert_i2c_serial_bus
147 *
148 ******************************************************************************/
149
150struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[16] = {
151 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
152 ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus),
153 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_i2c_serial_bus)},
154
155 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
156 sizeof(struct aml_resource_i2c_serialbus),
157 0},
158
159 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
160 AML_OFFSET(common_serial_bus.revision_id),
161 1},
162
163 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
164 AML_OFFSET(common_serial_bus.type),
165 1},
166
167 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
168 AML_OFFSET(common_serial_bus.flags),
169 0},
170
171 {ACPI_RSC_1BITFLAG,
172 ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
173 AML_OFFSET(common_serial_bus.flags),
174 1},
175
176 {ACPI_RSC_MOVE8,
177 ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
178 AML_OFFSET(common_serial_bus.type_revision_id),
179 1},
180
181 {ACPI_RSC_MOVE16,
182 ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
183 AML_OFFSET(common_serial_bus.type_data_length),
184 1},
185
186 /* Vendor data */
187
188 {ACPI_RSC_COUNT_SERIAL_VEN,
189 ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
190 AML_OFFSET(common_serial_bus.type_data_length),
191 AML_RESOURCE_I2C_MIN_DATA_LEN},
192
193 {ACPI_RSC_MOVE_SERIAL_VEN,
194 ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
195 0,
196 sizeof(struct aml_resource_i2c_serialbus)},
197
198 /* Resource Source */
199
200 {ACPI_RSC_MOVE8,
201 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
202 AML_OFFSET(common_serial_bus.res_source_index),
203 1},
204
205 {ACPI_RSC_COUNT_SERIAL_RES,
206 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
207 AML_OFFSET(common_serial_bus.type_data_length),
208 sizeof(struct aml_resource_common_serialbus)},
209
210 {ACPI_RSC_MOVE_SERIAL_RES,
211 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
212 AML_OFFSET(common_serial_bus.type_data_length),
213 sizeof(struct aml_resource_common_serialbus)},
214
215 /* I2C bus type specific */
216
217 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.i2c_serial_bus.access_mode),
218 AML_OFFSET(i2c_serial_bus.type_specific_flags),
219 0},
220
221 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.i2c_serial_bus.connection_speed),
222 AML_OFFSET(i2c_serial_bus.connection_speed),
223 1},
224
225 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.i2c_serial_bus.slave_address),
226 AML_OFFSET(i2c_serial_bus.slave_address),
227 1},
228};
229
230/*******************************************************************************
231 *
232 * acpi_rs_convert_spi_serial_bus
233 *
234 ******************************************************************************/
235
236struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[20] = {
237 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
238 ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),
239 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_spi_serial_bus)},
240
241 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
242 sizeof(struct aml_resource_spi_serialbus),
243 0},
244
245 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
246 AML_OFFSET(common_serial_bus.revision_id),
247 1},
248
249 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
250 AML_OFFSET(common_serial_bus.type),
251 1},
252
253 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
254 AML_OFFSET(common_serial_bus.flags),
255 0},
256
257 {ACPI_RSC_1BITFLAG,
258 ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
259 AML_OFFSET(common_serial_bus.flags),
260 1},
261
262 {ACPI_RSC_MOVE8,
263 ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
264 AML_OFFSET(common_serial_bus.type_revision_id),
265 1},
266
267 {ACPI_RSC_MOVE16,
268 ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
269 AML_OFFSET(common_serial_bus.type_data_length),
270 1},
271
272 /* Vendor data */
273
274 {ACPI_RSC_COUNT_SERIAL_VEN,
275 ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
276 AML_OFFSET(common_serial_bus.type_data_length),
277 AML_RESOURCE_SPI_MIN_DATA_LEN},
278
279 {ACPI_RSC_MOVE_SERIAL_VEN,
280 ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
281 0,
282 sizeof(struct aml_resource_spi_serialbus)},
283
284 /* Resource Source */
285
286 {ACPI_RSC_MOVE8,
287 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
288 AML_OFFSET(common_serial_bus.res_source_index),
289 1},
290
291 {ACPI_RSC_COUNT_SERIAL_RES,
292 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
293 AML_OFFSET(common_serial_bus.type_data_length),
294 sizeof(struct aml_resource_common_serialbus)},
295
296 {ACPI_RSC_MOVE_SERIAL_RES,
297 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
298 AML_OFFSET(common_serial_bus.type_data_length),
299 sizeof(struct aml_resource_common_serialbus)},
300
301 /* Spi bus type specific */
302
303 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.wire_mode),
304 AML_OFFSET(spi_serial_bus.type_specific_flags),
305 0},
306
307 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.device_polarity),
308 AML_OFFSET(spi_serial_bus.type_specific_flags),
309 1},
310
311 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.data_bit_length),
312 AML_OFFSET(spi_serial_bus.data_bit_length),
313 1},
314
315 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_phase),
316 AML_OFFSET(spi_serial_bus.clock_phase),
317 1},
318
319 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_polarity),
320 AML_OFFSET(spi_serial_bus.clock_polarity),
321 1},
322
323 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.spi_serial_bus.device_selection),
324 AML_OFFSET(spi_serial_bus.device_selection),
325 1},
326
327 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.spi_serial_bus.connection_speed),
328 AML_OFFSET(spi_serial_bus.connection_speed),
329 1},
330};
331
332/*******************************************************************************
333 *
334 * acpi_rs_convert_uart_serial_bus
335 *
336 ******************************************************************************/
337
338struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[22] = {
339 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
340 ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),
341 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_uart_serial_bus)},
342
343 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
344 sizeof(struct aml_resource_uart_serialbus),
345 0},
346
347 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
348 AML_OFFSET(common_serial_bus.revision_id),
349 1},
350
351 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
352 AML_OFFSET(common_serial_bus.type),
353 1},
354
355 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
356 AML_OFFSET(common_serial_bus.flags),
357 0},
358
359 {ACPI_RSC_1BITFLAG,
360 ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
361 AML_OFFSET(common_serial_bus.flags),
362 1},
363
364 {ACPI_RSC_MOVE8,
365 ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
366 AML_OFFSET(common_serial_bus.type_revision_id),
367 1},
368
369 {ACPI_RSC_MOVE16,
370 ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
371 AML_OFFSET(common_serial_bus.type_data_length),
372 1},
373
374 /* Vendor data */
375
376 {ACPI_RSC_COUNT_SERIAL_VEN,
377 ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
378 AML_OFFSET(common_serial_bus.type_data_length),
379 AML_RESOURCE_UART_MIN_DATA_LEN},
380
381 {ACPI_RSC_MOVE_SERIAL_VEN,
382 ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
383 0,
384 sizeof(struct aml_resource_uart_serialbus)},
385
386 /* Resource Source */
387
388 {ACPI_RSC_MOVE8,
389 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
390 AML_OFFSET(common_serial_bus.res_source_index),
391 1},
392
393 {ACPI_RSC_COUNT_SERIAL_RES,
394 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
395 AML_OFFSET(common_serial_bus.type_data_length),
396 sizeof(struct aml_resource_common_serialbus)},
397
398 {ACPI_RSC_MOVE_SERIAL_RES,
399 ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
400 AML_OFFSET(common_serial_bus.type_data_length),
401 sizeof(struct aml_resource_common_serialbus)},
402
403 /* Uart bus type specific */
404
405 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.flow_control),
406 AML_OFFSET(uart_serial_bus.type_specific_flags),
407 0},
408
409 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.stop_bits),
410 AML_OFFSET(uart_serial_bus.type_specific_flags),
411 2},
412
413 {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.data_bits),
414 AML_OFFSET(uart_serial_bus.type_specific_flags),
415 4},
416
417 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.endian),
418 AML_OFFSET(uart_serial_bus.type_specific_flags),
419 7},
420
421 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.parity),
422 AML_OFFSET(uart_serial_bus.parity),
423 1},
424
425 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.lines_enabled),
426 AML_OFFSET(uart_serial_bus.lines_enabled),
427 1},
428
429 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.rx_fifo_size),
430 AML_OFFSET(uart_serial_bus.rx_fifo_size),
431 1},
432
433 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.tx_fifo_size),
434 AML_OFFSET(uart_serial_bus.tx_fifo_size),
435 1},
436
437 {ACPI_RSC_MOVE32,
438 ACPI_RS_OFFSET(data.uart_serial_bus.default_baud_rate),
439 AML_OFFSET(uart_serial_bus.default_baud_rate),
440 1},
441};
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index 37d5241c0ac..231811e5693 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -53,8 +53,8 @@ ACPI_MODULE_NAME("rsutils")
53 * 53 *
54 * FUNCTION: acpi_rs_decode_bitmask 54 * FUNCTION: acpi_rs_decode_bitmask
55 * 55 *
56 * PARAMETERS: mask - Bitmask to decode 56 * PARAMETERS: Mask - Bitmask to decode
57 * list - Where the converted list is returned 57 * List - Where the converted list is returned
58 * 58 *
59 * RETURN: Count of bits set (length of list) 59 * RETURN: Count of bits set (length of list)
60 * 60 *
@@ -86,8 +86,8 @@ u8 acpi_rs_decode_bitmask(u16 mask, u8 * list)
86 * 86 *
87 * FUNCTION: acpi_rs_encode_bitmask 87 * FUNCTION: acpi_rs_encode_bitmask
88 * 88 *
89 * PARAMETERS: list - List of values to encode 89 * PARAMETERS: List - List of values to encode
90 * count - Length of list 90 * Count - Length of list
91 * 91 *
92 * RETURN: Encoded bitmask 92 * RETURN: Encoded bitmask
93 * 93 *
@@ -115,8 +115,8 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
115 * 115 *
116 * FUNCTION: acpi_rs_move_data 116 * FUNCTION: acpi_rs_move_data
117 * 117 *
118 * PARAMETERS: destination - Pointer to the destination descriptor 118 * PARAMETERS: Destination - Pointer to the destination descriptor
119 * source - Pointer to the source descriptor 119 * Source - Pointer to the source descriptor
120 * item_count - How many items to move 120 * item_count - How many items to move
121 * move_type - Byte width 121 * move_type - Byte width
122 * 122 *
@@ -144,9 +144,6 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
144 * since there are no alignment or endian issues 144 * since there are no alignment or endian issues
145 */ 145 */
146 case ACPI_RSC_MOVE8: 146 case ACPI_RSC_MOVE8:
147 case ACPI_RSC_MOVE_GPIO_RES:
148 case ACPI_RSC_MOVE_SERIAL_VEN:
149 case ACPI_RSC_MOVE_SERIAL_RES:
150 ACPI_MEMCPY(destination, source, item_count); 147 ACPI_MEMCPY(destination, source, item_count);
151 return; 148 return;
152 149
@@ -156,7 +153,6 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
156 * misaligned memory transfers 153 * misaligned memory transfers
157 */ 154 */
158 case ACPI_RSC_MOVE16: 155 case ACPI_RSC_MOVE16:
159 case ACPI_RSC_MOVE_GPIO_PIN:
160 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i], 156 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
161 &ACPI_CAST_PTR(u16, source)[i]); 157 &ACPI_CAST_PTR(u16, source)[i]);
162 break; 158 break;
@@ -183,7 +179,7 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
183 * 179 *
184 * PARAMETERS: total_length - Length of the AML descriptor, including 180 * PARAMETERS: total_length - Length of the AML descriptor, including
185 * the header and length fields. 181 * the header and length fields.
186 * aml - Pointer to the raw AML descriptor 182 * Aml - Pointer to the raw AML descriptor
187 * 183 *
188 * RETURN: None 184 * RETURN: None
189 * 185 *
@@ -235,7 +231,7 @@ acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
235 * PARAMETERS: descriptor_type - Byte to be inserted as the type 231 * PARAMETERS: descriptor_type - Byte to be inserted as the type
236 * total_length - Length of the AML descriptor, including 232 * total_length - Length of the AML descriptor, including
237 * the header and length fields. 233 * the header and length fields.
238 * aml - Pointer to the raw AML descriptor 234 * Aml - Pointer to the raw AML descriptor
239 * 235 *
240 * RETURN: None 236 * RETURN: None
241 * 237 *
@@ -265,8 +261,8 @@ acpi_rs_set_resource_header(u8 descriptor_type,
265 * 261 *
266 * FUNCTION: acpi_rs_strcpy 262 * FUNCTION: acpi_rs_strcpy
267 * 263 *
268 * PARAMETERS: destination - Pointer to the destination string 264 * PARAMETERS: Destination - Pointer to the destination string
269 * source - Pointer to the source string 265 * Source - Pointer to the source string
270 * 266 *
271 * RETURN: String length, including NULL terminator 267 * RETURN: String length, including NULL terminator
272 * 268 *
@@ -300,7 +296,7 @@ static u16 acpi_rs_strcpy(char *destination, char *source)
300 * minimum_length - Minimum length of the descriptor (minus 296 * minimum_length - Minimum length of the descriptor (minus
301 * any optional fields) 297 * any optional fields)
302 * resource_source - Where the resource_source is returned 298 * resource_source - Where the resource_source is returned
303 * aml - Pointer to the raw AML descriptor 299 * Aml - Pointer to the raw AML descriptor
304 * string_ptr - (optional) where to store the actual 300 * string_ptr - (optional) where to store the actual
305 * resource_source string 301 * resource_source string
306 * 302 *
@@ -386,7 +382,7 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length,
386 * 382 *
387 * FUNCTION: acpi_rs_set_resource_source 383 * FUNCTION: acpi_rs_set_resource_source
388 * 384 *
389 * PARAMETERS: aml - Pointer to the raw AML descriptor 385 * PARAMETERS: Aml - Pointer to the raw AML descriptor
390 * minimum_length - Minimum length of the descriptor (minus 386 * minimum_length - Minimum length of the descriptor (minus
391 * any optional fields) 387 * any optional fields)
392 * resource_source - Internal resource_source 388 * resource_source - Internal resource_source
@@ -445,7 +441,7 @@ acpi_rs_set_resource_source(union aml_resource * aml,
445 * 441 *
446 * FUNCTION: acpi_rs_get_prt_method_data 442 * FUNCTION: acpi_rs_get_prt_method_data
447 * 443 *
448 * PARAMETERS: node - Device node 444 * PARAMETERS: Node - Device node
449 * ret_buffer - Pointer to a buffer structure for the 445 * ret_buffer - Pointer to a buffer structure for the
450 * results 446 * results
451 * 447 *
@@ -494,7 +490,7 @@ acpi_rs_get_prt_method_data(struct acpi_namespace_node * node,
494 * 490 *
495 * FUNCTION: acpi_rs_get_crs_method_data 491 * FUNCTION: acpi_rs_get_crs_method_data
496 * 492 *
497 * PARAMETERS: node - Device node 493 * PARAMETERS: Node - Device node
498 * ret_buffer - Pointer to a buffer structure for the 494 * ret_buffer - Pointer to a buffer structure for the
499 * results 495 * results
500 * 496 *
@@ -534,7 +530,7 @@ acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
534 */ 530 */
535 status = acpi_rs_create_resource_list(obj_desc, ret_buffer); 531 status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
536 532
537 /* On exit, we must delete the object returned by evaluateObject */ 533 /* On exit, we must delete the object returned by evaluate_object */
538 534
539 acpi_ut_remove_reference(obj_desc); 535 acpi_ut_remove_reference(obj_desc);
540 return_ACPI_STATUS(status); 536 return_ACPI_STATUS(status);
@@ -544,7 +540,7 @@ acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
544 * 540 *
545 * FUNCTION: acpi_rs_get_prs_method_data 541 * FUNCTION: acpi_rs_get_prs_method_data
546 * 542 *
547 * PARAMETERS: node - Device node 543 * PARAMETERS: Node - Device node
548 * ret_buffer - Pointer to a buffer structure for the 544 * ret_buffer - Pointer to a buffer structure for the
549 * results 545 * results
550 * 546 *
@@ -585,7 +581,7 @@ acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
585 */ 581 */
586 status = acpi_rs_create_resource_list(obj_desc, ret_buffer); 582 status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
587 583
588 /* On exit, we must delete the object returned by evaluateObject */ 584 /* On exit, we must delete the object returned by evaluate_object */
589 585
590 acpi_ut_remove_reference(obj_desc); 586 acpi_ut_remove_reference(obj_desc);
591 return_ACPI_STATUS(status); 587 return_ACPI_STATUS(status);
@@ -594,60 +590,10 @@ acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
594 590
595/******************************************************************************* 591/*******************************************************************************
596 * 592 *
597 * FUNCTION: acpi_rs_get_aei_method_data
598 *
599 * PARAMETERS: node - Device node
600 * ret_buffer - Pointer to a buffer structure for the
601 * results
602 *
603 * RETURN: Status
604 *
605 * DESCRIPTION: This function is called to get the _AEI value of an object
606 * contained in an object specified by the handle passed in
607 *
608 * If the function fails an appropriate status will be returned
609 * and the contents of the callers buffer is undefined.
610 *
611 ******************************************************************************/
612
613acpi_status
614acpi_rs_get_aei_method_data(struct acpi_namespace_node *node,
615 struct acpi_buffer *ret_buffer)
616{
617 union acpi_operand_object *obj_desc;
618 acpi_status status;
619
620 ACPI_FUNCTION_TRACE(rs_get_aei_method_data);
621
622 /* Parameters guaranteed valid by caller */
623
624 /* Execute the method, no parameters */
625
626 status = acpi_ut_evaluate_object(node, METHOD_NAME__AEI,
627 ACPI_BTYPE_BUFFER, &obj_desc);
628 if (ACPI_FAILURE(status)) {
629 return_ACPI_STATUS(status);
630 }
631
632 /*
633 * Make the call to create a resource linked list from the
634 * byte stream buffer that comes back from the _CRS method
635 * execution.
636 */
637 status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
638
639 /* On exit, we must delete the object returned by evaluateObject */
640
641 acpi_ut_remove_reference(obj_desc);
642 return_ACPI_STATUS(status);
643}
644
645/*******************************************************************************
646 *
647 * FUNCTION: acpi_rs_get_method_data 593 * FUNCTION: acpi_rs_get_method_data
648 * 594 *
649 * PARAMETERS: handle - Handle to the containing object 595 * PARAMETERS: Handle - Handle to the containing object
650 * path - Path to method, relative to Handle 596 * Path - Path to method, relative to Handle
651 * ret_buffer - Pointer to a buffer structure for the 597 * ret_buffer - Pointer to a buffer structure for the
652 * results 598 * results
653 * 599 *
@@ -697,7 +643,7 @@ acpi_rs_get_method_data(acpi_handle handle,
697 * 643 *
698 * FUNCTION: acpi_rs_set_srs_method_data 644 * FUNCTION: acpi_rs_set_srs_method_data
699 * 645 *
700 * PARAMETERS: node - Device node 646 * PARAMETERS: Node - Device node
701 * in_buffer - Pointer to a buffer structure of the 647 * in_buffer - Pointer to a buffer structure of the
702 * parameter 648 * parameter
703 * 649 *
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index 5aad744b5b8..2ff657a28f2 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include "accommon.h" 45#include "accommon.h"
47#include "acresrc.h" 46#include "acresrc.h"
@@ -79,7 +78,7 @@ acpi_rs_validate_parameters(acpi_handle device_handle,
79 * FUNCTION: acpi_rs_validate_parameters 78 * FUNCTION: acpi_rs_validate_parameters
80 * 79 *
81 * PARAMETERS: device_handle - Handle to a device 80 * PARAMETERS: device_handle - Handle to a device
82 * buffer - Pointer to a data buffer 81 * Buffer - Pointer to a data buffer
83 * return_node - Pointer to where the device node is returned 82 * return_node - Pointer to where the device node is returned
84 * 83 *
85 * RETURN: Status 84 * RETURN: Status
@@ -307,52 +306,12 @@ acpi_set_current_resources(acpi_handle device_handle,
307 306
308ACPI_EXPORT_SYMBOL(acpi_set_current_resources) 307ACPI_EXPORT_SYMBOL(acpi_set_current_resources)
309 308
310/*******************************************************************************
311 *
312 * FUNCTION: acpi_get_event_resources
313 *
314 * PARAMETERS: device_handle - Handle to the device object for the
315 * device we are getting resources
316 * in_buffer - Pointer to a buffer containing the
317 * resources to be set for the device
318 *
319 * RETURN: Status
320 *
321 * DESCRIPTION: This function is called to get the event resources for a
322 * specific device. The caller must first acquire a handle for
323 * the desired device. The resource data is passed to the routine
324 * the buffer pointed to by the in_buffer variable. Uses the
325 * _AEI method.
326 *
327 ******************************************************************************/
328acpi_status
329acpi_get_event_resources(acpi_handle device_handle,
330 struct acpi_buffer *ret_buffer)
331{
332 acpi_status status;
333 struct acpi_namespace_node *node;
334
335 ACPI_FUNCTION_TRACE(acpi_get_event_resources);
336
337 /* Validate parameters then dispatch to internal routine */
338
339 status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node);
340 if (ACPI_FAILURE(status)) {
341 return_ACPI_STATUS(status);
342 }
343
344 status = acpi_rs_get_aei_method_data(node, ret_buffer);
345 return_ACPI_STATUS(status);
346}
347
348ACPI_EXPORT_SYMBOL(acpi_get_event_resources)
349
350/****************************************************************************** 309/******************************************************************************
351 * 310 *
352 * FUNCTION: acpi_resource_to_address64 311 * FUNCTION: acpi_resource_to_address64
353 * 312 *
354 * PARAMETERS: resource - Pointer to a resource 313 * PARAMETERS: Resource - Pointer to a resource
355 * out - Pointer to the users's return buffer 314 * Out - Pointer to the users's return buffer
356 * (a struct acpi_resource_address64) 315 * (a struct acpi_resource_address64)
357 * 316 *
358 * RETURN: Status 317 * RETURN: Status
@@ -415,9 +374,9 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64)
415 * FUNCTION: acpi_get_vendor_resource 374 * FUNCTION: acpi_get_vendor_resource
416 * 375 *
417 * PARAMETERS: device_handle - Handle for the parent device object 376 * PARAMETERS: device_handle - Handle for the parent device object
418 * name - Method name for the parent resource 377 * Name - Method name for the parent resource
419 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 378 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
420 * uuid - Pointer to the UUID to be matched. 379 * Uuid - Pointer to the UUID to be matched.
421 * includes both subtype and 16-byte UUID 380 * includes both subtype and 16-byte UUID
422 * ret_buffer - Where the vendor resource is returned 381 * ret_buffer - Where the vendor resource is returned
423 * 382 *
@@ -526,11 +485,10 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
526 * 485 *
527 * PARAMETERS: device_handle - Handle to the device object for the 486 * PARAMETERS: device_handle - Handle to the device object for the
528 * device we are querying 487 * device we are querying
529 * name - Method name of the resources we want. 488 * Name - Method name of the resources we want
530 * (METHOD_NAME__CRS, METHOD_NAME__PRS, or 489 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
531 * METHOD_NAME__AEI)
532 * user_function - Called for each resource 490 * user_function - Called for each resource
533 * context - Passed to user_function 491 * Context - Passed to user_function
534 * 492 *
535 * RETURN: Status 493 * RETURN: Status
536 * 494 *
@@ -555,12 +513,11 @@ acpi_walk_resources(acpi_handle device_handle,
555 513
556 if (!device_handle || !user_function || !name || 514 if (!device_handle || !user_function || !name ||
557 (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) && 515 (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
558 !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) && 516 !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS))) {
559 !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
560 return_ACPI_STATUS(AE_BAD_PARAMETER); 517 return_ACPI_STATUS(AE_BAD_PARAMETER);
561 } 518 }
562 519
563 /* Get the _CRS/_PRS/_AEI resource list */ 520 /* Get the _CRS or _PRS resource list */
564 521
565 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 522 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
566 status = acpi_rs_get_method_data(device_handle, name, &buffer); 523 status = acpi_rs_get_method_data(device_handle, name, &buffer);
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 390651860bf..6f5588e62c0 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -49,10 +49,9 @@
49ACPI_MODULE_NAME("tbfadt") 49ACPI_MODULE_NAME("tbfadt")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52static void 52static ACPI_INLINE void
53acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, 53acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
54 u8 space_id, 54 u8 space_id, u8 byte_width, u64 address);
55 u8 byte_width, u64 address, char *register_name);
56 55
57static void acpi_tb_convert_fadt(void); 56static void acpi_tb_convert_fadt(void);
58 57
@@ -64,15 +63,14 @@ static void acpi_tb_setup_fadt_registers(void);
64 63
65typedef struct acpi_fadt_info { 64typedef struct acpi_fadt_info {
66 char *name; 65 char *name;
67 u16 address64; 66 u8 address64;
68 u16 address32; 67 u8 address32;
69 u16 length; 68 u8 length;
70 u8 default_length; 69 u8 default_length;
71 u8 type; 70 u8 type;
72 71
73} acpi_fadt_info; 72} acpi_fadt_info;
74 73
75#define ACPI_FADT_OPTIONAL 0
76#define ACPI_FADT_REQUIRED 1 74#define ACPI_FADT_REQUIRED 1
77#define ACPI_FADT_SEPARATE_LENGTH 2 75#define ACPI_FADT_SEPARATE_LENGTH 2
78 76
@@ -89,7 +87,7 @@ static struct acpi_fadt_info fadt_info_table[] = {
89 ACPI_FADT_OFFSET(pm1b_event_block), 87 ACPI_FADT_OFFSET(pm1b_event_block),
90 ACPI_FADT_OFFSET(pm1_event_length), 88 ACPI_FADT_OFFSET(pm1_event_length),
91 ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ 89 ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
92 ACPI_FADT_OPTIONAL}, 90 0},
93 91
94 {"Pm1aControlBlock", 92 {"Pm1aControlBlock",
95 ACPI_FADT_OFFSET(xpm1a_control_block), 93 ACPI_FADT_OFFSET(xpm1a_control_block),
@@ -103,7 +101,7 @@ static struct acpi_fadt_info fadt_info_table[] = {
103 ACPI_FADT_OFFSET(pm1b_control_block), 101 ACPI_FADT_OFFSET(pm1b_control_block),
104 ACPI_FADT_OFFSET(pm1_control_length), 102 ACPI_FADT_OFFSET(pm1_control_length),
105 ACPI_PM1_REGISTER_WIDTH, 103 ACPI_PM1_REGISTER_WIDTH,
106 ACPI_FADT_OPTIONAL}, 104 0},
107 105
108 {"Pm2ControlBlock", 106 {"Pm2ControlBlock",
109 ACPI_FADT_OFFSET(xpm2_control_block), 107 ACPI_FADT_OFFSET(xpm2_control_block),
@@ -141,7 +139,7 @@ static struct acpi_fadt_info fadt_info_table[] = {
141 139
142typedef struct acpi_fadt_pm_info { 140typedef struct acpi_fadt_pm_info {
143 struct acpi_generic_address *target; 141 struct acpi_generic_address *target;
144 u16 source; 142 u8 source;
145 u8 register_num; 143 u8 register_num;
146 144
147} acpi_fadt_pm_info; 145} acpi_fadt_pm_info;
@@ -173,7 +171,7 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
173 * 171 *
174 * PARAMETERS: generic_address - GAS struct to be initialized 172 * PARAMETERS: generic_address - GAS struct to be initialized
175 * byte_width - Width of this register 173 * byte_width - Width of this register
176 * address - Address of the register 174 * Address - Address of the register
177 * 175 *
178 * RETURN: None 176 * RETURN: None
179 * 177 *
@@ -183,25 +181,10 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
183 * 181 *
184 ******************************************************************************/ 182 ******************************************************************************/
185 183
186static void 184static ACPI_INLINE void
187acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, 185acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
188 u8 space_id, 186 u8 space_id, u8 byte_width, u64 address)
189 u8 byte_width, u64 address, char *register_name)
190{ 187{
191 u8 bit_width;
192
193 /* Bit width field in the GAS is only one byte long, 255 max */
194
195 bit_width = (u8)(byte_width * 8);
196
197 if (byte_width > 31) { /* (31*8)=248 */
198 ACPI_ERROR((AE_INFO,
199 "%s - 32-bit FADT register is too long (%u bytes, %u bits) "
200 "to convert to GAS struct - 255 bits max, truncating",
201 register_name, byte_width, (byte_width * 8)));
202
203 bit_width = 255;
204 }
205 188
206 /* 189 /*
207 * The 64-bit Address field is non-aligned in the byte packed 190 * The 64-bit Address field is non-aligned in the byte packed
@@ -212,7 +195,7 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
212 /* All other fields are byte-wide */ 195 /* All other fields are byte-wide */
213 196
214 generic_address->space_id = space_id; 197 generic_address->space_id = space_id;
215 generic_address->bit_width = bit_width; 198 generic_address->bit_width = (u8)ACPI_MUL_8(byte_width);
216 generic_address->bit_offset = 0; 199 generic_address->bit_offset = 0;
217 generic_address->access_width = 0; /* Access width ANY */ 200 generic_address->access_width = 0; /* Access width ANY */
218} 201}
@@ -270,21 +253,16 @@ void acpi_tb_parse_fadt(u32 table_index)
270 acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt, 253 acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
271 ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); 254 ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
272 255
273 /* If Hardware Reduced flag is set, there is no FACS */ 256 acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs,
274 257 ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
275 if (!acpi_gbl_reduced_hardware) {
276 acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.
277 Xfacs, ACPI_SIG_FACS,
278 ACPI_TABLE_INDEX_FACS);
279 }
280} 258}
281 259
282/******************************************************************************* 260/*******************************************************************************
283 * 261 *
284 * FUNCTION: acpi_tb_create_local_fadt 262 * FUNCTION: acpi_tb_create_local_fadt
285 * 263 *
286 * PARAMETERS: table - Pointer to BIOS FADT 264 * PARAMETERS: Table - Pointer to BIOS FADT
287 * length - Length of the table 265 * Length - Length of the table
288 * 266 *
289 * RETURN: None 267 * RETURN: None
290 * 268 *
@@ -299,15 +277,15 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
299{ 277{
300 /* 278 /*
301 * Check if the FADT is larger than the largest table that we expect 279 * Check if the FADT is larger than the largest table that we expect
302 * (the ACPI 5.0 version). If so, truncate the table, and issue 280 * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue
303 * a warning. 281 * a warning.
304 */ 282 */
305 if (length > sizeof(struct acpi_table_fadt)) { 283 if (length > sizeof(struct acpi_table_fadt)) {
306 ACPI_BIOS_WARNING((AE_INFO, 284 ACPI_WARNING((AE_INFO,
307 "FADT (revision %u) is longer than ACPI 5.0 version, " 285 "FADT (revision %u) is longer than ACPI 2.0 version, "
308 "truncating length %u to %u", 286 "truncating length %u to %u",
309 table->revision, length, 287 table->revision, length,
310 (u32)sizeof(struct acpi_table_fadt))); 288 (u32)sizeof(struct acpi_table_fadt)));
311 } 289 }
312 290
313 /* Clear the entire local FADT */ 291 /* Clear the entire local FADT */
@@ -319,13 +297,6 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
319 ACPI_MEMCPY(&acpi_gbl_FADT, table, 297 ACPI_MEMCPY(&acpi_gbl_FADT, table,
320 ACPI_MIN(length, sizeof(struct acpi_table_fadt))); 298 ACPI_MIN(length, sizeof(struct acpi_table_fadt)));
321 299
322 /* Take a copy of the Hardware Reduced flag */
323
324 acpi_gbl_reduced_hardware = FALSE;
325 if (acpi_gbl_FADT.flags & ACPI_FADT_HW_REDUCED) {
326 acpi_gbl_reduced_hardware = TRUE;
327 }
328
329 /* Convert the local copy of the FADT to the common internal format */ 300 /* Convert the local copy of the FADT to the common internal format */
330 301
331 acpi_tb_convert_fadt(); 302 acpi_tb_convert_fadt();
@@ -379,6 +350,10 @@ static void acpi_tb_convert_fadt(void)
379 u32 address32; 350 u32 address32;
380 u32 i; 351 u32 i;
381 352
353 /* Update the local FADT table header length */
354
355 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
356
382 /* 357 /*
383 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. 358 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
384 * Later code will always use the X 64-bit field. Also, check for an 359 * Later code will always use the X 64-bit field. Also, check for an
@@ -420,10 +395,6 @@ static void acpi_tb_convert_fadt(void)
420 acpi_gbl_FADT.boot_flags = 0; 395 acpi_gbl_FADT.boot_flags = 0;
421 } 396 }
422 397
423 /* Update the local FADT table header length */
424
425 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
426
427 /* 398 /*
428 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" 399 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
429 * generic address structures as necessary. Later code will always use 400 * generic address structures as necessary. Later code will always use
@@ -452,13 +423,11 @@ static void acpi_tb_convert_fadt(void)
452 * they must match. 423 * they must match.
453 */ 424 */
454 if (address64->address && address32 && 425 if (address64->address && address32 &&
455 (address64->address != (u64)address32)) { 426 (address64->address != (u64) address32)) {
456 ACPI_BIOS_ERROR((AE_INFO, 427 ACPI_ERROR((AE_INFO,
457 "32/64X address mismatch in FADT/%s: " 428 "32/64X address mismatch in %s: 0x%8.8X/0x%8.8X%8.8X, using 32",
458 "0x%8.8X/0x%8.8X%8.8X, using 32", 429 fadt_info_table[i].name, address32,
459 fadt_info_table[i].name, address32, 430 ACPI_FORMAT_UINT64(address64->address)));
460 ACPI_FORMAT_UINT64(address64->
461 address)));
462 } 431 }
463 432
464 /* Always use 32-bit address if it is valid (non-null) */ 433 /* Always use 32-bit address if it is valid (non-null) */
@@ -474,8 +443,7 @@ static void acpi_tb_convert_fadt(void)
474 &acpi_gbl_FADT, 443 &acpi_gbl_FADT,
475 fadt_info_table 444 fadt_info_table
476 [i].length), 445 [i].length),
477 (u64) address32, 446 (u64) address32);
478 fadt_info_table[i].name);
479 } 447 }
480 } 448 }
481} 449}
@@ -484,7 +452,7 @@ static void acpi_tb_convert_fadt(void)
484 * 452 *
485 * FUNCTION: acpi_tb_validate_fadt 453 * FUNCTION: acpi_tb_validate_fadt
486 * 454 *
487 * PARAMETERS: table - Pointer to the FADT to be validated 455 * PARAMETERS: Table - Pointer to the FADT to be validated
488 * 456 *
489 * RETURN: None 457 * RETURN: None
490 * 458 *
@@ -513,31 +481,25 @@ static void acpi_tb_validate_fadt(void)
513 * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. 481 * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
514 */ 482 */
515 if (acpi_gbl_FADT.facs && 483 if (acpi_gbl_FADT.facs &&
516 (acpi_gbl_FADT.Xfacs != (u64)acpi_gbl_FADT.facs)) { 484 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
517 ACPI_BIOS_WARNING((AE_INFO, 485 ACPI_WARNING((AE_INFO,
518 "32/64X FACS address mismatch in FADT - " 486 "32/64X FACS address mismatch in FADT - "
519 "0x%8.8X/0x%8.8X%8.8X, using 32", 487 "0x%8.8X/0x%8.8X%8.8X, using 32",
520 acpi_gbl_FADT.facs, 488 acpi_gbl_FADT.facs,
521 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs))); 489 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs)));
522
523 acpi_gbl_FADT.Xfacs = (u64)acpi_gbl_FADT.facs;
524 }
525 490
526 if (acpi_gbl_FADT.dsdt && 491 acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
527 (acpi_gbl_FADT.Xdsdt != (u64)acpi_gbl_FADT.dsdt)) {
528 ACPI_BIOS_WARNING((AE_INFO,
529 "32/64X DSDT address mismatch in FADT - "
530 "0x%8.8X/0x%8.8X%8.8X, using 32",
531 acpi_gbl_FADT.dsdt,
532 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
533
534 acpi_gbl_FADT.Xdsdt = (u64)acpi_gbl_FADT.dsdt;
535 } 492 }
536 493
537 /* If Hardware Reduced flag is set, we are all done */ 494 if (acpi_gbl_FADT.dsdt &&
495 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
496 ACPI_WARNING((AE_INFO,
497 "32/64X DSDT address mismatch in FADT - "
498 "0x%8.8X/0x%8.8X%8.8X, using 32",
499 acpi_gbl_FADT.dsdt,
500 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
538 501
539 if (acpi_gbl_reduced_hardware) { 502 acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
540 return;
541 } 503 }
542 504
543 /* Examine all of the 64-bit extended address fields (X fields) */ 505 /* Examine all of the 64-bit extended address fields (X fields) */
@@ -561,10 +523,10 @@ static void acpi_tb_validate_fadt(void)
561 */ 523 */
562 if (address64->address && 524 if (address64->address &&
563 (address64->bit_width != ACPI_MUL_8(length))) { 525 (address64->bit_width != ACPI_MUL_8(length))) {
564 ACPI_BIOS_WARNING((AE_INFO, 526 ACPI_WARNING((AE_INFO,
565 "32/64X length mismatch in FADT/%s: %u/%u", 527 "32/64X length mismatch in %s: %u/%u",
566 name, ACPI_MUL_8(length), 528 name, ACPI_MUL_8(length),
567 address64->bit_width)); 529 address64->bit_width));
568 } 530 }
569 531
570 if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) { 532 if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) {
@@ -573,29 +535,29 @@ static void acpi_tb_validate_fadt(void)
573 * Both the address and length must be non-zero. 535 * Both the address and length must be non-zero.
574 */ 536 */
575 if (!address64->address || !length) { 537 if (!address64->address || !length) {
576 ACPI_BIOS_ERROR((AE_INFO, 538 ACPI_ERROR((AE_INFO,
577 "Required FADT field %s has zero address and/or length: " 539 "Required field %s has zero address and/or length:"
578 "0x%8.8X%8.8X/0x%X", 540 " 0x%8.8X%8.8X/0x%X",
579 name, 541 name,
580 ACPI_FORMAT_UINT64(address64-> 542 ACPI_FORMAT_UINT64(address64->
581 address), 543 address),
582 length)); 544 length));
583 } 545 }
584 } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) { 546 } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) {
585 /* 547 /*
586 * Field is optional (Pm2_control, GPE0, GPE1) AND has its own 548 * Field is optional (PM2Control, GPE0, GPE1) AND has its own
587 * length field. If present, both the address and length must 549 * length field. If present, both the address and length must
588 * be valid. 550 * be valid.
589 */ 551 */
590 if ((address64->address && !length) || 552 if ((address64->address && !length) ||
591 (!address64->address && length)) { 553 (!address64->address && length)) {
592 ACPI_BIOS_WARNING((AE_INFO, 554 ACPI_WARNING((AE_INFO,
593 "Optional FADT field %s has zero address or length: " 555 "Optional field %s has zero address or length: "
594 "0x%8.8X%8.8X/0x%X", 556 "0x%8.8X%8.8X/0x%X",
595 name, 557 name,
596 ACPI_FORMAT_UINT64 558 ACPI_FORMAT_UINT64(address64->
597 (address64->address), 559 address),
598 length)); 560 length));
599 } 561 }
600 } 562 }
601 } 563 }
@@ -640,12 +602,12 @@ static void acpi_tb_setup_fadt_registers(void)
640 (fadt_info_table[i].default_length > 0) && 602 (fadt_info_table[i].default_length > 0) &&
641 (fadt_info_table[i].default_length != 603 (fadt_info_table[i].default_length !=
642 target64->bit_width)) { 604 target64->bit_width)) {
643 ACPI_BIOS_WARNING((AE_INFO, 605 ACPI_WARNING((AE_INFO,
644 "Invalid length for FADT/%s: %u, using default %u", 606 "Invalid length for %s: %u, using default %u",
645 fadt_info_table[i].name, 607 fadt_info_table[i].name,
646 target64->bit_width, 608 target64->bit_width,
647 fadt_info_table[i]. 609 fadt_info_table[i].
648 default_length)); 610 default_length));
649 611
650 /* Incorrect size, set width to the default */ 612 /* Incorrect size, set width to the default */
651 613
@@ -689,8 +651,7 @@ static void acpi_tb_setup_fadt_registers(void)
689 source64->address + 651 source64->address +
690 (fadt_pm_info_table[i]. 652 (fadt_pm_info_table[i].
691 register_num * 653 register_num *
692 pm1_register_byte_width), 654 pm1_register_byte_width));
693 "PmRegisters");
694 } 655 }
695 } 656 }
696} 657}
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 77d1db29a72..a55cb2bb5ab 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -52,7 +52,7 @@ ACPI_MODULE_NAME("tbfind")
52 * 52 *
53 * FUNCTION: acpi_tb_find_table 53 * FUNCTION: acpi_tb_find_table
54 * 54 *
55 * PARAMETERS: signature - String with ACPI table signature 55 * PARAMETERS: Signature - String with ACPI table signature
56 * oem_id - String with the table OEM ID 56 * oem_id - String with the table OEM ID
57 * oem_table_id - String with the OEM Table ID 57 * oem_table_id - String with the OEM Table ID
58 * table_index - Where the table index is returned 58 * table_index - Where the table index is returned
@@ -77,7 +77,7 @@ acpi_tb_find_table(char *signature,
77 /* Normalize the input strings */ 77 /* Normalize the input strings */
78 78
79 ACPI_MEMSET(&header, 0, sizeof(struct acpi_table_header)); 79 ACPI_MEMSET(&header, 0, sizeof(struct acpi_table_header));
80 ACPI_MOVE_NAME(header.signature, signature); 80 ACPI_STRNCPY(header.signature, signature, ACPI_NAME_SIZE);
81 ACPI_STRNCPY(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); 81 ACPI_STRNCPY(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
82 ACPI_STRNCPY(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); 82 ACPI_STRNCPY(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
83 83
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index f540ae46292..62365f6075d 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -114,6 +114,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
114{ 114{
115 u32 i; 115 u32 i;
116 acpi_status status = AE_OK; 116 acpi_status status = AE_OK;
117 struct acpi_table_header *override_table = NULL;
117 118
118 ACPI_FUNCTION_TRACE(tb_add_table); 119 ACPI_FUNCTION_TRACE(tb_add_table);
119 120
@@ -138,14 +139,13 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
138 if ((table_desc->pointer->signature[0] != 0x00) && 139 if ((table_desc->pointer->signature[0] != 0x00) &&
139 (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT)) 140 (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT))
140 && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) { 141 && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) {
141 ACPI_BIOS_ERROR((AE_INFO, 142 ACPI_ERROR((AE_INFO,
142 "Table has invalid signature [%4.4s] (0x%8.8X), " 143 "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx",
143 "must be SSDT or OEMx", 144 acpi_ut_valid_acpi_name(*(u32 *)table_desc->
144 acpi_ut_valid_acpi_name(*(u32 *)table_desc-> 145 pointer->
145 pointer-> 146 signature) ? table_desc->
146 signature) ? 147 pointer->signature : "????",
147 table_desc->pointer->signature : "????", 148 *(u32 *)table_desc->pointer->signature));
148 *(u32 *)table_desc->pointer->signature));
149 149
150 return_ACPI_STATUS(AE_BAD_SIGNATURE); 150 return_ACPI_STATUS(AE_BAD_SIGNATURE);
151 } 151 }
@@ -224,10 +224,25 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
224 /* 224 /*
225 * ACPI Table Override: 225 * ACPI Table Override:
226 * Allow the host to override dynamically loaded tables. 226 * Allow the host to override dynamically loaded tables.
227 * NOTE: the table is fully mapped at this point, and the mapping will
228 * be deleted by tb_table_override if the table is actually overridden.
229 */ 227 */
230 (void)acpi_tb_table_override(table_desc->pointer, table_desc); 228 status = acpi_os_table_override(table_desc->pointer, &override_table);
229 if (ACPI_SUCCESS(status) && override_table) {
230 ACPI_INFO((AE_INFO,
231 "%4.4s @ 0x%p Table override, replaced with:",
232 table_desc->pointer->signature,
233 ACPI_CAST_PTR(void, table_desc->address)));
234
235 /* We can delete the table that was passed as a parameter */
236
237 acpi_tb_delete_table(table_desc);
238
239 /* Setup descriptor for the new table */
240
241 table_desc->address = ACPI_PTR_TO_PHYSADDR(override_table);
242 table_desc->pointer = override_table;
243 table_desc->length = override_table->length;
244 table_desc->flags = ACPI_TABLE_ORIGIN_OVERRIDE;
245 }
231 246
232 /* Add the table to the global root table list */ 247 /* Add the table to the global root table list */
233 248
@@ -248,95 +263,6 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
248 263
249/******************************************************************************* 264/*******************************************************************************
250 * 265 *
251 * FUNCTION: acpi_tb_table_override
252 *
253 * PARAMETERS: table_header - Header for the original table
254 * table_desc - Table descriptor initialized for the
255 * original table. May or may not be mapped.
256 *
257 * RETURN: Pointer to the entire new table. NULL if table not overridden.
258 * If overridden, installs the new table within the input table
259 * descriptor.
260 *
261 * DESCRIPTION: Attempt table override by calling the OSL override functions.
262 * Note: If the table is overridden, then the entire new table
263 * is mapped and returned by this function.
264 *
265 ******************************************************************************/
266
267struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
268 *table_header,
269 struct acpi_table_desc
270 *table_desc)
271{
272 acpi_status status;
273 struct acpi_table_header *new_table = NULL;
274 acpi_physical_address new_address = 0;
275 u32 new_table_length = 0;
276 u8 new_flags;
277 char *override_type;
278
279 /* (1) Attempt logical override (returns a logical address) */
280
281 status = acpi_os_table_override(table_header, &new_table);
282 if (ACPI_SUCCESS(status) && new_table) {
283 new_address = ACPI_PTR_TO_PHYSADDR(new_table);
284 new_table_length = new_table->length;
285 new_flags = ACPI_TABLE_ORIGIN_OVERRIDE;
286 override_type = "Logical";
287 goto finish_override;
288 }
289
290 /* (2) Attempt physical override (returns a physical address) */
291
292 status = acpi_os_physical_table_override(table_header,
293 &new_address,
294 &new_table_length);
295 if (ACPI_SUCCESS(status) && new_address && new_table_length) {
296
297 /* Map the entire new table */
298
299 new_table = acpi_os_map_memory(new_address, new_table_length);
300 if (!new_table) {
301 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
302 "%4.4s %p Attempted physical table override failed",
303 table_header->signature,
304 ACPI_CAST_PTR(void,
305 table_desc->address)));
306 return (NULL);
307 }
308
309 override_type = "Physical";
310 new_flags = ACPI_TABLE_ORIGIN_MAPPED;
311 goto finish_override;
312 }
313
314 return (NULL); /* There was no override */
315
316 finish_override:
317
318 ACPI_INFO((AE_INFO,
319 "%4.4s %p %s table override, new table: %p",
320 table_header->signature,
321 ACPI_CAST_PTR(void, table_desc->address),
322 override_type, new_table));
323
324 /* We can now unmap/delete the original table (if fully mapped) */
325
326 acpi_tb_delete_table(table_desc);
327
328 /* Setup descriptor for the new table */
329
330 table_desc->address = new_address;
331 table_desc->pointer = new_table;
332 table_desc->length = new_table_length;
333 table_desc->flags = new_flags;
334
335 return (new_table);
336}
337
338/*******************************************************************************
339 *
340 * FUNCTION: acpi_tb_resize_root_table_list 266 * FUNCTION: acpi_tb_resize_root_table_list
341 * 267 *
342 * PARAMETERS: None 268 * PARAMETERS: None
@@ -350,7 +276,6 @@ struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
350acpi_status acpi_tb_resize_root_table_list(void) 276acpi_status acpi_tb_resize_root_table_list(void)
351{ 277{
352 struct acpi_table_desc *tables; 278 struct acpi_table_desc *tables;
353 u32 table_count;
354 279
355 ACPI_FUNCTION_TRACE(tb_resize_root_table_list); 280 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
356 281
@@ -364,13 +289,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
364 289
365 /* Increase the Table Array size */ 290 /* Increase the Table Array size */
366 291
367 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { 292 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list.
368 table_count = acpi_gbl_root_table_list.max_table_count; 293 max_table_count +
369 } else {
370 table_count = acpi_gbl_root_table_list.current_table_count;
371 }
372
373 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
374 ACPI_ROOT_TABLE_SIZE_INCREMENT) * 294 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
375 sizeof(struct acpi_table_desc)); 295 sizeof(struct acpi_table_desc));
376 if (!tables) { 296 if (!tables) {
@@ -383,8 +303,8 @@ acpi_status acpi_tb_resize_root_table_list(void)
383 303
384 if (acpi_gbl_root_table_list.tables) { 304 if (acpi_gbl_root_table_list.tables) {
385 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, 305 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
386 (acpi_size) table_count * 306 (acpi_size) acpi_gbl_root_table_list.
387 sizeof(struct acpi_table_desc)); 307 max_table_count * sizeof(struct acpi_table_desc));
388 308
389 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { 309 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
390 ACPI_FREE(acpi_gbl_root_table_list.tables); 310 ACPI_FREE(acpi_gbl_root_table_list.tables);
@@ -392,9 +312,9 @@ acpi_status acpi_tb_resize_root_table_list(void)
392 } 312 }
393 313
394 acpi_gbl_root_table_list.tables = tables; 314 acpi_gbl_root_table_list.tables = tables;
395 acpi_gbl_root_table_list.max_table_count = 315 acpi_gbl_root_table_list.max_table_count +=
396 table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; 316 ACPI_ROOT_TABLE_SIZE_INCREMENT;
397 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; 317 acpi_gbl_root_table_list.flags |= (u8)ACPI_ROOT_ORIGIN_ALLOCATED;
398 318
399 return_ACPI_STATUS(AE_OK); 319 return_ACPI_STATUS(AE_OK);
400} 320}
@@ -403,10 +323,10 @@ acpi_status acpi_tb_resize_root_table_list(void)
403 * 323 *
404 * FUNCTION: acpi_tb_store_table 324 * FUNCTION: acpi_tb_store_table
405 * 325 *
406 * PARAMETERS: address - Table address 326 * PARAMETERS: Address - Table address
407 * table - Table header 327 * Table - Table header
408 * length - Table length 328 * Length - Table length
409 * flags - flags 329 * Flags - flags
410 * 330 *
411 * RETURN: Status and table index. 331 * RETURN: Status and table index.
412 * 332 *
@@ -476,11 +396,7 @@ void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
476 case ACPI_TABLE_ORIGIN_ALLOCATED: 396 case ACPI_TABLE_ORIGIN_ALLOCATED:
477 ACPI_FREE(table_desc->pointer); 397 ACPI_FREE(table_desc->pointer);
478 break; 398 break;
479 399 default:;
480 /* Not mapped or allocated, there is nothing we can do */
481
482 default:
483 return;
484 } 400 }
485 401
486 table_desc->pointer = NULL; 402 table_desc->pointer = NULL;
@@ -526,8 +442,6 @@ void acpi_tb_terminate(void)
526 442
527 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); 443 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
528 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 444 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
529
530 return_VOID;
531} 445}
532 446
533/******************************************************************************* 447/*******************************************************************************
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 285e24b9738..0f2d395feab 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -118,7 +118,6 @@ acpi_tb_check_xsdt(acpi_physical_address address)
118 return AE_OK; 118 return AE_OK;
119} 119}
120 120
121#if (!ACPI_REDUCED_HARDWARE)
122/******************************************************************************* 121/*******************************************************************************
123 * 122 *
124 * FUNCTION: acpi_tb_initialize_facs 123 * FUNCTION: acpi_tb_initialize_facs
@@ -136,20 +135,12 @@ acpi_status acpi_tb_initialize_facs(void)
136{ 135{
137 acpi_status status; 136 acpi_status status;
138 137
139 /* If Hardware Reduced flag is set, there is no FACS */
140
141 if (acpi_gbl_reduced_hardware) {
142 acpi_gbl_FACS = NULL;
143 return (AE_OK);
144 }
145
146 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, 138 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
147 ACPI_CAST_INDIRECT_PTR(struct 139 ACPI_CAST_INDIRECT_PTR(struct
148 acpi_table_header, 140 acpi_table_header,
149 &acpi_gbl_FACS)); 141 &acpi_gbl_FACS));
150 return status; 142 return status;
151} 143}
152#endif /* !ACPI_REDUCED_HARDWARE */
153 144
154/******************************************************************************* 145/*******************************************************************************
155 * 146 *
@@ -178,8 +169,8 @@ u8 acpi_tb_tables_loaded(void)
178 * 169 *
179 * FUNCTION: acpi_tb_fix_string 170 * FUNCTION: acpi_tb_fix_string
180 * 171 *
181 * PARAMETERS: string - String to be repaired 172 * PARAMETERS: String - String to be repaired
182 * length - Maximum length 173 * Length - Maximum length
183 * 174 *
184 * RETURN: None 175 * RETURN: None
185 * 176 *
@@ -205,7 +196,7 @@ static void acpi_tb_fix_string(char *string, acpi_size length)
205 * FUNCTION: acpi_tb_cleanup_table_header 196 * FUNCTION: acpi_tb_cleanup_table_header
206 * 197 *
207 * PARAMETERS: out_header - Where the cleaned header is returned 198 * PARAMETERS: out_header - Where the cleaned header is returned
208 * header - Input ACPI table header 199 * Header - Input ACPI table header
209 * 200 *
210 * RETURN: Returns the cleaned header in out_header 201 * RETURN: Returns the cleaned header in out_header
211 * 202 *
@@ -231,8 +222,8 @@ acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
231 * 222 *
232 * FUNCTION: acpi_tb_print_table_header 223 * FUNCTION: acpi_tb_print_table_header
233 * 224 *
234 * PARAMETERS: address - Table physical address 225 * PARAMETERS: Address - Table physical address
235 * header - Table header 226 * Header - Table header
236 * 227 *
237 * RETURN: None 228 * RETURN: None
238 * 229 *
@@ -296,8 +287,8 @@ acpi_tb_print_table_header(acpi_physical_address address,
296 * 287 *
297 * FUNCTION: acpi_tb_validate_checksum 288 * FUNCTION: acpi_tb_validate_checksum
298 * 289 *
299 * PARAMETERS: table - ACPI table to verify 290 * PARAMETERS: Table - ACPI table to verify
300 * length - Length of entire table 291 * Length - Length of entire table
301 * 292 *
302 * RETURN: Status 293 * RETURN: Status
303 * 294 *
@@ -317,11 +308,10 @@ acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
317 /* Checksum ok? (should be zero) */ 308 /* Checksum ok? (should be zero) */
318 309
319 if (checksum) { 310 if (checksum) {
320 ACPI_BIOS_WARNING((AE_INFO, 311 ACPI_WARNING((AE_INFO,
321 "Incorrect checksum in table [%4.4s] - 0x%2.2X, " 312 "Incorrect checksum in table [%4.4s] - 0x%2.2X, should be 0x%2.2X",
322 "should be 0x%2.2X", 313 table->signature, table->checksum,
323 table->signature, table->checksum, 314 (u8) (table->checksum - checksum)));
324 (u8)(table->checksum - checksum)));
325 315
326#if (ACPI_CHECKSUM_ABORT) 316#if (ACPI_CHECKSUM_ABORT)
327 317
@@ -336,8 +326,8 @@ acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
336 * 326 *
337 * FUNCTION: acpi_tb_checksum 327 * FUNCTION: acpi_tb_checksum
338 * 328 *
339 * PARAMETERS: buffer - Pointer to memory region to be checked 329 * PARAMETERS: Buffer - Pointer to memory region to be checked
340 * length - Length of this memory region 330 * Length - Length of this memory region
341 * 331 *
342 * RETURN: Checksum (u8) 332 * RETURN: Checksum (u8)
343 * 333 *
@@ -354,7 +344,7 @@ u8 acpi_tb_checksum(u8 *buffer, u32 length)
354 sum = (u8) (sum + *(buffer++)); 344 sum = (u8) (sum + *(buffer++));
355 } 345 }
356 346
357 return (sum); 347 return sum;
358} 348}
359 349
360/******************************************************************************* 350/*******************************************************************************
@@ -378,9 +368,8 @@ void acpi_tb_check_dsdt_header(void)
378 368
379 if (acpi_gbl_original_dsdt_header.length != acpi_gbl_DSDT->length || 369 if (acpi_gbl_original_dsdt_header.length != acpi_gbl_DSDT->length ||
380 acpi_gbl_original_dsdt_header.checksum != acpi_gbl_DSDT->checksum) { 370 acpi_gbl_original_dsdt_header.checksum != acpi_gbl_DSDT->checksum) {
381 ACPI_BIOS_ERROR((AE_INFO, 371 ACPI_ERROR((AE_INFO,
382 "The DSDT has been corrupted or replaced - " 372 "The DSDT has been corrupted or replaced - old, new headers below"));
383 "old, new headers below"));
384 acpi_tb_print_table_header(0, &acpi_gbl_original_dsdt_header); 373 acpi_tb_print_table_header(0, &acpi_gbl_original_dsdt_header);
385 acpi_tb_print_table_header(0, acpi_gbl_DSDT); 374 acpi_tb_print_table_header(0, acpi_gbl_DSDT);
386 375
@@ -440,15 +429,15 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
440 * 429 *
441 * FUNCTION: acpi_tb_install_table 430 * FUNCTION: acpi_tb_install_table
442 * 431 *
443 * PARAMETERS: address - Physical address of DSDT or FACS 432 * PARAMETERS: Address - Physical address of DSDT or FACS
444 * signature - Table signature, NULL if no need to 433 * Signature - Table signature, NULL if no need to
445 * match 434 * match
446 * table_index - Index into root table array 435 * table_index - Index into root table array
447 * 436 *
448 * RETURN: None 437 * RETURN: None
449 * 438 *
450 * DESCRIPTION: Install an ACPI table into the global data structure. The 439 * DESCRIPTION: Install an ACPI table into the global data structure. The
451 * table override mechanism is called to allow the host 440 * table override mechanism is implemented here to allow the host
452 * OS to replace any table before it is installed in the root 441 * OS to replace any table before it is installed in the root
453 * table array. 442 * table array.
454 * 443 *
@@ -458,9 +447,11 @@ void
458acpi_tb_install_table(acpi_physical_address address, 447acpi_tb_install_table(acpi_physical_address address,
459 char *signature, u32 table_index) 448 char *signature, u32 table_index)
460{ 449{
461 struct acpi_table_header *table; 450 u8 flags;
462 struct acpi_table_header *final_table; 451 acpi_status status;
463 struct acpi_table_desc *table_desc; 452 struct acpi_table_header *table_to_install;
453 struct acpi_table_header *mapped_table;
454 struct acpi_table_header *override_table = NULL;
464 455
465 if (!address) { 456 if (!address) {
466 ACPI_ERROR((AE_INFO, 457 ACPI_ERROR((AE_INFO,
@@ -471,79 +462,69 @@ acpi_tb_install_table(acpi_physical_address address,
471 462
472 /* Map just the table header */ 463 /* Map just the table header */
473 464
474 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); 465 mapped_table =
475 if (!table) { 466 acpi_os_map_memory(address, sizeof(struct acpi_table_header));
476 ACPI_ERROR((AE_INFO, 467 if (!mapped_table) {
477 "Could not map memory for table [%s] at %p",
478 signature, ACPI_CAST_PTR(void, address)));
479 return; 468 return;
480 } 469 }
481 470
482 /* If a particular signature is expected (DSDT/FACS), it must match */ 471 /* If a particular signature is expected (DSDT/FACS), it must match */
483 472
484 if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) { 473 if (signature && !ACPI_COMPARE_NAME(mapped_table->signature, signature)) {
485 ACPI_BIOS_ERROR((AE_INFO, 474 ACPI_ERROR((AE_INFO,
486 "Invalid signature 0x%X for ACPI table, expected [%s]", 475 "Invalid signature 0x%X for ACPI table, expected [%s]",
487 *ACPI_CAST_PTR(u32, table->signature), 476 *ACPI_CAST_PTR(u32, mapped_table->signature),
488 signature)); 477 signature));
489 goto unmap_and_exit; 478 goto unmap_and_exit;
490 } 479 }
491 480
492 /* 481 /*
493 * Initialize the table entry. Set the pointer to NULL, since the
494 * table is not fully mapped at this time.
495 */
496 table_desc = &acpi_gbl_root_table_list.tables[table_index];
497
498 table_desc->address = address;
499 table_desc->pointer = NULL;
500 table_desc->length = table->length;
501 table_desc->flags = ACPI_TABLE_ORIGIN_MAPPED;
502 ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature);
503
504 /*
505 * ACPI Table Override: 482 * ACPI Table Override:
506 * 483 *
507 * Before we install the table, let the host OS override it with a new 484 * Before we install the table, let the host OS override it with a new
508 * one if desired. Any table within the RSDT/XSDT can be replaced, 485 * one if desired. Any table within the RSDT/XSDT can be replaced,
509 * including the DSDT which is pointed to by the FADT. 486 * including the DSDT which is pointed to by the FADT.
510 *
511 * NOTE: If the table is overridden, then final_table will contain a
512 * mapped pointer to the full new table. If the table is not overridden,
513 * or if there has been a physical override, then the table will be
514 * fully mapped later (in verify table). In any case, we must
515 * unmap the header that was mapped above.
516 */ 487 */
517 final_table = acpi_tb_table_override(table, table_desc); 488 status = acpi_os_table_override(mapped_table, &override_table);
518 if (!final_table) { 489 if (ACPI_SUCCESS(status) && override_table) {
519 final_table = table; /* There was no override */ 490 ACPI_INFO((AE_INFO,
491 "%4.4s @ 0x%p Table override, replaced with:",
492 mapped_table->signature, ACPI_CAST_PTR(void,
493 address)));
494
495 acpi_gbl_root_table_list.tables[table_index].pointer =
496 override_table;
497 address = ACPI_PTR_TO_PHYSADDR(override_table);
498
499 table_to_install = override_table;
500 flags = ACPI_TABLE_ORIGIN_OVERRIDE;
501 } else {
502 table_to_install = mapped_table;
503 flags = ACPI_TABLE_ORIGIN_MAPPED;
520 } 504 }
521 505
522 acpi_tb_print_table_header(table_desc->address, final_table); 506 /* Initialize the table entry */
507
508 acpi_gbl_root_table_list.tables[table_index].address = address;
509 acpi_gbl_root_table_list.tables[table_index].length =
510 table_to_install->length;
511 acpi_gbl_root_table_list.tables[table_index].flags = flags;
512
513 ACPI_MOVE_32_TO_32(&
514 (acpi_gbl_root_table_list.tables[table_index].
515 signature), table_to_install->signature);
523 516
524 /* Set the global integer width (based upon revision of the DSDT) */ 517 acpi_tb_print_table_header(address, table_to_install);
525 518
526 if (table_index == ACPI_TABLE_INDEX_DSDT) { 519 if (table_index == ACPI_TABLE_INDEX_DSDT) {
527 acpi_ut_set_integer_width(final_table->revision);
528 }
529 520
530 /* 521 /* Global integer width is based upon revision of the DSDT */
531 * If we have a physical override during this early loading of the ACPI 522
532 * tables, unmap the table for now. It will be mapped again later when 523 acpi_ut_set_integer_width(table_to_install->revision);
533 * it is actually used. This supports very early loading of ACPI tables,
534 * before virtual memory is fully initialized and running within the
535 * host OS. Note: A logical override has the ACPI_TABLE_ORIGIN_OVERRIDE
536 * flag set and will not be deleted below.
537 */
538 if (final_table != table) {
539 acpi_tb_delete_table(table_desc);
540 } 524 }
541 525
542 unmap_and_exit: 526 unmap_and_exit:
543 527 acpi_os_unmap_memory(mapped_table, sizeof(struct acpi_table_header));
544 /* Always unmap the table header that we mapped above */
545
546 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
547} 528}
548 529
549/******************************************************************************* 530/*******************************************************************************
@@ -592,10 +573,10 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
592 573
593 /* Will truncate 64-bit address to 32 bits, issue warning */ 574 /* Will truncate 64-bit address to 32 bits, issue warning */
594 575
595 ACPI_BIOS_WARNING((AE_INFO, 576 ACPI_WARNING((AE_INFO,
596 "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X)," 577 "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X),"
597 " truncating", 578 " truncating",
598 ACPI_FORMAT_UINT64(address64))); 579 ACPI_FORMAT_UINT64(address64)));
599 } 580 }
600#endif 581#endif
601 return ((acpi_physical_address) (address64)); 582 return ((acpi_physical_address) (address64));
@@ -606,7 +587,7 @@ acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
606 * 587 *
607 * FUNCTION: acpi_tb_parse_root_table 588 * FUNCTION: acpi_tb_parse_root_table
608 * 589 *
609 * PARAMETERS: rsdp - Pointer to the RSDP 590 * PARAMETERS: Rsdp - Pointer to the RSDP
610 * 591 *
611 * RETURN: Status 592 * RETURN: Status
612 * 593 *
@@ -697,9 +678,8 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
697 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); 678 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
698 679
699 if (length < sizeof(struct acpi_table_header)) { 680 if (length < sizeof(struct acpi_table_header)) {
700 ACPI_BIOS_ERROR((AE_INFO, 681 ACPI_ERROR((AE_INFO, "Invalid length 0x%X in RSDT/XSDT",
701 "Invalid table length 0x%X in RSDT/XSDT", 682 length));
702 length));
703 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 683 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
704 } 684 }
705 685
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index f5632780421..4b7085dfc68 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -1,11 +1,12 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: tbxface - ACPI table oriented external interfaces 3 * Module Name: tbxface - Public interfaces to the ACPI subsystem
4 * ACPI table oriented interfaces
4 * 5 *
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
7/* 8/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 10 * All rights reserved.
10 * 11 *
11 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -41,7 +42,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
42 */ 43 */
43 44
44#include <linux/export.h>
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
@@ -50,6 +50,11 @@
50#define _COMPONENT ACPI_TABLES 50#define _COMPONENT ACPI_TABLES
51ACPI_MODULE_NAME("tbxface") 51ACPI_MODULE_NAME("tbxface")
52 52
53/* Local prototypes */
54static acpi_status acpi_tb_load_namespace(void);
55
56static int no_auto_ssdt;
57
53/******************************************************************************* 58/*******************************************************************************
54 * 59 *
55 * FUNCTION: acpi_allocate_root_table 60 * FUNCTION: acpi_allocate_root_table
@@ -59,10 +64,11 @@ ACPI_MODULE_NAME("tbxface")
59 * 64 *
60 * RETURN: Status 65 * RETURN: Status
61 * 66 *
62 * DESCRIPTION: Allocate a root table array. Used by iASL compiler and 67 * DESCRIPTION: Allocate a root table array. Used by i_aSL compiler and
63 * acpi_initialize_tables. 68 * acpi_initialize_tables.
64 * 69 *
65 ******************************************************************************/ 70 ******************************************************************************/
71
66acpi_status acpi_allocate_root_table(u32 initial_table_count) 72acpi_status acpi_allocate_root_table(u32 initial_table_count)
67{ 73{
68 74
@@ -159,12 +165,14 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array,
159 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the 165 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
160 * root list from the previously provided scratch area. Should 166 * root list from the previously provided scratch area. Should
161 * be called once dynamic memory allocation is available in the 167 * be called once dynamic memory allocation is available in the
162 * kernel. 168 * kernel
163 * 169 *
164 ******************************************************************************/ 170 ******************************************************************************/
165acpi_status acpi_reallocate_root_table(void) 171acpi_status acpi_reallocate_root_table(void)
166{ 172{
167 acpi_status status; 173 struct acpi_table_desc *tables;
174 acpi_size new_size;
175 acpi_size current_size;
168 176
169 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); 177 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
170 178
@@ -176,18 +184,89 @@ acpi_status acpi_reallocate_root_table(void)
176 return_ACPI_STATUS(AE_SUPPORT); 184 return_ACPI_STATUS(AE_SUPPORT);
177 } 185 }
178 186
179 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE; 187 /*
188 * Get the current size of the root table and add the default
189 * increment to create the new table size.
190 */
191 current_size = (acpi_size)
192 acpi_gbl_root_table_list.current_table_count *
193 sizeof(struct acpi_table_desc);
180 194
181 status = acpi_tb_resize_root_table_list(); 195 new_size = current_size +
182 return_ACPI_STATUS(status); 196 (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof(struct acpi_table_desc));
197
198 /* Create new array and copy the old array */
199
200 tables = ACPI_ALLOCATE_ZEROED(new_size);
201 if (!tables) {
202 return_ACPI_STATUS(AE_NO_MEMORY);
203 }
204
205 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, current_size);
206
207 /*
208 * Update the root table descriptor. The new size will be the current
209 * number of tables plus the increment, independent of the reserved
210 * size of the original table list.
211 */
212 acpi_gbl_root_table_list.tables = tables;
213 acpi_gbl_root_table_list.max_table_count =
214 acpi_gbl_root_table_list.current_table_count +
215 ACPI_ROOT_TABLE_SIZE_INCREMENT;
216 acpi_gbl_root_table_list.flags =
217 ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
218
219 return_ACPI_STATUS(AE_OK);
220}
221
222/*******************************************************************************
223 *
224 * FUNCTION: acpi_load_table
225 *
226 * PARAMETERS: table_ptr - pointer to a buffer containing the entire
227 * table to be loaded
228 *
229 * RETURN: Status
230 *
231 * DESCRIPTION: This function is called to load a table from the caller's
232 * buffer. The buffer must contain an entire ACPI Table including
233 * a valid header. The header fields will be verified, and if it
234 * is determined that the table is invalid, the call will fail.
235 *
236 ******************************************************************************/
237acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
238{
239 acpi_status status;
240 u32 table_index;
241 struct acpi_table_desc table_desc;
242
243 if (!table_ptr)
244 return AE_BAD_PARAMETER;
245
246 ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc));
247 table_desc.pointer = table_ptr;
248 table_desc.length = table_ptr->length;
249 table_desc.flags = ACPI_TABLE_ORIGIN_UNKNOWN;
250
251 /*
252 * Install the new table into the local data structures
253 */
254 status = acpi_tb_add_table(&table_desc, &table_index);
255 if (ACPI_FAILURE(status)) {
256 return status;
257 }
258 status = acpi_ns_load_table(table_index, acpi_gbl_root_node);
259 return status;
183} 260}
184 261
262ACPI_EXPORT_SYMBOL(acpi_load_table)
263
185/******************************************************************************* 264/*******************************************************************************
186 * 265 *
187 * FUNCTION: acpi_get_table_header 266 * FUNCTION: acpi_get_table_header
188 * 267 *
189 * PARAMETERS: signature - ACPI signature of needed table 268 * PARAMETERS: Signature - ACPI signature of needed table
190 * instance - Which instance (for SSDTs) 269 * Instance - Which instance (for SSDTs)
191 * out_table_header - The pointer to the table header to fill 270 * out_table_header - The pointer to the table header to fill
192 * 271 *
193 * RETURN: Status and pointer to mapped table header 272 * RETURN: Status and pointer to mapped table header
@@ -236,7 +315,7 @@ acpi_get_table_header(char *signature,
236 sizeof(struct 315 sizeof(struct
237 acpi_table_header)); 316 acpi_table_header));
238 if (!header) { 317 if (!header) {
239 return (AE_NO_MEMORY); 318 return AE_NO_MEMORY;
240 } 319 }
241 ACPI_MEMCPY(out_table_header, header, 320 ACPI_MEMCPY(out_table_header, header,
242 sizeof(struct acpi_table_header)); 321 sizeof(struct acpi_table_header));
@@ -244,7 +323,7 @@ acpi_get_table_header(char *signature,
244 sizeof(struct 323 sizeof(struct
245 acpi_table_header)); 324 acpi_table_header));
246 } else { 325 } else {
247 return (AE_NOT_FOUND); 326 return AE_NOT_FOUND;
248 } 327 }
249 } else { 328 } else {
250 ACPI_MEMCPY(out_table_header, 329 ACPI_MEMCPY(out_table_header,
@@ -302,8 +381,8 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
302 * 381 *
303 * FUNCTION: acpi_get_table_with_size 382 * FUNCTION: acpi_get_table_with_size
304 * 383 *
305 * PARAMETERS: signature - ACPI signature of needed table 384 * PARAMETERS: Signature - ACPI signature of needed table
306 * instance - Which instance (for SSDTs) 385 * Instance - Which instance (for SSDTs)
307 * out_table - Where the pointer to the table is returned 386 * out_table - Where the pointer to the table is returned
308 * 387 *
309 * RETURN: Status and pointer to table 388 * RETURN: Status and pointer to table
@@ -356,7 +435,6 @@ acpi_get_table_with_size(char *signature,
356 435
357 return (AE_NOT_FOUND); 436 return (AE_NOT_FOUND);
358} 437}
359ACPI_EXPORT_SYMBOL(acpi_get_table_with_size)
360 438
361acpi_status 439acpi_status
362acpi_get_table(char *signature, 440acpi_get_table(char *signature,
@@ -374,7 +452,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table)
374 * FUNCTION: acpi_get_table_by_index 452 * FUNCTION: acpi_get_table_by_index
375 * 453 *
376 * PARAMETERS: table_index - Table index 454 * PARAMETERS: table_index - Table index
377 * table - Where the pointer to the table is returned 455 * Table - Where the pointer to the table is returned
378 * 456 *
379 * RETURN: Status and pointer to the table 457 * RETURN: Status and pointer to the table
380 * 458 *
@@ -423,13 +501,157 @@ acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table)
423 501
424ACPI_EXPORT_SYMBOL(acpi_get_table_by_index) 502ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
425 503
504/*******************************************************************************
505 *
506 * FUNCTION: acpi_tb_load_namespace
507 *
508 * PARAMETERS: None
509 *
510 * RETURN: Status
511 *
512 * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
513 * the RSDT/XSDT.
514 *
515 ******************************************************************************/
516static acpi_status acpi_tb_load_namespace(void)
517{
518 acpi_status status;
519 u32 i;
520 struct acpi_table_header *new_dsdt;
521
522 ACPI_FUNCTION_TRACE(tb_load_namespace);
523
524 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
525
526 /*
527 * Load the namespace. The DSDT is required, but any SSDT and
528 * PSDT tables are optional. Verify the DSDT.
529 */
530 if (!acpi_gbl_root_table_list.current_table_count ||
531 !ACPI_COMPARE_NAME(&
532 (acpi_gbl_root_table_list.
533 tables[ACPI_TABLE_INDEX_DSDT].signature),
534 ACPI_SIG_DSDT)
535 ||
536 ACPI_FAILURE(acpi_tb_verify_table
537 (&acpi_gbl_root_table_list.
538 tables[ACPI_TABLE_INDEX_DSDT]))) {
539 status = AE_NO_ACPI_TABLES;
540 goto unlock_and_exit;
541 }
542
543 /*
544 * Save the DSDT pointer for simple access. This is the mapped memory
545 * address. We must take care here because the address of the .Tables
546 * array can change dynamically as tables are loaded at run-time. Note:
547 * .Pointer field is not validated until after call to acpi_tb_verify_table.
548 */
549 acpi_gbl_DSDT =
550 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer;
551
552 /*
553 * Optionally copy the entire DSDT to local memory (instead of simply
554 * mapping it.) There are some BIOSs that corrupt or replace the original
555 * DSDT, creating the need for this option. Default is FALSE, do not copy
556 * the DSDT.
557 */
558 if (acpi_gbl_copy_dsdt_locally) {
559 new_dsdt = acpi_tb_copy_dsdt(ACPI_TABLE_INDEX_DSDT);
560 if (new_dsdt) {
561 acpi_gbl_DSDT = new_dsdt;
562 }
563 }
564
565 /*
566 * Save the original DSDT header for detection of table corruption
567 * and/or replacement of the DSDT from outside the OS.
568 */
569 ACPI_MEMCPY(&acpi_gbl_original_dsdt_header, acpi_gbl_DSDT,
570 sizeof(struct acpi_table_header));
571
572 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
573
574 /* Load and parse tables */
575
576 status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node);
577 if (ACPI_FAILURE(status)) {
578 return_ACPI_STATUS(status);
579 }
580
581 /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
582
583 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
584 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
585 if ((!ACPI_COMPARE_NAME
586 (&(acpi_gbl_root_table_list.tables[i].signature),
587 ACPI_SIG_SSDT)
588 &&
589 !ACPI_COMPARE_NAME(&
590 (acpi_gbl_root_table_list.tables[i].
591 signature), ACPI_SIG_PSDT))
592 ||
593 ACPI_FAILURE(acpi_tb_verify_table
594 (&acpi_gbl_root_table_list.tables[i]))) {
595 continue;
596 }
597
598 if (no_auto_ssdt) {
599 printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n");
600 continue;
601 }
602
603 /* Ignore errors while loading tables, get as many as possible */
604
605 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
606 (void)acpi_ns_load_table(i, acpi_gbl_root_node);
607 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
608 }
609
610 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
611
612 unlock_and_exit:
613 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
614 return_ACPI_STATUS(status);
615}
616
617/*******************************************************************************
618 *
619 * FUNCTION: acpi_load_tables
620 *
621 * PARAMETERS: None
622 *
623 * RETURN: Status
624 *
625 * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
626 *
627 ******************************************************************************/
628
629acpi_status acpi_load_tables(void)
630{
631 acpi_status status;
632
633 ACPI_FUNCTION_TRACE(acpi_load_tables);
634
635 /* Load the namespace from the tables */
636
637 status = acpi_tb_load_namespace();
638 if (ACPI_FAILURE(status)) {
639 ACPI_EXCEPTION((AE_INFO, status,
640 "While loading namespace from ACPI tables"));
641 }
642
643 return_ACPI_STATUS(status);
644}
645
646ACPI_EXPORT_SYMBOL(acpi_load_tables)
647
426 648
427/******************************************************************************* 649/*******************************************************************************
428 * 650 *
429 * FUNCTION: acpi_install_table_handler 651 * FUNCTION: acpi_install_table_handler
430 * 652 *
431 * PARAMETERS: handler - Table event handler 653 * PARAMETERS: Handler - Table event handler
432 * context - Value passed to the handler on each event 654 * Context - Value passed to the handler on each event
433 * 655 *
434 * RETURN: Status 656 * RETURN: Status
435 * 657 *
@@ -475,7 +697,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
475 * 697 *
476 * FUNCTION: acpi_remove_table_handler 698 * FUNCTION: acpi_remove_table_handler
477 * 699 *
478 * PARAMETERS: handler - Table event handler that was installed 700 * PARAMETERS: Handler - Table event handler that was installed
479 * previously. 701 * previously.
480 * 702 *
481 * RETURN: Status 703 * RETURN: Status
@@ -511,3 +733,15 @@ acpi_status acpi_remove_table_handler(acpi_tbl_handler handler)
511} 733}
512 734
513ACPI_EXPORT_SYMBOL(acpi_remove_table_handler) 735ACPI_EXPORT_SYMBOL(acpi_remove_table_handler)
736
737
738static int __init acpi_no_auto_ssdt_setup(char *s) {
739
740 printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n");
741
742 no_auto_ssdt = 1;
743
744 return 1;
745}
746
747__setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
deleted file mode 100644
index a5e1e4e4709..00000000000
--- a/drivers/acpi/acpica/tbxfload.c
+++ /dev/null
@@ -1,389 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: tbxfload - Table load/unload external interfaces
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <linux/export.h>
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "acnamesp.h"
48#include "actables.h"
49
50#define _COMPONENT ACPI_TABLES
51ACPI_MODULE_NAME("tbxfload")
52
53/* Local prototypes */
54static acpi_status acpi_tb_load_namespace(void);
55
56static int no_auto_ssdt;
57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_load_tables
61 *
62 * PARAMETERS: None
63 *
64 * RETURN: Status
65 *
66 * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
67 *
68 ******************************************************************************/
69
70acpi_status acpi_load_tables(void)
71{
72 acpi_status status;
73
74 ACPI_FUNCTION_TRACE(acpi_load_tables);
75
76 /* Load the namespace from the tables */
77
78 status = acpi_tb_load_namespace();
79 if (ACPI_FAILURE(status)) {
80 ACPI_EXCEPTION((AE_INFO, status,
81 "While loading namespace from ACPI tables"));
82 }
83
84 return_ACPI_STATUS(status);
85}
86
87ACPI_EXPORT_SYMBOL(acpi_load_tables)
88
89/*******************************************************************************
90 *
91 * FUNCTION: acpi_tb_load_namespace
92 *
93 * PARAMETERS: None
94 *
95 * RETURN: Status
96 *
97 * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
98 * the RSDT/XSDT.
99 *
100 ******************************************************************************/
101static acpi_status acpi_tb_load_namespace(void)
102{
103 acpi_status status;
104 u32 i;
105 struct acpi_table_header *new_dsdt;
106
107 ACPI_FUNCTION_TRACE(tb_load_namespace);
108
109 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
110
111 /*
112 * Load the namespace. The DSDT is required, but any SSDT and
113 * PSDT tables are optional. Verify the DSDT.
114 */
115 if (!acpi_gbl_root_table_list.current_table_count ||
116 !ACPI_COMPARE_NAME(&
117 (acpi_gbl_root_table_list.
118 tables[ACPI_TABLE_INDEX_DSDT].signature),
119 ACPI_SIG_DSDT)
120 ||
121 ACPI_FAILURE(acpi_tb_verify_table
122 (&acpi_gbl_root_table_list.
123 tables[ACPI_TABLE_INDEX_DSDT]))) {
124 status = AE_NO_ACPI_TABLES;
125 goto unlock_and_exit;
126 }
127
128 /*
129 * Save the DSDT pointer for simple access. This is the mapped memory
130 * address. We must take care here because the address of the .Tables
131 * array can change dynamically as tables are loaded at run-time. Note:
132 * .Pointer field is not validated until after call to acpi_tb_verify_table.
133 */
134 acpi_gbl_DSDT =
135 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer;
136
137 /*
138 * Optionally copy the entire DSDT to local memory (instead of simply
139 * mapping it.) There are some BIOSs that corrupt or replace the original
140 * DSDT, creating the need for this option. Default is FALSE, do not copy
141 * the DSDT.
142 */
143 if (acpi_gbl_copy_dsdt_locally) {
144 new_dsdt = acpi_tb_copy_dsdt(ACPI_TABLE_INDEX_DSDT);
145 if (new_dsdt) {
146 acpi_gbl_DSDT = new_dsdt;
147 }
148 }
149
150 /*
151 * Save the original DSDT header for detection of table corruption
152 * and/or replacement of the DSDT from outside the OS.
153 */
154 ACPI_MEMCPY(&acpi_gbl_original_dsdt_header, acpi_gbl_DSDT,
155 sizeof(struct acpi_table_header));
156
157 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
158
159 /* Load and parse tables */
160
161 status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node);
162 if (ACPI_FAILURE(status)) {
163 return_ACPI_STATUS(status);
164 }
165
166 /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
167
168 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
169 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
170 if ((!ACPI_COMPARE_NAME
171 (&(acpi_gbl_root_table_list.tables[i].signature),
172 ACPI_SIG_SSDT)
173 &&
174 !ACPI_COMPARE_NAME(&
175 (acpi_gbl_root_table_list.tables[i].
176 signature), ACPI_SIG_PSDT))
177 ||
178 ACPI_FAILURE(acpi_tb_verify_table
179 (&acpi_gbl_root_table_list.tables[i]))) {
180 continue;
181 }
182
183 if (no_auto_ssdt) {
184 printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n");
185 continue;
186 }
187
188 /* Ignore errors while loading tables, get as many as possible */
189
190 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
191 (void)acpi_ns_load_table(i, acpi_gbl_root_node);
192 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
193 }
194
195 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
196
197 unlock_and_exit:
198 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
199 return_ACPI_STATUS(status);
200}
201
202/*******************************************************************************
203 *
204 * FUNCTION: acpi_load_table
205 *
206 * PARAMETERS: table - Pointer to a buffer containing the ACPI
207 * table to be loaded.
208 *
209 * RETURN: Status
210 *
211 * DESCRIPTION: Dynamically load an ACPI table from the caller's buffer. Must
212 * be a valid ACPI table with a valid ACPI table header.
213 * Note1: Mainly intended to support hotplug addition of SSDTs.
214 * Note2: Does not copy the incoming table. User is responsible
215 * to ensure that the table is not deleted or unmapped.
216 *
217 ******************************************************************************/
218
219acpi_status acpi_load_table(struct acpi_table_header *table)
220{
221 acpi_status status;
222 struct acpi_table_desc table_desc;
223 u32 table_index;
224
225 ACPI_FUNCTION_TRACE(acpi_load_table);
226
227 /* Parameter validation */
228
229 if (!table) {
230 return_ACPI_STATUS(AE_BAD_PARAMETER);
231 }
232
233 /* Init local table descriptor */
234
235 ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc));
236 table_desc.address = ACPI_PTR_TO_PHYSADDR(table);
237 table_desc.pointer = table;
238 table_desc.length = table->length;
239 table_desc.flags = ACPI_TABLE_ORIGIN_UNKNOWN;
240
241 /* Must acquire the interpreter lock during this operation */
242
243 status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
244 if (ACPI_FAILURE(status)) {
245 return_ACPI_STATUS(status);
246 }
247
248 /* Install the table and load it into the namespace */
249
250 ACPI_INFO((AE_INFO, "Host-directed Dynamic ACPI Table Load:"));
251 status = acpi_tb_add_table(&table_desc, &table_index);
252 if (ACPI_FAILURE(status)) {
253 goto unlock_and_exit;
254 }
255
256 status = acpi_ns_load_table(table_index, acpi_gbl_root_node);
257
258 /* Invoke table handler if present */
259
260 if (acpi_gbl_table_handler) {
261 (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_LOAD, table,
262 acpi_gbl_table_handler_context);
263 }
264
265 unlock_and_exit:
266 (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
267 return_ACPI_STATUS(status);
268}
269
270ACPI_EXPORT_SYMBOL(acpi_load_table)
271
272/*******************************************************************************
273 *
274 * FUNCTION: acpi_unload_parent_table
275 *
276 * PARAMETERS: object - Handle to any namespace object owned by
277 * the table to be unloaded
278 *
279 * RETURN: Status
280 *
281 * DESCRIPTION: Via any namespace object within an SSDT or OEMx table, unloads
282 * the table and deletes all namespace objects associated with
283 * that table. Unloading of the DSDT is not allowed.
284 * Note: Mainly intended to support hotplug removal of SSDTs.
285 *
286 ******************************************************************************/
287acpi_status acpi_unload_parent_table(acpi_handle object)
288{
289 struct acpi_namespace_node *node =
290 ACPI_CAST_PTR(struct acpi_namespace_node, object);
291 acpi_status status = AE_NOT_EXIST;
292 acpi_owner_id owner_id;
293 u32 i;
294
295 ACPI_FUNCTION_TRACE(acpi_unload_parent_table);
296
297 /* Parameter validation */
298
299 if (!object) {
300 return_ACPI_STATUS(AE_BAD_PARAMETER);
301 }
302
303 /*
304 * The node owner_id is currently the same as the parent table ID.
305 * However, this could change in the future.
306 */
307 owner_id = node->owner_id;
308 if (!owner_id) {
309
310 /* owner_id==0 means DSDT is the owner. DSDT cannot be unloaded */
311
312 return_ACPI_STATUS(AE_TYPE);
313 }
314
315 /* Must acquire the interpreter lock during this operation */
316
317 status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
318 if (ACPI_FAILURE(status)) {
319 return_ACPI_STATUS(status);
320 }
321
322 /* Find the table in the global table list */
323
324 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
325 if (owner_id != acpi_gbl_root_table_list.tables[i].owner_id) {
326 continue;
327 }
328
329 /*
330 * Allow unload of SSDT and OEMx tables only. Do not allow unload
331 * of the DSDT. No other types of tables should get here, since
332 * only these types can contain AML and thus are the only types
333 * that can create namespace objects.
334 */
335 if (ACPI_COMPARE_NAME
336 (acpi_gbl_root_table_list.tables[i].signature.ascii,
337 ACPI_SIG_DSDT)) {
338 status = AE_TYPE;
339 break;
340 }
341
342 /* Ensure the table is actually loaded */
343
344 if (!acpi_tb_is_table_loaded(i)) {
345 status = AE_NOT_EXIST;
346 break;
347 }
348
349 /* Invoke table handler if present */
350
351 if (acpi_gbl_table_handler) {
352 (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD,
353 acpi_gbl_root_table_list.
354 tables[i].pointer,
355 acpi_gbl_table_handler_context);
356 }
357
358 /*
359 * Delete all namespace objects owned by this table. Note that
360 * these objects can appear anywhere in the namespace by virtue
361 * of the AML "Scope" operator. Thus, we need to track ownership
362 * by an ID, not simply a position within the hierarchy.
363 */
364 status = acpi_tb_delete_namespace_by_owner(i);
365 if (ACPI_FAILURE(status)) {
366 break;
367 }
368
369 status = acpi_tb_release_owner_id(i);
370 acpi_tb_set_table_loaded_flag(i, FALSE);
371 break;
372 }
373
374 (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
375 return_ACPI_STATUS(status);
376}
377
378ACPI_EXPORT_SYMBOL(acpi_unload_parent_table)
379
380static int __init acpi_no_auto_ssdt_setup(char *s) {
381
382 printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n");
383
384 no_auto_ssdt = 1;
385
386 return 1;
387}
388
389__setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index 28f330230f9..7eb6c6cc1ed 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -57,7 +57,7 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp);
57 * 57 *
58 * FUNCTION: acpi_tb_validate_rsdp 58 * FUNCTION: acpi_tb_validate_rsdp
59 * 59 *
60 * PARAMETERS: rsdp - Pointer to unvalidated RSDP 60 * PARAMETERS: Rsdp - Pointer to unvalidated RSDP
61 * 61 *
62 * RETURN: Status 62 * RETURN: Status
63 * 63 *
@@ -67,6 +67,7 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp);
67 67
68static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) 68static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
69{ 69{
70 ACPI_FUNCTION_ENTRY();
70 71
71 /* 72 /*
72 * The signature and checksum must both be correct 73 * The signature and checksum must both be correct
@@ -106,10 +107,10 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
106 * 107 *
107 * RETURN: Status, RSDP physical address 108 * RETURN: Status, RSDP physical address
108 * 109 *
109 * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor 110 * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor
110 * pointer structure. If it is found, set *RSDP to point to it. 111 * pointer structure. If it is found, set *RSDP to point to it.
111 * 112 *
112 * NOTE1: The RSDP must be either in the first 1K of the Extended 113 * NOTE1: The RSDP must be either in the first 1_k of the Extended
113 * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) 114 * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
114 * Only a 32-bit physical address is necessary. 115 * Only a 32-bit physical address is necessary.
115 * 116 *
@@ -151,7 +152,7 @@ acpi_status acpi_find_root_pointer(acpi_size *table_address)
151 if (physical_address > 0x400) { 152 if (physical_address > 0x400) {
152 /* 153 /*
153 * 1b) Search EBDA paragraphs (EBDA is required to be a 154 * 1b) Search EBDA paragraphs (EBDA is required to be a
154 * minimum of 1K length) 155 * minimum of 1_k length)
155 */ 156 */
156 table_ptr = acpi_os_map_memory((acpi_physical_address) 157 table_ptr = acpi_os_map_memory((acpi_physical_address)
157 physical_address, 158 physical_address,
@@ -215,7 +216,7 @@ acpi_status acpi_find_root_pointer(acpi_size *table_address)
215 216
216 /* A valid RSDP was not found */ 217 /* A valid RSDP was not found */
217 218
218 ACPI_BIOS_ERROR((AE_INFO, "A valid RSDP was not found")); 219 ACPI_ERROR((AE_INFO, "A valid RSDP was not found"));
219 return_ACPI_STATUS(AE_NOT_FOUND); 220 return_ACPI_STATUS(AE_NOT_FOUND);
220} 221}
221 222
@@ -224,7 +225,7 @@ acpi_status acpi_find_root_pointer(acpi_size *table_address)
224 * FUNCTION: acpi_tb_scan_memory_for_rsdp 225 * FUNCTION: acpi_tb_scan_memory_for_rsdp
225 * 226 *
226 * PARAMETERS: start_address - Starting pointer for search 227 * PARAMETERS: start_address - Starting pointer for search
227 * length - Maximum length to search 228 * Length - Maximum length to search
228 * 229 *
229 * RETURN: Pointer to the RSDP if found, otherwise NULL. 230 * RETURN: Pointer to the RSDP if found, otherwise NULL.
230 * 231 *
diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c
deleted file mode 100644
index 64880306133..00000000000
--- a/drivers/acpi/acpica/utaddress.c
+++ /dev/null
@@ -1,294 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utaddress - op_region address range check
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acnamesp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utaddress")
50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_ut_add_address_range
54 *
55 * PARAMETERS: space_id - Address space ID
56 * address - op_region start address
57 * length - op_region length
58 * region_node - op_region namespace node
59 *
60 * RETURN: Status
61 *
62 * DESCRIPTION: Add the Operation Region address range to the global list.
63 * The only supported Space IDs are Memory and I/O. Called when
64 * the op_region address/length operands are fully evaluated.
65 *
66 * MUTEX: Locks the namespace
67 *
68 * NOTE: Because this interface is only called when an op_region argument
69 * list is evaluated, there cannot be any duplicate region_nodes.
70 * Duplicate Address/Length values are allowed, however, so that multiple
71 * address conflicts can be detected.
72 *
73 ******************************************************************************/
74acpi_status
75acpi_ut_add_address_range(acpi_adr_space_type space_id,
76 acpi_physical_address address,
77 u32 length, struct acpi_namespace_node *region_node)
78{
79 struct acpi_address_range *range_info;
80 acpi_status status;
81
82 ACPI_FUNCTION_TRACE(ut_add_address_range);
83
84 if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
85 (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
86 return_ACPI_STATUS(AE_OK);
87 }
88
89 /* Allocate/init a new info block, add it to the appropriate list */
90
91 range_info = ACPI_ALLOCATE(sizeof(struct acpi_address_range));
92 if (!range_info) {
93 return_ACPI_STATUS(AE_NO_MEMORY);
94 }
95
96 range_info->start_address = address;
97 range_info->end_address = (address + length - 1);
98 range_info->region_node = region_node;
99
100 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
101 if (ACPI_FAILURE(status)) {
102 ACPI_FREE(range_info);
103 return_ACPI_STATUS(status);
104 }
105
106 range_info->next = acpi_gbl_address_range_list[space_id];
107 acpi_gbl_address_range_list[space_id] = range_info;
108
109 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
110 "\nAdded [%4.4s] address range: 0x%p-0x%p\n",
111 acpi_ut_get_node_name(range_info->region_node),
112 ACPI_CAST_PTR(void, address),
113 ACPI_CAST_PTR(void, range_info->end_address)));
114
115 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
116 return_ACPI_STATUS(AE_OK);
117}
118
119/*******************************************************************************
120 *
121 * FUNCTION: acpi_ut_remove_address_range
122 *
123 * PARAMETERS: space_id - Address space ID
124 * region_node - op_region namespace node
125 *
126 * RETURN: None
127 *
128 * DESCRIPTION: Remove the Operation Region from the global list. The only
129 * supported Space IDs are Memory and I/O. Called when an
130 * op_region is deleted.
131 *
132 * MUTEX: Assumes the namespace is locked
133 *
134 ******************************************************************************/
135
136void
137acpi_ut_remove_address_range(acpi_adr_space_type space_id,
138 struct acpi_namespace_node *region_node)
139{
140 struct acpi_address_range *range_info;
141 struct acpi_address_range *prev;
142
143 ACPI_FUNCTION_TRACE(ut_remove_address_range);
144
145 if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
146 (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
147 return_VOID;
148 }
149
150 /* Get the appropriate list head and check the list */
151
152 range_info = prev = acpi_gbl_address_range_list[space_id];
153 while (range_info) {
154 if (range_info->region_node == region_node) {
155 if (range_info == prev) { /* Found at list head */
156 acpi_gbl_address_range_list[space_id] =
157 range_info->next;
158 } else {
159 prev->next = range_info->next;
160 }
161
162 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
163 "\nRemoved [%4.4s] address range: 0x%p-0x%p\n",
164 acpi_ut_get_node_name(range_info->
165 region_node),
166 ACPI_CAST_PTR(void,
167 range_info->
168 start_address),
169 ACPI_CAST_PTR(void,
170 range_info->
171 end_address)));
172
173 ACPI_FREE(range_info);
174 return_VOID;
175 }
176
177 prev = range_info;
178 range_info = range_info->next;
179 }
180
181 return_VOID;
182}
183
184/*******************************************************************************
185 *
186 * FUNCTION: acpi_ut_check_address_range
187 *
188 * PARAMETERS: space_id - Address space ID
189 * address - Start address
190 * length - Length of address range
191 * warn - TRUE if warning on overlap desired
192 *
193 * RETURN: Count of the number of conflicts detected. Zero is always
194 * returned for Space IDs other than Memory or I/O.
195 *
196 * DESCRIPTION: Check if the input address range overlaps any of the
197 * ASL operation region address ranges. The only supported
198 * Space IDs are Memory and I/O.
199 *
200 * MUTEX: Assumes the namespace is locked.
201 *
202 ******************************************************************************/
203
204u32
205acpi_ut_check_address_range(acpi_adr_space_type space_id,
206 acpi_physical_address address, u32 length, u8 warn)
207{
208 struct acpi_address_range *range_info;
209 acpi_physical_address end_address;
210 char *pathname;
211 u32 overlap_count = 0;
212
213 ACPI_FUNCTION_TRACE(ut_check_address_range);
214
215 if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
216 (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
217 return_UINT32(0);
218 }
219
220 range_info = acpi_gbl_address_range_list[space_id];
221 end_address = address + length - 1;
222
223 /* Check entire list for all possible conflicts */
224
225 while (range_info) {
226 /*
227 * Check if the requested Address/Length overlaps this address_range.
228 * Four cases to consider:
229 *
230 * 1) Input address/length is contained completely in the address range
231 * 2) Input address/length overlaps range at the range start
232 * 3) Input address/length overlaps range at the range end
233 * 4) Input address/length completely encompasses the range
234 */
235 if ((address <= range_info->end_address) &&
236 (end_address >= range_info->start_address)) {
237
238 /* Found an address range overlap */
239
240 overlap_count++;
241 if (warn) { /* Optional warning message */
242 pathname =
243 acpi_ns_get_external_pathname(range_info->
244 region_node);
245
246 ACPI_WARNING((AE_INFO,
247 "0x%p-0x%p %s conflicts with Region %s %d",
248 ACPI_CAST_PTR(void, address),
249 ACPI_CAST_PTR(void, end_address),
250 acpi_ut_get_region_name(space_id),
251 pathname, overlap_count));
252 ACPI_FREE(pathname);
253 }
254 }
255
256 range_info = range_info->next;
257 }
258
259 return_UINT32(overlap_count);
260}
261
262/*******************************************************************************
263 *
264 * FUNCTION: acpi_ut_delete_address_lists
265 *
266 * PARAMETERS: None
267 *
268 * RETURN: None
269 *
270 * DESCRIPTION: Delete all global address range lists (called during
271 * subsystem shutdown).
272 *
273 ******************************************************************************/
274
275void acpi_ut_delete_address_lists(void)
276{
277 struct acpi_address_range *next;
278 struct acpi_address_range *range_info;
279 int i;
280
281 /* Delete all elements in all address range lists */
282
283 for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) {
284 next = acpi_gbl_address_range_list[i];
285
286 while (next) {
287 range_info = next;
288 next = range_info->next;
289 ACPI_FREE(range_info);
290 }
291
292 acpi_gbl_address_range_list[i] = NULL;
293 }
294}
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index ed29d474095..0a697351cf6 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -189,7 +189,7 @@ acpi_status acpi_ut_delete_caches(void)
189 * 189 *
190 * FUNCTION: acpi_ut_validate_buffer 190 * FUNCTION: acpi_ut_validate_buffer
191 * 191 *
192 * PARAMETERS: buffer - Buffer descriptor to be validated 192 * PARAMETERS: Buffer - Buffer descriptor to be validated
193 * 193 *
194 * RETURN: Status 194 * RETURN: Status
195 * 195 *
@@ -227,7 +227,7 @@ acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
227 * 227 *
228 * FUNCTION: acpi_ut_initialize_buffer 228 * FUNCTION: acpi_ut_initialize_buffer
229 * 229 *
230 * PARAMETERS: buffer - Buffer to be validated 230 * PARAMETERS: Buffer - Buffer to be validated
231 * required_length - Length needed 231 * required_length - Length needed
232 * 232 *
233 * RETURN: Status 233 * RETURN: Status
@@ -308,10 +308,10 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
308 * 308 *
309 * FUNCTION: acpi_ut_allocate 309 * FUNCTION: acpi_ut_allocate
310 * 310 *
311 * PARAMETERS: size - Size of the allocation 311 * PARAMETERS: Size - Size of the allocation
312 * component - Component type of caller 312 * Component - Component type of caller
313 * module - Source file name of caller 313 * Module - Source file name of caller
314 * line - Line number of caller 314 * Line - Line number of caller
315 * 315 *
316 * RETURN: Address of the allocated memory on success, NULL on failure. 316 * RETURN: Address of the allocated memory on success, NULL on failure.
317 * 317 *
@@ -352,10 +352,10 @@ void *acpi_ut_allocate(acpi_size size,
352 * 352 *
353 * FUNCTION: acpi_ut_allocate_zeroed 353 * FUNCTION: acpi_ut_allocate_zeroed
354 * 354 *
355 * PARAMETERS: size - Size of the allocation 355 * PARAMETERS: Size - Size of the allocation
356 * component - Component type of caller 356 * Component - Component type of caller
357 * module - Source file name of caller 357 * Module - Source file name of caller
358 * line - Line number of caller 358 * Line - Line number of caller
359 * 359 *
360 * RETURN: Address of the allocated memory on success, NULL on failure. 360 * RETURN: Address of the allocated memory on success, NULL on failure.
361 * 361 *
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c
deleted file mode 100644
index e1d40ed2639..00000000000
--- a/drivers/acpi/acpica/utcache.c
+++ /dev/null
@@ -1,323 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utcache - local cache allocation routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utcache")
49
50#ifdef ACPI_USE_LOCAL_CACHE
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_os_create_cache
54 *
55 * PARAMETERS: cache_name - Ascii name for the cache
56 * object_size - Size of each cached object
57 * max_depth - Maximum depth of the cache (in objects)
58 * return_cache - Where the new cache object is returned
59 *
60 * RETURN: Status
61 *
62 * DESCRIPTION: Create a cache object
63 *
64 ******************************************************************************/
65acpi_status
66acpi_os_create_cache(char *cache_name,
67 u16 object_size,
68 u16 max_depth, struct acpi_memory_list ** return_cache)
69{
70 struct acpi_memory_list *cache;
71
72 ACPI_FUNCTION_ENTRY();
73
74 if (!cache_name || !return_cache || (object_size < 16)) {
75 return (AE_BAD_PARAMETER);
76 }
77
78 /* Create the cache object */
79
80 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
81 if (!cache) {
82 return (AE_NO_MEMORY);
83 }
84
85 /* Populate the cache object and return it */
86
87 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
88 cache->link_offset = 8;
89 cache->list_name = cache_name;
90 cache->object_size = object_size;
91 cache->max_depth = max_depth;
92
93 *return_cache = cache;
94 return (AE_OK);
95}
96
97/*******************************************************************************
98 *
99 * FUNCTION: acpi_os_purge_cache
100 *
101 * PARAMETERS: cache - Handle to cache object
102 *
103 * RETURN: Status
104 *
105 * DESCRIPTION: Free all objects within the requested cache.
106 *
107 ******************************************************************************/
108
109acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
110{
111 char *next;
112 acpi_status status;
113
114 ACPI_FUNCTION_ENTRY();
115
116 if (!cache) {
117 return (AE_BAD_PARAMETER);
118 }
119
120 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
121 if (ACPI_FAILURE(status)) {
122 return (status);
123 }
124
125 /* Walk the list of objects in this cache */
126
127 while (cache->list_head) {
128
129 /* Delete and unlink one cached state object */
130
131 next = *(ACPI_CAST_INDIRECT_PTR(char,
132 &(((char *)cache->
133 list_head)[cache->
134 link_offset])));
135 ACPI_FREE(cache->list_head);
136
137 cache->list_head = next;
138 cache->current_depth--;
139 }
140
141 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
142 return (AE_OK);
143}
144
145/*******************************************************************************
146 *
147 * FUNCTION: acpi_os_delete_cache
148 *
149 * PARAMETERS: cache - Handle to cache object
150 *
151 * RETURN: Status
152 *
153 * DESCRIPTION: Free all objects within the requested cache and delete the
154 * cache object.
155 *
156 ******************************************************************************/
157
158acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache)
159{
160 acpi_status status;
161
162 ACPI_FUNCTION_ENTRY();
163
164 /* Purge all objects in the cache */
165
166 status = acpi_os_purge_cache(cache);
167 if (ACPI_FAILURE(status)) {
168 return (status);
169 }
170
171 /* Now we can delete the cache object */
172
173 acpi_os_free(cache);
174 return (AE_OK);
175}
176
177/*******************************************************************************
178 *
179 * FUNCTION: acpi_os_release_object
180 *
181 * PARAMETERS: cache - Handle to cache object
182 * object - The object to be released
183 *
184 * RETURN: None
185 *
186 * DESCRIPTION: Release an object to the specified cache. If cache is full,
187 * the object is deleted.
188 *
189 ******************************************************************************/
190
191acpi_status
192acpi_os_release_object(struct acpi_memory_list * cache, void *object)
193{
194 acpi_status status;
195
196 ACPI_FUNCTION_ENTRY();
197
198 if (!cache || !object) {
199 return (AE_BAD_PARAMETER);
200 }
201
202 /* If cache is full, just free this object */
203
204 if (cache->current_depth >= cache->max_depth) {
205 ACPI_FREE(object);
206 ACPI_MEM_TRACKING(cache->total_freed++);
207 }
208
209 /* Otherwise put this object back into the cache */
210
211 else {
212 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
213 if (ACPI_FAILURE(status)) {
214 return (status);
215 }
216
217 /* Mark the object as cached */
218
219 ACPI_MEMSET(object, 0xCA, cache->object_size);
220 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED);
221
222 /* Put the object at the head of the cache list */
223
224 *(ACPI_CAST_INDIRECT_PTR(char,
225 &(((char *)object)[cache->
226 link_offset]))) =
227 cache->list_head;
228 cache->list_head = object;
229 cache->current_depth++;
230
231 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
232 }
233
234 return (AE_OK);
235}
236
237/*******************************************************************************
238 *
239 * FUNCTION: acpi_os_acquire_object
240 *
241 * PARAMETERS: cache - Handle to cache object
242 *
243 * RETURN: the acquired object. NULL on error
244 *
245 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
246 * the object is allocated.
247 *
248 ******************************************************************************/
249
250void *acpi_os_acquire_object(struct acpi_memory_list *cache)
251{
252 acpi_status status;
253 void *object;
254
255 ACPI_FUNCTION_NAME(os_acquire_object);
256
257 if (!cache) {
258 return (NULL);
259 }
260
261 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
262 if (ACPI_FAILURE(status)) {
263 return (NULL);
264 }
265
266 ACPI_MEM_TRACKING(cache->requests++);
267
268 /* Check the cache first */
269
270 if (cache->list_head) {
271
272 /* There is an object available, use it */
273
274 object = cache->list_head;
275 cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char,
276 &(((char *)
277 object)[cache->
278 link_offset])));
279
280 cache->current_depth--;
281
282 ACPI_MEM_TRACKING(cache->hits++);
283 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
284 "Object %p from %s cache\n", object,
285 cache->list_name));
286
287 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
288 if (ACPI_FAILURE(status)) {
289 return (NULL);
290 }
291
292 /* Clear (zero) the previously used Object */
293
294 ACPI_MEMSET(object, 0, cache->object_size);
295 } else {
296 /* The cache is empty, create a new object */
297
298 ACPI_MEM_TRACKING(cache->total_allocated++);
299
300#ifdef ACPI_DBG_TRACK_ALLOCATIONS
301 if ((cache->total_allocated - cache->total_freed) >
302 cache->max_occupied) {
303 cache->max_occupied =
304 cache->total_allocated - cache->total_freed;
305 }
306#endif
307
308 /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */
309
310 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
311 if (ACPI_FAILURE(status)) {
312 return (NULL);
313 }
314
315 object = ACPI_ALLOCATE_ZEROED(cache->object_size);
316 if (!object) {
317 return (NULL);
318 }
319 }
320
321 return (object);
322}
323#endif /* ACPI_USE_LOCAL_CACHE */
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 294692ae76e..aded299a2fa 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -317,7 +317,7 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type,
317 * FUNCTION: acpi_ut_copy_ipackage_to_epackage 317 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
318 * 318 *
319 * PARAMETERS: internal_object - Pointer to the object we are returning 319 * PARAMETERS: internal_object - Pointer to the object we are returning
320 * buffer - Where the object is returned 320 * Buffer - Where the object is returned
321 * space_used - Where the object length is returned 321 * space_used - Where the object length is returned
322 * 322 *
323 * RETURN: Status 323 * RETURN: Status
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 5d95166245a..a9bcd816dc2 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,15 +41,13 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include "accommon.h" 45#include "accommon.h"
47 46
48#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utdebug") 48ACPI_MODULE_NAME("utdebug")
50
51#ifdef ACPI_DEBUG_OUTPUT 49#ifdef ACPI_DEBUG_OUTPUT
52static acpi_thread_id acpi_gbl_prev_thread_id = (acpi_thread_id) 0xFFFFFFFF; 50static acpi_thread_id acpi_gbl_prev_thread_id;
53static char *acpi_gbl_fn_entry_str = "----Entry"; 51static char *acpi_gbl_fn_entry_str = "----Entry";
54static char *acpi_gbl_fn_exit_str = "----Exit-"; 52static char *acpi_gbl_fn_exit_str = "----Exit-";
55 53
@@ -110,7 +108,7 @@ void acpi_ut_track_stack_ptr(void)
110 * RETURN: Updated pointer to the function name 108 * RETURN: Updated pointer to the function name
111 * 109 *
112 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. 110 * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
113 * This allows compiler macros such as __FUNCTION__ to be used 111 * This allows compiler macros such as __func__ to be used
114 * with no change to the debug output. 112 * with no change to the debug output.
115 * 113 *
116 ******************************************************************************/ 114 ******************************************************************************/
@@ -146,7 +144,7 @@ static const char *acpi_ut_trim_function_name(const char *function_name)
146 * function_name - Caller's procedure name 144 * function_name - Caller's procedure name
147 * module_name - Caller's module name 145 * module_name - Caller's module name
148 * component_id - Caller's component ID 146 * component_id - Caller's component ID
149 * format - Printf format field 147 * Format - Printf format field
150 * ... - Optional printf arguments 148 * ... - Optional printf arguments
151 * 149 *
152 * RETURN: None 150 * RETURN: None
@@ -218,12 +216,12 @@ ACPI_EXPORT_SYMBOL(acpi_debug_print)
218 * function_name - Caller's procedure name 216 * function_name - Caller's procedure name
219 * module_name - Caller's module name 217 * module_name - Caller's module name
220 * component_id - Caller's component ID 218 * component_id - Caller's component ID
221 * format - Printf format field 219 * Format - Printf format field
222 * ... - Optional printf arguments 220 * ... - Optional printf arguments
223 * 221 *
224 * RETURN: None 222 * RETURN: None
225 * 223 *
226 * DESCRIPTION: Print message with no headers. Has same interface as 224 * DESCRIPTION: Print message with no headers. Has same interface as
227 * debug_print so that the same macros can be used. 225 * debug_print so that the same macros can be used.
228 * 226 *
229 ******************************************************************************/ 227 ******************************************************************************/
@@ -259,7 +257,7 @@ ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
259 * 257 *
260 * RETURN: None 258 * RETURN: None
261 * 259 *
262 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 260 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
263 * set in debug_level 261 * set in debug_level
264 * 262 *
265 ******************************************************************************/ 263 ******************************************************************************/
@@ -287,11 +285,11 @@ ACPI_EXPORT_SYMBOL(acpi_ut_trace)
287 * function_name - Caller's procedure name 285 * function_name - Caller's procedure name
288 * module_name - Caller's module name 286 * module_name - Caller's module name
289 * component_id - Caller's component ID 287 * component_id - Caller's component ID
290 * pointer - Pointer to display 288 * Pointer - Pointer to display
291 * 289 *
292 * RETURN: None 290 * RETURN: None
293 * 291 *
294 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 292 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
295 * set in debug_level 293 * set in debug_level
296 * 294 *
297 ******************************************************************************/ 295 ******************************************************************************/
@@ -300,7 +298,6 @@ acpi_ut_trace_ptr(u32 line_number,
300 const char *function_name, 298 const char *function_name,
301 const char *module_name, u32 component_id, void *pointer) 299 const char *module_name, u32 component_id, void *pointer)
302{ 300{
303
304 acpi_gbl_nesting_level++; 301 acpi_gbl_nesting_level++;
305 acpi_ut_track_stack_ptr(); 302 acpi_ut_track_stack_ptr();
306 303
@@ -317,11 +314,11 @@ acpi_ut_trace_ptr(u32 line_number,
317 * function_name - Caller's procedure name 314 * function_name - Caller's procedure name
318 * module_name - Caller's module name 315 * module_name - Caller's module name
319 * component_id - Caller's component ID 316 * component_id - Caller's component ID
320 * string - Additional string to display 317 * String - Additional string to display
321 * 318 *
322 * RETURN: None 319 * RETURN: None
323 * 320 *
324 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 321 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
325 * set in debug_level 322 * set in debug_level
326 * 323 *
327 ******************************************************************************/ 324 ******************************************************************************/
@@ -348,11 +345,11 @@ acpi_ut_trace_str(u32 line_number,
348 * function_name - Caller's procedure name 345 * function_name - Caller's procedure name
349 * module_name - Caller's module name 346 * module_name - Caller's module name
350 * component_id - Caller's component ID 347 * component_id - Caller's component ID
351 * integer - Integer to display 348 * Integer - Integer to display
352 * 349 *
353 * RETURN: None 350 * RETURN: None
354 * 351 *
355 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is 352 * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
356 * set in debug_level 353 * set in debug_level
357 * 354 *
358 ******************************************************************************/ 355 ******************************************************************************/
@@ -382,7 +379,7 @@ acpi_ut_trace_u32(u32 line_number,
382 * 379 *
383 * RETURN: None 380 * RETURN: None
384 * 381 *
385 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 382 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
386 * set in debug_level 383 * set in debug_level
387 * 384 *
388 ******************************************************************************/ 385 ******************************************************************************/
@@ -410,11 +407,11 @@ ACPI_EXPORT_SYMBOL(acpi_ut_exit)
410 * function_name - Caller's procedure name 407 * function_name - Caller's procedure name
411 * module_name - Caller's module name 408 * module_name - Caller's module name
412 * component_id - Caller's component ID 409 * component_id - Caller's component ID
413 * status - Exit status code 410 * Status - Exit status code
414 * 411 *
415 * RETURN: None 412 * RETURN: None
416 * 413 *
417 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 414 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
418 * set in debug_level. Prints exit status also. 415 * set in debug_level. Prints exit status also.
419 * 416 *
420 ******************************************************************************/ 417 ******************************************************************************/
@@ -451,11 +448,11 @@ ACPI_EXPORT_SYMBOL(acpi_ut_status_exit)
451 * function_name - Caller's procedure name 448 * function_name - Caller's procedure name
452 * module_name - Caller's module name 449 * module_name - Caller's module name
453 * component_id - Caller's component ID 450 * component_id - Caller's component ID
454 * value - Value to be printed with exit msg 451 * Value - Value to be printed with exit msg
455 * 452 *
456 * RETURN: None 453 * RETURN: None
457 * 454 *
458 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 455 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
459 * set in debug_level. Prints exit value also. 456 * set in debug_level. Prints exit value also.
460 * 457 *
461 ******************************************************************************/ 458 ******************************************************************************/
@@ -483,11 +480,11 @@ ACPI_EXPORT_SYMBOL(acpi_ut_value_exit)
483 * function_name - Caller's procedure name 480 * function_name - Caller's procedure name
484 * module_name - Caller's module name 481 * module_name - Caller's module name
485 * component_id - Caller's component ID 482 * component_id - Caller's component ID
486 * ptr - Pointer to display 483 * Ptr - Pointer to display
487 * 484 *
488 * RETURN: None 485 * RETURN: None
489 * 486 *
490 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is 487 * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
491 * set in debug_level. Prints exit value also. 488 * set in debug_level. Prints exit value also.
492 * 489 *
493 ******************************************************************************/ 490 ******************************************************************************/
@@ -510,10 +507,10 @@ acpi_ut_ptr_exit(u32 line_number,
510 * 507 *
511 * FUNCTION: acpi_ut_dump_buffer 508 * FUNCTION: acpi_ut_dump_buffer
512 * 509 *
513 * PARAMETERS: buffer - Buffer to dump 510 * PARAMETERS: Buffer - Buffer to dump
514 * count - Amount to dump, in bytes 511 * Count - Amount to dump, in bytes
515 * display - BYTE, WORD, DWORD, or QWORD display 512 * Display - BYTE, WORD, DWORD, or QWORD display
516 * offset - Beginning buffer offset (display only) 513 * component_iD - Caller's component ID
517 * 514 *
518 * RETURN: None 515 * RETURN: None
519 * 516 *
@@ -521,7 +518,7 @@ acpi_ut_ptr_exit(u32 line_number,
521 * 518 *
522 ******************************************************************************/ 519 ******************************************************************************/
523 520
524void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) 521void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display)
525{ 522{
526 u32 i = 0; 523 u32 i = 0;
527 u32 j; 524 u32 j;
@@ -543,7 +540,7 @@ void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset)
543 540
544 /* Print current offset */ 541 /* Print current offset */
545 542
546 acpi_os_printf("%6.4X: ", (base_offset + i)); 543 acpi_os_printf("%6.4X: ", i);
547 544
548 /* Print 16 hex chars */ 545 /* Print 16 hex chars */
549 546
@@ -625,12 +622,12 @@ void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset)
625 622
626/******************************************************************************* 623/*******************************************************************************
627 * 624 *
628 * FUNCTION: acpi_ut_debug_dump_buffer 625 * FUNCTION: acpi_ut_dump_buffer
629 * 626 *
630 * PARAMETERS: buffer - Buffer to dump 627 * PARAMETERS: Buffer - Buffer to dump
631 * count - Amount to dump, in bytes 628 * Count - Amount to dump, in bytes
632 * display - BYTE, WORD, DWORD, or QWORD display 629 * Display - BYTE, WORD, DWORD, or QWORD display
633 * component_ID - Caller's component ID 630 * component_iD - Caller's component ID
634 * 631 *
635 * RETURN: None 632 * RETURN: None
636 * 633 *
@@ -638,8 +635,7 @@ void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset)
638 * 635 *
639 ******************************************************************************/ 636 ******************************************************************************/
640 637
641void 638void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id)
642acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
643{ 639{
644 640
645 /* Only dump the buffer if tracing is enabled */ 641 /* Only dump the buffer if tracing is enabled */
@@ -649,5 +645,5 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
649 return; 645 return;
650 } 646 }
651 647
652 acpi_ut_dump_buffer(buffer, count, display, 0); 648 acpi_ut_dump_buffer2(buffer, count, display);
653} 649}
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index 60a158472d8..97cb36f85ce 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include "accommon.h" 45#include "accommon.h"
47#include "acnamesp.h" 46#include "acnamesp.h"
@@ -49,6 +48,41 @@
49#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utdecode") 49ACPI_MODULE_NAME("utdecode")
51 50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_format_exception
54 *
55 * PARAMETERS: Status - The acpi_status code to be formatted
56 *
57 * RETURN: A string containing the exception text. A valid pointer is
58 * always returned.
59 *
60 * DESCRIPTION: This function translates an ACPI exception into an ASCII string
61 * It is here instead of utxface.c so it is always present.
62 *
63 ******************************************************************************/
64const char *acpi_format_exception(acpi_status status)
65{
66 const char *exception = NULL;
67
68 ACPI_FUNCTION_ENTRY();
69
70 exception = acpi_ut_validate_exception(status);
71 if (!exception) {
72
73 /* Exception code was not recognized */
74
75 ACPI_ERROR((AE_INFO,
76 "Unknown exception code: 0x%8.8X", status));
77
78 exception = "UNKNOWN_STATUS_CODE";
79 }
80
81 return (ACPI_CAST_PTR(const char, exception));
82}
83
84ACPI_EXPORT_SYMBOL(acpi_format_exception)
85
52/* 86/*
53 * Properties of the ACPI Object Types, both internal and external. 87 * Properties of the ACPI Object Types, both internal and external.
54 * The table is indexed by values of acpi_object_type 88 * The table is indexed by values of acpi_object_type
@@ -91,8 +125,8 @@ const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES] = {
91 * 125 *
92 * FUNCTION: acpi_ut_hex_to_ascii_char 126 * FUNCTION: acpi_ut_hex_to_ascii_char
93 * 127 *
94 * PARAMETERS: integer - Contains the hex digit 128 * PARAMETERS: Integer - Contains the hex digit
95 * position - bit position of the digit within the 129 * Position - bit position of the digit within the
96 * integer (multiple of 4) 130 * integer (multiple of 4)
97 * 131 *
98 * RETURN: The converted Ascii character 132 * RETURN: The converted Ascii character
@@ -129,17 +163,14 @@ char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
129/* Region type decoding */ 163/* Region type decoding */
130 164
131const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = { 165const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
132 "SystemMemory", /* 0x00 */ 166 "SystemMemory",
133 "SystemIO", /* 0x01 */ 167 "SystemIO",
134 "PCI_Config", /* 0x02 */ 168 "PCI_Config",
135 "EmbeddedControl", /* 0x03 */ 169 "EmbeddedControl",
136 "SMBus", /* 0x04 */ 170 "SMBus",
137 "SystemCMOS", /* 0x05 */ 171 "SystemCMOS",
138 "PCIBARTarget", /* 0x06 */ 172 "PCIBARTarget",
139 "IPMI", /* 0x07 */ 173 "IPMI"
140 "GeneralPurposeIo", /* 0x08 */
141 "GenericSerialBus", /* 0x09 */
142 "PCC" /* 0x0A */
143}; 174};
144 175
145char *acpi_ut_get_region_name(u8 space_id) 176char *acpi_ut_get_region_name(u8 space_id)
@@ -194,7 +225,7 @@ char *acpi_ut_get_event_name(u32 event_id)
194 * 225 *
195 * FUNCTION: acpi_ut_get_type_name 226 * FUNCTION: acpi_ut_get_type_name
196 * 227 *
197 * PARAMETERS: type - An ACPI object type 228 * PARAMETERS: Type - An ACPI object type
198 * 229 *
199 * RETURN: Decoded ACPI object type name 230 * RETURN: Decoded ACPI object type name
200 * 231 *
@@ -272,7 +303,7 @@ char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
272 * 303 *
273 * FUNCTION: acpi_ut_get_node_name 304 * FUNCTION: acpi_ut_get_node_name
274 * 305 *
275 * PARAMETERS: object - A namespace node 306 * PARAMETERS: Object - A namespace node
276 * 307 *
277 * RETURN: ASCII name of the node 308 * RETURN: ASCII name of the node
278 * 309 *
@@ -317,7 +348,7 @@ char *acpi_ut_get_node_name(void *object)
317 * 348 *
318 * FUNCTION: acpi_ut_get_descriptor_name 349 * FUNCTION: acpi_ut_get_descriptor_name
319 * 350 *
320 * PARAMETERS: object - An ACPI object 351 * PARAMETERS: Object - An ACPI object
321 * 352 *
322 * RETURN: Decoded name of the descriptor type 353 * RETURN: Decoded name of the descriptor type
323 * 354 *
@@ -367,7 +398,7 @@ char *acpi_ut_get_descriptor_name(void *object)
367 * 398 *
368 * FUNCTION: acpi_ut_get_reference_name 399 * FUNCTION: acpi_ut_get_reference_name
369 * 400 *
370 * PARAMETERS: object - An ACPI reference object 401 * PARAMETERS: Object - An ACPI reference object
371 * 402 *
372 * RETURN: Decoded name of the type of reference 403 * RETURN: Decoded name of the type of reference
373 * 404 *
@@ -463,20 +494,19 @@ char *acpi_ut_get_mutex_name(u32 mutex_id)
463 494
464/* Names for Notify() values, used for debug output */ 495/* Names for Notify() values, used for debug output */
465 496
466static const char *acpi_gbl_notify_value_names[ACPI_NOTIFY_MAX + 1] = { 497static const char *acpi_gbl_notify_value_names[] = {
467 /* 00 */ "Bus Check", 498 "Bus Check",
468 /* 01 */ "Device Check", 499 "Device Check",
469 /* 02 */ "Device Wake", 500 "Device Wake",
470 /* 03 */ "Eject Request", 501 "Eject Request",
471 /* 04 */ "Device Check Light", 502 "Device Check Light",
472 /* 05 */ "Frequency Mismatch", 503 "Frequency Mismatch",
473 /* 06 */ "Bus Mode Mismatch", 504 "Bus Mode Mismatch",
474 /* 07 */ "Power Fault", 505 "Power Fault",
475 /* 08 */ "Capabilities Check", 506 "Capabilities Check",
476 /* 09 */ "Device PLD Check", 507 "Device PLD Check",
477 /* 10 */ "Reserved", 508 "Reserved",
478 /* 11 */ "System Locality Update", 509 "System Locality Update"
479 /* 12 */ "Shutdown Request"
480}; 510};
481 511
482const char *acpi_ut_get_notify_name(u32 notify_value) 512const char *acpi_ut_get_notify_name(u32 notify_value)
@@ -486,10 +516,9 @@ const char *acpi_ut_get_notify_name(u32 notify_value)
486 return (acpi_gbl_notify_value_names[notify_value]); 516 return (acpi_gbl_notify_value_names[notify_value]);
487 } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) { 517 } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
488 return ("Reserved"); 518 return ("Reserved");
489 } else if (notify_value <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) { 519 } else { /* Greater or equal to 0x80 */
490 return ("Device Specific"); 520
491 } else { 521 return ("**Device Specific**");
492 return ("Hardware Specific");
493 } 522 }
494} 523}
495#endif 524#endif
@@ -498,7 +527,7 @@ const char *acpi_ut_get_notify_name(u32 notify_value)
498 * 527 *
499 * FUNCTION: acpi_ut_valid_object_type 528 * FUNCTION: acpi_ut_valid_object_type
500 * 529 *
501 * PARAMETERS: type - Object type to be validated 530 * PARAMETERS: Type - Object type to be validated
502 * 531 *
503 * RETURN: TRUE if valid object type, FALSE otherwise 532 * RETURN: TRUE if valid object type, FALSE otherwise
504 * 533 *
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index 798105443d0..31f5a7832ef 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -60,7 +60,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action);
60 * 60 *
61 * FUNCTION: acpi_ut_delete_internal_obj 61 * FUNCTION: acpi_ut_delete_internal_obj
62 * 62 *
63 * PARAMETERS: object - Object to be deleted 63 * PARAMETERS: Object - Object to be deleted
64 * 64 *
65 * RETURN: None 65 * RETURN: None
66 * 66 *
@@ -152,7 +152,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
152 case ACPI_TYPE_PROCESSOR: 152 case ACPI_TYPE_PROCESSOR:
153 case ACPI_TYPE_THERMAL: 153 case ACPI_TYPE_THERMAL:
154 154
155 /* Walk the address handler list for this object */ 155 /* Walk the notify handler list for this object */
156 156
157 handler_desc = object->common_notify.handler; 157 handler_desc = object->common_notify.handler;
158 while (handler_desc) { 158 while (handler_desc) {
@@ -215,14 +215,11 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
215 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 215 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
216 "***** Region %p\n", object)); 216 "***** Region %p\n", object));
217 217
218 /* 218 /* Invalidate the region address/length via the host OS */
219 * Update address_range list. However, only permanent regions 219
220 * are installed in this list. (Not created within a method) 220 acpi_os_invalidate_address(object->region.space_id,
221 */ 221 object->region.address,
222 if (!(object->region.node->flags & ANOBJ_TEMPORARY)) { 222 (acpi_size) object->region.length);
223 acpi_ut_remove_address_range(object->region.space_id,
224 object->region.node);
225 }
226 223
227 second_desc = acpi_ns_get_secondary_object(object); 224 second_desc = acpi_ns_get_secondary_object(object);
228 if (second_desc) { 225 if (second_desc) {
@@ -358,8 +355,8 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
358 * 355 *
359 * FUNCTION: acpi_ut_update_ref_count 356 * FUNCTION: acpi_ut_update_ref_count
360 * 357 *
361 * PARAMETERS: object - Object whose ref count is to be updated 358 * PARAMETERS: Object - Object whose ref count is to be updated
362 * action - What to do 359 * Action - What to do
363 * 360 *
364 * RETURN: New ref count 361 * RETURN: New ref count
365 * 362 *
@@ -456,9 +453,9 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
456 * 453 *
457 * FUNCTION: acpi_ut_update_object_reference 454 * FUNCTION: acpi_ut_update_object_reference
458 * 455 *
459 * PARAMETERS: object - Increment ref count for this object 456 * PARAMETERS: Object - Increment ref count for this object
460 * and all sub-objects 457 * and all sub-objects
461 * action - Either REF_INCREMENT or REF_DECREMENT or 458 * Action - Either REF_INCREMENT or REF_DECREMENT or
462 * REF_FORCE_DELETE 459 * REF_FORCE_DELETE
463 * 460 *
464 * RETURN: Status 461 * RETURN: Status
@@ -480,7 +477,6 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
480 acpi_status status = AE_OK; 477 acpi_status status = AE_OK;
481 union acpi_generic_state *state_list = NULL; 478 union acpi_generic_state *state_list = NULL;
482 union acpi_operand_object *next_object = NULL; 479 union acpi_operand_object *next_object = NULL;
483 union acpi_operand_object *prev_object;
484 union acpi_generic_state *state; 480 union acpi_generic_state *state;
485 u32 i; 481 u32 i;
486 482
@@ -506,21 +502,12 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
506 case ACPI_TYPE_POWER: 502 case ACPI_TYPE_POWER:
507 case ACPI_TYPE_THERMAL: 503 case ACPI_TYPE_THERMAL:
508 504
509 /* 505 /* Update the notify objects for these types (if present) */
510 * Update the notify objects for these types (if present) 506
511 * Two lists, system and device notify handlers. 507 acpi_ut_update_ref_count(object->common_notify.
512 */ 508 system_notify, action);
513 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) { 509 acpi_ut_update_ref_count(object->common_notify.
514 prev_object = 510 device_notify, action);
515 object->common_notify.notify_list[i];
516 while (prev_object) {
517 next_object =
518 prev_object->notify.next[i];
519 acpi_ut_update_ref_count(prev_object,
520 action);
521 prev_object = next_object;
522 }
523 }
524 break; 511 break;
525 512
526 case ACPI_TYPE_PACKAGE: 513 case ACPI_TYPE_PACKAGE:
@@ -640,7 +627,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
640 * 627 *
641 * FUNCTION: acpi_ut_add_reference 628 * FUNCTION: acpi_ut_add_reference
642 * 629 *
643 * PARAMETERS: object - Object whose reference count is to be 630 * PARAMETERS: Object - Object whose reference count is to be
644 * incremented 631 * incremented
645 * 632 *
646 * RETURN: None 633 * RETURN: None
@@ -674,7 +661,7 @@ void acpi_ut_add_reference(union acpi_operand_object *object)
674 * 661 *
675 * FUNCTION: acpi_ut_remove_reference 662 * FUNCTION: acpi_ut_remove_reference
676 * 663 *
677 * PARAMETERS: object - Object whose ref count will be decremented 664 * PARAMETERS: Object - Object whose ref count will be decremented
678 * 665 *
679 * RETURN: None 666 * RETURN: None
680 * 667 *
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index a9c65fbea5f..18f73c9d10b 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -53,7 +53,7 @@ ACPI_MODULE_NAME("uteval")
53 * FUNCTION: acpi_ut_evaluate_object 53 * FUNCTION: acpi_ut_evaluate_object
54 * 54 *
55 * PARAMETERS: prefix_node - Starting node 55 * PARAMETERS: prefix_node - Starting node
56 * path - Path to object from starting node 56 * Path - Path to object from starting node
57 * expected_return_types - Bitmap of allowed return types 57 * expected_return_types - Bitmap of allowed return types
58 * return_desc - Where a return value is stored 58 * return_desc - Where a return value is stored
59 * 59 *
@@ -187,7 +187,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
187 * 187 *
188 * PARAMETERS: object_name - Object name to be evaluated 188 * PARAMETERS: object_name - Object name to be evaluated
189 * device_node - Node for the device 189 * device_node - Node for the device
190 * value - Where the value is returned 190 * Value - Where the value is returned
191 * 191 *
192 * RETURN: Status 192 * RETURN: Status
193 * 193 *
@@ -229,7 +229,7 @@ acpi_ut_evaluate_numeric_object(char *object_name,
229 * FUNCTION: acpi_ut_execute_STA 229 * FUNCTION: acpi_ut_execute_STA
230 * 230 *
231 * PARAMETERS: device_node - Node for the device 231 * PARAMETERS: device_node - Node for the device
232 * flags - Where the status flags are returned 232 * Flags - Where the status flags are returned
233 * 233 *
234 * RETURN: Status 234 * RETURN: Status
235 * 235 *
diff --git a/drivers/acpi/acpica/utexcep.c b/drivers/acpi/acpica/utexcep.c
deleted file mode 100644
index 23b98945f6b..00000000000
--- a/drivers/acpi/acpica/utexcep.c
+++ /dev/null
@@ -1,153 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: utexcep - Exception code support
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#define ACPI_DEFINE_EXCEPTION_TABLE
45#include <linux/export.h>
46#include <acpi/acpi.h>
47#include "accommon.h"
48
49#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utexcep")
51
52/*******************************************************************************
53 *
54 * FUNCTION: acpi_format_exception
55 *
56 * PARAMETERS: status - The acpi_status code to be formatted
57 *
58 * RETURN: A string containing the exception text. A valid pointer is
59 * always returned.
60 *
61 * DESCRIPTION: This function translates an ACPI exception into an ASCII
62 * string. Returns "unknown status" string for invalid codes.
63 *
64 ******************************************************************************/
65const char *acpi_format_exception(acpi_status status)
66{
67 const char *exception = NULL;
68
69 ACPI_FUNCTION_ENTRY();
70
71 exception = acpi_ut_validate_exception(status);
72 if (!exception) {
73
74 /* Exception code was not recognized */
75
76 ACPI_ERROR((AE_INFO,
77 "Unknown exception code: 0x%8.8X", status));
78
79 exception = "UNKNOWN_STATUS_CODE";
80 }
81
82 return (ACPI_CAST_PTR(const char, exception));
83}
84
85ACPI_EXPORT_SYMBOL(acpi_format_exception)
86
87/*******************************************************************************
88 *
89 * FUNCTION: acpi_ut_validate_exception
90 *
91 * PARAMETERS: status - The acpi_status code to be formatted
92 *
93 * RETURN: A string containing the exception text. NULL if exception is
94 * not valid.
95 *
96 * DESCRIPTION: This function validates and translates an ACPI exception into
97 * an ASCII string.
98 *
99 ******************************************************************************/
100const char *acpi_ut_validate_exception(acpi_status status)
101{
102 u32 sub_status;
103 const char *exception = NULL;
104
105 ACPI_FUNCTION_ENTRY();
106
107 /*
108 * Status is composed of two parts, a "type" and an actual code
109 */
110 sub_status = (status & ~AE_CODE_MASK);
111
112 switch (status & AE_CODE_MASK) {
113 case AE_CODE_ENVIRONMENTAL:
114
115 if (sub_status <= AE_CODE_ENV_MAX) {
116 exception = acpi_gbl_exception_names_env[sub_status];
117 }
118 break;
119
120 case AE_CODE_PROGRAMMER:
121
122 if (sub_status <= AE_CODE_PGM_MAX) {
123 exception = acpi_gbl_exception_names_pgm[sub_status];
124 }
125 break;
126
127 case AE_CODE_ACPI_TABLES:
128
129 if (sub_status <= AE_CODE_TBL_MAX) {
130 exception = acpi_gbl_exception_names_tbl[sub_status];
131 }
132 break;
133
134 case AE_CODE_AML:
135
136 if (sub_status <= AE_CODE_AML_MAX) {
137 exception = acpi_gbl_exception_names_aml[sub_status];
138 }
139 break;
140
141 case AE_CODE_CONTROL:
142
143 if (sub_status <= AE_CODE_CTRL_MAX) {
144 exception = acpi_gbl_exception_names_ctrl[sub_status];
145 }
146 break;
147
148 default:
149 break;
150 }
151
152 return (ACPI_CAST_PTR(const char, exception));
153}
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index ed1893155f8..833a38a9c90 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -43,7 +43,6 @@
43 43
44#define DEFINE_ACPI_GLOBALS 44#define DEFINE_ACPI_GLOBALS
45 45
46#include <linux/export.h>
47#include <acpi/acpi.h> 46#include <acpi/acpi.h>
48#include "accommon.h" 47#include "accommon.h"
49 48
@@ -140,7 +139,6 @@ const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
140 {NULL, ACPI_TYPE_ANY, NULL} 139 {NULL, ACPI_TYPE_ANY, NULL}
141}; 140};
142 141
143#if (!ACPI_REDUCED_HARDWARE)
144/****************************************************************************** 142/******************************************************************************
145 * 143 *
146 * Event and Hardware globals 144 * Event and Hardware globals
@@ -237,7 +235,6 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
237 ACPI_BITMASK_RT_CLOCK_STATUS, 235 ACPI_BITMASK_RT_CLOCK_STATUS,
238 ACPI_BITMASK_RT_CLOCK_ENABLE}, 236 ACPI_BITMASK_RT_CLOCK_ENABLE},
239}; 237};
240#endif /* !ACPI_REDUCED_HARDWARE */
241 238
242/******************************************************************************* 239/*******************************************************************************
243 * 240 *
@@ -247,9 +244,8 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
247 * 244 *
248 * RETURN: Status 245 * RETURN: Status
249 * 246 *
250 * DESCRIPTION: Initialize ACPICA globals. All globals that require specific 247 * DESCRIPTION: Init library globals. All globals that require specific
251 * initialization should be initialized here. This allows for 248 * initialization should be initialized here!
252 * a warm restart.
253 * 249 *
254 ******************************************************************************/ 250 ******************************************************************************/
255 251
@@ -267,12 +263,6 @@ acpi_status acpi_ut_init_globals(void)
267 return_ACPI_STATUS(status); 263 return_ACPI_STATUS(status);
268 } 264 }
269 265
270 /* Address Range lists */
271
272 for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) {
273 acpi_gbl_address_range_list[i] = NULL;
274 }
275
276 /* Mutex locked flags */ 266 /* Mutex locked flags */
277 267
278 for (i = 0; i < ACPI_NUM_MUTEX; i++) { 268 for (i = 0; i < ACPI_NUM_MUTEX; i++) {
@@ -285,12 +275,10 @@ acpi_status acpi_ut_init_globals(void)
285 acpi_gbl_owner_id_mask[i] = 0; 275 acpi_gbl_owner_id_mask[i] = 0;
286 } 276 }
287 277
288 /* Last owner_ID is never valid */ 278 /* Last owner_iD is never valid */
289 279
290 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; 280 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
291 281
292#if (!ACPI_REDUCED_HARDWARE)
293
294 /* GPE support */ 282 /* GPE support */
295 283
296 acpi_gbl_gpe_xrupt_list_head = NULL; 284 acpi_gbl_gpe_xrupt_list_head = NULL;
@@ -299,18 +287,15 @@ acpi_status acpi_ut_init_globals(void)
299 acpi_current_gpe_count = 0; 287 acpi_current_gpe_count = 0;
300 acpi_gbl_all_gpes_initialized = FALSE; 288 acpi_gbl_all_gpes_initialized = FALSE;
301 289
302 acpi_gbl_global_event_handler = NULL;
303
304#endif /* !ACPI_REDUCED_HARDWARE */
305
306 /* Global handlers */ 290 /* Global handlers */
307 291
308 acpi_gbl_global_notify[0].handler = NULL; 292 acpi_gbl_system_notify.handler = NULL;
309 acpi_gbl_global_notify[1].handler = NULL; 293 acpi_gbl_device_notify.handler = NULL;
310 acpi_gbl_exception_handler = NULL; 294 acpi_gbl_exception_handler = NULL;
311 acpi_gbl_init_handler = NULL; 295 acpi_gbl_init_handler = NULL;
312 acpi_gbl_table_handler = NULL; 296 acpi_gbl_table_handler = NULL;
313 acpi_gbl_interface_handler = NULL; 297 acpi_gbl_interface_handler = NULL;
298 acpi_gbl_global_event_handler = NULL;
314 299
315 /* Global Lock support */ 300 /* Global Lock support */
316 301
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
index 774c3aefbf5..b679ea69354 100644
--- a/drivers/acpi/acpica/utids.c
+++ b/drivers/acpi/acpica/utids.c
@@ -1,11 +1,11 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: utids - support for device Ids - HID, UID, CID 3 * Module Name: utids - support for device IDs - HID, UID, CID
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -67,10 +67,10 @@ ACPI_MODULE_NAME("utids")
67 ******************************************************************************/ 67 ******************************************************************************/
68acpi_status 68acpi_status
69acpi_ut_execute_HID(struct acpi_namespace_node *device_node, 69acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
70 struct acpi_pnp_device_id **return_id) 70 struct acpica_device_id **return_id)
71{ 71{
72 union acpi_operand_object *obj_desc; 72 union acpi_operand_object *obj_desc;
73 struct acpi_pnp_device_id *hid; 73 struct acpica_device_id *hid;
74 u32 length; 74 u32 length;
75 acpi_status status; 75 acpi_status status;
76 76
@@ -94,17 +94,16 @@ acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
94 /* Allocate a buffer for the HID */ 94 /* Allocate a buffer for the HID */
95 95
96 hid = 96 hid =
97 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + 97 ACPI_ALLOCATE_ZEROED(sizeof(struct acpica_device_id) +
98 (acpi_size) length); 98 (acpi_size) length);
99 if (!hid) { 99 if (!hid) {
100 status = AE_NO_MEMORY; 100 status = AE_NO_MEMORY;
101 goto cleanup; 101 goto cleanup;
102 } 102 }
103 103
104 /* Area for the string starts after PNP_DEVICE_ID struct */ 104 /* Area for the string starts after DEVICE_ID struct */
105 105
106 hid->string = 106 hid->string = ACPI_ADD_PTR(char, hid, sizeof(struct acpica_device_id));
107 ACPI_ADD_PTR(char, hid, sizeof(struct acpi_pnp_device_id));
108 107
109 /* Convert EISAID to a string or simply copy existing string */ 108 /* Convert EISAID to a string or simply copy existing string */
110 109
@@ -127,73 +126,6 @@ cleanup:
127 126
128/******************************************************************************* 127/*******************************************************************************
129 * 128 *
130 * FUNCTION: acpi_ut_execute_SUB
131 *
132 * PARAMETERS: device_node - Node for the device
133 * return_id - Where the _SUB is returned
134 *
135 * RETURN: Status
136 *
137 * DESCRIPTION: Executes the _SUB control method that returns the subsystem
138 * ID of the device. The _SUB value is always a string containing
139 * either a valid PNP or ACPI ID.
140 *
141 * NOTE: Internal function, no parameter validation
142 *
143 ******************************************************************************/
144
145acpi_status
146acpi_ut_execute_SUB(struct acpi_namespace_node *device_node,
147 struct acpi_pnp_device_id **return_id)
148{
149 union acpi_operand_object *obj_desc;
150 struct acpi_pnp_device_id *sub;
151 u32 length;
152 acpi_status status;
153
154 ACPI_FUNCTION_TRACE(ut_execute_SUB);
155
156 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__SUB,
157 ACPI_BTYPE_STRING, &obj_desc);
158 if (ACPI_FAILURE(status)) {
159 return_ACPI_STATUS(status);
160 }
161
162 /* Get the size of the String to be returned, includes null terminator */
163
164 length = obj_desc->string.length + 1;
165
166 /* Allocate a buffer for the SUB */
167
168 sub =
169 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
170 (acpi_size) length);
171 if (!sub) {
172 status = AE_NO_MEMORY;
173 goto cleanup;
174 }
175
176 /* Area for the string starts after PNP_DEVICE_ID struct */
177
178 sub->string =
179 ACPI_ADD_PTR(char, sub, sizeof(struct acpi_pnp_device_id));
180
181 /* Simply copy existing string */
182
183 ACPI_STRCPY(sub->string, obj_desc->string.pointer);
184 sub->length = length;
185 *return_id = sub;
186
187 cleanup:
188
189 /* On exit, we must delete the return object */
190
191 acpi_ut_remove_reference(obj_desc);
192 return_ACPI_STATUS(status);
193}
194
195/*******************************************************************************
196 *
197 * FUNCTION: acpi_ut_execute_UID 129 * FUNCTION: acpi_ut_execute_UID
198 * 130 *
199 * PARAMETERS: device_node - Node for the device 131 * PARAMETERS: device_node - Node for the device
@@ -212,10 +144,10 @@ acpi_ut_execute_SUB(struct acpi_namespace_node *device_node,
212 144
213acpi_status 145acpi_status
214acpi_ut_execute_UID(struct acpi_namespace_node *device_node, 146acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
215 struct acpi_pnp_device_id **return_id) 147 struct acpica_device_id **return_id)
216{ 148{
217 union acpi_operand_object *obj_desc; 149 union acpi_operand_object *obj_desc;
218 struct acpi_pnp_device_id *uid; 150 struct acpica_device_id *uid;
219 u32 length; 151 u32 length;
220 acpi_status status; 152 acpi_status status;
221 153
@@ -239,17 +171,16 @@ acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
239 /* Allocate a buffer for the UID */ 171 /* Allocate a buffer for the UID */
240 172
241 uid = 173 uid =
242 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) + 174 ACPI_ALLOCATE_ZEROED(sizeof(struct acpica_device_id) +
243 (acpi_size) length); 175 (acpi_size) length);
244 if (!uid) { 176 if (!uid) {
245 status = AE_NO_MEMORY; 177 status = AE_NO_MEMORY;
246 goto cleanup; 178 goto cleanup;
247 } 179 }
248 180
249 /* Area for the string starts after PNP_DEVICE_ID struct */ 181 /* Area for the string starts after DEVICE_ID struct */
250 182
251 uid->string = 183 uid->string = ACPI_ADD_PTR(char, uid, sizeof(struct acpica_device_id));
252 ACPI_ADD_PTR(char, uid, sizeof(struct acpi_pnp_device_id));
253 184
254 /* Convert an Integer to string, or just copy an existing string */ 185 /* Convert an Integer to string, or just copy an existing string */
255 186
@@ -295,11 +226,11 @@ cleanup:
295 226
296acpi_status 227acpi_status
297acpi_ut_execute_CID(struct acpi_namespace_node *device_node, 228acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
298 struct acpi_pnp_device_id_list **return_cid_list) 229 struct acpica_device_id_list **return_cid_list)
299{ 230{
300 union acpi_operand_object **cid_objects; 231 union acpi_operand_object **cid_objects;
301 union acpi_operand_object *obj_desc; 232 union acpi_operand_object *obj_desc;
302 struct acpi_pnp_device_id_list *cid_list; 233 struct acpica_device_id_list *cid_list;
303 char *next_id_string; 234 char *next_id_string;
304 u32 string_area_size; 235 u32 string_area_size;
305 u32 length; 236 u32 length;
@@ -357,12 +288,11 @@ acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
357 /* 288 /*
358 * Now that we know the length of the CIDs, allocate return buffer: 289 * Now that we know the length of the CIDs, allocate return buffer:
359 * 1) Size of the base structure + 290 * 1) Size of the base structure +
360 * 2) Size of the CID PNP_DEVICE_ID array + 291 * 2) Size of the CID DEVICE_ID array +
361 * 3) Size of the actual CID strings 292 * 3) Size of the actual CID strings
362 */ 293 */
363 cid_list_size = sizeof(struct acpi_pnp_device_id_list) + 294 cid_list_size = sizeof(struct acpica_device_id_list) +
364 ((count - 1) * sizeof(struct acpi_pnp_device_id)) + 295 ((count - 1) * sizeof(struct acpica_device_id)) + string_area_size;
365 string_area_size;
366 296
367 cid_list = ACPI_ALLOCATE_ZEROED(cid_list_size); 297 cid_list = ACPI_ALLOCATE_ZEROED(cid_list_size);
368 if (!cid_list) { 298 if (!cid_list) {
@@ -370,10 +300,10 @@ acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
370 goto cleanup; 300 goto cleanup;
371 } 301 }
372 302
373 /* Area for CID strings starts after the CID PNP_DEVICE_ID array */ 303 /* Area for CID strings starts after the CID DEVICE_ID array */
374 304
375 next_id_string = ACPI_CAST_PTR(char, cid_list->ids) + 305 next_id_string = ACPI_CAST_PTR(char, cid_list->ids) +
376 ((acpi_size) count * sizeof(struct acpi_pnp_device_id)); 306 ((acpi_size) count * sizeof(struct acpica_device_id));
377 307
378 /* Copy/convert the CIDs to the return buffer */ 308 /* Copy/convert the CIDs to the return buffer */
379 309
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index 246798e4c93..191b6828cce 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -53,35 +53,27 @@ ACPI_MODULE_NAME("utinit")
53/* Local prototypes */ 53/* Local prototypes */
54static void acpi_ut_terminate(void); 54static void acpi_ut_terminate(void);
55 55
56#if (!ACPI_REDUCED_HARDWARE)
57
58static void acpi_ut_free_gpe_lists(void);
59
60#else
61
62#define acpi_ut_free_gpe_lists()
63#endif /* !ACPI_REDUCED_HARDWARE */
64
65#if (!ACPI_REDUCED_HARDWARE)
66/****************************************************************************** 56/******************************************************************************
67 * 57 *
68 * FUNCTION: acpi_ut_free_gpe_lists 58 * FUNCTION: acpi_ut_terminate
69 * 59 *
70 * PARAMETERS: none 60 * PARAMETERS: none
71 * 61 *
72 * RETURN: none 62 * RETURN: none
73 * 63 *
74 * DESCRIPTION: Free global GPE lists 64 * DESCRIPTION: Free global memory
75 * 65 *
76 ******************************************************************************/ 66 ******************************************************************************/
77 67
78static void acpi_ut_free_gpe_lists(void) 68static void acpi_ut_terminate(void)
79{ 69{
80 struct acpi_gpe_block_info *gpe_block; 70 struct acpi_gpe_block_info *gpe_block;
81 struct acpi_gpe_block_info *next_gpe_block; 71 struct acpi_gpe_block_info *next_gpe_block;
82 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 72 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
83 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; 73 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
84 74
75 ACPI_FUNCTION_TRACE(ut_terminate);
76
85 /* Free global GPE blocks and related info structures */ 77 /* Free global GPE blocks and related info structures */
86 78
87 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; 79 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
@@ -99,27 +91,7 @@ static void acpi_ut_free_gpe_lists(void)
99 ACPI_FREE(gpe_xrupt_info); 91 ACPI_FREE(gpe_xrupt_info);
100 gpe_xrupt_info = next_gpe_xrupt_info; 92 gpe_xrupt_info = next_gpe_xrupt_info;
101 } 93 }
102}
103#endif /* !ACPI_REDUCED_HARDWARE */
104
105/******************************************************************************
106 *
107 * FUNCTION: acpi_ut_terminate
108 *
109 * PARAMETERS: none
110 *
111 * RETURN: none
112 *
113 * DESCRIPTION: Free global memory
114 *
115 ******************************************************************************/
116
117static void acpi_ut_terminate(void)
118{
119 ACPI_FUNCTION_TRACE(ut_terminate);
120 94
121 acpi_ut_free_gpe_lists();
122 acpi_ut_delete_address_lists();
123 return_VOID; 95 return_VOID;
124} 96}
125 97
diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c
index b1eb7f17e11..f6bb75c6faf 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -52,7 +52,7 @@ ACPI_MODULE_NAME("utlock")
52 * FUNCTION: acpi_ut_create_rw_lock 52 * FUNCTION: acpi_ut_create_rw_lock
53 * acpi_ut_delete_rw_lock 53 * acpi_ut_delete_rw_lock
54 * 54 *
55 * PARAMETERS: lock - Pointer to a valid RW lock 55 * PARAMETERS: Lock - Pointer to a valid RW lock
56 * 56 *
57 * RETURN: Status 57 * RETURN: Status
58 * 58 *
@@ -89,7 +89,7 @@ void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock)
89 * FUNCTION: acpi_ut_acquire_read_lock 89 * FUNCTION: acpi_ut_acquire_read_lock
90 * acpi_ut_release_read_lock 90 * acpi_ut_release_read_lock
91 * 91 *
92 * PARAMETERS: lock - Pointer to a valid RW lock 92 * PARAMETERS: Lock - Pointer to a valid RW lock
93 * 93 *
94 * RETURN: Status 94 * RETURN: Status
95 * 95 *
@@ -149,7 +149,7 @@ acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock)
149 * FUNCTION: acpi_ut_acquire_write_lock 149 * FUNCTION: acpi_ut_acquire_write_lock
150 * acpi_ut_release_write_lock 150 * acpi_ut_release_write_lock
151 * 151 *
152 * PARAMETERS: lock - Pointer to a valid RW lock 152 * PARAMETERS: Lock - Pointer to a valid RW lock
153 * 153 *
154 * RETURN: Status 154 * RETURN: Status
155 * 155 *
diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c
index 49563674833..ce481da9bb4 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -73,15 +73,15 @@ typedef union uint64_overlay {
73 * 73 *
74 * FUNCTION: acpi_ut_short_divide 74 * FUNCTION: acpi_ut_short_divide
75 * 75 *
76 * PARAMETERS: dividend - 64-bit dividend 76 * PARAMETERS: Dividend - 64-bit dividend
77 * divisor - 32-bit divisor 77 * Divisor - 32-bit divisor
78 * out_quotient - Pointer to where the quotient is returned 78 * out_quotient - Pointer to where the quotient is returned
79 * out_remainder - Pointer to where the remainder is returned 79 * out_remainder - Pointer to where the remainder is returned
80 * 80 *
81 * RETURN: Status (Checks for divide-by-zero) 81 * RETURN: Status (Checks for divide-by-zero)
82 * 82 *
83 * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits) 83 * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits)
84 * divide and modulo. The result is a 64-bit quotient and a 84 * divide and modulo. The result is a 64-bit quotient and a
85 * 32-bit remainder. 85 * 32-bit remainder.
86 * 86 *
87 ******************************************************************************/ 87 ******************************************************************************/
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 9286a69eb9a..c33a852d4f4 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,6 +41,8 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/module.h>
45
44#include <acpi/acpi.h> 46#include <acpi/acpi.h>
45#include "accommon.h" 47#include "accommon.h"
46#include "acnamesp.h" 48#include "acnamesp.h"
@@ -48,41 +50,79 @@
48#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utmisc") 51ACPI_MODULE_NAME("utmisc")
50 52
51#if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
52/******************************************************************************* 53/*******************************************************************************
53 * 54 *
54 * FUNCTION: ut_convert_backslashes 55 * FUNCTION: acpi_ut_validate_exception
55 * 56 *
56 * PARAMETERS: pathname - File pathname string to be converted 57 * PARAMETERS: Status - The acpi_status code to be formatted
57 * 58 *
58 * RETURN: Modifies the input Pathname 59 * RETURN: A string containing the exception text. NULL if exception is
60 * not valid.
59 * 61 *
60 * DESCRIPTION: Convert all backslashes (0x5C) to forward slashes (0x2F) within 62 * DESCRIPTION: This function validates and translates an ACPI exception into
61 * the entire input file pathname string. 63 * an ASCII string.
62 * 64 *
63 ******************************************************************************/ 65 ******************************************************************************/
64void ut_convert_backslashes(char *pathname) 66const char *acpi_ut_validate_exception(acpi_status status)
65{ 67{
68 u32 sub_status;
69 const char *exception = NULL;
66 70
67 if (!pathname) { 71 ACPI_FUNCTION_ENTRY();
68 return; 72
69 } 73 /*
74 * Status is composed of two parts, a "type" and an actual code
75 */
76 sub_status = (status & ~AE_CODE_MASK);
77
78 switch (status & AE_CODE_MASK) {
79 case AE_CODE_ENVIRONMENTAL:
80
81 if (sub_status <= AE_CODE_ENV_MAX) {
82 exception = acpi_gbl_exception_names_env[sub_status];
83 }
84 break;
70 85
71 while (*pathname) { 86 case AE_CODE_PROGRAMMER:
72 if (*pathname == '\\') { 87
73 *pathname = '/'; 88 if (sub_status <= AE_CODE_PGM_MAX) {
89 exception = acpi_gbl_exception_names_pgm[sub_status];
90 }
91 break;
92
93 case AE_CODE_ACPI_TABLES:
94
95 if (sub_status <= AE_CODE_TBL_MAX) {
96 exception = acpi_gbl_exception_names_tbl[sub_status];
74 } 97 }
98 break;
99
100 case AE_CODE_AML:
101
102 if (sub_status <= AE_CODE_AML_MAX) {
103 exception = acpi_gbl_exception_names_aml[sub_status];
104 }
105 break;
106
107 case AE_CODE_CONTROL:
75 108
76 pathname++; 109 if (sub_status <= AE_CODE_CTRL_MAX) {
110 exception = acpi_gbl_exception_names_ctrl[sub_status];
111 }
112 break;
113
114 default:
115 break;
77 } 116 }
117
118 return (ACPI_CAST_PTR(const char, exception));
78} 119}
79#endif
80 120
81/******************************************************************************* 121/*******************************************************************************
82 * 122 *
83 * FUNCTION: acpi_ut_is_pci_root_bridge 123 * FUNCTION: acpi_ut_is_pci_root_bridge
84 * 124 *
85 * PARAMETERS: id - The HID/CID in string format 125 * PARAMETERS: Id - The HID/CID in string format
86 * 126 *
87 * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge 127 * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
88 * 128 *
@@ -110,7 +150,7 @@ u8 acpi_ut_is_pci_root_bridge(char *id)
110 * 150 *
111 * FUNCTION: acpi_ut_is_aml_table 151 * FUNCTION: acpi_ut_is_aml_table
112 * 152 *
113 * PARAMETERS: table - An ACPI table 153 * PARAMETERS: Table - An ACPI table
114 * 154 *
115 * RETURN: TRUE if table contains executable AML; FALSE otherwise 155 * RETURN: TRUE if table contains executable AML; FALSE otherwise
116 * 156 *
@@ -199,8 +239,8 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
199 */ 239 */
200 acpi_gbl_owner_id_mask[j] |= (1 << k); 240 acpi_gbl_owner_id_mask[j] |= (1 << k);
201 241
202 acpi_gbl_last_owner_id_index = (u8)j; 242 acpi_gbl_last_owner_id_index = (u8) j;
203 acpi_gbl_next_owner_id_offset = (u8)(k + 1); 243 acpi_gbl_next_owner_id_offset = (u8) (k + 1);
204 244
205 /* 245 /*
206 * Construct encoded ID from the index and bit position 246 * Construct encoded ID from the index and bit position
@@ -244,13 +284,13 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
244 * 284 *
245 * FUNCTION: acpi_ut_release_owner_id 285 * FUNCTION: acpi_ut_release_owner_id
246 * 286 *
247 * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_ID 287 * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD
248 * 288 *
249 * RETURN: None. No error is returned because we are either exiting a 289 * RETURN: None. No error is returned because we are either exiting a
250 * control method or unloading a table. Either way, we would 290 * control method or unloading a table. Either way, we would
251 * ignore any error anyway. 291 * ignore any error anyway.
252 * 292 *
253 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 293 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
254 * 294 *
255 ******************************************************************************/ 295 ******************************************************************************/
256 296
@@ -267,7 +307,7 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
267 307
268 *owner_id_ptr = 0; 308 *owner_id_ptr = 0;
269 309
270 /* Zero is not a valid owner_ID */ 310 /* Zero is not a valid owner_iD */
271 311
272 if (owner_id == 0) { 312 if (owner_id == 0) {
273 ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id)); 313 ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id));
@@ -337,78 +377,11 @@ void acpi_ut_strupr(char *src_string)
337 return; 377 return;
338} 378}
339 379
340#ifdef ACPI_ASL_COMPILER
341/*******************************************************************************
342 *
343 * FUNCTION: acpi_ut_strlwr (strlwr)
344 *
345 * PARAMETERS: src_string - The source string to convert
346 *
347 * RETURN: None
348 *
349 * DESCRIPTION: Convert string to lowercase
350 *
351 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
352 *
353 ******************************************************************************/
354
355void acpi_ut_strlwr(char *src_string)
356{
357 char *string;
358
359 ACPI_FUNCTION_ENTRY();
360
361 if (!src_string) {
362 return;
363 }
364
365 /* Walk entire string, lowercasing the letters */
366
367 for (string = src_string; *string; string++) {
368 *string = (char)ACPI_TOLOWER(*string);
369 }
370
371 return;
372}
373
374/******************************************************************************
375 *
376 * FUNCTION: acpi_ut_stricmp
377 *
378 * PARAMETERS: string1 - first string to compare
379 * string2 - second string to compare
380 *
381 * RETURN: int that signifies string relationship. Zero means strings
382 * are equal.
383 *
384 * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare
385 * strings with no case sensitivity)
386 *
387 ******************************************************************************/
388
389int acpi_ut_stricmp(char *string1, char *string2)
390{
391 int c1;
392 int c2;
393
394 do {
395 c1 = tolower((int)*string1);
396 c2 = tolower((int)*string2);
397
398 string1++;
399 string2++;
400 }
401 while ((c1 == c2) && (c1));
402
403 return (c1 - c2);
404}
405#endif
406
407/******************************************************************************* 380/*******************************************************************************
408 * 381 *
409 * FUNCTION: acpi_ut_print_string 382 * FUNCTION: acpi_ut_print_string
410 * 383 *
411 * PARAMETERS: string - Null terminated ASCII string 384 * PARAMETERS: String - Null terminated ASCII string
412 * max_length - Maximum output length 385 * max_length - Maximum output length
413 * 386 *
414 * RETURN: None 387 * RETURN: None
@@ -494,7 +467,7 @@ void acpi_ut_print_string(char *string, u8 max_length)
494 * 467 *
495 * FUNCTION: acpi_ut_dword_byte_swap 468 * FUNCTION: acpi_ut_dword_byte_swap
496 * 469 *
497 * PARAMETERS: value - Value to be converted 470 * PARAMETERS: Value - Value to be converted
498 * 471 *
499 * RETURN: u32 integer with bytes swapped 472 * RETURN: u32 integer with bytes swapped
500 * 473 *
@@ -534,8 +507,8 @@ u32 acpi_ut_dword_byte_swap(u32 value)
534 * RETURN: None 507 * RETURN: None
535 * 508 *
536 * DESCRIPTION: Set the global integer bit width based upon the revision 509 * DESCRIPTION: Set the global integer bit width based upon the revision
537 * of the DSDT. For Revision 1 and 0, Integers are 32 bits. 510 * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
538 * For Revision 2 and above, Integers are 64 bits. Yes, this 511 * For Revision 2 and above, Integers are 64 bits. Yes, this
539 * makes a difference. 512 * makes a difference.
540 * 513 *
541 ******************************************************************************/ 514 ******************************************************************************/
@@ -564,9 +537,9 @@ void acpi_ut_set_integer_width(u8 revision)
564 * 537 *
565 * FUNCTION: acpi_ut_display_init_pathname 538 * FUNCTION: acpi_ut_display_init_pathname
566 * 539 *
567 * PARAMETERS: type - Object type of the node 540 * PARAMETERS: Type - Object type of the node
568 * obj_handle - Handle whose pathname will be displayed 541 * obj_handle - Handle whose pathname will be displayed
569 * path - Additional path string to be appended. 542 * Path - Additional path string to be appended.
570 * (NULL if no extra path) 543 * (NULL if no extra path)
571 * 544 *
572 * RETURN: acpi_status 545 * RETURN: acpi_status
@@ -631,8 +604,8 @@ acpi_ut_display_init_pathname(u8 type,
631 * 604 *
632 * FUNCTION: acpi_ut_valid_acpi_char 605 * FUNCTION: acpi_ut_valid_acpi_char
633 * 606 *
634 * PARAMETERS: char - The character to be examined 607 * PARAMETERS: Char - The character to be examined
635 * position - Byte position (0-3) 608 * Position - Byte position (0-3)
636 * 609 *
637 * RETURN: TRUE if the character is valid, FALSE otherwise 610 * RETURN: TRUE if the character is valid, FALSE otherwise
638 * 611 *
@@ -667,11 +640,11 @@ u8 acpi_ut_valid_acpi_char(char character, u32 position)
667 * 640 *
668 * FUNCTION: acpi_ut_valid_acpi_name 641 * FUNCTION: acpi_ut_valid_acpi_name
669 * 642 *
670 * PARAMETERS: name - The name to be examined 643 * PARAMETERS: Name - The name to be examined
671 * 644 *
672 * RETURN: TRUE if the name is valid, FALSE otherwise 645 * RETURN: TRUE if the name is valid, FALSE otherwise
673 * 646 *
674 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: 647 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
675 * 1) Upper case alpha 648 * 1) Upper case alpha
676 * 2) numeric 649 * 2) numeric
677 * 3) underscore 650 * 3) underscore
@@ -698,72 +671,42 @@ u8 acpi_ut_valid_acpi_name(u32 name)
698 * 671 *
699 * FUNCTION: acpi_ut_repair_name 672 * FUNCTION: acpi_ut_repair_name
700 * 673 *
701 * PARAMETERS: name - The ACPI name to be repaired 674 * PARAMETERS: Name - The ACPI name to be repaired
702 * 675 *
703 * RETURN: Repaired version of the name 676 * RETURN: Repaired version of the name
704 * 677 *
705 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and 678 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
706 * return the new name. NOTE: the Name parameter must reside in 679 * return the new name.
707 * read/write memory, cannot be a const.
708 *
709 * An ACPI Name must consist of valid ACPI characters. We will repair the name
710 * if necessary because we don't want to abort because of this, but we want
711 * all namespace names to be printable. A warning message is appropriate.
712 *
713 * This issue came up because there are in fact machines that exhibit
714 * this problem, and we want to be able to enable ACPI support for them,
715 * even though there are a few bad names.
716 * 680 *
717 ******************************************************************************/ 681 ******************************************************************************/
718 682
719void acpi_ut_repair_name(char *name) 683acpi_name acpi_ut_repair_name(char *name)
720{ 684{
721 u32 i; 685 u32 i;
722 u8 found_bad_char = FALSE; 686 char new_name[ACPI_NAME_SIZE];
723 u32 original_name;
724
725 ACPI_FUNCTION_NAME(ut_repair_name);
726
727 ACPI_MOVE_NAME(&original_name, name);
728
729 /* Check each character in the name */
730 687
731 for (i = 0; i < ACPI_NAME_SIZE; i++) { 688 for (i = 0; i < ACPI_NAME_SIZE; i++) {
732 if (acpi_ut_valid_acpi_char(name[i], i)) { 689 new_name[i] = name[i];
733 continue;
734 }
735 690
736 /* 691 /*
737 * Replace a bad character with something printable, yet technically 692 * Replace a bad character with something printable, yet technically
738 * still invalid. This prevents any collisions with existing "good" 693 * still invalid. This prevents any collisions with existing "good"
739 * names in the namespace. 694 * names in the namespace.
740 */ 695 */
741 name[i] = '*'; 696 if (!acpi_ut_valid_acpi_char(name[i], i)) {
742 found_bad_char = TRUE; 697 new_name[i] = '*';
743 }
744
745 if (found_bad_char) {
746
747 /* Report warning only if in strict mode or debug mode */
748
749 if (!acpi_gbl_enable_interpreter_slack) {
750 ACPI_WARNING((AE_INFO,
751 "Found bad character(s) in name, repaired: [%4.4s]\n",
752 name));
753 } else {
754 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
755 "Found bad character(s) in name, repaired: [%4.4s]\n",
756 name));
757 } 698 }
758 } 699 }
700
701 return (*(u32 *) new_name);
759} 702}
760 703
761/******************************************************************************* 704/*******************************************************************************
762 * 705 *
763 * FUNCTION: acpi_ut_strtoul64 706 * FUNCTION: acpi_ut_strtoul64
764 * 707 *
765 * PARAMETERS: string - Null terminated string 708 * PARAMETERS: String - Null terminated string
766 * base - Radix of the string: 16 or ACPI_ANY_BASE; 709 * Base - Radix of the string: 16 or ACPI_ANY_BASE;
767 * ACPI_ANY_BASE means 'in behalf of to_integer' 710 * ACPI_ANY_BASE means 'in behalf of to_integer'
768 * ret_integer - Where the converted integer is returned 711 * ret_integer - Where the converted integer is returned
769 * 712 *
@@ -776,7 +719,7 @@ void acpi_ut_repair_name(char *name)
776 * 719 *
777 ******************************************************************************/ 720 ******************************************************************************/
778 721
779acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) 722acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer)
780{ 723{
781 u32 this_digit = 0; 724 u32 this_digit = 0;
782 u64 return_value = 0; 725 u64 return_value = 0;
@@ -812,7 +755,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
812 755
813 if (to_integer_op) { 756 if (to_integer_op) {
814 /* 757 /*
815 * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. 758 * Base equal to ACPI_ANY_BASE means 'to_integer operation case'.
816 * We need to determine if it is decimal or hexadecimal. 759 * We need to determine if it is decimal or hexadecimal.
817 */ 760 */
818 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { 761 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
@@ -849,14 +792,14 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
849 792
850 /* Convert ASCII 0-9 to Decimal value */ 793 /* Convert ASCII 0-9 to Decimal value */
851 794
852 this_digit = ((u8)*string) - '0'; 795 this_digit = ((u8) * string) - '0';
853 } else if (base == 10) { 796 } else if (base == 10) {
854 797
855 /* Digit is out of range; possible in to_integer case only */ 798 /* Digit is out of range; possible in to_integer case only */
856 799
857 term = 1; 800 term = 1;
858 } else { 801 } else {
859 this_digit = (u8)ACPI_TOUPPER(*string); 802 this_digit = (u8) ACPI_TOUPPER(*string);
860 if (ACPI_IS_XDIGIT((char)this_digit)) { 803 if (ACPI_IS_XDIGIT((char)this_digit)) {
861 804
862 /* Convert ASCII Hex char to value */ 805 /* Convert ASCII Hex char to value */
@@ -883,9 +826,8 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
883 826
884 valid_digits++; 827 valid_digits++;
885 828
886 if (sign_of0x 829 if (sign_of0x && ((valid_digits > 16)
887 && ((valid_digits > 16) 830 || ((valid_digits > 8) && mode32))) {
888 || ((valid_digits > 8) && mode32))) {
889 /* 831 /*
890 * This is to_integer operation case. 832 * This is to_integer operation case.
891 * No any restrictions for string-to-integer conversion, 833 * No any restrictions for string-to-integer conversion,
@@ -896,7 +838,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
896 838
897 /* Divide the digit into the correct position */ 839 /* Divide the digit into the correct position */
898 840
899 (void)acpi_ut_short_divide((dividend - (u64)this_digit), 841 (void)acpi_ut_short_divide((dividend - (u64) this_digit),
900 base, &quotient, NULL); 842 base, &quotient, NULL);
901 843
902 if (return_value > quotient) { 844 if (return_value > quotient) {
@@ -936,8 +878,8 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
936 * 878 *
937 * FUNCTION: acpi_ut_create_update_state_and_push 879 * FUNCTION: acpi_ut_create_update_state_and_push
938 * 880 *
939 * PARAMETERS: object - Object to be added to the new state 881 * PARAMETERS: Object - Object to be added to the new state
940 * action - Increment/Decrement 882 * Action - Increment/Decrement
941 * state_list - List the state will be added to 883 * state_list - List the state will be added to
942 * 884 *
943 * RETURN: Status 885 * RETURN: Status
@@ -977,7 +919,7 @@ acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
977 * PARAMETERS: source_object - The package to walk 919 * PARAMETERS: source_object - The package to walk
978 * target_object - Target object (if package is being copied) 920 * target_object - Target object (if package is being copied)
979 * walk_callback - Called once for each package element 921 * walk_callback - Called once for each package element
980 * context - Passed to the callback function 922 * Context - Passed to the callback function
981 * 923 *
982 * RETURN: Status 924 * RETURN: Status
983 * 925 *
@@ -986,7 +928,7 @@ acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
986 ******************************************************************************/ 928 ******************************************************************************/
987 929
988acpi_status 930acpi_status
989acpi_ut_walk_package_tree(union acpi_operand_object *source_object, 931acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
990 void *target_object, 932 void *target_object,
991 acpi_pkg_callback walk_callback, void *context) 933 acpi_pkg_callback walk_callback, void *context)
992{ 934{
@@ -1013,10 +955,10 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
1013 955
1014 /* 956 /*
1015 * Check for: 957 * Check for:
1016 * 1) An uninitialized package element. It is completely 958 * 1) An uninitialized package element. It is completely
1017 * legal to declare a package and leave it uninitialized 959 * legal to declare a package and leave it uninitialized
1018 * 2) Not an internal object - can be a namespace node instead 960 * 2) Not an internal object - can be a namespace node instead
1019 * 3) Any type other than a package. Packages are handled in else 961 * 3) Any type other than a package. Packages are handled in else
1020 * case below. 962 * case below.
1021 */ 963 */
1022 if ((!this_source_obj) || 964 if ((!this_source_obj) ||
@@ -1035,7 +977,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
1035 state->pkg.source_object->package.count) { 977 state->pkg.source_object->package.count) {
1036 /* 978 /*
1037 * We've handled all of the objects at this level, This means 979 * We've handled all of the objects at this level, This means
1038 * that we have just completed a package. That package may 980 * that we have just completed a package. That package may
1039 * have contained one or more packages itself. 981 * have contained one or more packages itself.
1040 * 982 *
1041 * Delete this state and pop the previous state (package). 983 * Delete this state and pop the previous state (package).
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 5ccf57c0d87..7d797e2baec 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -147,7 +147,7 @@ void acpi_ut_mutex_terminate(void)
147 * 147 *
148 * FUNCTION: acpi_ut_create_mutex 148 * FUNCTION: acpi_ut_create_mutex
149 * 149 *
150 * PARAMETERS: mutex_ID - ID of the mutex to be created 150 * PARAMETERS: mutex_iD - ID of the mutex to be created
151 * 151 *
152 * RETURN: Status 152 * RETURN: Status
153 * 153 *
@@ -176,7 +176,7 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
176 * 176 *
177 * FUNCTION: acpi_ut_delete_mutex 177 * FUNCTION: acpi_ut_delete_mutex
178 * 178 *
179 * PARAMETERS: mutex_ID - ID of the mutex to be deleted 179 * PARAMETERS: mutex_iD - ID of the mutex to be deleted
180 * 180 *
181 * RETURN: Status 181 * RETURN: Status
182 * 182 *
@@ -193,15 +193,13 @@ static void acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
193 193
194 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 194 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
195 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 195 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
196
197 return_VOID;
198} 196}
199 197
200/******************************************************************************* 198/*******************************************************************************
201 * 199 *
202 * FUNCTION: acpi_ut_acquire_mutex 200 * FUNCTION: acpi_ut_acquire_mutex
203 * 201 *
204 * PARAMETERS: mutex_ID - ID of the mutex to be acquired 202 * PARAMETERS: mutex_iD - ID of the mutex to be acquired
205 * 203 *
206 * RETURN: Status 204 * RETURN: Status
207 * 205 *
@@ -228,9 +226,9 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
228 /* 226 /*
229 * Mutex debug code, for internal debugging only. 227 * Mutex debug code, for internal debugging only.
230 * 228 *
231 * Deadlock prevention. Check if this thread owns any mutexes of value 229 * Deadlock prevention. Check if this thread owns any mutexes of value
232 * greater than or equal to this one. If so, the thread has violated 230 * greater than or equal to this one. If so, the thread has violated
233 * the mutex ordering rule. This indicates a coding error somewhere in 231 * the mutex ordering rule. This indicates a coding error somewhere in
234 * the ACPI subsystem code. 232 * the ACPI subsystem code.
235 */ 233 */
236 for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) { 234 for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) {
@@ -285,7 +283,7 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
285 * 283 *
286 * FUNCTION: acpi_ut_release_mutex 284 * FUNCTION: acpi_ut_release_mutex
287 * 285 *
288 * PARAMETERS: mutex_ID - ID of the mutex to be released 286 * PARAMETERS: mutex_iD - ID of the mutex to be released
289 * 287 *
290 * RETURN: Status 288 * RETURN: Status
291 * 289 *
@@ -295,10 +293,14 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
295 293
296acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) 294acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
297{ 295{
296 acpi_thread_id this_thread_id;
297
298 ACPI_FUNCTION_NAME(ut_release_mutex); 298 ACPI_FUNCTION_NAME(ut_release_mutex);
299 299
300 this_thread_id = acpi_os_get_thread_id();
301
300 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n", 302 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n",
301 (u32)acpi_os_get_thread_id(), 303 (u32)this_thread_id,
302 acpi_ut_get_mutex_name(mutex_id))); 304 acpi_ut_get_mutex_name(mutex_id)));
303 305
304 if (mutex_id > ACPI_MAX_MUTEX) { 306 if (mutex_id > ACPI_MAX_MUTEX) {
@@ -321,14 +323,13 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
321 /* 323 /*
322 * Mutex debug code, for internal debugging only. 324 * Mutex debug code, for internal debugging only.
323 * 325 *
324 * Deadlock prevention. Check if this thread owns any mutexes of value 326 * Deadlock prevention. Check if this thread owns any mutexes of value
325 * greater than this one. If so, the thread has violated the mutex 327 * greater than this one. If so, the thread has violated the mutex
326 * ordering rule. This indicates a coding error somewhere in 328 * ordering rule. This indicates a coding error somewhere in
327 * the ACPI subsystem code. 329 * the ACPI subsystem code.
328 */ 330 */
329 for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) { 331 for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) {
330 if (acpi_gbl_mutex_info[i].thread_id == 332 if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
331 acpi_os_get_thread_id()) {
332 if (i == mutex_id) { 333 if (i == mutex_id) {
333 continue; 334 continue;
334 } 335 }
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index 5c52ca78f6f..188340a017b 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -69,7 +69,7 @@ acpi_ut_get_element_length(u8 object_type,
69 * PARAMETERS: module_name - Source file name of caller 69 * PARAMETERS: module_name - Source file name of caller
70 * line_number - Line number of caller 70 * line_number - Line number of caller
71 * component_id - Component type of caller 71 * component_id - Component type of caller
72 * type - ACPI Type of the new object 72 * Type - ACPI Type of the new object
73 * 73 *
74 * RETURN: A new internal object, null on failure 74 * RETURN: A new internal object, null on failure
75 * 75 *
@@ -77,7 +77,7 @@ acpi_ut_get_element_length(u8 object_type,
77 * 77 *
78 * NOTE: We always allocate the worst-case object descriptor because 78 * NOTE: We always allocate the worst-case object descriptor because
79 * these objects are cached, and we want them to be 79 * these objects are cached, and we want them to be
80 * one-size-satisifies-any-request. This in itself may not be 80 * one-size-satisifies-any-request. This in itself may not be
81 * the most memory efficient, but the efficiency of the object 81 * the most memory efficient, but the efficiency of the object
82 * cache should more than make up for this! 82 * cache should more than make up for this!
83 * 83 *
@@ -150,7 +150,7 @@ union acpi_operand_object *acpi_ut_create_internal_object_dbg(const char
150 * 150 *
151 * FUNCTION: acpi_ut_create_package_object 151 * FUNCTION: acpi_ut_create_package_object
152 * 152 *
153 * PARAMETERS: count - Number of package elements 153 * PARAMETERS: Count - Number of package elements
154 * 154 *
155 * RETURN: Pointer to a new Package object, null on failure 155 * RETURN: Pointer to a new Package object, null on failure
156 * 156 *
@@ -323,11 +323,11 @@ union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size)
323 * 323 *
324 * FUNCTION: acpi_ut_valid_internal_object 324 * FUNCTION: acpi_ut_valid_internal_object
325 * 325 *
326 * PARAMETERS: object - Object to be validated 326 * PARAMETERS: Object - Object to be validated
327 * 327 *
328 * RETURN: TRUE if object is valid, FALSE otherwise 328 * RETURN: TRUE if object is valid, FALSE otherwise
329 * 329 *
330 * DESCRIPTION: Validate a pointer to be of type union acpi_operand_object 330 * DESCRIPTION: Validate a pointer to be a union acpi_operand_object
331 * 331 *
332 ******************************************************************************/ 332 ******************************************************************************/
333 333
@@ -348,7 +348,7 @@ u8 acpi_ut_valid_internal_object(void *object)
348 switch (ACPI_GET_DESCRIPTOR_TYPE(object)) { 348 switch (ACPI_GET_DESCRIPTOR_TYPE(object)) {
349 case ACPI_DESC_TYPE_OPERAND: 349 case ACPI_DESC_TYPE_OPERAND:
350 350
351 /* The object appears to be a valid union acpi_operand_object */ 351 /* The object appears to be a valid union acpi_operand_object */
352 352
353 return (TRUE); 353 return (TRUE);
354 354
@@ -370,9 +370,9 @@ u8 acpi_ut_valid_internal_object(void *object)
370 * line_number - Caller's line number (for error output) 370 * line_number - Caller's line number (for error output)
371 * component_id - Caller's component ID (for error output) 371 * component_id - Caller's component ID (for error output)
372 * 372 *
373 * RETURN: Pointer to newly allocated object descriptor. Null on error 373 * RETURN: Pointer to newly allocated object descriptor. Null on error
374 * 374 *
375 * DESCRIPTION: Allocate a new object descriptor. Gracefully handle 375 * DESCRIPTION: Allocate a new object descriptor. Gracefully handle
376 * error conditions. 376 * error conditions.
377 * 377 *
378 ******************************************************************************/ 378 ******************************************************************************/
@@ -407,7 +407,7 @@ void *acpi_ut_allocate_object_desc_dbg(const char *module_name,
407 * 407 *
408 * FUNCTION: acpi_ut_delete_object_desc 408 * FUNCTION: acpi_ut_delete_object_desc
409 * 409 *
410 * PARAMETERS: object - An Acpi internal object to be deleted 410 * PARAMETERS: Object - An Acpi internal object to be deleted
411 * 411 *
412 * RETURN: None. 412 * RETURN: None.
413 * 413 *
@@ -419,7 +419,7 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object)
419{ 419{
420 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object); 420 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object);
421 421
422 /* Object must be a union acpi_operand_object */ 422 /* Object must be a union acpi_operand_object */
423 423
424 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { 424 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
425 ACPI_ERROR((AE_INFO, 425 ACPI_ERROR((AE_INFO,
@@ -554,7 +554,7 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
554 554
555 /* 555 /*
556 * Account for the space required by the object rounded up to the next 556 * Account for the space required by the object rounded up to the next
557 * multiple of the machine word size. This keeps each object aligned 557 * multiple of the machine word size. This keeps each object aligned
558 * on a machine word boundary. (preventing alignment faults on some 558 * on a machine word boundary. (preventing alignment faults on some
559 * machines.) 559 * machines.)
560 */ 560 */
diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c
index 676285d6116..1fb10cb8f11 100644
--- a/drivers/acpi/acpica/utosi.c
+++ b/drivers/acpi/acpica/utosi.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -68,12 +68,11 @@ static struct acpi_interface_info acpi_default_supported_interfaces[] = {
68 {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ 68 {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
69 {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ 69 {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
70 {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ 70 {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
71 {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows vista - Added 03/2006 */ 71 {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
72 {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ 72 {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
73 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ 73 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
74 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */ 74 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
75 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ 75 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
76 {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */
77 76
78 /* Feature Group Strings */ 77 /* Feature Group Strings */
79 78
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index e38bef4980b..6ffd3a8bdaa 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -43,7 +43,7 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "acresrc.h" 46#include "amlresrc.h"
47 47
48#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utresrc") 49ACPI_MODULE_NAME("utresrc")
@@ -154,138 +154,6 @@ const char *acpi_gbl_typ_decode[] = {
154 "TypeF" 154 "TypeF"
155}; 155};
156 156
157const char *acpi_gbl_ppc_decode[] = {
158 "PullDefault",
159 "PullUp",
160 "PullDown",
161 "PullNone"
162};
163
164const char *acpi_gbl_ior_decode[] = {
165 "IoRestrictionNone",
166 "IoRestrictionInputOnly",
167 "IoRestrictionOutputOnly",
168 "IoRestrictionNoneAndPreserve"
169};
170
171const char *acpi_gbl_dts_decode[] = {
172 "Width8bit",
173 "Width16bit",
174 "Width32bit",
175 "Width64bit",
176 "Width128bit",
177 "Width256bit",
178};
179
180/* GPIO connection type */
181
182const char *acpi_gbl_ct_decode[] = {
183 "Interrupt",
184 "I/O"
185};
186
187/* Serial bus type */
188
189const char *acpi_gbl_sbt_decode[] = {
190 "/* UNKNOWN serial bus type */",
191 "I2C",
192 "SPI",
193 "UART"
194};
195
196/* I2C serial bus access mode */
197
198const char *acpi_gbl_am_decode[] = {
199 "AddressingMode7Bit",
200 "AddressingMode10Bit"
201};
202
203/* I2C serial bus slave mode */
204
205const char *acpi_gbl_sm_decode[] = {
206 "ControllerInitiated",
207 "DeviceInitiated"
208};
209
210/* SPI serial bus wire mode */
211
212const char *acpi_gbl_wm_decode[] = {
213 "FourWireMode",
214 "ThreeWireMode"
215};
216
217/* SPI serial clock phase */
218
219const char *acpi_gbl_cph_decode[] = {
220 "ClockPhaseFirst",
221 "ClockPhaseSecond"
222};
223
224/* SPI serial bus clock polarity */
225
226const char *acpi_gbl_cpo_decode[] = {
227 "ClockPolarityLow",
228 "ClockPolarityHigh"
229};
230
231/* SPI serial bus device polarity */
232
233const char *acpi_gbl_dp_decode[] = {
234 "PolarityLow",
235 "PolarityHigh"
236};
237
238/* UART serial bus endian */
239
240const char *acpi_gbl_ed_decode[] = {
241 "LittleEndian",
242 "BigEndian"
243};
244
245/* UART serial bus bits per byte */
246
247const char *acpi_gbl_bpb_decode[] = {
248 "DataBitsFive",
249 "DataBitsSix",
250 "DataBitsSeven",
251 "DataBitsEight",
252 "DataBitsNine",
253 "/* UNKNOWN Bits per byte */",
254 "/* UNKNOWN Bits per byte */",
255 "/* UNKNOWN Bits per byte */"
256};
257
258/* UART serial bus stop bits */
259
260const char *acpi_gbl_sb_decode[] = {
261 "StopBitsNone",
262 "StopBitsOne",
263 "StopBitsOnePlusHalf",
264 "StopBitsTwo"
265};
266
267/* UART serial bus flow control */
268
269const char *acpi_gbl_fc_decode[] = {
270 "FlowControlNone",
271 "FlowControlHardware",
272 "FlowControlXON",
273 "/* UNKNOWN flow control keyword */"
274};
275
276/* UART serial bus parity type */
277
278const char *acpi_gbl_pt_decode[] = {
279 "ParityTypeNone",
280 "ParityTypeEven",
281 "ParityTypeOdd",
282 "ParityTypeMark",
283 "ParityTypeSpace",
284 "/* UNKNOWN parity keyword */",
285 "/* UNKNOWN parity keyword */",
286 "/* UNKNOWN parity keyword */"
287};
288
289#endif 157#endif
290 158
291/* 159/*
@@ -305,7 +173,7 @@ const u8 acpi_gbl_resource_aml_sizes[] = {
305 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent), 173 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent),
306 ACPI_AML_SIZE_SMALL(struct aml_resource_io), 174 ACPI_AML_SIZE_SMALL(struct aml_resource_io),
307 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io), 175 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io),
308 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_dma), 176 0,
309 0, 177 0,
310 0, 178 0,
311 0, 179 0,
@@ -325,17 +193,7 @@ const u8 acpi_gbl_resource_aml_sizes[] = {
325 ACPI_AML_SIZE_LARGE(struct aml_resource_address16), 193 ACPI_AML_SIZE_LARGE(struct aml_resource_address16),
326 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq), 194 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq),
327 ACPI_AML_SIZE_LARGE(struct aml_resource_address64), 195 ACPI_AML_SIZE_LARGE(struct aml_resource_address64),
328 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64), 196 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64)
329 ACPI_AML_SIZE_LARGE(struct aml_resource_gpio),
330 0,
331 ACPI_AML_SIZE_LARGE(struct aml_resource_common_serialbus),
332};
333
334const u8 acpi_gbl_resource_aml_serial_bus_sizes[] = {
335 0,
336 ACPI_AML_SIZE_LARGE(struct aml_resource_i2c_serialbus),
337 ACPI_AML_SIZE_LARGE(struct aml_resource_spi_serialbus),
338 ACPI_AML_SIZE_LARGE(struct aml_resource_uart_serialbus),
339}; 197};
340 198
341/* 199/*
@@ -351,58 +209,44 @@ static const u8 acpi_gbl_resource_types[] = {
351 0, 209 0,
352 0, 210 0,
353 0, 211 0,
354 ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */ 212 ACPI_SMALL_VARIABLE_LENGTH,
355 ACPI_FIXED_LENGTH, /* 05 DMA */ 213 ACPI_FIXED_LENGTH,
356 ACPI_SMALL_VARIABLE_LENGTH, /* 06 start_dependent_functions */ 214 ACPI_SMALL_VARIABLE_LENGTH,
357 ACPI_FIXED_LENGTH, /* 07 end_dependent_functions */ 215 ACPI_FIXED_LENGTH,
358 ACPI_FIXED_LENGTH, /* 08 IO */ 216 ACPI_FIXED_LENGTH,
359 ACPI_FIXED_LENGTH, /* 09 fixed_IO */ 217 ACPI_FIXED_LENGTH,
360 ACPI_FIXED_LENGTH, /* 0A fixed_DMA */ 218 0,
361 0, 219 0,
362 0, 220 0,
363 0, 221 0,
364 ACPI_VARIABLE_LENGTH, /* 0E vendor_short */ 222 ACPI_VARIABLE_LENGTH,
365 ACPI_FIXED_LENGTH, /* 0F end_tag */ 223 ACPI_FIXED_LENGTH,
366 224
367 /* Large descriptors */ 225 /* Large descriptors */
368 226
369 0, 227 0,
370 ACPI_FIXED_LENGTH, /* 01 Memory24 */ 228 ACPI_FIXED_LENGTH,
371 ACPI_FIXED_LENGTH, /* 02 generic_register */ 229 ACPI_FIXED_LENGTH,
372 0, 230 0,
373 ACPI_VARIABLE_LENGTH, /* 04 vendor_long */ 231 ACPI_VARIABLE_LENGTH,
374 ACPI_FIXED_LENGTH, /* 05 Memory32 */ 232 ACPI_FIXED_LENGTH,
375 ACPI_FIXED_LENGTH, /* 06 memory32_fixed */ 233 ACPI_FIXED_LENGTH,
376 ACPI_VARIABLE_LENGTH, /* 07 Dword* address */ 234 ACPI_VARIABLE_LENGTH,
377 ACPI_VARIABLE_LENGTH, /* 08 Word* address */ 235 ACPI_VARIABLE_LENGTH,
378 ACPI_VARIABLE_LENGTH, /* 09 extended_IRQ */ 236 ACPI_VARIABLE_LENGTH,
379 ACPI_VARIABLE_LENGTH, /* 0A Qword* address */ 237 ACPI_VARIABLE_LENGTH,
380 ACPI_FIXED_LENGTH, /* 0B Extended* address */ 238 ACPI_FIXED_LENGTH
381 ACPI_VARIABLE_LENGTH, /* 0C Gpio* */
382 0,
383 ACPI_VARIABLE_LENGTH /* 0E *serial_bus */
384}; 239};
385 240
386/*
387 * For the iASL compiler/disassembler, we don't want any error messages
388 * because the disassembler uses the resource validation code to determine
389 * if Buffer objects are actually Resource Templates.
390 */
391#ifdef ACPI_ASL_COMPILER
392#define ACPI_RESOURCE_ERROR(plist)
393#else
394#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)
395#endif
396
397/******************************************************************************* 241/*******************************************************************************
398 * 242 *
399 * FUNCTION: acpi_ut_walk_aml_resources 243 * FUNCTION: acpi_ut_walk_aml_resources
400 * 244 *
401 * PARAMETERS: aml - Pointer to the raw AML resource template 245 * PARAMETERS: Aml - Pointer to the raw AML resource template
402 * aml_length - Length of the entire template 246 * aml_length - Length of the entire template
403 * user_function - Called once for each descriptor found. If 247 * user_function - Called once for each descriptor found. If
404 * NULL, a pointer to the end_tag is returned 248 * NULL, a pointer to the end_tag is returned
405 * context - Passed to user_function 249 * Context - Passed to user_function
406 * 250 *
407 * RETURN: Status 251 * RETURN: Status
408 * 252 *
@@ -421,7 +265,6 @@ acpi_ut_walk_aml_resources(u8 * aml,
421 u8 resource_index; 265 u8 resource_index;
422 u32 length; 266 u32 length;
423 u32 offset = 0; 267 u32 offset = 0;
424 u8 end_tag[2] = { 0x79, 0x00 };
425 268
426 ACPI_FUNCTION_TRACE(ut_walk_aml_resources); 269 ACPI_FUNCTION_TRACE(ut_walk_aml_resources);
427 270
@@ -443,10 +286,6 @@ acpi_ut_walk_aml_resources(u8 * aml,
443 286
444 status = acpi_ut_validate_resource(aml, &resource_index); 287 status = acpi_ut_validate_resource(aml, &resource_index);
445 if (ACPI_FAILURE(status)) { 288 if (ACPI_FAILURE(status)) {
446 /*
447 * Exit on failure. Cannot continue because the descriptor length
448 * may be bogus also.
449 */
450 return_ACPI_STATUS(status); 289 return_ACPI_STATUS(status);
451 } 290 }
452 291
@@ -461,7 +300,7 @@ acpi_ut_walk_aml_resources(u8 * aml,
461 user_function(aml, length, offset, resource_index, 300 user_function(aml, length, offset, resource_index,
462 context); 301 context);
463 if (ACPI_FAILURE(status)) { 302 if (ACPI_FAILURE(status)) {
464 return_ACPI_STATUS(status); 303 return (status);
465 } 304 }
466 } 305 }
467 306
@@ -494,26 +333,14 @@ acpi_ut_walk_aml_resources(u8 * aml,
494 333
495 /* Did not find an end_tag descriptor */ 334 /* Did not find an end_tag descriptor */
496 335
497 if (user_function) { 336 return (AE_AML_NO_RESOURCE_END_TAG);
498
499 /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */
500
501 (void)acpi_ut_validate_resource(end_tag, &resource_index);
502 status =
503 user_function(end_tag, 2, offset, resource_index, context);
504 if (ACPI_FAILURE(status)) {
505 return_ACPI_STATUS(status);
506 }
507 }
508
509 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
510} 337}
511 338
512/******************************************************************************* 339/*******************************************************************************
513 * 340 *
514 * FUNCTION: acpi_ut_validate_resource 341 * FUNCTION: acpi_ut_validate_resource
515 * 342 *
516 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 343 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
517 * return_index - Where the resource index is returned. NULL 344 * return_index - Where the resource index is returned. NULL
518 * if the index is not required. 345 * if the index is not required.
519 * 346 *
@@ -527,7 +354,6 @@ acpi_ut_walk_aml_resources(u8 * aml,
527 354
528acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) 355acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
529{ 356{
530 union aml_resource *aml_resource;
531 u8 resource_type; 357 u8 resource_type;
532 u8 resource_index; 358 u8 resource_index;
533 acpi_rs_length resource_length; 359 acpi_rs_length resource_length;
@@ -549,7 +375,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
549 /* Verify the large resource type (name) against the max */ 375 /* Verify the large resource type (name) against the max */
550 376
551 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 377 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
552 goto invalid_resource; 378 return (AE_AML_INVALID_RESOURCE_TYPE);
553 } 379 }
554 380
555 /* 381 /*
@@ -566,17 +392,15 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
566 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); 392 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
567 } 393 }
568 394
569 /* 395 /* Check validity of the resource type, zero indicates name is invalid */
570 * Check validity of the resource type, via acpi_gbl_resource_types. Zero 396
571 * indicates an invalid resource.
572 */
573 if (!acpi_gbl_resource_types[resource_index]) { 397 if (!acpi_gbl_resource_types[resource_index]) {
574 goto invalid_resource; 398 return (AE_AML_INVALID_RESOURCE_TYPE);
575 } 399 }
576 400
577 /* 401 /*
578 * Validate the resource_length field. This ensures that the length 402 * 2) Validate the resource_length field. This ensures that the length
579 * is at least reasonable, and guarantees that it is non-zero. 403 * is at least reasonable, and guarantees that it is non-zero.
580 */ 404 */
581 resource_length = acpi_ut_get_resource_length(aml); 405 resource_length = acpi_ut_get_resource_length(aml);
582 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index]; 406 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index];
@@ -589,7 +413,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
589 /* Fixed length resource, length must match exactly */ 413 /* Fixed length resource, length must match exactly */
590 414
591 if (resource_length != minimum_resource_length) { 415 if (resource_length != minimum_resource_length) {
592 goto bad_resource_length; 416 return (AE_AML_BAD_RESOURCE_LENGTH);
593 } 417 }
594 break; 418 break;
595 419
@@ -598,7 +422,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
598 /* Variable length resource, length must be at least the minimum */ 422 /* Variable length resource, length must be at least the minimum */
599 423
600 if (resource_length < minimum_resource_length) { 424 if (resource_length < minimum_resource_length) {
601 goto bad_resource_length; 425 return (AE_AML_BAD_RESOURCE_LENGTH);
602 } 426 }
603 break; 427 break;
604 428
@@ -608,7 +432,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
608 432
609 if ((resource_length > minimum_resource_length) || 433 if ((resource_length > minimum_resource_length) ||
610 (resource_length < (minimum_resource_length - 1))) { 434 (resource_length < (minimum_resource_length - 1))) {
611 goto bad_resource_length; 435 return (AE_AML_BAD_RESOURCE_LENGTH);
612 } 436 }
613 break; 437 break;
614 438
@@ -616,23 +440,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
616 440
617 /* Shouldn't happen (because of validation earlier), but be sure */ 441 /* Shouldn't happen (because of validation earlier), but be sure */
618 442
619 goto invalid_resource; 443 return (AE_AML_INVALID_RESOURCE_TYPE);
620 }
621
622 aml_resource = ACPI_CAST_PTR(union aml_resource, aml);
623 if (resource_type == ACPI_RESOURCE_NAME_SERIAL_BUS) {
624
625 /* Validate the bus_type field */
626
627 if ((aml_resource->common_serial_bus.type == 0) ||
628 (aml_resource->common_serial_bus.type >
629 AML_RESOURCE_MAX_SERIALBUSTYPE)) {
630 ACPI_RESOURCE_ERROR((AE_INFO,
631 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
632 aml_resource->common_serial_bus.
633 type));
634 return (AE_AML_INVALID_RESOURCE_TYPE);
635 }
636 } 444 }
637 445
638 /* Optionally return the resource table index */ 446 /* Optionally return the resource table index */
@@ -642,29 +450,13 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
642 } 450 }
643 451
644 return (AE_OK); 452 return (AE_OK);
645
646 invalid_resource:
647
648 ACPI_RESOURCE_ERROR((AE_INFO,
649 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
650 resource_type));
651 return (AE_AML_INVALID_RESOURCE_TYPE);
652
653 bad_resource_length:
654
655 ACPI_RESOURCE_ERROR((AE_INFO,
656 "Invalid resource descriptor length: Type "
657 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
658 resource_type, resource_length,
659 minimum_resource_length));
660 return (AE_AML_BAD_RESOURCE_LENGTH);
661} 453}
662 454
663/******************************************************************************* 455/*******************************************************************************
664 * 456 *
665 * FUNCTION: acpi_ut_get_resource_type 457 * FUNCTION: acpi_ut_get_resource_type
666 * 458 *
667 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 459 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
668 * 460 *
669 * RETURN: The Resource Type with no extraneous bits (except the 461 * RETURN: The Resource Type with no extraneous bits (except the
670 * Large/Small descriptor bit -- this is left alone) 462 * Large/Small descriptor bit -- this is left alone)
@@ -698,7 +490,7 @@ u8 acpi_ut_get_resource_type(void *aml)
698 * 490 *
699 * FUNCTION: acpi_ut_get_resource_length 491 * FUNCTION: acpi_ut_get_resource_length
700 * 492 *
701 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 493 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
702 * 494 *
703 * RETURN: Byte Length 495 * RETURN: Byte Length
704 * 496 *
@@ -738,7 +530,7 @@ u16 acpi_ut_get_resource_length(void *aml)
738 * 530 *
739 * FUNCTION: acpi_ut_get_resource_header_length 531 * FUNCTION: acpi_ut_get_resource_header_length
740 * 532 *
741 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 533 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
742 * 534 *
743 * RETURN: Length of the AML header (depends on large/small descriptor) 535 * RETURN: Length of the AML header (depends on large/small descriptor)
744 * 536 *
@@ -763,7 +555,7 @@ u8 acpi_ut_get_resource_header_length(void *aml)
763 * 555 *
764 * FUNCTION: acpi_ut_get_descriptor_length 556 * FUNCTION: acpi_ut_get_descriptor_length
765 * 557 *
766 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 558 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
767 * 559 *
768 * RETURN: Byte length 560 * RETURN: Byte length
769 * 561 *
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c
index cee0473ba81..30c21e1a936 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 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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,8 @@ ACPI_MODULE_NAME("utstate")
51 * 51 *
52 * FUNCTION: acpi_ut_create_pkg_state_and_push 52 * FUNCTION: acpi_ut_create_pkg_state_and_push
53 * 53 *
54 * PARAMETERS: object - Object to be added to the new state 54 * PARAMETERS: Object - Object to be added to the new state
55 * action - Increment/Decrement 55 * Action - Increment/Decrement
56 * state_list - List the state will be added to 56 * state_list - List the state will be added to
57 * 57 *
58 * RETURN: Status 58 * RETURN: Status
@@ -85,7 +85,7 @@ acpi_ut_create_pkg_state_and_push(void *internal_object,
85 * FUNCTION: acpi_ut_push_generic_state 85 * FUNCTION: acpi_ut_push_generic_state
86 * 86 *
87 * PARAMETERS: list_head - Head of the state stack 87 * PARAMETERS: list_head - Head of the state stack
88 * state - State object to push 88 * State - State object to push
89 * 89 *
90 * RETURN: None 90 * RETURN: None
91 * 91 *
@@ -147,7 +147,7 @@ union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
147 * 147 *
148 * RETURN: The new state object. NULL on failure. 148 * RETURN: The new state object. NULL on failure.
149 * 149 *
150 * DESCRIPTION: Create a generic state object. Attempt to obtain one from 150 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
151 * the global state cache; If none available, create a new one. 151 * the global state cache; If none available, create a new one.
152 * 152 *
153 ******************************************************************************/ 153 ******************************************************************************/
@@ -214,8 +214,8 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void)
214 * 214 *
215 * FUNCTION: acpi_ut_create_update_state 215 * FUNCTION: acpi_ut_create_update_state
216 * 216 *
217 * PARAMETERS: object - Initial Object to be installed in the state 217 * PARAMETERS: Object - Initial Object to be installed in the state
218 * action - Update action to be performed 218 * Action - Update action to be performed
219 * 219 *
220 * RETURN: New state object, null on failure 220 * RETURN: New state object, null on failure
221 * 221 *
@@ -252,8 +252,8 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
252 * 252 *
253 * FUNCTION: acpi_ut_create_pkg_state 253 * FUNCTION: acpi_ut_create_pkg_state
254 * 254 *
255 * PARAMETERS: object - Initial Object to be installed in the state 255 * PARAMETERS: Object - Initial Object to be installed in the state
256 * action - Update action to be performed 256 * Action - Update action to be performed
257 * 257 *
258 * RETURN: New state object, null on failure 258 * RETURN: New state object, null on failure
259 * 259 *
@@ -325,7 +325,7 @@ union acpi_generic_state *acpi_ut_create_control_state(void)
325 * 325 *
326 * FUNCTION: acpi_ut_delete_generic_state 326 * FUNCTION: acpi_ut_delete_generic_state
327 * 327 *
328 * PARAMETERS: state - The state object to be deleted 328 * PARAMETERS: State - The state object to be deleted
329 * 329 *
330 * RETURN: None 330 * RETURN: None
331 * 331 *
diff --git a/drivers/acpi/acpica/uttrack.c b/drivers/acpi/acpica/uttrack.c
deleted file mode 100644
index a424a9e3fea..00000000000
--- a/drivers/acpi/acpica/uttrack.c
+++ /dev/null
@@ -1,692 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: uttrack - Memory allocation tracking routines (debug only)
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44/*
45 * These procedures are used for tracking memory leaks in the subsystem, and
46 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
47 *
48 * Each memory allocation is tracked via a doubly linked list. Each
49 * element contains the caller's component, module name, function name, and
50 * line number. acpi_ut_allocate and acpi_ut_allocate_zeroed call
51 * acpi_ut_track_allocation to add an element to the list; deletion
52 * occurs in the body of acpi_ut_free.
53 */
54
55#include <acpi/acpi.h>
56#include "accommon.h"
57
58#ifdef ACPI_DBG_TRACK_ALLOCATIONS
59
60#define _COMPONENT ACPI_UTILITIES
61ACPI_MODULE_NAME("uttrack")
62
63/* Local prototypes */
64static struct acpi_debug_mem_block *acpi_ut_find_allocation(struct
65 acpi_debug_mem_block
66 *allocation);
67
68static acpi_status
69acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
70 acpi_size size,
71 u8 alloc_type,
72 u32 component, const char *module, u32 line);
73
74static acpi_status
75acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
76 u32 component, const char *module, u32 line);
77
78/*******************************************************************************
79 *
80 * FUNCTION: acpi_ut_create_list
81 *
82 * PARAMETERS: cache_name - Ascii name for the cache
83 * object_size - Size of each cached object
84 * return_cache - Where the new cache object is returned
85 *
86 * RETURN: Status
87 *
88 * DESCRIPTION: Create a local memory list for tracking purposed
89 *
90 ******************************************************************************/
91
92acpi_status
93acpi_ut_create_list(char *list_name,
94 u16 object_size, struct acpi_memory_list **return_cache)
95{
96 struct acpi_memory_list *cache;
97
98 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
99 if (!cache) {
100 return (AE_NO_MEMORY);
101 }
102
103 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
104
105 cache->list_name = list_name;
106 cache->object_size = object_size;
107
108 *return_cache = cache;
109 return (AE_OK);
110}
111
112/*******************************************************************************
113 *
114 * FUNCTION: acpi_ut_allocate_and_track
115 *
116 * PARAMETERS: size - Size of the allocation
117 * component - Component type of caller
118 * module - Source file name of caller
119 * line - Line number of caller
120 *
121 * RETURN: Address of the allocated memory on success, NULL on failure.
122 *
123 * DESCRIPTION: The subsystem's equivalent of malloc.
124 *
125 ******************************************************************************/
126
127void *acpi_ut_allocate_and_track(acpi_size size,
128 u32 component, const char *module, u32 line)
129{
130 struct acpi_debug_mem_block *allocation;
131 acpi_status status;
132
133 allocation =
134 acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header),
135 component, module, line);
136 if (!allocation) {
137 return (NULL);
138 }
139
140 status = acpi_ut_track_allocation(allocation, size,
141 ACPI_MEM_MALLOC, component, module,
142 line);
143 if (ACPI_FAILURE(status)) {
144 acpi_os_free(allocation);
145 return (NULL);
146 }
147
148 acpi_gbl_global_list->total_allocated++;
149 acpi_gbl_global_list->total_size += (u32)size;
150 acpi_gbl_global_list->current_total_size += (u32)size;
151 if (acpi_gbl_global_list->current_total_size >
152 acpi_gbl_global_list->max_occupied) {
153 acpi_gbl_global_list->max_occupied =
154 acpi_gbl_global_list->current_total_size;
155 }
156
157 return ((void *)&allocation->user_space);
158}
159
160/*******************************************************************************
161 *
162 * FUNCTION: acpi_ut_allocate_zeroed_and_track
163 *
164 * PARAMETERS: size - Size of the allocation
165 * component - Component type of caller
166 * module - Source file name of caller
167 * line - Line number of caller
168 *
169 * RETURN: Address of the allocated memory on success, NULL on failure.
170 *
171 * DESCRIPTION: Subsystem equivalent of calloc.
172 *
173 ******************************************************************************/
174
175void *acpi_ut_allocate_zeroed_and_track(acpi_size size,
176 u32 component,
177 const char *module, u32 line)
178{
179 struct acpi_debug_mem_block *allocation;
180 acpi_status status;
181
182 allocation =
183 acpi_ut_allocate_zeroed(size + sizeof(struct acpi_debug_mem_header),
184 component, module, line);
185 if (!allocation) {
186
187 /* Report allocation error */
188
189 ACPI_ERROR((module, line,
190 "Could not allocate size %u", (u32)size));
191 return (NULL);
192 }
193
194 status = acpi_ut_track_allocation(allocation, size,
195 ACPI_MEM_CALLOC, component, module,
196 line);
197 if (ACPI_FAILURE(status)) {
198 acpi_os_free(allocation);
199 return (NULL);
200 }
201
202 acpi_gbl_global_list->total_allocated++;
203 acpi_gbl_global_list->total_size += (u32)size;
204 acpi_gbl_global_list->current_total_size += (u32)size;
205 if (acpi_gbl_global_list->current_total_size >
206 acpi_gbl_global_list->max_occupied) {
207 acpi_gbl_global_list->max_occupied =
208 acpi_gbl_global_list->current_total_size;
209 }
210
211 return ((void *)&allocation->user_space);
212}
213
214/*******************************************************************************
215 *
216 * FUNCTION: acpi_ut_free_and_track
217 *
218 * PARAMETERS: allocation - Address of the memory to deallocate
219 * component - Component type of caller
220 * module - Source file name of caller
221 * line - Line number of caller
222 *
223 * RETURN: None
224 *
225 * DESCRIPTION: Frees the memory at Allocation
226 *
227 ******************************************************************************/
228
229void
230acpi_ut_free_and_track(void *allocation,
231 u32 component, const char *module, u32 line)
232{
233 struct acpi_debug_mem_block *debug_block;
234 acpi_status status;
235
236 ACPI_FUNCTION_TRACE_PTR(ut_free, allocation);
237
238 if (NULL == allocation) {
239 ACPI_ERROR((module, line, "Attempt to delete a NULL address"));
240
241 return_VOID;
242 }
243
244 debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block,
245 (((char *)allocation) -
246 sizeof(struct acpi_debug_mem_header)));
247
248 acpi_gbl_global_list->total_freed++;
249 acpi_gbl_global_list->current_total_size -= debug_block->size;
250
251 status = acpi_ut_remove_allocation(debug_block,
252 component, module, line);
253 if (ACPI_FAILURE(status)) {
254 ACPI_EXCEPTION((AE_INFO, status, "Could not free memory"));
255 }
256
257 acpi_os_free(debug_block);
258 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
259 return_VOID;
260}
261
262/*******************************************************************************
263 *
264 * FUNCTION: acpi_ut_find_allocation
265 *
266 * PARAMETERS: allocation - Address of allocated memory
267 *
268 * RETURN: Three cases:
269 * 1) List is empty, NULL is returned.
270 * 2) Element was found. Returns Allocation parameter.
271 * 3) Element was not found. Returns position where it should be
272 * inserted into the list.
273 *
274 * DESCRIPTION: Searches for an element in the global allocation tracking list.
275 * If the element is not found, returns the location within the
276 * list where the element should be inserted.
277 *
278 * Note: The list is ordered by larger-to-smaller addresses.
279 *
280 * This global list is used to detect memory leaks in ACPICA as
281 * well as other issues such as an attempt to release the same
282 * internal object more than once. Although expensive as far
283 * as cpu time, this list is much more helpful for finding these
284 * types of issues than using memory leak detectors outside of
285 * the ACPICA code.
286 *
287 ******************************************************************************/
288
289static struct acpi_debug_mem_block *acpi_ut_find_allocation(struct
290 acpi_debug_mem_block
291 *allocation)
292{
293 struct acpi_debug_mem_block *element;
294
295 element = acpi_gbl_global_list->list_head;
296 if (!element) {
297 return (NULL);
298 }
299
300 /*
301 * Search for the address.
302 *
303 * Note: List is ordered by larger-to-smaller addresses, on the
304 * assumption that a new allocation usually has a larger address
305 * than previous allocations.
306 */
307 while (element > allocation) {
308
309 /* Check for end-of-list */
310
311 if (!element->next) {
312 return (element);
313 }
314
315 element = element->next;
316 }
317
318 if (element == allocation) {
319 return (element);
320 }
321
322 return (element->previous);
323}
324
325/*******************************************************************************
326 *
327 * FUNCTION: acpi_ut_track_allocation
328 *
329 * PARAMETERS: allocation - Address of allocated memory
330 * size - Size of the allocation
331 * alloc_type - MEM_MALLOC or MEM_CALLOC
332 * component - Component type of caller
333 * module - Source file name of caller
334 * line - Line number of caller
335 *
336 * RETURN: Status
337 *
338 * DESCRIPTION: Inserts an element into the global allocation tracking list.
339 *
340 ******************************************************************************/
341
342static acpi_status
343acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
344 acpi_size size,
345 u8 alloc_type,
346 u32 component, const char *module, u32 line)
347{
348 struct acpi_memory_list *mem_list;
349 struct acpi_debug_mem_block *element;
350 acpi_status status = AE_OK;
351
352 ACPI_FUNCTION_TRACE_PTR(ut_track_allocation, allocation);
353
354 if (acpi_gbl_disable_mem_tracking) {
355 return_ACPI_STATUS(AE_OK);
356 }
357
358 mem_list = acpi_gbl_global_list;
359 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
360 if (ACPI_FAILURE(status)) {
361 return_ACPI_STATUS(status);
362 }
363
364 /*
365 * Search the global list for this address to make sure it is not
366 * already present. This will catch several kinds of problems.
367 */
368 element = acpi_ut_find_allocation(allocation);
369 if (element == allocation) {
370 ACPI_ERROR((AE_INFO,
371 "UtTrackAllocation: Allocation (%p) already present in global list!",
372 allocation));
373 goto unlock_and_exit;
374 }
375
376 /* Fill in the instance data */
377
378 allocation->size = (u32)size;
379 allocation->alloc_type = alloc_type;
380 allocation->component = component;
381 allocation->line = line;
382
383 ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME);
384 allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0;
385
386 if (!element) {
387
388 /* Insert at list head */
389
390 if (mem_list->list_head) {
391 ((struct acpi_debug_mem_block *)(mem_list->list_head))->
392 previous = allocation;
393 }
394
395 allocation->next = mem_list->list_head;
396 allocation->previous = NULL;
397
398 mem_list->list_head = allocation;
399 } else {
400 /* Insert after element */
401
402 allocation->next = element->next;
403 allocation->previous = element;
404
405 if (element->next) {
406 (element->next)->previous = allocation;
407 }
408
409 element->next = allocation;
410 }
411
412 unlock_and_exit:
413 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
414 return_ACPI_STATUS(status);
415}
416
417/*******************************************************************************
418 *
419 * FUNCTION: acpi_ut_remove_allocation
420 *
421 * PARAMETERS: allocation - Address of allocated memory
422 * component - Component type of caller
423 * module - Source file name of caller
424 * line - Line number of caller
425 *
426 * RETURN: Status
427 *
428 * DESCRIPTION: Deletes an element from the global allocation tracking list.
429 *
430 ******************************************************************************/
431
432static acpi_status
433acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
434 u32 component, const char *module, u32 line)
435{
436 struct acpi_memory_list *mem_list;
437 acpi_status status;
438
439 ACPI_FUNCTION_TRACE(ut_remove_allocation);
440
441 if (acpi_gbl_disable_mem_tracking) {
442 return_ACPI_STATUS(AE_OK);
443 }
444
445 mem_list = acpi_gbl_global_list;
446 if (NULL == mem_list->list_head) {
447
448 /* No allocations! */
449
450 ACPI_ERROR((module, line,
451 "Empty allocation list, nothing to free!"));
452
453 return_ACPI_STATUS(AE_OK);
454 }
455
456 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
457 if (ACPI_FAILURE(status)) {
458 return_ACPI_STATUS(status);
459 }
460
461 /* Unlink */
462
463 if (allocation->previous) {
464 (allocation->previous)->next = allocation->next;
465 } else {
466 mem_list->list_head = allocation->next;
467 }
468
469 if (allocation->next) {
470 (allocation->next)->previous = allocation->previous;
471 }
472
473 /* Mark the segment as deleted */
474
475 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
476
477 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
478 allocation->size));
479
480 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
481 return_ACPI_STATUS(status);
482}
483
484/*******************************************************************************
485 *
486 * FUNCTION: acpi_ut_dump_allocation_info
487 *
488 * PARAMETERS: None
489 *
490 * RETURN: None
491 *
492 * DESCRIPTION: Print some info about the outstanding allocations.
493 *
494 ******************************************************************************/
495
496void acpi_ut_dump_allocation_info(void)
497{
498/*
499 struct acpi_memory_list *mem_list;
500*/
501
502 ACPI_FUNCTION_TRACE(ut_dump_allocation_info);
503
504/*
505 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
506 ("%30s: %4d (%3d Kb)\n", "Current allocations",
507 mem_list->current_count,
508 ROUND_UP_TO_1K (mem_list->current_size)));
509
510 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
511 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
512 mem_list->max_concurrent_count,
513 ROUND_UP_TO_1K (mem_list->max_concurrent_size)));
514
515 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
516 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
517 running_object_count,
518 ROUND_UP_TO_1K (running_object_size)));
519
520 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
521 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
522 running_alloc_count,
523 ROUND_UP_TO_1K (running_alloc_size)));
524
525 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
526 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
527 acpi_gbl_current_node_count,
528 ROUND_UP_TO_1K (acpi_gbl_current_node_size)));
529
530 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
531 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
532 acpi_gbl_max_concurrent_node_count,
533 ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count *
534 sizeof (struct acpi_namespace_node)))));
535*/
536 return_VOID;
537}
538
539/*******************************************************************************
540 *
541 * FUNCTION: acpi_ut_dump_allocations
542 *
543 * PARAMETERS: component - Component(s) to dump info for.
544 * module - Module to dump info for. NULL means all.
545 *
546 * RETURN: None
547 *
548 * DESCRIPTION: Print a list of all outstanding allocations.
549 *
550 ******************************************************************************/
551
552void acpi_ut_dump_allocations(u32 component, const char *module)
553{
554 struct acpi_debug_mem_block *element;
555 union acpi_descriptor *descriptor;
556 u32 num_outstanding = 0;
557 u8 descriptor_type;
558
559 ACPI_FUNCTION_TRACE(ut_dump_allocations);
560
561 if (acpi_gbl_disable_mem_tracking) {
562 return_VOID;
563 }
564
565 /*
566 * Walk the allocation list.
567 */
568 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) {
569 return_VOID;
570 }
571
572 element = acpi_gbl_global_list->list_head;
573 while (element) {
574 if ((element->component & component) &&
575 ((module == NULL)
576 || (0 == ACPI_STRCMP(module, element->module)))) {
577 descriptor =
578 ACPI_CAST_PTR(union acpi_descriptor,
579 &element->user_space);
580
581 if (element->size <
582 sizeof(struct acpi_common_descriptor)) {
583 acpi_os_printf("%p Length 0x%04X %9.9s-%u "
584 "[Not a Descriptor - too small]\n",
585 descriptor, element->size,
586 element->module, element->line);
587 } else {
588 /* Ignore allocated objects that are in a cache */
589
590 if (ACPI_GET_DESCRIPTOR_TYPE(descriptor) !=
591 ACPI_DESC_TYPE_CACHED) {
592 acpi_os_printf
593 ("%p Length 0x%04X %9.9s-%u [%s] ",
594 descriptor, element->size,
595 element->module, element->line,
596 acpi_ut_get_descriptor_name
597 (descriptor));
598
599 /* Validate the descriptor type using Type field and length */
600
601 descriptor_type = 0; /* Not a valid descriptor type */
602
603 switch (ACPI_GET_DESCRIPTOR_TYPE
604 (descriptor)) {
605 case ACPI_DESC_TYPE_OPERAND:
606 if (element->size ==
607 sizeof(union
608 acpi_operand_object))
609 {
610 descriptor_type =
611 ACPI_DESC_TYPE_OPERAND;
612 }
613 break;
614
615 case ACPI_DESC_TYPE_PARSER:
616 if (element->size ==
617 sizeof(union
618 acpi_parse_object)) {
619 descriptor_type =
620 ACPI_DESC_TYPE_PARSER;
621 }
622 break;
623
624 case ACPI_DESC_TYPE_NAMED:
625 if (element->size ==
626 sizeof(struct
627 acpi_namespace_node))
628 {
629 descriptor_type =
630 ACPI_DESC_TYPE_NAMED;
631 }
632 break;
633
634 default:
635 break;
636 }
637
638 /* Display additional info for the major descriptor types */
639
640 switch (descriptor_type) {
641 case ACPI_DESC_TYPE_OPERAND:
642 acpi_os_printf
643 ("%12.12s RefCount 0x%04X\n",
644 acpi_ut_get_type_name
645 (descriptor->object.common.
646 type),
647 descriptor->object.common.
648 reference_count);
649 break;
650
651 case ACPI_DESC_TYPE_PARSER:
652 acpi_os_printf
653 ("AmlOpcode 0x%04hX\n",
654 descriptor->op.asl.
655 aml_opcode);
656 break;
657
658 case ACPI_DESC_TYPE_NAMED:
659 acpi_os_printf("%4.4s\n",
660 acpi_ut_get_node_name
661 (&descriptor->
662 node));
663 break;
664
665 default:
666 acpi_os_printf("\n");
667 break;
668 }
669 }
670 }
671
672 num_outstanding++;
673 }
674
675 element = element->next;
676 }
677
678 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY);
679
680 /* Print summary */
681
682 if (!num_outstanding) {
683 ACPI_INFO((AE_INFO, "No outstanding allocations"));
684 } else {
685 ACPI_ERROR((AE_INFO, "%u(0x%X) Outstanding allocations",
686 num_outstanding, num_outstanding));
687 }
688
689 return_VOID;
690}
691
692#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 390db0ca5e2..98ad125e14f 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -1,11 +1,11 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: utxface - External interfaces, miscellaneous utility functions 3 * Module Name: utxface - External interfaces for "global" ACPI functions
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,18 +41,277 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include "accommon.h" 45#include "accommon.h"
47#include "acevents.h" 46#include "acevents.h"
48#include "acnamesp.h" 47#include "acnamesp.h"
49#include "acdebug.h" 48#include "acdebug.h"
50#include "actables.h" 49#include "actables.h"
51#include "acinterp.h"
52 50
53#define _COMPONENT ACPI_UTILITIES 51#define _COMPONENT ACPI_UTILITIES
54ACPI_MODULE_NAME("utxface") 52ACPI_MODULE_NAME("utxface")
55 53
54#ifndef ACPI_ASL_COMPILER
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_initialize_subsystem
58 *
59 * PARAMETERS: None
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Initializes all global variables. This is the first function
64 * called, so any early initialization belongs here.
65 *
66 ******************************************************************************/
67acpi_status __init acpi_initialize_subsystem(void)
68{
69 acpi_status status;
70
71 ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
72
73 acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
74 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
75
76 /* Initialize the OS-Dependent layer */
77
78 status = acpi_os_initialize();
79 if (ACPI_FAILURE(status)) {
80 ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
81 return_ACPI_STATUS(status);
82 }
83
84 /* Initialize all globals used by the subsystem */
85
86 status = acpi_ut_init_globals();
87 if (ACPI_FAILURE(status)) {
88 ACPI_EXCEPTION((AE_INFO, status,
89 "During initialization of globals"));
90 return_ACPI_STATUS(status);
91 }
92
93 /* Create the default mutex objects */
94
95 status = acpi_ut_mutex_initialize();
96 if (ACPI_FAILURE(status)) {
97 ACPI_EXCEPTION((AE_INFO, status,
98 "During Global Mutex creation"));
99 return_ACPI_STATUS(status);
100 }
101
102 /*
103 * Initialize the namespace manager and
104 * the root of the namespace tree
105 */
106 status = acpi_ns_root_initialize();
107 if (ACPI_FAILURE(status)) {
108 ACPI_EXCEPTION((AE_INFO, status,
109 "During Namespace initialization"));
110 return_ACPI_STATUS(status);
111 }
112
113 /* Initialize the global OSI interfaces list with the static names */
114
115 status = acpi_ut_initialize_interfaces();
116 if (ACPI_FAILURE(status)) {
117 ACPI_EXCEPTION((AE_INFO, status,
118 "During OSI interfaces initialization"));
119 return_ACPI_STATUS(status);
120 }
121
122 /* If configured, initialize the AML debugger */
123
124 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
125 return_ACPI_STATUS(status);
126}
127
128/*******************************************************************************
129 *
130 * FUNCTION: acpi_enable_subsystem
131 *
132 * PARAMETERS: Flags - Init/enable Options
133 *
134 * RETURN: Status
135 *
136 * DESCRIPTION: Completes the subsystem initialization including hardware.
137 * Puts system into ACPI mode if it isn't already.
138 *
139 ******************************************************************************/
140acpi_status acpi_enable_subsystem(u32 flags)
141{
142 acpi_status status = AE_OK;
143
144 ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
145
146 /* Enable ACPI mode */
147
148 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
149 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
150 "[Init] Going into ACPI mode\n"));
151
152 acpi_gbl_original_mode = acpi_hw_get_mode();
153
154 status = acpi_enable();
155 if (ACPI_FAILURE(status)) {
156 ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
157 return_ACPI_STATUS(status);
158 }
159 }
160
161 /*
162 * Obtain a permanent mapping for the FACS. This is required for the
163 * Global Lock and the Firmware Waking Vector
164 */
165 status = acpi_tb_initialize_facs();
166 if (ACPI_FAILURE(status)) {
167 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
168 return_ACPI_STATUS(status);
169 }
170
171 /*
172 * Install the default op_region handlers. These are installed unless
173 * other handlers have already been installed via the
174 * install_address_space_handler interface.
175 */
176 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
177 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
178 "[Init] Installing default address space handlers\n"));
179
180 status = acpi_ev_install_region_handlers();
181 if (ACPI_FAILURE(status)) {
182 return_ACPI_STATUS(status);
183 }
184 }
185
186 /*
187 * Initialize ACPI Event handling (Fixed and General Purpose)
188 *
189 * Note1: We must have the hardware and events initialized before we can
190 * execute any control methods safely. Any control method can require
191 * ACPI hardware support, so the hardware must be fully initialized before
192 * any method execution!
193 *
194 * Note2: Fixed events are initialized and enabled here. GPEs are
195 * initialized, but cannot be enabled until after the hardware is
196 * completely initialized (SCI and global_lock activated)
197 */
198 if (!(flags & ACPI_NO_EVENT_INIT)) {
199 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
200 "[Init] Initializing ACPI events\n"));
201
202 status = acpi_ev_initialize_events();
203 if (ACPI_FAILURE(status)) {
204 return_ACPI_STATUS(status);
205 }
206 }
207
208 /*
209 * Install the SCI handler and Global Lock handler. This completes the
210 * hardware initialization.
211 */
212 if (!(flags & ACPI_NO_HANDLER_INIT)) {
213 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
214 "[Init] Installing SCI/GL handlers\n"));
215
216 status = acpi_ev_install_xrupt_handlers();
217 if (ACPI_FAILURE(status)) {
218 return_ACPI_STATUS(status);
219 }
220 }
221
222 return_ACPI_STATUS(status);
223}
224
225ACPI_EXPORT_SYMBOL(acpi_enable_subsystem)
226
227/*******************************************************************************
228 *
229 * FUNCTION: acpi_initialize_objects
230 *
231 * PARAMETERS: Flags - Init/enable Options
232 *
233 * RETURN: Status
234 *
235 * DESCRIPTION: Completes namespace initialization by initializing device
236 * objects and executing AML code for Regions, buffers, etc.
237 *
238 ******************************************************************************/
239acpi_status acpi_initialize_objects(u32 flags)
240{
241 acpi_status status = AE_OK;
242
243 ACPI_FUNCTION_TRACE(acpi_initialize_objects);
244
245 /*
246 * Run all _REG methods
247 *
248 * Note: Any objects accessed by the _REG methods will be automatically
249 * initialized, even if they contain executable AML (see the call to
250 * acpi_ns_initialize_objects below).
251 */
252 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
253 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
254 "[Init] Executing _REG OpRegion methods\n"));
255
256 status = acpi_ev_initialize_op_regions();
257 if (ACPI_FAILURE(status)) {
258 return_ACPI_STATUS(status);
259 }
260 }
261
262 /*
263 * Execute any module-level code that was detected during the table load
264 * phase. Although illegal since ACPI 2.0, there are many machines that
265 * contain this type of code. Each block of detected executable AML code
266 * outside of any control method is wrapped with a temporary control
267 * method object and placed on a global list. The methods on this list
268 * are executed below.
269 */
270 acpi_ns_exec_module_code_list();
271
272 /*
273 * Initialize the objects that remain uninitialized. This runs the
274 * executable AML that may be part of the declaration of these objects:
275 * operation_regions, buffer_fields, Buffers, and Packages.
276 */
277 if (!(flags & ACPI_NO_OBJECT_INIT)) {
278 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
279 "[Init] Completing Initialization of ACPI Objects\n"));
280
281 status = acpi_ns_initialize_objects();
282 if (ACPI_FAILURE(status)) {
283 return_ACPI_STATUS(status);
284 }
285 }
286
287 /*
288 * Initialize all device objects in the namespace. This runs the device
289 * _STA and _INI methods.
290 */
291 if (!(flags & ACPI_NO_DEVICE_INIT)) {
292 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
293 "[Init] Initializing ACPI Devices\n"));
294
295 status = acpi_ns_initialize_devices();
296 if (ACPI_FAILURE(status)) {
297 return_ACPI_STATUS(status);
298 }
299 }
300
301 /*
302 * Empty the caches (delete the cached objects) on the assumption that
303 * the table load filled them up more than they will be at runtime --
304 * thus wasting non-paged memory.
305 */
306 status = acpi_purge_cached_objects();
307
308 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
309 return_ACPI_STATUS(status);
310}
311
312ACPI_EXPORT_SYMBOL(acpi_initialize_objects)
313
314#endif
56/******************************************************************************* 315/*******************************************************************************
57 * 316 *
58 * FUNCTION: acpi_terminate 317 * FUNCTION: acpi_terminate
@@ -144,10 +403,10 @@ ACPI_EXPORT_SYMBOL(acpi_subsystem_status)
144 * PARAMETERS: out_buffer - A buffer to receive the resources for the 403 * PARAMETERS: out_buffer - A buffer to receive the resources for the
145 * device 404 * device
146 * 405 *
147 * RETURN: status - the status of the call 406 * RETURN: Status - the status of the call
148 * 407 *
149 * DESCRIPTION: This function is called to get information about the current 408 * DESCRIPTION: This function is called to get information about the current
150 * state of the ACPI subsystem. It will return system information 409 * state of the ACPI subsystem. It will return system information
151 * in the out_buffer. 410 * in the out_buffer.
152 * 411 *
153 * If the function fails an appropriate status will be returned 412 * If the function fails an appropriate status will be returned
@@ -215,8 +474,8 @@ ACPI_EXPORT_SYMBOL(acpi_get_system_info)
215 * 474 *
216 * FUNCTION: acpi_install_initialization_handler 475 * FUNCTION: acpi_install_initialization_handler
217 * 476 *
218 * PARAMETERS: handler - Callback procedure 477 * PARAMETERS: Handler - Callback procedure
219 * function - Not (currently) used, see below 478 * Function - Not (currently) used, see below
220 * 479 *
221 * RETURN: Status 480 * RETURN: Status
222 * 481 *
@@ -238,7 +497,7 @@ acpi_install_initialization_handler(acpi_init_handler handler, u32 function)
238 } 497 }
239 498
240 acpi_gbl_init_handler = handler; 499 acpi_gbl_init_handler = handler;
241 return (AE_OK); 500 return AE_OK;
242} 501}
243 502
244ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler) 503ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler)
@@ -263,7 +522,6 @@ acpi_status acpi_purge_cached_objects(void)
263 (void)acpi_os_purge_cache(acpi_gbl_operand_cache); 522 (void)acpi_os_purge_cache(acpi_gbl_operand_cache);
264 (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache); 523 (void)acpi_os_purge_cache(acpi_gbl_ps_node_cache);
265 (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache); 524 (void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache);
266
267 return_ACPI_STATUS(AE_OK); 525 return_ACPI_STATUS(AE_OK);
268} 526}
269 527
@@ -354,7 +612,7 @@ ACPI_EXPORT_SYMBOL(acpi_remove_interface)
354 * 612 *
355 * FUNCTION: acpi_install_interface_handler 613 * FUNCTION: acpi_install_interface_handler
356 * 614 *
357 * PARAMETERS: handler - The _OSI interface handler to install 615 * PARAMETERS: Handler - The _OSI interface handler to install
358 * NULL means "remove existing handler" 616 * NULL means "remove existing handler"
359 * 617 *
360 * RETURN: Status 618 * RETURN: Status
@@ -381,128 +639,4 @@ acpi_status acpi_install_interface_handler(acpi_interface_handler handler)
381} 639}
382 640
383ACPI_EXPORT_SYMBOL(acpi_install_interface_handler) 641ACPI_EXPORT_SYMBOL(acpi_install_interface_handler)
384
385/*****************************************************************************
386 *
387 * FUNCTION: acpi_check_address_range
388 *
389 * PARAMETERS: space_id - Address space ID
390 * address - Start address
391 * length - Length
392 * warn - TRUE if warning on overlap desired
393 *
394 * RETURN: Count of the number of conflicts detected.
395 *
396 * DESCRIPTION: Check if the input address range overlaps any of the
397 * ASL operation region address ranges.
398 *
399 ****************************************************************************/
400u32
401acpi_check_address_range(acpi_adr_space_type space_id,
402 acpi_physical_address address,
403 acpi_size length, u8 warn)
404{
405 u32 overlaps;
406 acpi_status status;
407
408 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
409 if (ACPI_FAILURE(status)) {
410 return (0);
411 }
412
413 overlaps = acpi_ut_check_address_range(space_id, address,
414 (u32)length, warn);
415
416 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
417 return (overlaps);
418}
419
420ACPI_EXPORT_SYMBOL(acpi_check_address_range)
421#endif /* !ACPI_ASL_COMPILER */ 642#endif /* !ACPI_ASL_COMPILER */
422/*******************************************************************************
423 *
424 * FUNCTION: acpi_decode_pld_buffer
425 *
426 * PARAMETERS: in_buffer - Buffer returned by _PLD method
427 * length - Length of the in_buffer
428 * return_buffer - Where the decode buffer is returned
429 *
430 * RETURN: Status and the decoded _PLD buffer. User must deallocate
431 * the buffer via ACPI_FREE.
432 *
433 * DESCRIPTION: Decode the bit-packed buffer returned by the _PLD method into
434 * a local struct that is much more useful to an ACPI driver.
435 *
436 ******************************************************************************/
437acpi_status
438acpi_decode_pld_buffer(u8 *in_buffer,
439 acpi_size length, struct acpi_pld_info ** return_buffer)
440{
441 struct acpi_pld_info *pld_info;
442 u32 *buffer = ACPI_CAST_PTR(u32, in_buffer);
443 u32 dword;
444
445 /* Parameter validation */
446
447 if (!in_buffer || !return_buffer || (length < 16)) {
448 return (AE_BAD_PARAMETER);
449 }
450
451 pld_info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pld_info));
452 if (!pld_info) {
453 return (AE_NO_MEMORY);
454 }
455
456 /* First 32-bit DWord */
457
458 ACPI_MOVE_32_TO_32(&dword, &buffer[0]);
459 pld_info->revision = ACPI_PLD_GET_REVISION(&dword);
460 pld_info->ignore_color = ACPI_PLD_GET_IGNORE_COLOR(&dword);
461 pld_info->color = ACPI_PLD_GET_COLOR(&dword);
462
463 /* Second 32-bit DWord */
464
465 ACPI_MOVE_32_TO_32(&dword, &buffer[1]);
466 pld_info->width = ACPI_PLD_GET_WIDTH(&dword);
467 pld_info->height = ACPI_PLD_GET_HEIGHT(&dword);
468
469 /* Third 32-bit DWord */
470
471 ACPI_MOVE_32_TO_32(&dword, &buffer[2]);
472 pld_info->user_visible = ACPI_PLD_GET_USER_VISIBLE(&dword);
473 pld_info->dock = ACPI_PLD_GET_DOCK(&dword);
474 pld_info->lid = ACPI_PLD_GET_LID(&dword);
475 pld_info->panel = ACPI_PLD_GET_PANEL(&dword);
476 pld_info->vertical_position = ACPI_PLD_GET_VERTICAL(&dword);
477 pld_info->horizontal_position = ACPI_PLD_GET_HORIZONTAL(&dword);
478 pld_info->shape = ACPI_PLD_GET_SHAPE(&dword);
479 pld_info->group_orientation = ACPI_PLD_GET_ORIENTATION(&dword);
480 pld_info->group_token = ACPI_PLD_GET_TOKEN(&dword);
481 pld_info->group_position = ACPI_PLD_GET_POSITION(&dword);
482 pld_info->bay = ACPI_PLD_GET_BAY(&dword);
483
484 /* Fourth 32-bit DWord */
485
486 ACPI_MOVE_32_TO_32(&dword, &buffer[3]);
487 pld_info->ejectable = ACPI_PLD_GET_EJECTABLE(&dword);
488 pld_info->ospm_eject_required = ACPI_PLD_GET_OSPM_EJECT(&dword);
489 pld_info->cabinet_number = ACPI_PLD_GET_CABINET(&dword);
490 pld_info->card_cage_number = ACPI_PLD_GET_CARD_CAGE(&dword);
491 pld_info->reference = ACPI_PLD_GET_REFERENCE(&dword);
492 pld_info->rotation = ACPI_PLD_GET_ROTATION(&dword);
493 pld_info->order = ACPI_PLD_GET_ORDER(&dword);
494
495 if (length >= ACPI_PLD_BUFFER_SIZE) {
496
497 /* Fifth 32-bit DWord (Revision 2 of _PLD) */
498
499 ACPI_MOVE_32_TO_32(&dword, &buffer[4]);
500 pld_info->vertical_offset = ACPI_PLD_GET_VERT_OFFSET(&dword);
501 pld_info->horizontal_offset = ACPI_PLD_GET_HORIZ_OFFSET(&dword);
502 }
503
504 *return_buffer = pld_info;
505 return (AE_OK);
506}
507
508ACPI_EXPORT_SYMBOL(acpi_decode_pld_buffer)
diff --git a/drivers/acpi/acpica/utxferror.c b/drivers/acpi/acpica/utxferror.c
index d4d3826140d..916ae097c43 100644
--- a/drivers/acpi/acpica/utxferror.c
+++ b/drivers/acpi/acpica/utxferror.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, 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
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include "accommon.h" 45#include "accommon.h"
47#include "acnamesp.h" 46#include "acnamesp.h"
@@ -53,7 +52,7 @@ ACPI_MODULE_NAME("utxferror")
53 * This module is used for the in-kernel ACPICA as well as the ACPICA 52 * This module is used for the in-kernel ACPICA as well as the ACPICA
54 * tools/applications. 53 * tools/applications.
55 * 54 *
56 * For the iASL compiler case, the output is redirected to stderr so that 55 * For the i_aSL compiler case, the output is redirected to stderr so that
57 * any of the various ACPI errors and warnings do not appear in the output 56 * any of the various ACPI errors and warnings do not appear in the output
58 * files, for either the compiler or disassembler portions of the tool. 57 * files, for either the compiler or disassembler portions of the tool.
59 */ 58 */
@@ -70,7 +69,7 @@ extern FILE *acpi_gbl_output_file;
70 69
71#else 70#else
72/* 71/*
73 * non-iASL case - no redirection, nothing to do 72 * non-i_aSL case - no redirection, nothing to do
74 */ 73 */
75#define ACPI_MSG_REDIRECT_BEGIN 74#define ACPI_MSG_REDIRECT_BEGIN
76#define ACPI_MSG_REDIRECT_END 75#define ACPI_MSG_REDIRECT_END
@@ -82,8 +81,6 @@ extern FILE *acpi_gbl_output_file;
82#define ACPI_MSG_EXCEPTION "ACPI Exception: " 81#define ACPI_MSG_EXCEPTION "ACPI Exception: "
83#define ACPI_MSG_WARNING "ACPI Warning: " 82#define ACPI_MSG_WARNING "ACPI Warning: "
84#define ACPI_MSG_INFO "ACPI: " 83#define ACPI_MSG_INFO "ACPI: "
85#define ACPI_MSG_BIOS_ERROR "ACPI BIOS Bug: Error: "
86#define ACPI_MSG_BIOS_WARNING "ACPI BIOS Bug: Warning: "
87/* 84/*
88 * Common message suffix 85 * Common message suffix
89 */ 86 */
@@ -95,7 +92,7 @@ extern FILE *acpi_gbl_output_file;
95 * 92 *
96 * PARAMETERS: module_name - Caller's module name (for error output) 93 * PARAMETERS: module_name - Caller's module name (for error output)
97 * line_number - Caller's line number (for error output) 94 * line_number - Caller's line number (for error output)
98 * format - Printf format string + additional args 95 * Format - Printf format string + additional args
99 * 96 *
100 * RETURN: None 97 * RETURN: None
101 * 98 *
@@ -126,8 +123,8 @@ ACPI_EXPORT_SYMBOL(acpi_error)
126 * 123 *
127 * PARAMETERS: module_name - Caller's module name (for error output) 124 * PARAMETERS: module_name - Caller's module name (for error output)
128 * line_number - Caller's line number (for error output) 125 * line_number - Caller's line number (for error output)
129 * status - Status to be formatted 126 * Status - Status to be formatted
130 * format - Printf format string + additional args 127 * Format - Printf format string + additional args
131 * 128 *
132 * RETURN: None 129 * RETURN: None
133 * 130 *
@@ -161,7 +158,7 @@ ACPI_EXPORT_SYMBOL(acpi_exception)
161 * 158 *
162 * PARAMETERS: module_name - Caller's module name (for error output) 159 * PARAMETERS: module_name - Caller's module name (for error output)
163 * line_number - Caller's line number (for error output) 160 * line_number - Caller's line number (for error output)
164 * format - Printf format string + additional args 161 * Format - Printf format string + additional args
165 * 162 *
166 * RETURN: None 163 * RETURN: None
167 * 164 *
@@ -192,7 +189,7 @@ ACPI_EXPORT_SYMBOL(acpi_warning)
192 * 189 *
193 * PARAMETERS: module_name - Caller's module name (for error output) 190 * PARAMETERS: module_name - Caller's module name (for error output)
194 * line_number - Caller's line number (for error output) 191 * line_number - Caller's line number (for error output)
195 * format - Printf format string + additional args 192 * Format - Printf format string + additional args
196 * 193 *
197 * RETURN: None 194 * RETURN: None
198 * 195 *
@@ -220,72 +217,6 @@ acpi_info(const char *module_name, u32 line_number, const char *format, ...)
220 217
221ACPI_EXPORT_SYMBOL(acpi_info) 218ACPI_EXPORT_SYMBOL(acpi_info)
222 219
223/*******************************************************************************
224 *
225 * FUNCTION: acpi_bios_error
226 *
227 * PARAMETERS: module_name - Caller's module name (for error output)
228 * line_number - Caller's line number (for error output)
229 * format - Printf format string + additional args
230 *
231 * RETURN: None
232 *
233 * DESCRIPTION: Print "ACPI Firmware Error" message with module/line/version
234 * info
235 *
236 ******************************************************************************/
237void ACPI_INTERNAL_VAR_XFACE
238acpi_bios_error(const char *module_name,
239 u32 line_number, const char *format, ...)
240{
241 va_list arg_list;
242
243 ACPI_MSG_REDIRECT_BEGIN;
244 acpi_os_printf(ACPI_MSG_BIOS_ERROR);
245
246 va_start(arg_list, format);
247 acpi_os_vprintf(format, arg_list);
248 ACPI_MSG_SUFFIX;
249 va_end(arg_list);
250
251 ACPI_MSG_REDIRECT_END;
252}
253
254ACPI_EXPORT_SYMBOL(acpi_bios_error)
255
256/*******************************************************************************
257 *
258 * FUNCTION: acpi_bios_warning
259 *
260 * PARAMETERS: module_name - Caller's module name (for error output)
261 * line_number - Caller's line number (for error output)
262 * format - Printf format string + additional args
263 *
264 * RETURN: None
265 *
266 * DESCRIPTION: Print "ACPI Firmware Warning" message with module/line/version
267 * info
268 *
269 ******************************************************************************/
270void ACPI_INTERNAL_VAR_XFACE
271acpi_bios_warning(const char *module_name,
272 u32 line_number, const char *format, ...)
273{
274 va_list arg_list;
275
276 ACPI_MSG_REDIRECT_BEGIN;
277 acpi_os_printf(ACPI_MSG_BIOS_WARNING);
278
279 va_start(arg_list, format);
280 acpi_os_vprintf(format, arg_list);
281 ACPI_MSG_SUFFIX;
282 va_end(arg_list);
283
284 ACPI_MSG_REDIRECT_END;
285}
286
287ACPI_EXPORT_SYMBOL(acpi_bios_warning)
288
289/* 220/*
290 * The remainder of this module contains internal error functions that may 221 * The remainder of this module contains internal error functions that may
291 * be configured out. 222 * be configured out.
@@ -339,9 +270,9 @@ acpi_ut_predefined_warning(const char *module_name,
339 * 270 *
340 * PARAMETERS: module_name - Caller's module name (for error output) 271 * PARAMETERS: module_name - Caller's module name (for error output)
341 * line_number - Caller's line number (for error output) 272 * line_number - Caller's line number (for error output)
342 * pathname - Full pathname to the node 273 * Pathname - Full pathname to the node
343 * node_flags - From Namespace node for the method/object 274 * node_flags - From Namespace node for the method/object
344 * format - Printf format string + additional args 275 * Format - Printf format string + additional args
345 * 276 *
346 * RETURN: None 277 * RETURN: None
347 * 278 *
@@ -408,7 +339,7 @@ acpi_ut_namespace_error(const char *module_name,
408 339
409 ACPI_MOVE_32_TO_32(&bad_name, 340 ACPI_MOVE_32_TO_32(&bad_name,
410 ACPI_CAST_PTR(u32, internal_name)); 341 ACPI_CAST_PTR(u32, internal_name));
411 acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name); 342 acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name);
412 } else { 343 } else {
413 /* Convert path to external format */ 344 /* Convert path to external format */
414 345
@@ -441,9 +372,9 @@ acpi_ut_namespace_error(const char *module_name,
441 * 372 *
442 * PARAMETERS: module_name - Caller's module name (for error output) 373 * PARAMETERS: module_name - Caller's module name (for error output)
443 * line_number - Caller's line number (for error output) 374 * line_number - Caller's line number (for error output)
444 * message - Error message to use on failure 375 * Message - Error message to use on failure
445 * prefix_node - Prefix relative to the path 376 * prefix_node - Prefix relative to the path
446 * path - Path to the node (optional) 377 * Path - Path to the node (optional)
447 * method_status - Execution status 378 * method_status - Execution status
448 * 379 *
449 * RETURN: None 380 * RETURN: None
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
deleted file mode 100644
index 14f523627a5..00000000000
--- a/drivers/acpi/acpica/utxfinit.c
+++ /dev/null
@@ -1,317 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utxfinit - External interfaces for ACPICA initialization
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <linux/export.h>
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "acevents.h"
48#include "acnamesp.h"
49#include "acdebug.h"
50#include "actables.h"
51
52#define _COMPONENT ACPI_UTILITIES
53ACPI_MODULE_NAME("utxfinit")
54
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_initialize_subsystem
58 *
59 * PARAMETERS: None
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Initializes all global variables. This is the first function
64 * called, so any early initialization belongs here.
65 *
66 ******************************************************************************/
67acpi_status acpi_initialize_subsystem(void)
68{
69 acpi_status status;
70
71 ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
72
73 acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
74 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
75
76 /* Initialize the OS-Dependent layer */
77
78 status = acpi_os_initialize();
79 if (ACPI_FAILURE(status)) {
80 ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
81 return_ACPI_STATUS(status);
82 }
83
84 /* Initialize all globals used by the subsystem */
85
86 status = acpi_ut_init_globals();
87 if (ACPI_FAILURE(status)) {
88 ACPI_EXCEPTION((AE_INFO, status,
89 "During initialization of globals"));
90 return_ACPI_STATUS(status);
91 }
92
93 /* Create the default mutex objects */
94
95 status = acpi_ut_mutex_initialize();
96 if (ACPI_FAILURE(status)) {
97 ACPI_EXCEPTION((AE_INFO, status,
98 "During Global Mutex creation"));
99 return_ACPI_STATUS(status);
100 }
101
102 /*
103 * Initialize the namespace manager and
104 * the root of the namespace tree
105 */
106 status = acpi_ns_root_initialize();
107 if (ACPI_FAILURE(status)) {
108 ACPI_EXCEPTION((AE_INFO, status,
109 "During Namespace initialization"));
110 return_ACPI_STATUS(status);
111 }
112
113 /* Initialize the global OSI interfaces list with the static names */
114
115 status = acpi_ut_initialize_interfaces();
116 if (ACPI_FAILURE(status)) {
117 ACPI_EXCEPTION((AE_INFO, status,
118 "During OSI interfaces initialization"));
119 return_ACPI_STATUS(status);
120 }
121
122 /* If configured, initialize the AML debugger */
123
124 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
125 return_ACPI_STATUS(status);
126}
127ACPI_EXPORT_SYMBOL(acpi_initialize_subsystem)
128
129/*******************************************************************************
130 *
131 * FUNCTION: acpi_enable_subsystem
132 *
133 * PARAMETERS: flags - Init/enable Options
134 *
135 * RETURN: Status
136 *
137 * DESCRIPTION: Completes the subsystem initialization including hardware.
138 * Puts system into ACPI mode if it isn't already.
139 *
140 ******************************************************************************/
141acpi_status acpi_enable_subsystem(u32 flags)
142{
143 acpi_status status = AE_OK;
144
145 ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
146
147#if (!ACPI_REDUCED_HARDWARE)
148
149 /* Enable ACPI mode */
150
151 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
152 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
153 "[Init] Going into ACPI mode\n"));
154
155 acpi_gbl_original_mode = acpi_hw_get_mode();
156
157 status = acpi_enable();
158 if (ACPI_FAILURE(status)) {
159 ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
160 return_ACPI_STATUS(status);
161 }
162 }
163
164 /*
165 * Obtain a permanent mapping for the FACS. This is required for the
166 * Global Lock and the Firmware Waking Vector
167 */
168 status = acpi_tb_initialize_facs();
169 if (ACPI_FAILURE(status)) {
170 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
171 return_ACPI_STATUS(status);
172 }
173#endif /* !ACPI_REDUCED_HARDWARE */
174
175 /*
176 * Install the default op_region handlers. These are installed unless
177 * other handlers have already been installed via the
178 * install_address_space_handler interface.
179 */
180 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
181 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
182 "[Init] Installing default address space handlers\n"));
183
184 status = acpi_ev_install_region_handlers();
185 if (ACPI_FAILURE(status)) {
186 return_ACPI_STATUS(status);
187 }
188 }
189#if (!ACPI_REDUCED_HARDWARE)
190 /*
191 * Initialize ACPI Event handling (Fixed and General Purpose)
192 *
193 * Note1: We must have the hardware and events initialized before we can
194 * execute any control methods safely. Any control method can require
195 * ACPI hardware support, so the hardware must be fully initialized before
196 * any method execution!
197 *
198 * Note2: Fixed events are initialized and enabled here. GPEs are
199 * initialized, but cannot be enabled until after the hardware is
200 * completely initialized (SCI and global_lock activated) and the various
201 * initialization control methods are run (_REG, _STA, _INI) on the
202 * entire namespace.
203 */
204 if (!(flags & ACPI_NO_EVENT_INIT)) {
205 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
206 "[Init] Initializing ACPI events\n"));
207
208 status = acpi_ev_initialize_events();
209 if (ACPI_FAILURE(status)) {
210 return_ACPI_STATUS(status);
211 }
212 }
213
214 /*
215 * Install the SCI handler and Global Lock handler. This completes the
216 * hardware initialization.
217 */
218 if (!(flags & ACPI_NO_HANDLER_INIT)) {
219 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
220 "[Init] Installing SCI/GL handlers\n"));
221
222 status = acpi_ev_install_xrupt_handlers();
223 if (ACPI_FAILURE(status)) {
224 return_ACPI_STATUS(status);
225 }
226 }
227#endif /* !ACPI_REDUCED_HARDWARE */
228
229 return_ACPI_STATUS(status);
230}
231ACPI_EXPORT_SYMBOL(acpi_enable_subsystem)
232
233/*******************************************************************************
234 *
235 * FUNCTION: acpi_initialize_objects
236 *
237 * PARAMETERS: flags - Init/enable Options
238 *
239 * RETURN: Status
240 *
241 * DESCRIPTION: Completes namespace initialization by initializing device
242 * objects and executing AML code for Regions, buffers, etc.
243 *
244 ******************************************************************************/
245acpi_status acpi_initialize_objects(u32 flags)
246{
247 acpi_status status = AE_OK;
248
249 ACPI_FUNCTION_TRACE(acpi_initialize_objects);
250
251 /*
252 * Run all _REG methods
253 *
254 * Note: Any objects accessed by the _REG methods will be automatically
255 * initialized, even if they contain executable AML (see the call to
256 * acpi_ns_initialize_objects below).
257 */
258 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
259 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
260 "[Init] Executing _REG OpRegion methods\n"));
261
262 status = acpi_ev_initialize_op_regions();
263 if (ACPI_FAILURE(status)) {
264 return_ACPI_STATUS(status);
265 }
266 }
267
268 /*
269 * Execute any module-level code that was detected during the table load
270 * phase. Although illegal since ACPI 2.0, there are many machines that
271 * contain this type of code. Each block of detected executable AML code
272 * outside of any control method is wrapped with a temporary control
273 * method object and placed on a global list. The methods on this list
274 * are executed below.
275 */
276 acpi_ns_exec_module_code_list();
277
278 /*
279 * Initialize the objects that remain uninitialized. This runs the
280 * executable AML that may be part of the declaration of these objects:
281 * operation_regions, buffer_fields, Buffers, and Packages.
282 */
283 if (!(flags & ACPI_NO_OBJECT_INIT)) {
284 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
285 "[Init] Completing Initialization of ACPI Objects\n"));
286
287 status = acpi_ns_initialize_objects();
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
290 }
291 }
292
293 /*
294 * Initialize all device objects in the namespace. This runs the device
295 * _STA and _INI methods.
296 */
297 if (!(flags & ACPI_NO_DEVICE_INIT)) {
298 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
299 "[Init] Initializing ACPI Devices\n"));
300
301 status = acpi_ns_initialize_devices();
302 if (ACPI_FAILURE(status)) {
303 return_ACPI_STATUS(status);
304 }
305 }
306
307 /*
308 * Empty the caches (delete the cached objects) on the assumption that
309 * the table load filled them up more than they will be at runtime --
310 * thus wasting non-paged memory.
311 */
312 status = acpi_purge_cached_objects();
313
314 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
315 return_ACPI_STATUS(status);
316}
317ACPI_EXPORT_SYMBOL(acpi_initialize_objects)
diff --git a/drivers/acpi/acpica/utxfmutex.c b/drivers/acpi/acpica/utxfmutex.c
deleted file mode 100644
index 0a40a851b35..00000000000
--- a/drivers/acpi/acpica/utxfmutex.c
+++ /dev/null
@@ -1,187 +0,0 @@
1/*******************************************************************************
2 *
3 * Module Name: utxfmutex - external AML mutex access functions
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acnamesp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utxfmutex")
50
51/* Local prototypes */
52static acpi_status
53acpi_ut_get_mutex_object(acpi_handle handle,
54 acpi_string pathname,
55 union acpi_operand_object **ret_obj);
56
57/*******************************************************************************
58 *
59 * FUNCTION: acpi_ut_get_mutex_object
60 *
61 * PARAMETERS: handle - Mutex or prefix handle (optional)
62 * pathname - Mutex pathname (optional)
63 * ret_obj - Where the mutex object is returned
64 *
65 * RETURN: Status
66 *
67 * DESCRIPTION: Get an AML mutex object. The mutex node is pointed to by
68 * Handle:Pathname. Either Handle or Pathname can be NULL, but
69 * not both.
70 *
71 ******************************************************************************/
72
73static acpi_status
74acpi_ut_get_mutex_object(acpi_handle handle,
75 acpi_string pathname,
76 union acpi_operand_object **ret_obj)
77{
78 struct acpi_namespace_node *mutex_node;
79 union acpi_operand_object *mutex_obj;
80 acpi_status status;
81
82 /* Parameter validation */
83
84 if (!ret_obj || (!handle && !pathname)) {
85 return (AE_BAD_PARAMETER);
86 }
87
88 /* Get a the namespace node for the mutex */
89
90 mutex_node = handle;
91 if (pathname != NULL) {
92 status = acpi_get_handle(handle, pathname,
93 ACPI_CAST_PTR(acpi_handle,
94 &mutex_node));
95 if (ACPI_FAILURE(status)) {
96 return (status);
97 }
98 }
99
100 /* Ensure that we actually have a Mutex object */
101
102 if (!mutex_node || (mutex_node->type != ACPI_TYPE_MUTEX)) {
103 return (AE_TYPE);
104 }
105
106 /* Get the low-level mutex object */
107
108 mutex_obj = acpi_ns_get_attached_object(mutex_node);
109 if (!mutex_obj) {
110 return (AE_NULL_OBJECT);
111 }
112
113 *ret_obj = mutex_obj;
114 return (AE_OK);
115}
116
117/*******************************************************************************
118 *
119 * FUNCTION: acpi_acquire_mutex
120 *
121 * PARAMETERS: handle - Mutex or prefix handle (optional)
122 * pathname - Mutex pathname (optional)
123 * timeout - Max time to wait for the lock (millisec)
124 *
125 * RETURN: Status
126 *
127 * DESCRIPTION: Acquire an AML mutex. This is a device driver interface to
128 * AML mutex objects, and allows for transaction locking between
129 * drivers and AML code. The mutex node is pointed to by
130 * Handle:Pathname. Either Handle or Pathname can be NULL, but
131 * not both.
132 *
133 ******************************************************************************/
134
135acpi_status
136acpi_acquire_mutex(acpi_handle handle, acpi_string pathname, u16 timeout)
137{
138 acpi_status status;
139 union acpi_operand_object *mutex_obj;
140
141 /* Get the low-level mutex associated with Handle:Pathname */
142
143 status = acpi_ut_get_mutex_object(handle, pathname, &mutex_obj);
144 if (ACPI_FAILURE(status)) {
145 return (status);
146 }
147
148 /* Acquire the OS mutex */
149
150 status = acpi_os_acquire_mutex(mutex_obj->mutex.os_mutex, timeout);
151 return (status);
152}
153
154/*******************************************************************************
155 *
156 * FUNCTION: acpi_release_mutex
157 *
158 * PARAMETERS: handle - Mutex or prefix handle (optional)
159 * pathname - Mutex pathname (optional)
160 *
161 * RETURN: Status
162 *
163 * DESCRIPTION: Release an AML mutex. This is a device driver interface to
164 * AML mutex objects, and allows for transaction locking between
165 * drivers and AML code. The mutex node is pointed to by
166 * Handle:Pathname. Either Handle or Pathname can be NULL, but
167 * not both.
168 *
169 ******************************************************************************/
170
171acpi_status acpi_release_mutex(acpi_handle handle, acpi_string pathname)
172{
173 acpi_status status;
174 union acpi_operand_object *mutex_obj;
175
176 /* Get the low-level mutex associated with Handle:Pathname */
177
178 status = acpi_ut_get_mutex_object(handle, pathname, &mutex_obj);
179 if (ACPI_FAILURE(status)) {
180 return (status);
181 }
182
183 /* Release the OS mutex */
184
185 acpi_os_release_mutex(mutex_obj->mutex.os_mutex);
186 return (AE_OK);
187}
diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig
index f0c1ce95a0e..e3f47872ec2 100644
--- a/drivers/acpi/apei/Kconfig
+++ b/drivers/acpi/apei/Kconfig
@@ -14,6 +14,7 @@ config ACPI_APEI_GHES
14 depends on ACPI_APEI && X86 14 depends on ACPI_APEI && X86
15 select ACPI_HED 15 select ACPI_HED
16 select IRQ_WORK 16 select IRQ_WORK
17 select LLIST
17 select GENERIC_ALLOCATOR 18 select GENERIC_ALLOCATOR
18 help 19 help
19 Generic Hardware Error Source provides a way to report 20 Generic Hardware Error Source provides a way to report
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index 00a783661d0..61540360d5c 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -34,13 +34,13 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/acpi_io.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39#include <linux/io.h> 38#include <linux/io.h>
40#include <linux/kref.h> 39#include <linux/kref.h>
41#include <linux/rculist.h> 40#include <linux/rculist.h>
42#include <linux/interrupt.h> 41#include <linux/interrupt.h>
43#include <linux/debugfs.h> 42#include <linux/debugfs.h>
43#include <acpi/atomicio.h>
44 44
45#include "apei-internal.h" 45#include "apei-internal.h"
46 46
@@ -70,7 +70,7 @@ int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val)
70{ 70{
71 int rc; 71 int rc;
72 72
73 rc = apei_read(val, &entry->register_region); 73 rc = acpi_atomic_read(val, &entry->register_region);
74 if (rc) 74 if (rc)
75 return rc; 75 return rc;
76 *val >>= entry->register_region.bit_offset; 76 *val >>= entry->register_region.bit_offset;
@@ -116,13 +116,13 @@ int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val)
116 val <<= entry->register_region.bit_offset; 116 val <<= entry->register_region.bit_offset;
117 if (entry->flags & APEI_EXEC_PRESERVE_REGISTER) { 117 if (entry->flags & APEI_EXEC_PRESERVE_REGISTER) {
118 u64 valr = 0; 118 u64 valr = 0;
119 rc = apei_read(&valr, &entry->register_region); 119 rc = acpi_atomic_read(&valr, &entry->register_region);
120 if (rc) 120 if (rc)
121 return rc; 121 return rc;
122 valr &= ~(entry->mask << entry->register_region.bit_offset); 122 valr &= ~(entry->mask << entry->register_region.bit_offset);
123 val |= valr; 123 val |= valr;
124 } 124 }
125 rc = apei_write(val, &entry->register_region); 125 rc = acpi_atomic_write(val, &entry->register_region);
126 126
127 return rc; 127 return rc;
128} 128}
@@ -243,7 +243,7 @@ static int pre_map_gar_callback(struct apei_exec_context *ctx,
243 u8 ins = entry->instruction; 243 u8 ins = entry->instruction;
244 244
245 if (ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER) 245 if (ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER)
246 return apei_map_generic_address(&entry->register_region); 246 return acpi_pre_map_gar(&entry->register_region);
247 247
248 return 0; 248 return 0;
249} 249}
@@ -276,7 +276,7 @@ static int post_unmap_gar_callback(struct apei_exec_context *ctx,
276 u8 ins = entry->instruction; 276 u8 ins = entry->instruction;
277 277
278 if (ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER) 278 if (ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER)
279 apei_unmap_generic_address(&entry->register_region); 279 acpi_post_unmap_gar(&entry->register_region);
280 280
281 return 0; 281 return 0;
282} 282}
@@ -421,17 +421,6 @@ static int apei_resources_merge(struct apei_resources *resources1,
421 return 0; 421 return 0;
422} 422}
423 423
424int apei_resources_add(struct apei_resources *resources,
425 unsigned long start, unsigned long size,
426 bool iomem)
427{
428 if (iomem)
429 return apei_res_add(&resources->iomem, start, size);
430 else
431 return apei_res_add(&resources->ioport, start, size);
432}
433EXPORT_SYMBOL_GPL(apei_resources_add);
434
435/* 424/*
436 * EINJ has two groups of GARs (EINJ table entry and trigger table 425 * EINJ has two groups of GARs (EINJ table entry and trigger table
437 * entry), so common resources are subtracted from the trigger table 426 * entry), so common resources are subtracted from the trigger table
@@ -449,19 +438,8 @@ int apei_resources_sub(struct apei_resources *resources1,
449} 438}
450EXPORT_SYMBOL_GPL(apei_resources_sub); 439EXPORT_SYMBOL_GPL(apei_resources_sub);
451 440
452static int apei_get_nvs_callback(__u64 start, __u64 size, void *data)
453{
454 struct apei_resources *resources = data;
455 return apei_res_add(&resources->iomem, start, size);
456}
457
458static int apei_get_nvs_resources(struct apei_resources *resources)
459{
460 return acpi_nvs_for_each_region(apei_get_nvs_callback, resources);
461}
462
463/* 441/*
464 * IO memory/port resource management mechanism is used to check 442 * IO memory/port rersource management mechanism is used to check
465 * whether memory/port area used by GARs conflicts with normal memory 443 * whether memory/port area used by GARs conflicts with normal memory
466 * or IO memory/port of devices. 444 * or IO memory/port of devices.
467 */ 445 */
@@ -470,35 +448,21 @@ int apei_resources_request(struct apei_resources *resources,
470{ 448{
471 struct apei_res *res, *res_bak = NULL; 449 struct apei_res *res, *res_bak = NULL;
472 struct resource *r; 450 struct resource *r;
473 struct apei_resources nvs_resources;
474 int rc; 451 int rc;
475 452
476 rc = apei_resources_sub(resources, &apei_resources_all); 453 rc = apei_resources_sub(resources, &apei_resources_all);
477 if (rc) 454 if (rc)
478 return rc; 455 return rc;
479 456
480 /*
481 * Some firmware uses ACPI NVS region, that has been marked as
482 * busy, so exclude it from APEI resources to avoid false
483 * conflict.
484 */
485 apei_resources_init(&nvs_resources);
486 rc = apei_get_nvs_resources(&nvs_resources);
487 if (rc)
488 goto res_fini;
489 rc = apei_resources_sub(resources, &nvs_resources);
490 if (rc)
491 goto res_fini;
492
493 rc = -EINVAL; 457 rc = -EINVAL;
494 list_for_each_entry(res, &resources->iomem, list) { 458 list_for_each_entry(res, &resources->iomem, list) {
495 r = request_mem_region(res->start, res->end - res->start, 459 r = request_mem_region(res->start, res->end - res->start,
496 desc); 460 desc);
497 if (!r) { 461 if (!r) {
498 pr_err(APEI_PFX 462 pr_err(APEI_PFX
499 "Can not request [mem %#010llx-%#010llx] for %s registers\n", 463 "Can not request iomem region <%016llx-%016llx> for GARs.\n",
500 (unsigned long long)res->start, 464 (unsigned long long)res->start,
501 (unsigned long long)res->end - 1, desc); 465 (unsigned long long)res->end);
502 res_bak = res; 466 res_bak = res;
503 goto err_unmap_iomem; 467 goto err_unmap_iomem;
504 } 468 }
@@ -508,9 +472,9 @@ int apei_resources_request(struct apei_resources *resources,
508 r = request_region(res->start, res->end - res->start, desc); 472 r = request_region(res->start, res->end - res->start, desc);
509 if (!r) { 473 if (!r) {
510 pr_err(APEI_PFX 474 pr_err(APEI_PFX
511 "Can not request [io %#06llx-%#06llx] for %s registers\n", 475 "Can not request ioport region <%016llx-%016llx> for GARs.\n",
512 (unsigned long long)res->start, 476 (unsigned long long)res->start,
513 (unsigned long long)res->end - 1, desc); 477 (unsigned long long)res->end);
514 res_bak = res; 478 res_bak = res;
515 goto err_unmap_ioport; 479 goto err_unmap_ioport;
516 } 480 }
@@ -536,8 +500,6 @@ err_unmap_iomem:
536 break; 500 break;
537 release_mem_region(res->start, res->end - res->start); 501 release_mem_region(res->start, res->end - res->start);
538 } 502 }
539res_fini:
540 apei_resources_fini(&nvs_resources);
541 return rc; 503 return rc;
542} 504}
543EXPORT_SYMBOL_GPL(apei_resources_request); 505EXPORT_SYMBOL_GPL(apei_resources_request);
@@ -558,137 +520,38 @@ void apei_resources_release(struct apei_resources *resources)
558} 520}
559EXPORT_SYMBOL_GPL(apei_resources_release); 521EXPORT_SYMBOL_GPL(apei_resources_release);
560 522
561static int apei_check_gar(struct acpi_generic_address *reg, u64 *paddr, 523static int apei_check_gar(struct acpi_generic_address *reg, u64 *paddr)
562 u32 *access_bit_width)
563{ 524{
564 u32 bit_width, bit_offset, access_size_code, space_id; 525 u32 width, space_id;
565 526
566 bit_width = reg->bit_width; 527 width = reg->bit_width;
567 bit_offset = reg->bit_offset;
568 access_size_code = reg->access_width;
569 space_id = reg->space_id; 528 space_id = reg->space_id;
570 /* Handle possible alignment issues */ 529 /* Handle possible alignment issues */
571 memcpy(paddr, &reg->address, sizeof(*paddr)); 530 memcpy(paddr, &reg->address, sizeof(*paddr));
572 if (!*paddr) { 531 if (!*paddr) {
573 pr_warning(FW_BUG APEI_PFX 532 pr_warning(FW_BUG APEI_PFX
574 "Invalid physical address in GAR [0x%llx/%u/%u/%u/%u]\n", 533 "Invalid physical address in GAR [0x%llx/%u/%u]\n",
575 *paddr, bit_width, bit_offset, access_size_code, 534 *paddr, width, space_id);
576 space_id);
577 return -EINVAL; 535 return -EINVAL;
578 } 536 }
579 537
580 if (access_size_code < 1 || access_size_code > 4) { 538 if ((width != 8) && (width != 16) && (width != 32) && (width != 64)) {
581 pr_warning(FW_BUG APEI_PFX 539 pr_warning(FW_BUG APEI_PFX
582 "Invalid access size code in GAR [0x%llx/%u/%u/%u/%u]\n", 540 "Invalid bit width in GAR [0x%llx/%u/%u]\n",
583 *paddr, bit_width, bit_offset, access_size_code, 541 *paddr, width, space_id);
584 space_id);
585 return -EINVAL;
586 }
587 *access_bit_width = 1UL << (access_size_code + 2);
588
589 /* Fixup common BIOS bug */
590 if (bit_width == 32 && bit_offset == 0 && (*paddr & 0x03) == 0 &&
591 *access_bit_width < 32)
592 *access_bit_width = 32;
593
594 if ((bit_width + bit_offset) > *access_bit_width) {
595 pr_warning(FW_BUG APEI_PFX
596 "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",
597 *paddr, bit_width, bit_offset, access_size_code,
598 space_id);
599 return -EINVAL; 542 return -EINVAL;
600 } 543 }
601 544
602 if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY && 545 if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY &&
603 space_id != ACPI_ADR_SPACE_SYSTEM_IO) { 546 space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
604 pr_warning(FW_BUG APEI_PFX 547 pr_warning(FW_BUG APEI_PFX
605 "Invalid address space type in GAR [0x%llx/%u/%u/%u/%u]\n", 548 "Invalid address space type in GAR [0x%llx/%u/%u]\n",
606 *paddr, bit_width, bit_offset, access_size_code, 549 *paddr, width, space_id);
607 space_id);
608 return -EINVAL;
609 }
610
611 return 0;
612}
613
614int apei_map_generic_address(struct acpi_generic_address *reg)
615{
616 int rc;
617 u32 access_bit_width;
618 u64 address;
619
620 rc = apei_check_gar(reg, &address, &access_bit_width);
621 if (rc)
622 return rc;
623 return acpi_os_map_generic_address(reg);
624}
625EXPORT_SYMBOL_GPL(apei_map_generic_address);
626
627/* read GAR in interrupt (including NMI) or process context */
628int apei_read(u64 *val, struct acpi_generic_address *reg)
629{
630 int rc;
631 u32 access_bit_width;
632 u64 address;
633 acpi_status status;
634
635 rc = apei_check_gar(reg, &address, &access_bit_width);
636 if (rc)
637 return rc;
638
639 *val = 0;
640 switch(reg->space_id) {
641 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
642 status = acpi_os_read_memory((acpi_physical_address) address,
643 val, access_bit_width);
644 if (ACPI_FAILURE(status))
645 return -EIO;
646 break;
647 case ACPI_ADR_SPACE_SYSTEM_IO:
648 status = acpi_os_read_port(address, (u32 *)val,
649 access_bit_width);
650 if (ACPI_FAILURE(status))
651 return -EIO;
652 break;
653 default:
654 return -EINVAL;
655 }
656
657 return 0;
658}
659EXPORT_SYMBOL_GPL(apei_read);
660
661/* write GAR in interrupt (including NMI) or process context */
662int apei_write(u64 val, struct acpi_generic_address *reg)
663{
664 int rc;
665 u32 access_bit_width;
666 u64 address;
667 acpi_status status;
668
669 rc = apei_check_gar(reg, &address, &access_bit_width);
670 if (rc)
671 return rc;
672
673 switch (reg->space_id) {
674 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
675 status = acpi_os_write_memory((acpi_physical_address) address,
676 val, access_bit_width);
677 if (ACPI_FAILURE(status))
678 return -EIO;
679 break;
680 case ACPI_ADR_SPACE_SYSTEM_IO:
681 status = acpi_os_write_port(address, val, access_bit_width);
682 if (ACPI_FAILURE(status))
683 return -EIO;
684 break;
685 default:
686 return -EINVAL; 550 return -EINVAL;
687 } 551 }
688 552
689 return 0; 553 return 0;
690} 554}
691EXPORT_SYMBOL_GPL(apei_write);
692 555
693static int collect_res_callback(struct apei_exec_context *ctx, 556static int collect_res_callback(struct apei_exec_context *ctx,
694 struct acpi_whea_header *entry, 557 struct acpi_whea_header *entry,
@@ -697,24 +560,23 @@ static int collect_res_callback(struct apei_exec_context *ctx,
697 struct apei_resources *resources = data; 560 struct apei_resources *resources = data;
698 struct acpi_generic_address *reg = &entry->register_region; 561 struct acpi_generic_address *reg = &entry->register_region;
699 u8 ins = entry->instruction; 562 u8 ins = entry->instruction;
700 u32 access_bit_width;
701 u64 paddr; 563 u64 paddr;
702 int rc; 564 int rc;
703 565
704 if (!(ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER)) 566 if (!(ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER))
705 return 0; 567 return 0;
706 568
707 rc = apei_check_gar(reg, &paddr, &access_bit_width); 569 rc = apei_check_gar(reg, &paddr);
708 if (rc) 570 if (rc)
709 return rc; 571 return rc;
710 572
711 switch (reg->space_id) { 573 switch (reg->space_id) {
712 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 574 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
713 return apei_res_add(&resources->iomem, paddr, 575 return apei_res_add(&resources->iomem, paddr,
714 access_bit_width / 8); 576 reg->bit_width / 8);
715 case ACPI_ADR_SPACE_SYSTEM_IO: 577 case ACPI_ADR_SPACE_SYSTEM_IO:
716 return apei_res_add(&resources->ioport, paddr, 578 return apei_res_add(&resources->ioport, paddr,
717 access_bit_width / 8); 579 reg->bit_width / 8);
718 default: 580 default:
719 return -EINVAL; 581 return -EINVAL;
720 } 582 }
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index f220d642136..f57050e7a5e 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -7,8 +7,6 @@
7#define APEI_INTERNAL_H 7#define APEI_INTERNAL_H
8 8
9#include <linux/cper.h> 9#include <linux/cper.h>
10#include <linux/acpi.h>
11#include <linux/acpi_io.h>
12 10
13struct apei_exec_context; 11struct apei_exec_context;
14 12
@@ -70,16 +68,6 @@ static inline int apei_exec_run_optional(struct apei_exec_context *ctx, u8 actio
70/* IP has been set in instruction function */ 68/* IP has been set in instruction function */
71#define APEI_EXEC_SET_IP 1 69#define APEI_EXEC_SET_IP 1
72 70
73int apei_map_generic_address(struct acpi_generic_address *reg);
74
75static inline void apei_unmap_generic_address(struct acpi_generic_address *reg)
76{
77 acpi_os_unmap_generic_address(reg);
78}
79
80int apei_read(u64 *val, struct acpi_generic_address *reg);
81int apei_write(u64 val, struct acpi_generic_address *reg);
82
83int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val); 71int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val);
84int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val); 72int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val);
85int apei_exec_read_register(struct apei_exec_context *ctx, 73int apei_exec_read_register(struct apei_exec_context *ctx,
@@ -107,9 +95,6 @@ static inline void apei_resources_init(struct apei_resources *resources)
107} 95}
108 96
109void apei_resources_fini(struct apei_resources *resources); 97void apei_resources_fini(struct apei_resources *resources);
110int apei_resources_add(struct apei_resources *resources,
111 unsigned long start, unsigned long size,
112 bool iomem);
113int apei_resources_sub(struct apei_resources *resources1, 98int apei_resources_sub(struct apei_resources *resources1,
114 struct apei_resources *resources2); 99 struct apei_resources *resources2);
115int apei_resources_request(struct apei_resources *resources, 100int apei_resources_request(struct apei_resources *resources,
diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
index e6defd86b42..5d4189464d6 100644
--- a/drivers/acpi/apei/cper.c
+++ b/drivers/acpi/apei/cper.c
@@ -362,7 +362,6 @@ void apei_estatus_print(const char *pfx,
362 gedata_len = gdata->error_data_length; 362 gedata_len = gdata->error_data_length;
363 apei_estatus_print_section(pfx, gdata, sec_no); 363 apei_estatus_print_section(pfx, gdata, sec_no);
364 data_len -= gedata_len + sizeof(*gdata); 364 data_len -= gedata_len + sizeof(*gdata);
365 gdata = (void *)(gdata + 1) + gedata_len;
366 sec_no++; 365 sec_no++;
367 } 366 }
368} 367}
@@ -397,7 +396,6 @@ int apei_estatus_check(const struct acpi_hest_generic_status *estatus)
397 if (gedata_len > data_len - sizeof(*gdata)) 396 if (gedata_len > data_len - sizeof(*gdata))
398 return -EINVAL; 397 return -EINVAL;
399 data_len -= gedata_len + sizeof(*gdata); 398 data_len -= gedata_len + sizeof(*gdata);
400 gdata = (void *)(gdata + 1) + gedata_len;
401 } 399 }
402 if (data_len) 400 if (data_len)
403 return -EINVAL; 401 return -EINVAL;
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index 8d457b55c55..589b96c3870 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -43,44 +43,6 @@
43#define FIRMWARE_TIMEOUT (1 * NSEC_PER_MSEC) 43#define FIRMWARE_TIMEOUT (1 * NSEC_PER_MSEC)
44 44
45/* 45/*
46 * ACPI version 5 provides a SET_ERROR_TYPE_WITH_ADDRESS action.
47 */
48static int acpi5;
49
50struct set_error_type_with_address {
51 u32 type;
52 u32 vendor_extension;
53 u32 flags;
54 u32 apicid;
55 u64 memory_address;
56 u64 memory_address_range;
57 u32 pcie_sbdf;
58};
59enum {
60 SETWA_FLAGS_APICID = 1,
61 SETWA_FLAGS_MEM = 2,
62 SETWA_FLAGS_PCIE_SBDF = 4,
63};
64
65/*
66 * Vendor extensions for platform specific operations
67 */
68struct vendor_error_type_extension {
69 u32 length;
70 u32 pcie_sbdf;
71 u16 vendor_id;
72 u16 device_id;
73 u8 rev_id;
74 u8 reserved[3];
75};
76
77static u32 notrigger;
78
79static u32 vendor_flags;
80static struct debugfs_blob_wrapper vendor_blob;
81static char vendor_dev[64];
82
83/*
84 * Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the 46 * Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the
85 * EINJ table through an unpublished extension. Use with caution as 47 * EINJ table through an unpublished extension. Use with caution as
86 * most will ignore the parameter and make their own choice of address 48 * most will ignore the parameter and make their own choice of address
@@ -141,7 +103,15 @@ static struct apei_exec_ins_type einj_ins_type[] = {
141 */ 103 */
142static DEFINE_MUTEX(einj_mutex); 104static DEFINE_MUTEX(einj_mutex);
143 105
144static void *einj_param; 106static struct einj_parameter *einj_param;
107
108#ifndef writeq
109static inline void writeq(__u64 val, volatile void __iomem *addr)
110{
111 writel(val, addr);
112 writel(val >> 32, addr+4);
113}
114#endif
145 115
146static void einj_exec_ctx_init(struct apei_exec_context *ctx) 116static void einj_exec_ctx_init(struct apei_exec_context *ctx)
147{ 117{
@@ -188,30 +158,10 @@ static int einj_timedout(u64 *t)
188 return 0; 158 return 0;
189} 159}
190 160
191static void check_vendor_extension(u64 paddr, 161static u64 einj_get_parameter_address(void)
192 struct set_error_type_with_address *v5param)
193{
194 int offset = v5param->vendor_extension;
195 struct vendor_error_type_extension *v;
196 u32 sbdf;
197
198 if (!offset)
199 return;
200 v = acpi_os_map_memory(paddr + offset, sizeof(*v));
201 if (!v)
202 return;
203 sbdf = v->pcie_sbdf;
204 sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n",
205 sbdf >> 24, (sbdf >> 16) & 0xff,
206 (sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7,
207 v->vendor_id, v->device_id, v->rev_id);
208 acpi_os_unmap_memory(v, sizeof(*v));
209}
210
211static void *einj_get_parameter_address(void)
212{ 162{
213 int i; 163 int i;
214 u64 paddrv4 = 0, paddrv5 = 0; 164 u64 paddr = 0;
215 struct acpi_whea_header *entry; 165 struct acpi_whea_header *entry;
216 166
217 entry = EINJ_TAB_ENTRY(einj_tab); 167 entry = EINJ_TAB_ENTRY(einj_tab);
@@ -220,40 +170,12 @@ static void *einj_get_parameter_address(void)
220 entry->instruction == ACPI_EINJ_WRITE_REGISTER && 170 entry->instruction == ACPI_EINJ_WRITE_REGISTER &&
221 entry->register_region.space_id == 171 entry->register_region.space_id ==
222 ACPI_ADR_SPACE_SYSTEM_MEMORY) 172 ACPI_ADR_SPACE_SYSTEM_MEMORY)
223 memcpy(&paddrv4, &entry->register_region.address, 173 memcpy(&paddr, &entry->register_region.address,
224 sizeof(paddrv4)); 174 sizeof(paddr));
225 if (entry->action == ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS &&
226 entry->instruction == ACPI_EINJ_WRITE_REGISTER &&
227 entry->register_region.space_id ==
228 ACPI_ADR_SPACE_SYSTEM_MEMORY)
229 memcpy(&paddrv5, &entry->register_region.address,
230 sizeof(paddrv5));
231 entry++; 175 entry++;
232 } 176 }
233 if (paddrv5) {
234 struct set_error_type_with_address *v5param;
235
236 v5param = acpi_os_map_memory(paddrv5, sizeof(*v5param));
237 if (v5param) {
238 acpi5 = 1;
239 check_vendor_extension(paddrv5, v5param);
240 return v5param;
241 }
242 }
243 if (param_extension && paddrv4) {
244 struct einj_parameter *v4param;
245
246 v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param));
247 if (!v4param)
248 return NULL;
249 if (v4param->reserved1 || v4param->reserved2) {
250 acpi_os_unmap_memory(v4param, sizeof(*v4param));
251 return NULL;
252 }
253 return v4param;
254 }
255 177
256 return NULL; 178 return paddr;
257} 179}
258 180
259/* do sanity check to trigger table */ 181/* do sanity check to trigger table */
@@ -262,7 +184,7 @@ static int einj_check_trigger_header(struct acpi_einj_trigger *trigger_tab)
262 if (trigger_tab->header_size != sizeof(struct acpi_einj_trigger)) 184 if (trigger_tab->header_size != sizeof(struct acpi_einj_trigger))
263 return -EINVAL; 185 return -EINVAL;
264 if (trigger_tab->table_size > PAGE_SIZE || 186 if (trigger_tab->table_size > PAGE_SIZE ||
265 trigger_tab->table_size < trigger_tab->header_size) 187 trigger_tab->table_size <= trigger_tab->header_size)
266 return -EINVAL; 188 return -EINVAL;
267 if (trigger_tab->entry_count != 189 if (trigger_tab->entry_count !=
268 (trigger_tab->table_size - trigger_tab->header_size) / 190 (trigger_tab->table_size - trigger_tab->header_size) /
@@ -272,29 +194,8 @@ static int einj_check_trigger_header(struct acpi_einj_trigger *trigger_tab)
272 return 0; 194 return 0;
273} 195}
274 196
275static struct acpi_generic_address *einj_get_trigger_parameter_region(
276 struct acpi_einj_trigger *trigger_tab, u64 param1, u64 param2)
277{
278 int i;
279 struct acpi_whea_header *entry;
280
281 entry = (struct acpi_whea_header *)
282 ((char *)trigger_tab + sizeof(struct acpi_einj_trigger));
283 for (i = 0; i < trigger_tab->entry_count; i++) {
284 if (entry->action == ACPI_EINJ_TRIGGER_ERROR &&
285 entry->instruction == ACPI_EINJ_WRITE_REGISTER_VALUE &&
286 entry->register_region.space_id ==
287 ACPI_ADR_SPACE_SYSTEM_MEMORY &&
288 (entry->register_region.address & param2) == (param1 & param2))
289 return &entry->register_region;
290 entry++;
291 }
292
293 return NULL;
294}
295/* Execute instructions in trigger error action table */ 197/* Execute instructions in trigger error action table */
296static int __einj_error_trigger(u64 trigger_paddr, u32 type, 198static int __einj_error_trigger(u64 trigger_paddr)
297 u64 param1, u64 param2)
298{ 199{
299 struct acpi_einj_trigger *trigger_tab = NULL; 200 struct acpi_einj_trigger *trigger_tab = NULL;
300 struct apei_exec_context trigger_ctx; 201 struct apei_exec_context trigger_ctx;
@@ -303,16 +204,14 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
303 struct resource *r; 204 struct resource *r;
304 u32 table_size; 205 u32 table_size;
305 int rc = -EIO; 206 int rc = -EIO;
306 struct acpi_generic_address *trigger_param_region = NULL;
307 207
308 r = request_mem_region(trigger_paddr, sizeof(*trigger_tab), 208 r = request_mem_region(trigger_paddr, sizeof(*trigger_tab),
309 "APEI EINJ Trigger Table"); 209 "APEI EINJ Trigger Table");
310 if (!r) { 210 if (!r) {
311 pr_err(EINJ_PFX 211 pr_err(EINJ_PFX
312 "Can not request [mem %#010llx-%#010llx] for Trigger table\n", 212 "Can not request iomem region <%016llx-%016llx> for Trigger table.\n",
313 (unsigned long long)trigger_paddr, 213 (unsigned long long)trigger_paddr,
314 (unsigned long long)trigger_paddr + 214 (unsigned long long)trigger_paddr+sizeof(*trigger_tab));
315 sizeof(*trigger_tab) - 1);
316 goto out; 215 goto out;
317 } 216 }
318 trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab)); 217 trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab));
@@ -326,11 +225,6 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
326 "The trigger error action table is invalid\n"); 225 "The trigger error action table is invalid\n");
327 goto out_rel_header; 226 goto out_rel_header;
328 } 227 }
329
330 /* No action structures in the TRIGGER_ERROR table, nothing to do */
331 if (!trigger_tab->entry_count)
332 goto out_rel_header;
333
334 rc = -EIO; 228 rc = -EIO;
335 table_size = trigger_tab->table_size; 229 table_size = trigger_tab->table_size;
336 r = request_mem_region(trigger_paddr + sizeof(*trigger_tab), 230 r = request_mem_region(trigger_paddr + sizeof(*trigger_tab),
@@ -338,9 +232,9 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
338 "APEI EINJ Trigger Table"); 232 "APEI EINJ Trigger Table");
339 if (!r) { 233 if (!r) {
340 pr_err(EINJ_PFX 234 pr_err(EINJ_PFX
341"Can not request [mem %#010llx-%#010llx] for Trigger Table Entry\n", 235"Can not request iomem region <%016llx-%016llx> for Trigger Table Entry.\n",
342 (unsigned long long)trigger_paddr + sizeof(*trigger_tab), 236 (unsigned long long)trigger_paddr+sizeof(*trigger_tab),
343 (unsigned long long)trigger_paddr + table_size - 1); 237 (unsigned long long)trigger_paddr + table_size);
344 goto out_rel_header; 238 goto out_rel_header;
345 } 239 }
346 iounmap(trigger_tab); 240 iounmap(trigger_tab);
@@ -361,30 +255,6 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
361 rc = apei_resources_sub(&trigger_resources, &einj_resources); 255 rc = apei_resources_sub(&trigger_resources, &einj_resources);
362 if (rc) 256 if (rc)
363 goto out_fini; 257 goto out_fini;
364 /*
365 * Some firmware will access target address specified in
366 * param1 to trigger the error when injecting memory error.
367 * This will cause resource conflict with regular memory. So
368 * remove it from trigger table resources.
369 */
370 if ((param_extension || acpi5) && (type & 0x0038) && param2) {
371 struct apei_resources addr_resources;
372 apei_resources_init(&addr_resources);
373 trigger_param_region = einj_get_trigger_parameter_region(
374 trigger_tab, param1, param2);
375 if (trigger_param_region) {
376 rc = apei_resources_add(&addr_resources,
377 trigger_param_region->address,
378 trigger_param_region->bit_width/8, true);
379 if (rc)
380 goto out_fini;
381 rc = apei_resources_sub(&trigger_resources,
382 &addr_resources);
383 }
384 apei_resources_fini(&addr_resources);
385 if (rc)
386 goto out_fini;
387 }
388 rc = apei_resources_request(&trigger_resources, "APEI EINJ Trigger"); 258 rc = apei_resources_request(&trigger_resources, "APEI EINJ Trigger");
389 if (rc) 259 if (rc)
390 goto out_fini; 260 goto out_fini;
@@ -423,56 +293,12 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2)
423 if (rc) 293 if (rc)
424 return rc; 294 return rc;
425 apei_exec_ctx_set_input(&ctx, type); 295 apei_exec_ctx_set_input(&ctx, type);
426 if (acpi5) { 296 rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
427 struct set_error_type_with_address *v5param = einj_param; 297 if (rc)
428 298 return rc;
429 v5param->type = type; 299 if (einj_param) {
430 if (type & 0x80000000) { 300 writeq(param1, &einj_param->param1);
431 switch (vendor_flags) { 301 writeq(param2, &einj_param->param2);
432 case SETWA_FLAGS_APICID:
433 v5param->apicid = param1;
434 break;
435 case SETWA_FLAGS_MEM:
436 v5param->memory_address = param1;
437 v5param->memory_address_range = param2;
438 break;
439 case SETWA_FLAGS_PCIE_SBDF:
440 v5param->pcie_sbdf = param1;
441 break;
442 }
443 v5param->flags = vendor_flags;
444 } else {
445 switch (type) {
446 case ACPI_EINJ_PROCESSOR_CORRECTABLE:
447 case ACPI_EINJ_PROCESSOR_UNCORRECTABLE:
448 case ACPI_EINJ_PROCESSOR_FATAL:
449 v5param->apicid = param1;
450 v5param->flags = SETWA_FLAGS_APICID;
451 break;
452 case ACPI_EINJ_MEMORY_CORRECTABLE:
453 case ACPI_EINJ_MEMORY_UNCORRECTABLE:
454 case ACPI_EINJ_MEMORY_FATAL:
455 v5param->memory_address = param1;
456 v5param->memory_address_range = param2;
457 v5param->flags = SETWA_FLAGS_MEM;
458 break;
459 case ACPI_EINJ_PCIX_CORRECTABLE:
460 case ACPI_EINJ_PCIX_UNCORRECTABLE:
461 case ACPI_EINJ_PCIX_FATAL:
462 v5param->pcie_sbdf = param1;
463 v5param->flags = SETWA_FLAGS_PCIE_SBDF;
464 break;
465 }
466 }
467 } else {
468 rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
469 if (rc)
470 return rc;
471 if (einj_param) {
472 struct einj_parameter *v4param = einj_param;
473 v4param->param1 = param1;
474 v4param->param2 = param2;
475 }
476 } 302 }
477 rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION); 303 rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION);
478 if (rc) 304 if (rc)
@@ -498,11 +324,9 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2)
498 if (rc) 324 if (rc)
499 return rc; 325 return rc;
500 trigger_paddr = apei_exec_ctx_get_output(&ctx); 326 trigger_paddr = apei_exec_ctx_get_output(&ctx);
501 if (notrigger == 0) { 327 rc = __einj_error_trigger(trigger_paddr);
502 rc = __einj_error_trigger(trigger_paddr, type, param1, param2); 328 if (rc)
503 if (rc) 329 return rc;
504 return rc;
505 }
506 rc = apei_exec_run_optional(&ctx, ACPI_EINJ_END_OPERATION); 330 rc = apei_exec_run_optional(&ctx, ACPI_EINJ_END_OPERATION);
507 331
508 return rc; 332 return rc;
@@ -584,25 +408,15 @@ static int error_type_set(void *data, u64 val)
584{ 408{
585 int rc; 409 int rc;
586 u32 available_error_type = 0; 410 u32 available_error_type = 0;
587 u32 tval, vendor;
588
589 /*
590 * Vendor defined types have 0x80000000 bit set, and
591 * are not enumerated by ACPI_EINJ_GET_ERROR_TYPE
592 */
593 vendor = val & 0x80000000;
594 tval = val & 0x7fffffff;
595 411
596 /* Only one error type can be specified */ 412 /* Only one error type can be specified */
597 if (tval & (tval - 1)) 413 if (val & (val - 1))
414 return -EINVAL;
415 rc = einj_get_available_error_type(&available_error_type);
416 if (rc)
417 return rc;
418 if (!(val & available_error_type))
598 return -EINVAL; 419 return -EINVAL;
599 if (!vendor) {
600 rc = einj_get_available_error_type(&available_error_type);
601 if (rc)
602 return rc;
603 if (!(val & available_error_type))
604 return -EINVAL;
605 }
606 error_type = val; 420 error_type = val;
607 421
608 return 0; 422 return 0;
@@ -641,6 +455,7 @@ static int einj_check_table(struct acpi_table_einj *einj_tab)
641static int __init einj_init(void) 455static int __init einj_init(void)
642{ 456{
643 int rc; 457 int rc;
458 u64 param_paddr;
644 acpi_status status; 459 acpi_status status;
645 struct dentry *fentry; 460 struct dentry *fentry;
646 struct apei_exec_context ctx; 461 struct apei_exec_context ctx;
@@ -650,9 +465,10 @@ static int __init einj_init(void)
650 465
651 status = acpi_get_table(ACPI_SIG_EINJ, 0, 466 status = acpi_get_table(ACPI_SIG_EINJ, 0,
652 (struct acpi_table_header **)&einj_tab); 467 (struct acpi_table_header **)&einj_tab);
653 if (status == AE_NOT_FOUND) 468 if (status == AE_NOT_FOUND) {
469 pr_info(EINJ_PFX "Table is not found!\n");
654 return -ENODEV; 470 return -ENODEV;
655 else if (ACPI_FAILURE(status)) { 471 } else if (ACPI_FAILURE(status)) {
656 const char *msg = acpi_format_exception(status); 472 const char *msg = acpi_format_exception(status);
657 pr_err(EINJ_PFX "Failed to get table, %s\n", msg); 473 pr_err(EINJ_PFX "Failed to get table, %s\n", msg);
658 return -EINVAL; 474 return -EINVAL;
@@ -693,35 +509,23 @@ static int __init einj_init(void)
693 rc = apei_exec_pre_map_gars(&ctx); 509 rc = apei_exec_pre_map_gars(&ctx);
694 if (rc) 510 if (rc)
695 goto err_release; 511 goto err_release;
696 512 if (param_extension) {
697 einj_param = einj_get_parameter_address(); 513 param_paddr = einj_get_parameter_address();
698 if ((param_extension || acpi5) && einj_param) { 514 if (param_paddr) {
699 fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR, 515 einj_param = ioremap(param_paddr, sizeof(*einj_param));
700 einj_debug_dir, &error_param1); 516 rc = -ENOMEM;
701 if (!fentry) 517 if (!einj_param)
702 goto err_unmap; 518 goto err_unmap;
703 fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR, 519 fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR,
704 einj_debug_dir, &error_param2); 520 einj_debug_dir, &error_param1);
705 if (!fentry) 521 if (!fentry)
706 goto err_unmap; 522 goto err_unmap;
707 523 fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR,
708 fentry = debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR, 524 einj_debug_dir, &error_param2);
709 einj_debug_dir, &notrigger); 525 if (!fentry)
710 if (!fentry) 526 goto err_unmap;
711 goto err_unmap; 527 } else
712 } 528 pr_warn(EINJ_PFX "Parameter extension is not supported.\n");
713
714 if (vendor_dev[0]) {
715 vendor_blob.data = vendor_dev;
716 vendor_blob.size = strlen(vendor_dev);
717 fentry = debugfs_create_blob("vendor", S_IRUSR,
718 einj_debug_dir, &vendor_blob);
719 if (!fentry)
720 goto err_unmap;
721 fentry = debugfs_create_x32("vendor_flags", S_IRUSR | S_IWUSR,
722 einj_debug_dir, &vendor_flags);
723 if (!fentry)
724 goto err_unmap;
725 } 529 }
726 530
727 pr_info(EINJ_PFX "Error INJection is initialized.\n"); 531 pr_info(EINJ_PFX "Error INJection is initialized.\n");
@@ -729,13 +533,8 @@ static int __init einj_init(void)
729 return 0; 533 return 0;
730 534
731err_unmap: 535err_unmap:
732 if (einj_param) { 536 if (einj_param)
733 acpi_size size = (acpi5) ? 537 iounmap(einj_param);
734 sizeof(struct set_error_type_with_address) :
735 sizeof(struct einj_parameter);
736
737 acpi_os_unmap_memory(einj_param, size);
738 }
739 apei_exec_post_unmap_gars(&ctx); 538 apei_exec_post_unmap_gars(&ctx);
740err_release: 539err_release:
741 apei_resources_release(&einj_resources); 540 apei_resources_release(&einj_resources);
@@ -751,13 +550,8 @@ static void __exit einj_exit(void)
751{ 550{
752 struct apei_exec_context ctx; 551 struct apei_exec_context ctx;
753 552
754 if (einj_param) { 553 if (einj_param)
755 acpi_size size = (acpi5) ? 554 iounmap(einj_param);
756 sizeof(struct set_error_type_with_address) :
757 sizeof(struct einj_parameter);
758
759 acpi_os_unmap_memory(einj_param, size);
760 }
761 einj_exec_ctx_init(&ctx); 555 einj_exec_ctx_init(&ctx);
762 apei_exec_post_unmap_gars(&ctx); 556 apei_exec_post_unmap_gars(&ctx);
763 apei_resources_release(&einj_resources); 557 apei_resources_release(&einj_resources);
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 04ab5c9d3ce..903549df809 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -111,17 +111,8 @@ retry_next:
111 if (rc) 111 if (rc)
112 goto out; 112 goto out;
113 /* no more record */ 113 /* no more record */
114 if (id == APEI_ERST_INVALID_RECORD_ID) { 114 if (id == APEI_ERST_INVALID_RECORD_ID)
115 /*
116 * If the persistent store is empty initially, the function
117 * 'erst_read' below will return "-ENOENT" value. This causes
118 * 'retry_next' label is entered again. The returned value
119 * should be zero indicating the read operation is EOF.
120 */
121 len = 0;
122
123 goto out; 115 goto out;
124 }
125retry: 116retry:
126 rc = len = erst_read(id, erst_dbg_buf, erst_dbg_buf_len); 117 rc = len = erst_read(id, erst_dbg_buf, erst_dbg_buf_len);
127 /* The record may be cleared by others, try read next record */ 118 /* The record may be cleared by others, try read next record */
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
index 6d894bfd8b8..2ca59dc69f7 100644
--- a/drivers/acpi/apei/erst.c
+++ b/drivers/acpi/apei/erst.c
@@ -917,7 +917,7 @@ static int erst_check_table(struct acpi_table_erst *erst_tab)
917{ 917{
918 if ((erst_tab->header_length != 918 if ((erst_tab->header_length !=
919 (sizeof(struct acpi_table_erst) - sizeof(erst_tab->header))) 919 (sizeof(struct acpi_table_erst) - sizeof(erst_tab->header)))
920 && (erst_tab->header_length != sizeof(struct acpi_table_erst))) 920 && (erst_tab->header_length != sizeof(struct acpi_table_einj)))
921 return -EINVAL; 921 return -EINVAL;
922 if (erst_tab->header.length < sizeof(struct acpi_table_erst)) 922 if (erst_tab->header.length < sizeof(struct acpi_table_erst))
923 return -EINVAL; 923 return -EINVAL;
@@ -931,14 +931,12 @@ static int erst_check_table(struct acpi_table_erst *erst_tab)
931 931
932static int erst_open_pstore(struct pstore_info *psi); 932static int erst_open_pstore(struct pstore_info *psi);
933static int erst_close_pstore(struct pstore_info *psi); 933static int erst_close_pstore(struct pstore_info *psi);
934static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count, 934static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
935 struct timespec *time, char **buf, 935 struct timespec *time, struct pstore_info *psi);
936 struct pstore_info *psi); 936static u64 erst_writer(enum pstore_type_id type, unsigned int part,
937static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
938 u64 *id, unsigned int part, int count,
939 size_t size, struct pstore_info *psi); 937 size_t size, struct pstore_info *psi);
940static int erst_clearer(enum pstore_type_id type, u64 id, int count, 938static int erst_clearer(enum pstore_type_id type, u64 id,
941 struct timespec time, struct pstore_info *psi); 939 struct pstore_info *psi);
942 940
943static struct pstore_info erst_info = { 941static struct pstore_info erst_info = {
944 .owner = THIS_MODULE, 942 .owner = THIS_MODULE,
@@ -987,24 +985,18 @@ static int erst_close_pstore(struct pstore_info *psi)
987 return 0; 985 return 0;
988} 986}
989 987
990static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count, 988static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
991 struct timespec *time, char **buf, 989 struct timespec *time, struct pstore_info *psi)
992 struct pstore_info *psi)
993{ 990{
994 int rc; 991 int rc;
995 ssize_t len = 0; 992 ssize_t len = 0;
996 u64 record_id; 993 u64 record_id;
997 struct cper_pstore_record *rcd; 994 struct cper_pstore_record *rcd = (struct cper_pstore_record *)
998 size_t rcd_len = sizeof(*rcd) + erst_info.bufsize; 995 (erst_info.buf - sizeof(*rcd));
999 996
1000 if (erst_disable) 997 if (erst_disable)
1001 return -ENODEV; 998 return -ENODEV;
1002 999
1003 rcd = kmalloc(rcd_len, GFP_KERNEL);
1004 if (!rcd) {
1005 rc = -ENOMEM;
1006 goto out;
1007 }
1008skip: 1000skip:
1009 rc = erst_get_record_id_next(&reader_pos, &record_id); 1001 rc = erst_get_record_id_next(&reader_pos, &record_id);
1010 if (rc) 1002 if (rc)
@@ -1012,27 +1004,22 @@ skip:
1012 1004
1013 /* no more record */ 1005 /* no more record */
1014 if (record_id == APEI_ERST_INVALID_RECORD_ID) { 1006 if (record_id == APEI_ERST_INVALID_RECORD_ID) {
1015 rc = -EINVAL; 1007 rc = -1;
1016 goto out; 1008 goto out;
1017 } 1009 }
1018 1010
1019 len = erst_read(record_id, &rcd->hdr, rcd_len); 1011 len = erst_read(record_id, &rcd->hdr, sizeof(*rcd) +
1012 erst_info.bufsize);
1020 /* The record may be cleared by others, try read next record */ 1013 /* The record may be cleared by others, try read next record */
1021 if (len == -ENOENT) 1014 if (len == -ENOENT)
1022 goto skip; 1015 goto skip;
1023 else if (len < sizeof(*rcd)) { 1016 else if (len < 0) {
1024 rc = -EIO; 1017 rc = -1;
1025 goto out; 1018 goto out;
1026 } 1019 }
1027 if (uuid_le_cmp(rcd->hdr.creator_id, CPER_CREATOR_PSTORE) != 0) 1020 if (uuid_le_cmp(rcd->hdr.creator_id, CPER_CREATOR_PSTORE) != 0)
1028 goto skip; 1021 goto skip;
1029 1022
1030 *buf = kmalloc(len, GFP_KERNEL);
1031 if (*buf == NULL) {
1032 rc = -ENOMEM;
1033 goto out;
1034 }
1035 memcpy(*buf, rcd->data, len - sizeof(*rcd));
1036 *id = record_id; 1023 *id = record_id;
1037 if (uuid_le_cmp(rcd->sec_hdr.section_type, 1024 if (uuid_le_cmp(rcd->sec_hdr.section_type,
1038 CPER_SECTION_TYPE_DMESG) == 0) 1025 CPER_SECTION_TYPE_DMESG) == 0)
@@ -1050,17 +1037,14 @@ skip:
1050 time->tv_nsec = 0; 1037 time->tv_nsec = 0;
1051 1038
1052out: 1039out:
1053 kfree(rcd);
1054 return (rc < 0) ? rc : (len - sizeof(*rcd)); 1040 return (rc < 0) ? rc : (len - sizeof(*rcd));
1055} 1041}
1056 1042
1057static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason, 1043static u64 erst_writer(enum pstore_type_id type, unsigned int part,
1058 u64 *id, unsigned int part, int count,
1059 size_t size, struct pstore_info *psi) 1044 size_t size, struct pstore_info *psi)
1060{ 1045{
1061 struct cper_pstore_record *rcd = (struct cper_pstore_record *) 1046 struct cper_pstore_record *rcd = (struct cper_pstore_record *)
1062 (erst_info.buf - sizeof(*rcd)); 1047 (erst_info.buf - sizeof(*rcd));
1063 int ret;
1064 1048
1065 memset(rcd, 0, sizeof(*rcd)); 1049 memset(rcd, 0, sizeof(*rcd));
1066 memcpy(rcd->hdr.signature, CPER_SIG_RECORD, CPER_SIG_SIZE); 1050 memcpy(rcd->hdr.signature, CPER_SIG_RECORD, CPER_SIG_SIZE);
@@ -1095,14 +1079,13 @@ static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
1095 } 1079 }
1096 rcd->sec_hdr.section_severity = CPER_SEV_FATAL; 1080 rcd->sec_hdr.section_severity = CPER_SEV_FATAL;
1097 1081
1098 ret = erst_write(&rcd->hdr); 1082 erst_write(&rcd->hdr);
1099 *id = rcd->hdr.record_id;
1100 1083
1101 return ret; 1084 return rcd->hdr.record_id;
1102} 1085}
1103 1086
1104static int erst_clearer(enum pstore_type_id type, u64 id, int count, 1087static int erst_clearer(enum pstore_type_id type, u64 id,
1105 struct timespec time, struct pstore_info *psi) 1088 struct pstore_info *psi)
1106{ 1089{
1107 return erst_clear(id); 1090 return erst_clear(id);
1108} 1091}
@@ -1127,9 +1110,10 @@ static int __init erst_init(void)
1127 1110
1128 status = acpi_get_table(ACPI_SIG_ERST, 0, 1111 status = acpi_get_table(ACPI_SIG_ERST, 0,
1129 (struct acpi_table_header **)&erst_tab); 1112 (struct acpi_table_header **)&erst_tab);
1130 if (status == AE_NOT_FOUND) 1113 if (status == AE_NOT_FOUND) {
1114 pr_info(ERST_PFX "Table is not found!\n");
1131 goto err; 1115 goto err;
1132 else if (ACPI_FAILURE(status)) { 1116 } else if (ACPI_FAILURE(status)) {
1133 const char *msg = acpi_format_exception(status); 1117 const char *msg = acpi_format_exception(status);
1134 pr_err(ERST_PFX "Failed to get table, %s\n", msg); 1118 pr_err(ERST_PFX "Failed to get table, %s\n", msg);
1135 rc = -EINVAL; 1119 rc = -EINVAL;
@@ -1181,7 +1165,7 @@ static int __init erst_init(void)
1181 goto err_release_erange; 1165 goto err_release_erange;
1182 1166
1183 buf = kmalloc(erst_erange.size, GFP_KERNEL); 1167 buf = kmalloc(erst_erange.size, GFP_KERNEL);
1184 spin_lock_init(&erst_info.buf_lock); 1168 mutex_init(&erst_info.buf_mutex);
1185 if (buf) { 1169 if (buf) {
1186 erst_info.buf = buf + sizeof(struct cper_pstore_record); 1170 erst_info.buf = buf + sizeof(struct cper_pstore_record);
1187 erst_info.bufsize = erst_erange.size - 1171 erst_info.bufsize = erst_erange.size -
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 7ae2750bb45..0784f99a466 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -33,7 +33,6 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/acpi.h> 35#include <linux/acpi.h>
36#include <linux/acpi_io.h>
37#include <linux/io.h> 36#include <linux/io.h>
38#include <linux/interrupt.h> 37#include <linux/interrupt.h>
39#include <linux/timer.h> 38#include <linux/timer.h>
@@ -46,13 +45,11 @@
46#include <linux/irq_work.h> 45#include <linux/irq_work.h>
47#include <linux/llist.h> 46#include <linux/llist.h>
48#include <linux/genalloc.h> 47#include <linux/genalloc.h>
49#include <linux/pci.h>
50#include <linux/aer.h>
51#include <acpi/apei.h> 48#include <acpi/apei.h>
49#include <acpi/atomicio.h>
52#include <acpi/hed.h> 50#include <acpi/hed.h>
53#include <asm/mce.h> 51#include <asm/mce.h>
54#include <asm/tlbflush.h> 52#include <asm/tlbflush.h>
55#include <asm/nmi.h>
56 53
57#include "apei-internal.h" 54#include "apei-internal.h"
58 55
@@ -120,7 +117,7 @@ struct ghes_estatus_cache {
120 struct rcu_head rcu; 117 struct rcu_head rcu;
121}; 118};
122 119
123bool ghes_disable; 120int ghes_disable;
124module_param_named(disable, ghes_disable, bool, 0); 121module_param_named(disable, ghes_disable, bool, 0);
125 122
126static int ghes_panic_timeout __read_mostly = 30; 123static int ghes_panic_timeout __read_mostly = 30;
@@ -301,7 +298,7 @@ static struct ghes *ghes_new(struct acpi_hest_generic *generic)
301 if (!ghes) 298 if (!ghes)
302 return ERR_PTR(-ENOMEM); 299 return ERR_PTR(-ENOMEM);
303 ghes->generic = generic; 300 ghes->generic = generic;
304 rc = apei_map_generic_address(&generic->error_status_address); 301 rc = acpi_pre_map_gar(&generic->error_status_address);
305 if (rc) 302 if (rc)
306 goto err_free; 303 goto err_free;
307 error_block_length = generic->error_block_length; 304 error_block_length = generic->error_block_length;
@@ -321,7 +318,7 @@ static struct ghes *ghes_new(struct acpi_hest_generic *generic)
321 return ghes; 318 return ghes;
322 319
323err_unmap: 320err_unmap:
324 apei_unmap_generic_address(&generic->error_status_address); 321 acpi_post_unmap_gar(&generic->error_status_address);
325err_free: 322err_free:
326 kfree(ghes); 323 kfree(ghes);
327 return ERR_PTR(rc); 324 return ERR_PTR(rc);
@@ -330,7 +327,7 @@ err_free:
330static void ghes_fini(struct ghes *ghes) 327static void ghes_fini(struct ghes *ghes)
331{ 328{
332 kfree(ghes->estatus); 329 kfree(ghes->estatus);
333 apei_unmap_generic_address(&ghes->generic->error_status_address); 330 acpi_post_unmap_gar(&ghes->generic->error_status_address);
334} 331}
335 332
336enum { 333enum {
@@ -401,7 +398,7 @@ static int ghes_read_estatus(struct ghes *ghes, int silent)
401 u32 len; 398 u32 len;
402 int rc; 399 int rc;
403 400
404 rc = apei_read(&buf_paddr, &g->error_status_address); 401 rc = acpi_atomic_read(&buf_paddr, &g->error_status_address);
405 if (rc) { 402 if (rc) {
406 if (!silent && printk_ratelimit()) 403 if (!silent && printk_ratelimit())
407 pr_warning(FW_WARN GHES_PFX 404 pr_warning(FW_WARN GHES_PFX
@@ -478,27 +475,6 @@ static void ghes_do_proc(const struct acpi_hest_generic_status *estatus)
478 } 475 }
479#endif 476#endif
480 } 477 }
481#ifdef CONFIG_ACPI_APEI_PCIEAER
482 else if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
483 CPER_SEC_PCIE)) {
484 struct cper_sec_pcie *pcie_err;
485 pcie_err = (struct cper_sec_pcie *)(gdata+1);
486 if (sev == GHES_SEV_RECOVERABLE &&
487 sec_sev == GHES_SEV_RECOVERABLE &&
488 pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID &&
489 pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO) {
490 unsigned int devfn;
491 int aer_severity;
492 devfn = PCI_DEVFN(pcie_err->device_id.device,
493 pcie_err->device_id.function);
494 aer_severity = cper_severity_to_aer(sev);
495 aer_recover_queue(pcie_err->device_id.segment,
496 pcie_err->device_id.bus,
497 devfn, aer_severity);
498 }
499
500 }
501#endif
502 } 478 }
503} 479}
504 480
@@ -506,22 +482,16 @@ static void __ghes_print_estatus(const char *pfx,
506 const struct acpi_hest_generic *generic, 482 const struct acpi_hest_generic *generic,
507 const struct acpi_hest_generic_status *estatus) 483 const struct acpi_hest_generic_status *estatus)
508{ 484{
509 static atomic_t seqno;
510 unsigned int curr_seqno;
511 char pfx_seq[64];
512
513 if (pfx == NULL) { 485 if (pfx == NULL) {
514 if (ghes_severity(estatus->error_severity) <= 486 if (ghes_severity(estatus->error_severity) <=
515 GHES_SEV_CORRECTED) 487 GHES_SEV_CORRECTED)
516 pfx = KERN_WARNING; 488 pfx = KERN_WARNING HW_ERR;
517 else 489 else
518 pfx = KERN_ERR; 490 pfx = KERN_ERR HW_ERR;
519 } 491 }
520 curr_seqno = atomic_inc_return(&seqno);
521 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
522 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n", 492 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
523 pfx_seq, generic->header.source_id); 493 pfx, generic->header.source_id);
524 apei_estatus_print(pfx_seq, estatus); 494 apei_estatus_print(pfx, estatus);
525} 495}
526 496
527static int ghes_print_estatus(const char *pfx, 497static int ghes_print_estatus(const char *pfx,
@@ -740,34 +710,26 @@ static int ghes_notify_sci(struct notifier_block *this,
740 return ret; 710 return ret;
741} 711}
742 712
743static struct llist_node *llist_nodes_reverse(struct llist_node *llnode)
744{
745 struct llist_node *next, *tail = NULL;
746
747 while (llnode) {
748 next = llnode->next;
749 llnode->next = tail;
750 tail = llnode;
751 llnode = next;
752 }
753
754 return tail;
755}
756
757static void ghes_proc_in_irq(struct irq_work *irq_work) 713static void ghes_proc_in_irq(struct irq_work *irq_work)
758{ 714{
759 struct llist_node *llnode, *next; 715 struct llist_node *llnode, *next, *tail = NULL;
760 struct ghes_estatus_node *estatus_node; 716 struct ghes_estatus_node *estatus_node;
761 struct acpi_hest_generic *generic; 717 struct acpi_hest_generic *generic;
762 struct acpi_hest_generic_status *estatus; 718 struct acpi_hest_generic_status *estatus;
763 u32 len, node_len; 719 u32 len, node_len;
764 720
765 llnode = llist_del_all(&ghes_estatus_llist);
766 /* 721 /*
767 * Because the time order of estatus in list is reversed, 722 * Because the time order of estatus in list is reversed,
768 * revert it back to proper order. 723 * revert it back to proper order.
769 */ 724 */
770 llnode = llist_nodes_reverse(llnode); 725 llnode = llist_del_all(&ghes_estatus_llist);
726 while (llnode) {
727 next = llnode->next;
728 llnode->next = tail;
729 tail = llnode;
730 llnode = next;
731 }
732 llnode = tail;
771 while (llnode) { 733 while (llnode) {
772 next = llnode->next; 734 next = llnode->next;
773 estatus_node = llist_entry(llnode, struct ghes_estatus_node, 735 estatus_node = llist_entry(llnode, struct ghes_estatus_node,
@@ -787,37 +749,15 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
787 } 749 }
788} 750}
789 751
790static void ghes_print_queued_estatus(void) 752static int ghes_notify_nmi(struct notifier_block *this,
791{ 753 unsigned long cmd, void *data)
792 struct llist_node *llnode;
793 struct ghes_estatus_node *estatus_node;
794 struct acpi_hest_generic *generic;
795 struct acpi_hest_generic_status *estatus;
796 u32 len, node_len;
797
798 llnode = llist_del_all(&ghes_estatus_llist);
799 /*
800 * Because the time order of estatus in list is reversed,
801 * revert it back to proper order.
802 */
803 llnode = llist_nodes_reverse(llnode);
804 while (llnode) {
805 estatus_node = llist_entry(llnode, struct ghes_estatus_node,
806 llnode);
807 estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
808 len = apei_estatus_len(estatus);
809 node_len = GHES_ESTATUS_NODE_LEN(len);
810 generic = estatus_node->generic;
811 ghes_print_estatus(NULL, generic, estatus);
812 llnode = llnode->next;
813 }
814}
815
816static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
817{ 754{
818 struct ghes *ghes, *ghes_global = NULL; 755 struct ghes *ghes, *ghes_global = NULL;
819 int sev, sev_global = -1; 756 int sev, sev_global = -1;
820 int ret = NMI_DONE; 757 int ret = NOTIFY_DONE;
758
759 if (cmd != DIE_NMI)
760 return ret;
821 761
822 raw_spin_lock(&ghes_nmi_lock); 762 raw_spin_lock(&ghes_nmi_lock);
823 list_for_each_entry_rcu(ghes, &ghes_nmi, list) { 763 list_for_each_entry_rcu(ghes, &ghes_nmi, list) {
@@ -830,16 +770,15 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
830 sev_global = sev; 770 sev_global = sev;
831 ghes_global = ghes; 771 ghes_global = ghes;
832 } 772 }
833 ret = NMI_HANDLED; 773 ret = NOTIFY_STOP;
834 } 774 }
835 775
836 if (ret == NMI_DONE) 776 if (ret == NOTIFY_DONE)
837 goto out; 777 goto out;
838 778
839 if (sev_global >= GHES_SEV_PANIC) { 779 if (sev_global >= GHES_SEV_PANIC) {
840 oops_begin(); 780 oops_begin();
841 ghes_print_queued_estatus(); 781 __ghes_print_estatus(KERN_EMERG HW_ERR, ghes_global->generic,
842 __ghes_print_estatus(KERN_EMERG, ghes_global->generic,
843 ghes_global->estatus); 782 ghes_global->estatus);
844 /* reboot to log the error! */ 783 /* reboot to log the error! */
845 if (panic_timeout == 0) 784 if (panic_timeout == 0)
@@ -886,6 +825,10 @@ static struct notifier_block ghes_notifier_sci = {
886 .notifier_call = ghes_notify_sci, 825 .notifier_call = ghes_notify_sci,
887}; 826};
888 827
828static struct notifier_block ghes_notifier_nmi = {
829 .notifier_call = ghes_notify_nmi,
830};
831
889static unsigned long ghes_esource_prealloc_size( 832static unsigned long ghes_esource_prealloc_size(
890 const struct acpi_hest_generic *generic) 833 const struct acpi_hest_generic *generic)
891{ 834{
@@ -901,7 +844,7 @@ static unsigned long ghes_esource_prealloc_size(
901 return prealloc_size; 844 return prealloc_size;
902} 845}
903 846
904static int ghes_probe(struct platform_device *ghes_dev) 847static int __devinit ghes_probe(struct platform_device *ghes_dev)
905{ 848{
906 struct acpi_hest_generic *generic; 849 struct acpi_hest_generic *generic;
907 struct ghes *ghes = NULL; 850 struct ghes *ghes = NULL;
@@ -975,8 +918,7 @@ static int ghes_probe(struct platform_device *ghes_dev)
975 ghes_estatus_pool_expand(len); 918 ghes_estatus_pool_expand(len);
976 mutex_lock(&ghes_list_mutex); 919 mutex_lock(&ghes_list_mutex);
977 if (list_empty(&ghes_nmi)) 920 if (list_empty(&ghes_nmi))
978 register_nmi_handler(NMI_LOCAL, ghes_notify_nmi, 0, 921 register_die_notifier(&ghes_notifier_nmi);
979 "ghes");
980 list_add_rcu(&ghes->list, &ghes_nmi); 922 list_add_rcu(&ghes->list, &ghes_nmi);
981 mutex_unlock(&ghes_list_mutex); 923 mutex_unlock(&ghes_list_mutex);
982 break; 924 break;
@@ -994,7 +936,7 @@ err:
994 return rc; 936 return rc;
995} 937}
996 938
997static int ghes_remove(struct platform_device *ghes_dev) 939static int __devexit ghes_remove(struct platform_device *ghes_dev)
998{ 940{
999 struct ghes *ghes; 941 struct ghes *ghes;
1000 struct acpi_hest_generic *generic; 942 struct acpi_hest_generic *generic;
@@ -1022,7 +964,7 @@ static int ghes_remove(struct platform_device *ghes_dev)
1022 mutex_lock(&ghes_list_mutex); 964 mutex_lock(&ghes_list_mutex);
1023 list_del_rcu(&ghes->list); 965 list_del_rcu(&ghes->list);
1024 if (list_empty(&ghes_nmi)) 966 if (list_empty(&ghes_nmi))
1025 unregister_nmi_handler(NMI_LOCAL, "ghes"); 967 unregister_die_notifier(&ghes_notifier_nmi);
1026 mutex_unlock(&ghes_list_mutex); 968 mutex_unlock(&ghes_list_mutex);
1027 /* 969 /*
1028 * To synchronize with NMI handler, ghes can only be 970 * To synchronize with NMI handler, ghes can only be
diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index 7f00cf38098..05fee06f4d6 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -41,7 +41,7 @@
41 41
42#define HEST_PFX "HEST: " 42#define HEST_PFX "HEST: "
43 43
44bool hest_disable; 44int hest_disable;
45EXPORT_SYMBOL_GPL(hest_disable); 45EXPORT_SYMBOL_GPL(hest_disable);
46 46
47/* HEST table parsing */ 47/* HEST table parsing */
@@ -221,9 +221,10 @@ void __init acpi_hest_init(void)
221 221
222 status = acpi_get_table(ACPI_SIG_HEST, 0, 222 status = acpi_get_table(ACPI_SIG_HEST, 0,
223 (struct acpi_table_header **)&hest_tab); 223 (struct acpi_table_header **)&hest_tab);
224 if (status == AE_NOT_FOUND) 224 if (status == AE_NOT_FOUND) {
225 pr_info(HEST_PFX "Table not found.\n");
225 goto err; 226 goto err;
226 else if (ACPI_FAILURE(status)) { 227 } else if (ACPI_FAILURE(status)) {
227 const char *msg = acpi_format_exception(status); 228 const char *msg = acpi_format_exception(status);
228 pr_err(HEST_PFX "Failed to get table, %s\n", msg); 229 pr_err(HEST_PFX "Failed to get table, %s\n", msg);
229 rc = -EINVAL; 230 rc = -EINVAL;
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 7efaeaa53b8..7711d94a040 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -34,7 +34,6 @@
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/suspend.h> 36#include <linux/suspend.h>
37#include <asm/unaligned.h>
38 37
39#ifdef CONFIG_ACPI_PROCFS_POWER 38#ifdef CONFIG_ACPI_PROCFS_POWER
40#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
@@ -96,18 +95,6 @@ enum {
96 ACPI_BATTERY_ALARM_PRESENT, 95 ACPI_BATTERY_ALARM_PRESENT,
97 ACPI_BATTERY_XINFO_PRESENT, 96 ACPI_BATTERY_XINFO_PRESENT,
98 ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, 97 ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
99 /* On Lenovo Thinkpad models from 2010 and 2011, the power unit
100 switches between mWh and mAh depending on whether the system
101 is running on battery or not. When mAh is the unit, most
102 reported values are incorrect and need to be adjusted by
103 10000/design_voltage. Verified on x201, t410, t410s, and x220.
104 Pre-2010 and 2012 models appear to always report in mWh and
105 are thus unaffected (tested with t42, t61, t500, x200, x300,
106 and x230). Also, in mid-2012 Lenovo issued a BIOS update for
107 the 2011 models that fixes the issue (tested on x220 with a
108 post-1.29 BIOS), but as of Nov. 2012, no such update is
109 available for the 2010 models. */
110 ACPI_BATTERY_QUIRK_THINKPAD_MAH,
111}; 98};
112 99
113struct acpi_battery { 100struct acpi_battery {
@@ -263,13 +250,6 @@ static int acpi_battery_get_property(struct power_supply *psy,
263 else 250 else
264 val->intval = battery->capacity_now * 1000; 251 val->intval = battery->capacity_now * 1000;
265 break; 252 break;
266 case POWER_SUPPLY_PROP_CAPACITY:
267 if (battery->capacity_now && battery->full_charge_capacity)
268 val->intval = battery->capacity_now * 100/
269 battery->full_charge_capacity;
270 else
271 val->intval = 0;
272 break;
273 case POWER_SUPPLY_PROP_MODEL_NAME: 253 case POWER_SUPPLY_PROP_MODEL_NAME:
274 val->strval = battery->model_number; 254 val->strval = battery->model_number;
275 break; 255 break;
@@ -296,7 +276,6 @@ static enum power_supply_property charge_battery_props[] = {
296 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 276 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
297 POWER_SUPPLY_PROP_CHARGE_FULL, 277 POWER_SUPPLY_PROP_CHARGE_FULL,
298 POWER_SUPPLY_PROP_CHARGE_NOW, 278 POWER_SUPPLY_PROP_CHARGE_NOW,
299 POWER_SUPPLY_PROP_CAPACITY,
300 POWER_SUPPLY_PROP_MODEL_NAME, 279 POWER_SUPPLY_PROP_MODEL_NAME,
301 POWER_SUPPLY_PROP_MANUFACTURER, 280 POWER_SUPPLY_PROP_MANUFACTURER,
302 POWER_SUPPLY_PROP_SERIAL_NUMBER, 281 POWER_SUPPLY_PROP_SERIAL_NUMBER,
@@ -313,7 +292,6 @@ static enum power_supply_property energy_battery_props[] = {
313 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 292 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
314 POWER_SUPPLY_PROP_ENERGY_FULL, 293 POWER_SUPPLY_PROP_ENERGY_FULL,
315 POWER_SUPPLY_PROP_ENERGY_NOW, 294 POWER_SUPPLY_PROP_ENERGY_NOW,
316 POWER_SUPPLY_PROP_CAPACITY,
317 POWER_SUPPLY_PROP_MODEL_NAME, 295 POWER_SUPPLY_PROP_MODEL_NAME,
318 POWER_SUPPLY_PROP_MANUFACTURER, 296 POWER_SUPPLY_PROP_MANUFACTURER,
319 POWER_SUPPLY_PROP_SERIAL_NUMBER, 297 POWER_SUPPLY_PROP_SERIAL_NUMBER,
@@ -451,21 +429,6 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
451 kfree(buffer.pointer); 429 kfree(buffer.pointer);
452 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)) 430 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags))
453 battery->full_charge_capacity = battery->design_capacity; 431 battery->full_charge_capacity = battery->design_capacity;
454 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags) &&
455 battery->power_unit && battery->design_voltage) {
456 battery->design_capacity = battery->design_capacity *
457 10000 / battery->design_voltage;
458 battery->full_charge_capacity = battery->full_charge_capacity *
459 10000 / battery->design_voltage;
460 battery->design_capacity_warning =
461 battery->design_capacity_warning *
462 10000 / battery->design_voltage;
463 /* Curiously, design_capacity_low, unlike the rest of them,
464 is correct. */
465 /* capacity_granularity_* equal 1 on the systems tested, so
466 it's impossible to tell if they would need an adjustment
467 or not if their values were higher. */
468 }
469 return result; 432 return result;
470} 433}
471 434
@@ -514,11 +477,6 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
514 && battery->capacity_now >= 0 && battery->capacity_now <= 100) 477 && battery->capacity_now >= 0 && battery->capacity_now <= 100)
515 battery->capacity_now = (battery->capacity_now * 478 battery->capacity_now = (battery->capacity_now *
516 battery->full_charge_capacity) / 100; 479 battery->full_charge_capacity) / 100;
517 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags) &&
518 battery->power_unit && battery->design_voltage) {
519 battery->capacity_now = battery->capacity_now *
520 10000 / battery->design_voltage;
521 }
522 return result; 480 return result;
523} 481}
524 482
@@ -628,24 +586,6 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
628 mutex_unlock(&battery->sysfs_lock); 586 mutex_unlock(&battery->sysfs_lock);
629} 587}
630 588
631static void find_battery(const struct dmi_header *dm, void *private)
632{
633 struct acpi_battery *battery = (struct acpi_battery *)private;
634 /* Note: the hardcoded offsets below have been extracted from
635 the source code of dmidecode. */
636 if (dm->type == DMI_ENTRY_PORTABLE_BATTERY && dm->length >= 8) {
637 const u8 *dmi_data = (const u8 *)(dm + 1);
638 int dmi_capacity = get_unaligned((const u16 *)(dmi_data + 6));
639 if (dm->length >= 18)
640 dmi_capacity *= dmi_data[17];
641 if (battery->design_capacity * battery->design_voltage / 1000
642 != dmi_capacity &&
643 battery->design_capacity * 10 == dmi_capacity)
644 set_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH,
645 &battery->flags);
646 }
647}
648
649/* 589/*
650 * According to the ACPI spec, some kinds of primary batteries can 590 * According to the ACPI spec, some kinds of primary batteries can
651 * report percentage battery remaining capacity directly to OS. 591 * report percentage battery remaining capacity directly to OS.
@@ -671,32 +611,6 @@ static void acpi_battery_quirks(struct acpi_battery *battery)
671 battery->capacity_now = (battery->capacity_now * 611 battery->capacity_now = (battery->capacity_now *
672 battery->full_charge_capacity) / 100; 612 battery->full_charge_capacity) / 100;
673 } 613 }
674
675 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags))
676 return ;
677
678 if (battery->power_unit && dmi_name_in_vendors("LENOVO")) {
679 const char *s;
680 s = dmi_get_system_info(DMI_PRODUCT_VERSION);
681 if (s && !strnicmp(s, "ThinkPad", 8)) {
682 dmi_walk(find_battery, battery);
683 if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH,
684 &battery->flags) &&
685 battery->design_voltage) {
686 battery->design_capacity =
687 battery->design_capacity *
688 10000 / battery->design_voltage;
689 battery->full_charge_capacity =
690 battery->full_charge_capacity *
691 10000 / battery->design_voltage;
692 battery->design_capacity_warning =
693 battery->design_capacity_warning *
694 10000 / battery->design_voltage;
695 battery->capacity_now = battery->capacity_now *
696 10000 / battery->design_voltage;
697 }
698 }
699 }
700} 614}
701 615
702static int acpi_battery_update(struct acpi_battery *battery) 616static int acpi_battery_update(struct acpi_battery *battery)
@@ -729,19 +643,11 @@ static int acpi_battery_update(struct acpi_battery *battery)
729 643
730static void acpi_battery_refresh(struct acpi_battery *battery) 644static void acpi_battery_refresh(struct acpi_battery *battery)
731{ 645{
732 int power_unit;
733
734 if (!battery->bat.dev) 646 if (!battery->bat.dev)
735 return; 647 return;
736 648
737 power_unit = battery->power_unit;
738
739 acpi_battery_get_info(battery); 649 acpi_battery_get_info(battery);
740 650 /* The battery may have changed its reporting units. */
741 if (power_unit == battery->power_unit)
742 return;
743
744 /* The battery has changed its reporting units. */
745 sysfs_remove_battery(battery); 651 sysfs_remove_battery(battery);
746 sysfs_add_battery(battery); 652 sysfs_add_battery(battery);
747} 653}
@@ -967,7 +873,7 @@ DECLARE_FILE_FUNCTIONS(alarm);
967 873
968static const struct battery_file { 874static const struct battery_file {
969 struct file_operations ops; 875 struct file_operations ops;
970 umode_t mode; 876 mode_t mode;
971 const char *name; 877 const char *name;
972} acpi_battery_file[] = { 878} acpi_battery_file[] = {
973 FILE_DESCRIPTION_RO(info), 879 FILE_DESCRIPTION_RO(info),
@@ -1129,26 +1035,17 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
1129 return 0; 1035 return 0;
1130} 1036}
1131 1037
1132#ifdef CONFIG_PM_SLEEP
1133/* this is needed to learn about changes made in suspended state */ 1038/* this is needed to learn about changes made in suspended state */
1134static int acpi_battery_resume(struct device *dev) 1039static int acpi_battery_resume(struct acpi_device *device)
1135{ 1040{
1136 struct acpi_battery *battery; 1041 struct acpi_battery *battery;
1137 1042 if (!device)
1138 if (!dev)
1139 return -EINVAL;
1140
1141 battery = acpi_driver_data(to_acpi_device(dev));
1142 if (!battery)
1143 return -EINVAL; 1043 return -EINVAL;
1144 1044 battery = acpi_driver_data(device);
1145 battery->update_time = 0; 1045 battery->update_time = 0;
1146 acpi_battery_update(battery); 1046 acpi_battery_update(battery);
1147 return 0; 1047 return 0;
1148} 1048}
1149#endif
1150
1151static SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume);
1152 1049
1153static struct acpi_driver acpi_battery_driver = { 1050static struct acpi_driver acpi_battery_driver = {
1154 .name = "battery", 1051 .name = "battery",
@@ -1157,10 +1054,10 @@ static struct acpi_driver acpi_battery_driver = {
1157 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 1054 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
1158 .ops = { 1055 .ops = {
1159 .add = acpi_battery_add, 1056 .add = acpi_battery_add,
1057 .resume = acpi_battery_resume,
1160 .remove = acpi_battery_remove, 1058 .remove = acpi_battery_remove,
1161 .notify = acpi_battery_notify, 1059 .notify = acpi_battery_notify,
1162 }, 1060 },
1163 .drv.pm = &acpi_battery_pm,
1164}; 1061};
1165 1062
1166static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) 1063static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
deleted file mode 100644
index be603995854..00000000000
--- a/drivers/acpi/bgrt.c
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * Copyright 2012 Red Hat, Inc <mjg@redhat.com>
3 * Copyright 2012 Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/device.h>
14#include <linux/sysfs.h>
15#include <linux/efi-bgrt.h>
16
17static struct kobject *bgrt_kobj;
18
19static ssize_t show_version(struct device *dev,
20 struct device_attribute *attr, char *buf)
21{
22 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->version);
23}
24static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
25
26static ssize_t show_status(struct device *dev,
27 struct device_attribute *attr, char *buf)
28{
29 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->status);
30}
31static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
32
33static ssize_t show_type(struct device *dev,
34 struct device_attribute *attr, char *buf)
35{
36 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_type);
37}
38static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
39
40static ssize_t show_xoffset(struct device *dev,
41 struct device_attribute *attr, char *buf)
42{
43 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_x);
44}
45static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL);
46
47static ssize_t show_yoffset(struct device *dev,
48 struct device_attribute *attr, char *buf)
49{
50 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_y);
51}
52static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL);
53
54static ssize_t show_image(struct file *file, struct kobject *kobj,
55 struct bin_attribute *attr, char *buf, loff_t off, size_t count)
56{
57 memcpy(buf, attr->private + off, count);
58 return count;
59}
60
61static struct bin_attribute image_attr = {
62 .attr = {
63 .name = "image",
64 .mode = S_IRUGO,
65 },
66 .read = show_image,
67};
68
69static struct attribute *bgrt_attributes[] = {
70 &dev_attr_version.attr,
71 &dev_attr_status.attr,
72 &dev_attr_type.attr,
73 &dev_attr_xoffset.attr,
74 &dev_attr_yoffset.attr,
75 NULL,
76};
77
78static struct attribute_group bgrt_attribute_group = {
79 .attrs = bgrt_attributes,
80};
81
82static int __init bgrt_init(void)
83{
84 int ret;
85
86 if (!bgrt_image)
87 return -ENODEV;
88
89 sysfs_bin_attr_init(&image_attr);
90 image_attr.private = bgrt_image;
91 image_attr.size = bgrt_image_size;
92
93 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
94 if (!bgrt_kobj)
95 return -EINVAL;
96
97 ret = sysfs_create_group(bgrt_kobj, &bgrt_attribute_group);
98 if (ret)
99 goto out_kobject;
100
101 ret = sysfs_create_bin_file(bgrt_kobj, &image_attr);
102 if (ret)
103 goto out_group;
104
105 return 0;
106
107out_group:
108 sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group);
109out_kobject:
110 kobject_put(bgrt_kobj);
111 return ret;
112}
113
114module_init(bgrt_init);
115
116MODULE_AUTHOR("Matthew Garrett, Josh Triplett <josh@joshtriplett.org>");
117MODULE_DESCRIPTION("BGRT boot graphic support");
118MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index cb9629638de..af308d03f49 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h>
31#include <linux/init.h> 32#include <linux/init.h>
32#include <linux/acpi.h> 33#include <linux/acpi.h>
33#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 1f0d457ecbc..437ddbf0c49 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -182,90 +182,47 @@ EXPORT_SYMBOL(acpi_bus_get_private_data);
182 Power Management 182 Power Management
183 -------------------------------------------------------------------------- */ 183 -------------------------------------------------------------------------- */
184 184
185static const char *state_string(int state)
186{
187 switch (state) {
188 case ACPI_STATE_D0:
189 return "D0";
190 case ACPI_STATE_D1:
191 return "D1";
192 case ACPI_STATE_D2:
193 return "D2";
194 case ACPI_STATE_D3_HOT:
195 return "D3hot";
196 case ACPI_STATE_D3_COLD:
197 return "D3";
198 default:
199 return "(unknown)";
200 }
201}
202
203static int __acpi_bus_get_power(struct acpi_device *device, int *state) 185static int __acpi_bus_get_power(struct acpi_device *device, int *state)
204{ 186{
205 int result = ACPI_STATE_UNKNOWN; 187 int result = 0;
188 acpi_status status = 0;
189 unsigned long long psc = 0;
206 190
207 if (!device || !state) 191 if (!device || !state)
208 return -EINVAL; 192 return -EINVAL;
209 193
210 if (!device->flags.power_manageable) { 194 *state = ACPI_STATE_UNKNOWN;
195
196 if (device->flags.power_manageable) {
197 /*
198 * Get the device's power state either directly (via _PSC) or
199 * indirectly (via power resources).
200 */
201 if (device->power.flags.power_resources) {
202 result = acpi_power_get_inferred_state(device, state);
203 if (result)
204 return result;
205 } else if (device->power.flags.explicit_get) {
206 status = acpi_evaluate_integer(device->handle, "_PSC",
207 NULL, &psc);
208 if (ACPI_FAILURE(status))
209 return -ENODEV;
210 *state = (int)psc;
211 }
212 } else {
211 /* TBD: Non-recursive algorithm for walking up hierarchy. */ 213 /* TBD: Non-recursive algorithm for walking up hierarchy. */
212 *state = device->parent ? 214 *state = device->parent ?
213 device->parent->power.state : ACPI_STATE_D0; 215 device->parent->power.state : ACPI_STATE_D0;
214 goto out;
215 }
216
217 /*
218 * Get the device's power state either directly (via _PSC) or
219 * indirectly (via power resources).
220 */
221 if (device->power.flags.explicit_get) {
222 unsigned long long psc;
223 acpi_status status = acpi_evaluate_integer(device->handle,
224 "_PSC", NULL, &psc);
225 if (ACPI_FAILURE(status))
226 return -ENODEV;
227
228 result = psc;
229 }
230 /* The test below covers ACPI_STATE_UNKNOWN too. */
231 if (result <= ACPI_STATE_D2) {
232 ; /* Do nothing. */
233 } else if (device->power.flags.power_resources) {
234 int error = acpi_power_get_inferred_state(device, &result);
235 if (error)
236 return error;
237 } else if (result == ACPI_STATE_D3_HOT) {
238 result = ACPI_STATE_D3;
239 } 216 }
240 217
241 /* 218 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
242 * If we were unsure about the device parent's power state up to this 219 device->pnp.bus_id, *state));
243 * point, the fact that the device is in D0 implies that the parent has
244 * to be in D0 too.
245 */
246 if (device->parent && device->parent->power.state == ACPI_STATE_UNKNOWN
247 && result == ACPI_STATE_D0)
248 device->parent->power.state = ACPI_STATE_D0;
249
250 *state = result;
251
252 out:
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is %s\n",
254 device->pnp.bus_id, state_string(*state)));
255 220
256 return 0; 221 return 0;
257} 222}
258 223
259 224
260/** 225static int __acpi_bus_set_power(struct acpi_device *device, int state)
261 * acpi_device_set_power - Set power state of an ACPI device.
262 * @device: Device to set the power state of.
263 * @state: New power state to set.
264 *
265 * Callers must ensure that the device is power manageable before using this
266 * function.
267 */
268int acpi_device_set_power(struct acpi_device *device, int state)
269{ 226{
270 int result = 0; 227 int result = 0;
271 acpi_status status = AE_OK; 228 acpi_status status = AE_OK;
@@ -277,14 +234,13 @@ int acpi_device_set_power(struct acpi_device *device, int state)
277 /* Make sure this is a valid target state */ 234 /* Make sure this is a valid target state */
278 235
279 if (state == device->power.state) { 236 if (state == device->power.state) {
280 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at %s\n", 237 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
281 state_string(state))); 238 state));
282 return 0; 239 return 0;
283 } 240 }
284 241
285 if (!device->power.states[state].flags.valid) { 242 if (!device->power.states[state].flags.valid) {
286 printk(KERN_WARNING PREFIX "Device does not support %s\n", 243 printk(KERN_WARNING PREFIX "Device does not support D%d\n", state);
287 state_string(state));
288 return -ENODEV; 244 return -ENODEV;
289 } 245 }
290 if (device->parent && (state < device->parent->power.state)) { 246 if (device->parent && (state < device->parent->power.state)) {
@@ -294,10 +250,6 @@ int acpi_device_set_power(struct acpi_device *device, int state)
294 return -ENODEV; 250 return -ENODEV;
295 } 251 }
296 252
297 /* For D3cold we should execute _PS3, not _PS4. */
298 if (state == ACPI_STATE_D3_COLD)
299 object_name[3] = '3';
300
301 /* 253 /*
302 * Transition Power 254 * Transition Power
303 * ---------------- 255 * ----------------
@@ -306,12 +258,6 @@ int acpi_device_set_power(struct acpi_device *device, int state)
306 * a lower-powered state. 258 * a lower-powered state.
307 */ 259 */
308 if (state < device->power.state) { 260 if (state < device->power.state) {
309 if (device->power.state >= ACPI_STATE_D3_HOT &&
310 state != ACPI_STATE_D0) {
311 printk(KERN_WARNING PREFIX
312 "Cannot transition to non-D0 state from D3\n");
313 return -ENODEV;
314 }
315 if (device->power.flags.power_resources) { 261 if (device->power.flags.power_resources) {
316 result = acpi_power_transition(device, state); 262 result = acpi_power_transition(device, state);
317 if (result) 263 if (result)
@@ -344,18 +290,17 @@ int acpi_device_set_power(struct acpi_device *device, int state)
344 end: 290 end:
345 if (result) 291 if (result)
346 printk(KERN_WARNING PREFIX 292 printk(KERN_WARNING PREFIX
347 "Device [%s] failed to transition to %s\n", 293 "Device [%s] failed to transition to D%d\n",
348 device->pnp.bus_id, state_string(state)); 294 device->pnp.bus_id, state);
349 else { 295 else {
350 device->power.state = state; 296 device->power.state = state;
351 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 297 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
352 "Device [%s] transitioned to %s\n", 298 "Device [%s] transitioned to D%d\n",
353 device->pnp.bus_id, state_string(state))); 299 device->pnp.bus_id, state));
354 } 300 }
355 301
356 return result; 302 return result;
357} 303}
358EXPORT_SYMBOL(acpi_device_set_power);
359 304
360 305
361int acpi_bus_set_power(acpi_handle handle, int state) 306int acpi_bus_set_power(acpi_handle handle, int state)
@@ -374,7 +319,7 @@ int acpi_bus_set_power(acpi_handle handle, int state)
374 return -ENODEV; 319 return -ENODEV;
375 } 320 }
376 321
377 return acpi_device_set_power(device, state); 322 return __acpi_bus_set_power(device, state);
378} 323}
379EXPORT_SYMBOL(acpi_bus_set_power); 324EXPORT_SYMBOL(acpi_bus_set_power);
380 325
@@ -417,7 +362,7 @@ int acpi_bus_update_power(acpi_handle handle, int *state_p)
417 if (result) 362 if (result)
418 return result; 363 return result;
419 364
420 result = acpi_device_set_power(device, state); 365 result = __acpi_bus_set_power(device, state);
421 if (!result && state_p) 366 if (!result && state_p)
422 *state_p = state; 367 *state_p = state;
423 368
@@ -599,10 +544,6 @@ static void acpi_bus_osc_support(void)
599 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT; 544 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT;
600#endif 545#endif
601 546
602#ifdef ACPI_HOTPLUG_OST
603 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_HOTPLUG_OST_SUPPORT;
604#endif
605
606 if (!ghes_disable) 547 if (!ghes_disable)
607 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_APEI_SUPPORT; 548 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_APEI_SUPPORT;
608 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) 549 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
@@ -970,7 +911,10 @@ void __init acpi_early_init(void)
970 } 911 }
971#endif 912#endif
972 913
973 status = acpi_enable_subsystem(~ACPI_NO_ACPI_ENABLE); 914 status =
915 acpi_enable_subsystem(~
916 (ACPI_NO_HARDWARE_INIT |
917 ACPI_NO_ACPI_ENABLE));
974 if (ACPI_FAILURE(status)) { 918 if (ACPI_FAILURE(status)) {
975 printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); 919 printk(KERN_ERR PREFIX "Unable to enable ACPI\n");
976 goto error0; 920 goto error0;
@@ -991,7 +935,8 @@ static int __init acpi_bus_init(void)
991 935
992 acpi_os_initialize1(); 936 acpi_os_initialize1();
993 937
994 status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE); 938 status =
939 acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);
995 if (ACPI_FAILURE(status)) { 940 if (ACPI_FAILURE(status)) {
996 printk(KERN_ERR PREFIX 941 printk(KERN_ERR PREFIX
997 "Unable to start the ACPI Interpreter\n"); 942 "Unable to start the ACPI Interpreter\n");
@@ -1009,6 +954,8 @@ static int __init acpi_bus_init(void)
1009 status = acpi_ec_ecdt_probe(); 954 status = acpi_ec_ecdt_probe();
1010 /* Ignore result. Not having an ECDT is not fatal. */ 955 /* Ignore result. Not having an ECDT is not fatal. */
1011 956
957 acpi_bus_osc_support();
958
1012 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); 959 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
1013 if (ACPI_FAILURE(status)) { 960 if (ACPI_FAILURE(status)) {
1014 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n"); 961 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
@@ -1016,12 +963,6 @@ static int __init acpi_bus_init(void)
1016 } 963 }
1017 964
1018 /* 965 /*
1019 * _OSC method may exist in module level code,
1020 * so it must be run after ACPI_FULL_INITIALIZATION
1021 */
1022 acpi_bus_osc_support();
1023
1024 /*
1025 * _PDC control method may load dynamic SSDT tables, 966 * _PDC control method may load dynamic SSDT tables,
1026 * and we need to install the table handler before that. 967 * and we need to install the table handler before that.
1027 */ 968 */
@@ -1073,7 +1014,6 @@ static int __init acpi_bus_init(void)
1073} 1014}
1074 1015
1075struct kobject *acpi_kobj; 1016struct kobject *acpi_kobj;
1076EXPORT_SYMBOL_GPL(acpi_kobj);
1077 1017
1078static int __init acpi_init(void) 1018static int __init acpi_init(void)
1079{ 1019{
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index f0d936b65e3..d27d072472f 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -76,23 +76,19 @@ MODULE_DEVICE_TABLE(acpi, button_device_ids);
76 76
77static int acpi_button_add(struct acpi_device *device); 77static int acpi_button_add(struct acpi_device *device);
78static int acpi_button_remove(struct acpi_device *device, int type); 78static int acpi_button_remove(struct acpi_device *device, int type);
79static int acpi_button_resume(struct acpi_device *device);
79static void acpi_button_notify(struct acpi_device *device, u32 event); 80static void acpi_button_notify(struct acpi_device *device, u32 event);
80 81
81#ifdef CONFIG_PM_SLEEP
82static int acpi_button_resume(struct device *dev);
83#endif
84static SIMPLE_DEV_PM_OPS(acpi_button_pm, NULL, acpi_button_resume);
85
86static struct acpi_driver acpi_button_driver = { 82static struct acpi_driver acpi_button_driver = {
87 .name = "button", 83 .name = "button",
88 .class = ACPI_BUTTON_CLASS, 84 .class = ACPI_BUTTON_CLASS,
89 .ids = button_device_ids, 85 .ids = button_device_ids,
90 .ops = { 86 .ops = {
91 .add = acpi_button_add, 87 .add = acpi_button_add,
88 .resume = acpi_button_resume,
92 .remove = acpi_button_remove, 89 .remove = acpi_button_remove,
93 .notify = acpi_button_notify, 90 .notify = acpi_button_notify,
94 }, 91 },
95 .drv.pm = &acpi_button_pm,
96}; 92};
97 93
98struct acpi_button { 94struct acpi_button {
@@ -312,17 +308,14 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
312 } 308 }
313} 309}
314 310
315#ifdef CONFIG_PM_SLEEP 311static int acpi_button_resume(struct acpi_device *device)
316static int acpi_button_resume(struct device *dev)
317{ 312{
318 struct acpi_device *device = to_acpi_device(dev);
319 struct acpi_button *button = acpi_driver_data(device); 313 struct acpi_button *button = acpi_driver_data(device);
320 314
321 if (button->type == ACPI_BUTTON_TYPE_LID) 315 if (button->type == ACPI_BUTTON_TYPE_LID)
322 return acpi_lid_send_state(device); 316 return acpi_lid_send_state(device);
323 return 0; 317 return 0;
324} 318}
325#endif
326 319
327static int acpi_button_add(struct acpi_device *device) 320static int acpi_button_add(struct acpi_device *device)
328{ 321{
@@ -450,4 +443,15 @@ static int acpi_button_remove(struct acpi_device *device, int type)
450 return 0; 443 return 0;
451} 444}
452 445
453module_acpi_driver(acpi_button_driver); 446static int __init acpi_button_init(void)
447{
448 return acpi_bus_register_driver(&acpi_button_driver);
449}
450
451static void __exit acpi_button_exit(void)
452{
453 acpi_bus_unregister_driver(&acpi_button_driver);
454}
455
456module_init(acpi_button_init);
457module_exit(acpi_button_exit);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 811910b50b7..45cd03b4630 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -92,24 +92,17 @@ static int is_device_present(acpi_handle handle)
92 return ((sta & ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT); 92 return ((sta & ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT);
93} 93}
94 94
95static bool is_container_device(const char *hid)
96{
97 const struct acpi_device_id *container_id;
98
99 for (container_id = container_device_ids;
100 container_id->id[0]; container_id++) {
101 if (!strcmp((char *)container_id->id, hid))
102 return true;
103 }
104
105 return false;
106}
107
108/*******************************************************************/ 95/*******************************************************************/
109static int acpi_container_add(struct acpi_device *device) 96static int acpi_container_add(struct acpi_device *device)
110{ 97{
111 struct acpi_container *container; 98 struct acpi_container *container;
112 99
100
101 if (!device) {
102 printk(KERN_ERR PREFIX "device is NULL\n");
103 return -EINVAL;
104 }
105
113 container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL); 106 container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL);
114 if (!container) 107 if (!container)
115 return -ENOMEM; 108 return -ENOMEM;
@@ -165,56 +158,43 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
165 int result; 158 int result;
166 int present; 159 int present;
167 acpi_status status; 160 acpi_status status;
168 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 161
162
163 present = is_device_present(handle);
169 164
170 switch (type) { 165 switch (type) {
171 case ACPI_NOTIFY_BUS_CHECK: 166 case ACPI_NOTIFY_BUS_CHECK:
172 /* Fall through */ 167 /* Fall through */
173 case ACPI_NOTIFY_DEVICE_CHECK: 168 case ACPI_NOTIFY_DEVICE_CHECK:
174 pr_debug("Container driver received %s event\n", 169 printk(KERN_WARNING "Container driver received %s event\n",
175 (type == ACPI_NOTIFY_BUS_CHECK) ? 170 (type == ACPI_NOTIFY_BUS_CHECK) ?
176 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); 171 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
177
178 present = is_device_present(handle);
179 status = acpi_bus_get_device(handle, &device); 172 status = acpi_bus_get_device(handle, &device);
180 if (!present) { 173 if (present) {
174 if (ACPI_FAILURE(status) || !device) {
175 result = container_device_add(&device, handle);
176 if (!result)
177 kobject_uevent(&device->dev.kobj,
178 KOBJ_ONLINE);
179 else
180 printk(KERN_WARNING
181 "Failed to add container\n");
182 }
183 } else {
181 if (ACPI_SUCCESS(status)) { 184 if (ACPI_SUCCESS(status)) {
182 /* device exist and this is a remove request */ 185 /* device exist and this is a remove request */
183 device->flags.eject_pending = 1;
184 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 186 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
185 return;
186 } 187 }
187 break;
188 }
189
190 if (!ACPI_FAILURE(status) || device)
191 break;
192
193 result = container_device_add(&device, handle);
194 if (result) {
195 acpi_handle_warn(handle, "Failed to add container\n");
196 break;
197 } 188 }
198
199 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
200 ost_code = ACPI_OST_SC_SUCCESS;
201 break; 189 break;
202
203 case ACPI_NOTIFY_EJECT_REQUEST: 190 case ACPI_NOTIFY_EJECT_REQUEST:
204 if (!acpi_bus_get_device(handle, &device) && device) { 191 if (!acpi_bus_get_device(handle, &device) && device) {
205 device->flags.eject_pending = 1;
206 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 192 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
207 return;
208 } 193 }
209 break; 194 break;
210
211 default: 195 default:
212 /* non-hotplug event; possibly handled by other handler */ 196 break;
213 return;
214 } 197 }
215
216 /* Inform firmware that the hotplug operation has completed */
217 (void) acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
218 return; 198 return;
219} 199}
220 200
@@ -239,8 +219,10 @@ container_walk_namespace_cb(acpi_handle handle,
239 goto end; 219 goto end;
240 } 220 }
241 221
242 if (!is_container_device(hid)) 222 if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") &&
223 strcmp(hid, "PNP0A06")) {
243 goto end; 224 goto end;
225 }
244 226
245 switch (*action) { 227 switch (*action) {
246 case INSTALL_NOTIFY_HANDLER: 228 case INSTALL_NOTIFY_HANDLER:
diff --git a/drivers/acpi/debugfs.c b/drivers/acpi/debugfs.c
index b55d6a20dc0..182a9fc3635 100644
--- a/drivers/acpi/debugfs.c
+++ b/drivers/acpi/debugfs.c
@@ -2,7 +2,6 @@
2 * debugfs.c - ACPI debugfs interface to userspace. 2 * debugfs.c - ACPI debugfs interface to userspace.
3 */ 3 */
4 4
5#include <linux/export.h>
6#include <linux/init.h> 5#include <linux/init.h>
7#include <linux/debugfs.h> 6#include <linux/debugfs.h>
8#include <acpi/acpi_drivers.h> 7#include <acpi/acpi_drivers.h>
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
deleted file mode 100644
index c6ff606c6d5..00000000000
--- a/drivers/acpi/device_pm.c
+++ /dev/null
@@ -1,667 +0,0 @@
1/*
2 * drivers/acpi/device_pm.c - ACPI device power management routines.
3 *
4 * Copyright (C) 2012, Intel Corp.
5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */
24
25#include <linux/device.h>
26#include <linux/export.h>
27#include <linux/mutex.h>
28#include <linux/pm_qos.h>
29#include <linux/pm_runtime.h>
30
31#include <acpi/acpi.h>
32#include <acpi/acpi_bus.h>
33
34static DEFINE_MUTEX(acpi_pm_notifier_lock);
35
36/**
37 * acpi_add_pm_notifier - Register PM notifier for given ACPI device.
38 * @adev: ACPI device to add the notifier for.
39 * @context: Context information to pass to the notifier routine.
40 *
41 * NOTE: @adev need not be a run-wake or wakeup device to be a valid source of
42 * PM wakeup events. For example, wakeup events may be generated for bridges
43 * if one of the devices below the bridge is signaling wakeup, even if the
44 * bridge itself doesn't have a wakeup GPE associated with it.
45 */
46acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
47 acpi_notify_handler handler, void *context)
48{
49 acpi_status status = AE_ALREADY_EXISTS;
50
51 mutex_lock(&acpi_pm_notifier_lock);
52
53 if (adev->wakeup.flags.notifier_present)
54 goto out;
55
56 status = acpi_install_notify_handler(adev->handle,
57 ACPI_SYSTEM_NOTIFY,
58 handler, context);
59 if (ACPI_FAILURE(status))
60 goto out;
61
62 adev->wakeup.flags.notifier_present = true;
63
64 out:
65 mutex_unlock(&acpi_pm_notifier_lock);
66 return status;
67}
68
69/**
70 * acpi_remove_pm_notifier - Unregister PM notifier from given ACPI device.
71 * @adev: ACPI device to remove the notifier from.
72 */
73acpi_status acpi_remove_pm_notifier(struct acpi_device *adev,
74 acpi_notify_handler handler)
75{
76 acpi_status status = AE_BAD_PARAMETER;
77
78 mutex_lock(&acpi_pm_notifier_lock);
79
80 if (!adev->wakeup.flags.notifier_present)
81 goto out;
82
83 status = acpi_remove_notify_handler(adev->handle,
84 ACPI_SYSTEM_NOTIFY,
85 handler);
86 if (ACPI_FAILURE(status))
87 goto out;
88
89 adev->wakeup.flags.notifier_present = false;
90
91 out:
92 mutex_unlock(&acpi_pm_notifier_lock);
93 return status;
94}
95
96/**
97 * acpi_device_power_state - Get preferred power state of ACPI device.
98 * @dev: Device whose preferred target power state to return.
99 * @adev: ACPI device node corresponding to @dev.
100 * @target_state: System state to match the resultant device state.
101 * @d_max_in: Deepest low-power state to take into consideration.
102 * @d_min_p: Location to store the upper limit of the allowed states range.
103 * Return value: Preferred power state of the device on success, -ENODEV
104 * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure
105 *
106 * Find the lowest power (highest number) ACPI device power state that the
107 * device can be in while the system is in the state represented by
108 * @target_state. If @d_min_p is set, the highest power (lowest number) device
109 * power state that @dev can be in for the given system sleep state is stored
110 * at the location pointed to by it.
111 *
112 * Callers must ensure that @dev and @adev are valid pointers and that @adev
113 * actually corresponds to @dev before using this function.
114 */
115int acpi_device_power_state(struct device *dev, struct acpi_device *adev,
116 u32 target_state, int d_max_in, int *d_min_p)
117{
118 char acpi_method[] = "_SxD";
119 unsigned long long d_min, d_max;
120 bool wakeup = false;
121
122 if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3)
123 return -EINVAL;
124
125 if (d_max_in > ACPI_STATE_D3_HOT) {
126 enum pm_qos_flags_status stat;
127
128 stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF);
129 if (stat == PM_QOS_FLAGS_ALL)
130 d_max_in = ACPI_STATE_D3_HOT;
131 }
132
133 acpi_method[2] = '0' + target_state;
134 /*
135 * If the sleep state is S0, the lowest limit from ACPI is D3,
136 * but if the device has _S0W, we will use the value from _S0W
137 * as the lowest limit from ACPI. Finally, we will constrain
138 * the lowest limit with the specified one.
139 */
140 d_min = ACPI_STATE_D0;
141 d_max = ACPI_STATE_D3;
142
143 /*
144 * If present, _SxD methods return the minimum D-state (highest power
145 * state) we can use for the corresponding S-states. Otherwise, the
146 * minimum D-state is D0 (ACPI 3.x).
147 *
148 * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
149 * provided -- that's our fault recovery, we ignore retval.
150 */
151 if (target_state > ACPI_STATE_S0) {
152 acpi_evaluate_integer(adev->handle, acpi_method, NULL, &d_min);
153 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid
154 && adev->wakeup.sleep_state >= target_state;
155 } else if (dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) !=
156 PM_QOS_FLAGS_NONE) {
157 wakeup = adev->wakeup.flags.valid;
158 }
159
160 /*
161 * If _PRW says we can wake up the system from the target sleep state,
162 * the D-state returned by _SxD is sufficient for that (we assume a
163 * wakeup-aware driver if wake is set). Still, if _SxW exists
164 * (ACPI 3.x), it should return the maximum (lowest power) D-state that
165 * can wake the system. _S0W may be valid, too.
166 */
167 if (wakeup) {
168 acpi_status status;
169
170 acpi_method[3] = 'W';
171 status = acpi_evaluate_integer(adev->handle, acpi_method, NULL,
172 &d_max);
173 if (ACPI_FAILURE(status)) {
174 if (target_state != ACPI_STATE_S0 ||
175 status != AE_NOT_FOUND)
176 d_max = d_min;
177 } else if (d_max < d_min) {
178 /* Warn the user of the broken DSDT */
179 printk(KERN_WARNING "ACPI: Wrong value from %s\n",
180 acpi_method);
181 /* Sanitize it */
182 d_min = d_max;
183 }
184 }
185
186 if (d_max_in < d_min)
187 return -EINVAL;
188 if (d_min_p)
189 *d_min_p = d_min;
190 /* constrain d_max with specified lowest limit (max number) */
191 if (d_max > d_max_in) {
192 for (d_max = d_max_in; d_max > d_min; d_max--) {
193 if (adev->power.states[d_max].flags.valid)
194 break;
195 }
196 }
197 return d_max;
198}
199EXPORT_SYMBOL_GPL(acpi_device_power_state);
200
201/**
202 * acpi_pm_device_sleep_state - Get preferred power state of ACPI device.
203 * @dev: Device whose preferred target power state to return.
204 * @d_min_p: Location to store the upper limit of the allowed states range.
205 * @d_max_in: Deepest low-power state to take into consideration.
206 * Return value: Preferred power state of the device on success, -ENODEV
207 * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure
208 *
209 * The caller must ensure that @dev is valid before using this function.
210 */
211int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
212{
213 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
214 struct acpi_device *adev;
215
216 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
217 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
218 return -ENODEV;
219 }
220
221 return acpi_device_power_state(dev, adev, acpi_target_system_state(),
222 d_max_in, d_min_p);
223}
224EXPORT_SYMBOL(acpi_pm_device_sleep_state);
225
226#ifdef CONFIG_PM_RUNTIME
227/**
228 * acpi_wakeup_device - Wakeup notification handler for ACPI devices.
229 * @handle: ACPI handle of the device the notification is for.
230 * @event: Type of the signaled event.
231 * @context: Device corresponding to @handle.
232 */
233static void acpi_wakeup_device(acpi_handle handle, u32 event, void *context)
234{
235 struct device *dev = context;
236
237 if (event == ACPI_NOTIFY_DEVICE_WAKE && dev) {
238 pm_wakeup_event(dev, 0);
239 pm_runtime_resume(dev);
240 }
241}
242
243/**
244 * __acpi_device_run_wake - Enable/disable runtime remote wakeup for device.
245 * @adev: ACPI device to enable/disable the remote wakeup for.
246 * @enable: Whether to enable or disable the wakeup functionality.
247 *
248 * Enable/disable the GPE associated with @adev so that it can generate
249 * wakeup signals for the device in response to external (remote) events and
250 * enable/disable device wakeup power.
251 *
252 * Callers must ensure that @adev is a valid ACPI device node before executing
253 * this function.
254 */
255int __acpi_device_run_wake(struct acpi_device *adev, bool enable)
256{
257 struct acpi_device_wakeup *wakeup = &adev->wakeup;
258
259 if (enable) {
260 acpi_status res;
261 int error;
262
263 error = acpi_enable_wakeup_device_power(adev, ACPI_STATE_S0);
264 if (error)
265 return error;
266
267 res = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number);
268 if (ACPI_FAILURE(res)) {
269 acpi_disable_wakeup_device_power(adev);
270 return -EIO;
271 }
272 } else {
273 acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number);
274 acpi_disable_wakeup_device_power(adev);
275 }
276 return 0;
277}
278
279/**
280 * acpi_pm_device_run_wake - Enable/disable remote wakeup for given device.
281 * @dev: Device to enable/disable the platform to wake up.
282 * @enable: Whether to enable or disable the wakeup functionality.
283 */
284int acpi_pm_device_run_wake(struct device *phys_dev, bool enable)
285{
286 struct acpi_device *adev;
287 acpi_handle handle;
288
289 if (!device_run_wake(phys_dev))
290 return -EINVAL;
291
292 handle = DEVICE_ACPI_HANDLE(phys_dev);
293 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
294 dev_dbg(phys_dev, "ACPI handle without context in %s!\n",
295 __func__);
296 return -ENODEV;
297 }
298
299 return __acpi_device_run_wake(adev, enable);
300}
301EXPORT_SYMBOL(acpi_pm_device_run_wake);
302#else
303static inline void acpi_wakeup_device(acpi_handle handle, u32 event,
304 void *context) {}
305#endif /* CONFIG_PM_RUNTIME */
306
307 #ifdef CONFIG_PM_SLEEP
308/**
309 * __acpi_device_sleep_wake - Enable or disable device to wake up the system.
310 * @dev: Device to enable/desible to wake up the system.
311 * @target_state: System state the device is supposed to wake up from.
312 * @enable: Whether to enable or disable @dev to wake up the system.
313 */
314int __acpi_device_sleep_wake(struct acpi_device *adev, u32 target_state,
315 bool enable)
316{
317 return enable ?
318 acpi_enable_wakeup_device_power(adev, target_state) :
319 acpi_disable_wakeup_device_power(adev);
320}
321
322/**
323 * acpi_pm_device_sleep_wake - Enable or disable device to wake up the system.
324 * @dev: Device to enable/desible to wake up the system from sleep states.
325 * @enable: Whether to enable or disable @dev to wake up the system.
326 */
327int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
328{
329 acpi_handle handle;
330 struct acpi_device *adev;
331 int error;
332
333 if (!device_can_wakeup(dev))
334 return -EINVAL;
335
336 handle = DEVICE_ACPI_HANDLE(dev);
337 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
338 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
339 return -ENODEV;
340 }
341
342 error = __acpi_device_sleep_wake(adev, acpi_target_system_state(),
343 enable);
344 if (!error)
345 dev_info(dev, "System wakeup %s by ACPI\n",
346 enable ? "enabled" : "disabled");
347
348 return error;
349}
350#endif /* CONFIG_PM_SLEEP */
351
352/**
353 * acpi_dev_pm_get_node - Get ACPI device node for the given physical device.
354 * @dev: Device to get the ACPI node for.
355 */
356static struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
357{
358 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
359 struct acpi_device *adev;
360
361 return handle && !acpi_bus_get_device(handle, &adev) ? adev : NULL;
362}
363
364/**
365 * acpi_dev_pm_low_power - Put ACPI device into a low-power state.
366 * @dev: Device to put into a low-power state.
367 * @adev: ACPI device node corresponding to @dev.
368 * @system_state: System state to choose the device state for.
369 */
370static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev,
371 u32 system_state)
372{
373 int power_state;
374
375 if (!acpi_device_power_manageable(adev))
376 return 0;
377
378 power_state = acpi_device_power_state(dev, adev, system_state,
379 ACPI_STATE_D3, NULL);
380 if (power_state < ACPI_STATE_D0 || power_state > ACPI_STATE_D3)
381 return -EIO;
382
383 return acpi_device_set_power(adev, power_state);
384}
385
386/**
387 * acpi_dev_pm_full_power - Put ACPI device into the full-power state.
388 * @adev: ACPI device node to put into the full-power state.
389 */
390static int acpi_dev_pm_full_power(struct acpi_device *adev)
391{
392 return acpi_device_power_manageable(adev) ?
393 acpi_device_set_power(adev, ACPI_STATE_D0) : 0;
394}
395
396#ifdef CONFIG_PM_RUNTIME
397/**
398 * acpi_dev_runtime_suspend - Put device into a low-power state using ACPI.
399 * @dev: Device to put into a low-power state.
400 *
401 * Put the given device into a runtime low-power state using the standard ACPI
402 * mechanism. Set up remote wakeup if desired, choose the state to put the
403 * device into (this checks if remote wakeup is expected to work too), and set
404 * the power state of the device.
405 */
406int acpi_dev_runtime_suspend(struct device *dev)
407{
408 struct acpi_device *adev = acpi_dev_pm_get_node(dev);
409 bool remote_wakeup;
410 int error;
411
412 if (!adev)
413 return 0;
414
415 remote_wakeup = dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) >
416 PM_QOS_FLAGS_NONE;
417 error = __acpi_device_run_wake(adev, remote_wakeup);
418 if (remote_wakeup && error)
419 return -EAGAIN;
420
421 error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
422 if (error)
423 __acpi_device_run_wake(adev, false);
424
425 return error;
426}
427EXPORT_SYMBOL_GPL(acpi_dev_runtime_suspend);
428
429/**
430 * acpi_dev_runtime_resume - Put device into the full-power state using ACPI.
431 * @dev: Device to put into the full-power state.
432 *
433 * Put the given device into the full-power state using the standard ACPI
434 * mechanism at run time. Set the power state of the device to ACPI D0 and
435 * disable remote wakeup.
436 */
437int acpi_dev_runtime_resume(struct device *dev)
438{
439 struct acpi_device *adev = acpi_dev_pm_get_node(dev);
440 int error;
441
442 if (!adev)
443 return 0;
444
445 error = acpi_dev_pm_full_power(adev);
446 __acpi_device_run_wake(adev, false);
447 return error;
448}
449EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume);
450
451/**
452 * acpi_subsys_runtime_suspend - Suspend device using ACPI.
453 * @dev: Device to suspend.
454 *
455 * Carry out the generic runtime suspend procedure for @dev and use ACPI to put
456 * it into a runtime low-power state.
457 */
458int acpi_subsys_runtime_suspend(struct device *dev)
459{
460 int ret = pm_generic_runtime_suspend(dev);
461 return ret ? ret : acpi_dev_runtime_suspend(dev);
462}
463EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
464
465/**
466 * acpi_subsys_runtime_resume - Resume device using ACPI.
467 * @dev: Device to Resume.
468 *
469 * Use ACPI to put the given device into the full-power state and carry out the
470 * generic runtime resume procedure for it.
471 */
472int acpi_subsys_runtime_resume(struct device *dev)
473{
474 int ret = acpi_dev_runtime_resume(dev);
475 return ret ? ret : pm_generic_runtime_resume(dev);
476}
477EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume);
478#endif /* CONFIG_PM_RUNTIME */
479
480#ifdef CONFIG_PM_SLEEP
481/**
482 * acpi_dev_suspend_late - Put device into a low-power state using ACPI.
483 * @dev: Device to put into a low-power state.
484 *
485 * Put the given device into a low-power state during system transition to a
486 * sleep state using the standard ACPI mechanism. Set up system wakeup if
487 * desired, choose the state to put the device into (this checks if system
488 * wakeup is expected to work too), and set the power state of the device.
489 */
490int acpi_dev_suspend_late(struct device *dev)
491{
492 struct acpi_device *adev = acpi_dev_pm_get_node(dev);
493 u32 target_state;
494 bool wakeup;
495 int error;
496
497 if (!adev)
498 return 0;
499
500 target_state = acpi_target_system_state();
501 wakeup = device_may_wakeup(dev);
502 error = __acpi_device_sleep_wake(adev, target_state, wakeup);
503 if (wakeup && error)
504 return error;
505
506 error = acpi_dev_pm_low_power(dev, adev, target_state);
507 if (error)
508 __acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false);
509
510 return error;
511}
512EXPORT_SYMBOL_GPL(acpi_dev_suspend_late);
513
514/**
515 * acpi_dev_resume_early - Put device into the full-power state using ACPI.
516 * @dev: Device to put into the full-power state.
517 *
518 * Put the given device into the full-power state using the standard ACPI
519 * mechanism during system transition to the working state. Set the power
520 * state of the device to ACPI D0 and disable remote wakeup.
521 */
522int acpi_dev_resume_early(struct device *dev)
523{
524 struct acpi_device *adev = acpi_dev_pm_get_node(dev);
525 int error;
526
527 if (!adev)
528 return 0;
529
530 error = acpi_dev_pm_full_power(adev);
531 __acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false);
532 return error;
533}
534EXPORT_SYMBOL_GPL(acpi_dev_resume_early);
535
536/**
537 * acpi_subsys_prepare - Prepare device for system transition to a sleep state.
538 * @dev: Device to prepare.
539 */
540int acpi_subsys_prepare(struct device *dev)
541{
542 /*
543 * Follow PCI and resume devices suspended at run time before running
544 * their system suspend callbacks.
545 */
546 pm_runtime_resume(dev);
547 return pm_generic_prepare(dev);
548}
549EXPORT_SYMBOL_GPL(acpi_subsys_prepare);
550
551/**
552 * acpi_subsys_suspend_late - Suspend device using ACPI.
553 * @dev: Device to suspend.
554 *
555 * Carry out the generic late suspend procedure for @dev and use ACPI to put
556 * it into a low-power state during system transition into a sleep state.
557 */
558int acpi_subsys_suspend_late(struct device *dev)
559{
560 int ret = pm_generic_suspend_late(dev);
561 return ret ? ret : acpi_dev_suspend_late(dev);
562}
563EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late);
564
565/**
566 * acpi_subsys_resume_early - Resume device using ACPI.
567 * @dev: Device to Resume.
568 *
569 * Use ACPI to put the given device into the full-power state and carry out the
570 * generic early resume procedure for it during system transition into the
571 * working state.
572 */
573int acpi_subsys_resume_early(struct device *dev)
574{
575 int ret = acpi_dev_resume_early(dev);
576 return ret ? ret : pm_generic_resume_early(dev);
577}
578EXPORT_SYMBOL_GPL(acpi_subsys_resume_early);
579#endif /* CONFIG_PM_SLEEP */
580
581static struct dev_pm_domain acpi_general_pm_domain = {
582 .ops = {
583#ifdef CONFIG_PM_RUNTIME
584 .runtime_suspend = acpi_subsys_runtime_suspend,
585 .runtime_resume = acpi_subsys_runtime_resume,
586 .runtime_idle = pm_generic_runtime_idle,
587#endif
588#ifdef CONFIG_PM_SLEEP
589 .prepare = acpi_subsys_prepare,
590 .suspend_late = acpi_subsys_suspend_late,
591 .resume_early = acpi_subsys_resume_early,
592 .poweroff_late = acpi_subsys_suspend_late,
593 .restore_early = acpi_subsys_resume_early,
594#endif
595 },
596};
597
598/**
599 * acpi_dev_pm_attach - Prepare device for ACPI power management.
600 * @dev: Device to prepare.
601 * @power_on: Whether or not to power on the device.
602 *
603 * If @dev has a valid ACPI handle that has a valid struct acpi_device object
604 * attached to it, install a wakeup notification handler for the device and
605 * add it to the general ACPI PM domain. If @power_on is set, the device will
606 * be put into the ACPI D0 state before the function returns.
607 *
608 * This assumes that the @dev's bus type uses generic power management callbacks
609 * (or doesn't use any power management callbacks at all).
610 *
611 * Callers must ensure proper synchronization of this function with power
612 * management callbacks.
613 */
614int acpi_dev_pm_attach(struct device *dev, bool power_on)
615{
616 struct acpi_device *adev = acpi_dev_pm_get_node(dev);
617
618 if (!adev)
619 return -ENODEV;
620
621 if (dev->pm_domain)
622 return -EEXIST;
623
624 acpi_add_pm_notifier(adev, acpi_wakeup_device, dev);
625 dev->pm_domain = &acpi_general_pm_domain;
626 if (power_on) {
627 acpi_dev_pm_full_power(adev);
628 __acpi_device_run_wake(adev, false);
629 }
630 return 0;
631}
632EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
633
634/**
635 * acpi_dev_pm_detach - Remove ACPI power management from the device.
636 * @dev: Device to take care of.
637 * @power_off: Whether or not to try to remove power from the device.
638 *
639 * Remove the device from the general ACPI PM domain and remove its wakeup
640 * notifier. If @power_off is set, additionally remove power from the device if
641 * possible.
642 *
643 * Callers must ensure proper synchronization of this function with power
644 * management callbacks.
645 */
646void acpi_dev_pm_detach(struct device *dev, bool power_off)
647{
648 struct acpi_device *adev = acpi_dev_pm_get_node(dev);
649
650 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
651 dev->pm_domain = NULL;
652 acpi_remove_pm_notifier(adev, acpi_wakeup_device);
653 if (power_off) {
654 /*
655 * If the device's PM QoS resume latency limit or flags
656 * have been exposed to user space, they have to be
657 * hidden at this point, so that they don't affect the
658 * choice of the low-power state to put the device into.
659 */
660 dev_pm_qos_hide_latency_limit(dev);
661 dev_pm_qos_hide_flags(dev);
662 __acpi_device_run_wake(adev, false);
663 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
664 }
665 }
666}
667EXPORT_SYMBOL_GPL(acpi_dev_pm_detach);
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index f32bd47b35e..19a61136d84 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -31,7 +31,6 @@
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/stddef.h> 33#include <linux/stddef.h>
34#include <linux/acpi.h>
35#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h> 35#include <acpi/acpi_drivers.h>
37 36
@@ -44,7 +43,7 @@ MODULE_AUTHOR("Kristen Carlson Accardi");
44MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION); 43MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION);
45MODULE_LICENSE("GPL"); 44MODULE_LICENSE("GPL");
46 45
47static bool immediate_undock = 1; 46static int immediate_undock = 1;
48module_param(immediate_undock, bool, 0644); 47module_param(immediate_undock, bool, 0644);
49MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to " 48MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
50 "undock immediately when the undock button is pressed, 0 will cause" 49 "undock immediately when the undock button is pressed, 0 will cause"
@@ -461,8 +460,12 @@ static void handle_dock(struct dock_station *ds, int dock)
461 struct acpi_object_list arg_list; 460 struct acpi_object_list arg_list;
462 union acpi_object arg; 461 union acpi_object arg;
463 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 462 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
463 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
464 464
465 acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking"); 465 acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer);
466
467 printk(KERN_INFO PREFIX "%s - %s\n",
468 (char *)name_buffer.pointer, dock ? "docking" : "undocking");
466 469
467 /* _DCK method has one argument */ 470 /* _DCK method has one argument */
468 arg_list.count = 1; 471 arg_list.count = 1;
@@ -471,10 +474,11 @@ static void handle_dock(struct dock_station *ds, int dock)
471 arg.integer.value = dock; 474 arg.integer.value = dock;
472 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); 475 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
473 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) 476 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
474 acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n", 477 ACPI_EXCEPTION((AE_INFO, status, "%s - failed to execute"
475 status); 478 " _DCK\n", (char *)name_buffer.pointer));
476 479
477 kfree(buffer.pointer); 480 kfree(buffer.pointer);
481 kfree(name_buffer.pointer);
478} 482}
479 483
480static inline void dock(struct dock_station *ds) 484static inline void dock(struct dock_station *ds)
@@ -521,11 +525,9 @@ static void dock_lock(struct dock_station *ds, int lock)
521 status = acpi_evaluate_object(ds->handle, "_LCK", &arg_list, NULL); 525 status = acpi_evaluate_object(ds->handle, "_LCK", &arg_list, NULL);
522 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 526 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
523 if (lock) 527 if (lock)
524 acpi_handle_warn(ds->handle, 528 printk(KERN_WARNING PREFIX "Locking device failed\n");
525 "Locking device failed (0x%x)\n", status);
526 else 529 else
527 acpi_handle_warn(ds->handle, 530 printk(KERN_WARNING PREFIX "Unlocking device failed\n");
528 "Unlocking device failed (0x%x)\n", status);
529 } 531 }
530} 532}
531 533
@@ -665,7 +667,7 @@ static int handle_eject_request(struct dock_station *ds, u32 event)
665 dock_lock(ds, 0); 667 dock_lock(ds, 0);
666 eject_dock(ds); 668 eject_dock(ds);
667 if (dock_present(ds)) { 669 if (dock_present(ds)) {
668 acpi_handle_err(ds->handle, "Unable to undock!\n"); 670 printk(KERN_ERR PREFIX "Unable to undock!\n");
669 return -EBUSY; 671 return -EBUSY;
670 } 672 }
671 complete_undock(ds); 673 complete_undock(ds);
@@ -713,7 +715,7 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
713 begin_dock(ds); 715 begin_dock(ds);
714 dock(ds); 716 dock(ds);
715 if (!dock_present(ds)) { 717 if (!dock_present(ds)) {
716 acpi_handle_err(handle, "Unable to dock!\n"); 718 printk(KERN_ERR PREFIX "Unable to dock!\n");
717 complete_dock(ds); 719 complete_dock(ds);
718 break; 720 break;
719 } 721 }
@@ -741,7 +743,7 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
741 dock_event(ds, event, UNDOCK_EVENT); 743 dock_event(ds, event, UNDOCK_EVENT);
742 break; 744 break;
743 default: 745 default:
744 acpi_handle_err(handle, "Unknown dock event %d\n", event); 746 printk(KERN_ERR PREFIX "Unknown dock event %d\n", event);
745 } 747 }
746} 748}
747 749
@@ -985,7 +987,7 @@ err_rmgroup:
985 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group); 987 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
986err_unregister: 988err_unregister:
987 platform_device_unregister(dd); 989 platform_device_unregister(dd);
988 acpi_handle_err(handle, "%s encountered error %d\n", __func__, ret); 990 printk(KERN_ERR "%s encountered error %d\n", __func__, ret);
989 return ret; 991 return ret;
990} 992}
991 993
@@ -1014,39 +1016,51 @@ static int dock_remove(struct dock_station *ds)
1014} 1016}
1015 1017
1016/** 1018/**
1017 * find_dock_and_bay - look for dock stations and bays 1019 * find_dock - look for a dock station
1018 * @handle: acpi handle of a device 1020 * @handle: acpi handle of a device
1019 * @lvl: unused 1021 * @lvl: unused
1020 * @context: unused 1022 * @context: counter of dock stations found
1021 * @rv: unused 1023 * @rv: unused
1022 * 1024 *
1023 * This is called by acpi_walk_namespace to look for dock stations and bays. 1025 * This is called by acpi_walk_namespace to look for dock stations.
1024 */ 1026 */
1025static __init acpi_status 1027static __init acpi_status
1026find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv) 1028find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
1027{ 1029{
1028 if (is_dock(handle) || is_ejectable_bay(handle)) 1030 if (is_dock(handle))
1029 dock_add(handle); 1031 dock_add(handle);
1030 1032
1031 return AE_OK; 1033 return AE_OK;
1032} 1034}
1033 1035
1036static __init acpi_status
1037find_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
1038{
1039 /* If bay is a dock, it's already handled */
1040 if (is_ejectable_bay(handle) && !is_dock(handle))
1041 dock_add(handle);
1042 return AE_OK;
1043}
1044
1034static int __init dock_init(void) 1045static int __init dock_init(void)
1035{ 1046{
1036 if (acpi_disabled) 1047 if (acpi_disabled)
1037 return 0; 1048 return 0;
1038 1049
1039 /* look for dock stations and bays */ 1050 /* look for a dock station */
1040 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1051 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1041 ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL); 1052 ACPI_UINT32_MAX, find_dock, NULL, NULL, NULL);
1042 1053
1054 /* look for bay */
1055 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1056 ACPI_UINT32_MAX, find_bay, NULL, NULL, NULL);
1043 if (!dock_station_count) { 1057 if (!dock_station_count) {
1044 pr_info(PREFIX "No dock devices found.\n"); 1058 printk(KERN_INFO PREFIX "No dock devices found.\n");
1045 return 0; 1059 return 0;
1046 } 1060 }
1047 1061
1048 register_acpi_bus_notifier(&dock_acpi_notifier); 1062 register_acpi_bus_notifier(&dock_acpi_notifier);
1049 pr_info(PREFIX "%s: %d docks/bays found\n", 1063 printk(KERN_INFO PREFIX "%s: %d docks/bays found\n",
1050 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count); 1064 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);
1051 return 0; 1065 return 0;
1052} 1066}
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 354007d490d..b19a18dd994 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -71,6 +71,9 @@ enum ec_command {
71#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 71#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
72#define ACPI_EC_MSI_UDELAY 550 /* Wait 550us for MSI EC */ 72#define ACPI_EC_MSI_UDELAY 550 /* Wait 550us for MSI EC */
73 73
74#define ACPI_EC_STORM_THRESHOLD 8 /* number of false interrupts
75 per one transaction */
76
74enum { 77enum {
75 EC_FLAGS_QUERY_PENDING, /* Query is pending */ 78 EC_FLAGS_QUERY_PENDING, /* Query is pending */
76 EC_FLAGS_GPE_STORM, /* GPE storm detected */ 79 EC_FLAGS_GPE_STORM, /* GPE storm detected */
@@ -84,15 +87,6 @@ static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY;
84module_param(ec_delay, uint, 0644); 87module_param(ec_delay, uint, 0644);
85MODULE_PARM_DESC(ec_delay, "Timeout(ms) waited until an EC command completes"); 88MODULE_PARM_DESC(ec_delay, "Timeout(ms) waited until an EC command completes");
86 89
87/*
88 * If the number of false interrupts per one transaction exceeds
89 * this threshold, will think there is a GPE storm happened and
90 * will disable the GPE for normal transaction.
91 */
92static unsigned int ec_storm_threshold __read_mostly = 8;
93module_param(ec_storm_threshold, uint, 0644);
94MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm");
95
96/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 90/* If we find an EC via the ECDT, we need to keep a ptr to its context */
97/* External interfaces use first EC only, so remember */ 91/* External interfaces use first EC only, so remember */
98typedef int (*acpi_ec_query_func) (void *data); 92typedef int (*acpi_ec_query_func) (void *data);
@@ -158,10 +152,10 @@ static int ec_transaction_done(struct acpi_ec *ec)
158{ 152{
159 unsigned long flags; 153 unsigned long flags;
160 int ret = 0; 154 int ret = 0;
161 spin_lock_irqsave(&ec->lock, flags); 155 spin_lock_irqsave(&ec->curr_lock, flags);
162 if (!ec->curr || ec->curr->done) 156 if (!ec->curr || ec->curr->done)
163 ret = 1; 157 ret = 1;
164 spin_unlock_irqrestore(&ec->lock, flags); 158 spin_unlock_irqrestore(&ec->curr_lock, flags);
165 return ret; 159 return ret;
166} 160}
167 161
@@ -175,38 +169,32 @@ static void start_transaction(struct acpi_ec *ec)
175static void advance_transaction(struct acpi_ec *ec, u8 status) 169static void advance_transaction(struct acpi_ec *ec, u8 status)
176{ 170{
177 unsigned long flags; 171 unsigned long flags;
178 struct transaction *t = ec->curr; 172 spin_lock_irqsave(&ec->curr_lock, flags);
179 173 if (!ec->curr)
180 spin_lock_irqsave(&ec->lock, flags);
181 if (!t)
182 goto unlock; 174 goto unlock;
183 if (t->wlen > t->wi) { 175 if (ec->curr->wlen > ec->curr->wi) {
184 if ((status & ACPI_EC_FLAG_IBF) == 0) 176 if ((status & ACPI_EC_FLAG_IBF) == 0)
185 acpi_ec_write_data(ec, 177 acpi_ec_write_data(ec,
186 t->wdata[t->wi++]); 178 ec->curr->wdata[ec->curr->wi++]);
187 else 179 else
188 goto err; 180 goto err;
189 } else if (t->rlen > t->ri) { 181 } else if (ec->curr->rlen > ec->curr->ri) {
190 if ((status & ACPI_EC_FLAG_OBF) == 1) { 182 if ((status & ACPI_EC_FLAG_OBF) == 1) {
191 t->rdata[t->ri++] = acpi_ec_read_data(ec); 183 ec->curr->rdata[ec->curr->ri++] = acpi_ec_read_data(ec);
192 if (t->rlen == t->ri) 184 if (ec->curr->rlen == ec->curr->ri)
193 t->done = true; 185 ec->curr->done = true;
194 } else 186 } else
195 goto err; 187 goto err;
196 } else if (t->wlen == t->wi && 188 } else if (ec->curr->wlen == ec->curr->wi &&
197 (status & ACPI_EC_FLAG_IBF) == 0) 189 (status & ACPI_EC_FLAG_IBF) == 0)
198 t->done = true; 190 ec->curr->done = true;
199 goto unlock; 191 goto unlock;
200err: 192err:
201 /* 193 /* false interrupt, state didn't change */
202 * If SCI bit is set, then don't think it's a false IRQ 194 if (in_interrupt())
203 * otherwise will take a not handled IRQ as a false one. 195 ++ec->curr->irq_count;
204 */
205 if (in_interrupt() && !(status & ACPI_EC_FLAG_SCI))
206 ++t->irq_count;
207
208unlock: 196unlock:
209 spin_unlock_irqrestore(&ec->lock, flags); 197 spin_unlock_irqrestore(&ec->curr_lock, flags);
210} 198}
211 199
212static int acpi_ec_sync_query(struct acpi_ec *ec); 200static int acpi_ec_sync_query(struct acpi_ec *ec);
@@ -244,9 +232,9 @@ static int ec_poll(struct acpi_ec *ec)
244 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) 232 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
245 break; 233 break;
246 pr_debug(PREFIX "controller reset, restart transaction\n"); 234 pr_debug(PREFIX "controller reset, restart transaction\n");
247 spin_lock_irqsave(&ec->lock, flags); 235 spin_lock_irqsave(&ec->curr_lock, flags);
248 start_transaction(ec); 236 start_transaction(ec);
249 spin_unlock_irqrestore(&ec->lock, flags); 237 spin_unlock_irqrestore(&ec->curr_lock, flags);
250 } 238 }
251 return -ETIME; 239 return -ETIME;
252} 240}
@@ -259,17 +247,17 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
259 if (EC_FLAGS_MSI) 247 if (EC_FLAGS_MSI)
260 udelay(ACPI_EC_MSI_UDELAY); 248 udelay(ACPI_EC_MSI_UDELAY);
261 /* start transaction */ 249 /* start transaction */
262 spin_lock_irqsave(&ec->lock, tmp); 250 spin_lock_irqsave(&ec->curr_lock, tmp);
263 /* following two actions should be kept atomic */ 251 /* following two actions should be kept atomic */
264 ec->curr = t; 252 ec->curr = t;
265 start_transaction(ec); 253 start_transaction(ec);
266 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) 254 if (ec->curr->command == ACPI_EC_COMMAND_QUERY)
267 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 255 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
268 spin_unlock_irqrestore(&ec->lock, tmp); 256 spin_unlock_irqrestore(&ec->curr_lock, tmp);
269 ret = ec_poll(ec); 257 ret = ec_poll(ec);
270 spin_lock_irqsave(&ec->lock, tmp); 258 spin_lock_irqsave(&ec->curr_lock, tmp);
271 ec->curr = NULL; 259 ec->curr = NULL;
272 spin_unlock_irqrestore(&ec->lock, tmp); 260 spin_unlock_irqrestore(&ec->curr_lock, tmp);
273 return ret; 261 return ret;
274} 262}
275 263
@@ -298,7 +286,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
298 return -EINVAL; 286 return -EINVAL;
299 if (t->rdata) 287 if (t->rdata)
300 memset(t->rdata, 0, t->rlen); 288 memset(t->rdata, 0, t->rlen);
301 mutex_lock(&ec->mutex); 289 mutex_lock(&ec->lock);
302 if (test_bit(EC_FLAGS_BLOCKED, &ec->flags)) { 290 if (test_bit(EC_FLAGS_BLOCKED, &ec->flags)) {
303 status = -EINVAL; 291 status = -EINVAL;
304 goto unlock; 292 goto unlock;
@@ -316,8 +304,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
316 status = -ETIME; 304 status = -ETIME;
317 goto end; 305 goto end;
318 } 306 }
319 pr_debug(PREFIX "transaction start (cmd=0x%02x, addr=0x%02x)\n", 307 pr_debug(PREFIX "transaction start\n");
320 t->command, t->wdata ? t->wdata[0] : 0);
321 /* disable GPE during transaction if storm is detected */ 308 /* disable GPE during transaction if storm is detected */
322 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { 309 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
323 /* It has to be disabled, so that it doesn't trigger. */ 310 /* It has to be disabled, so that it doesn't trigger. */
@@ -332,10 +319,9 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
332 msleep(1); 319 msleep(1);
333 /* It is safe to enable the GPE outside of the transaction. */ 320 /* It is safe to enable the GPE outside of the transaction. */
334 acpi_enable_gpe(NULL, ec->gpe); 321 acpi_enable_gpe(NULL, ec->gpe);
335 } else if (t->irq_count > ec_storm_threshold) { 322 } else if (t->irq_count > ACPI_EC_STORM_THRESHOLD) {
336 pr_info(PREFIX "GPE storm detected(%d GPEs), " 323 pr_info(PREFIX "GPE storm detected, "
337 "transactions will use polling mode\n", 324 "transactions will use polling mode\n");
338 t->irq_count);
339 set_bit(EC_FLAGS_GPE_STORM, &ec->flags); 325 set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
340 } 326 }
341 pr_debug(PREFIX "transaction end\n"); 327 pr_debug(PREFIX "transaction end\n");
@@ -343,7 +329,7 @@ end:
343 if (ec->global_lock) 329 if (ec->global_lock)
344 acpi_release_global_lock(glk); 330 acpi_release_global_lock(glk);
345unlock: 331unlock:
346 mutex_unlock(&ec->mutex); 332 mutex_unlock(&ec->lock);
347 return status; 333 return status;
348} 334}
349 335
@@ -411,7 +397,7 @@ int ec_burst_disable(void)
411 397
412EXPORT_SYMBOL(ec_burst_disable); 398EXPORT_SYMBOL(ec_burst_disable);
413 399
414int ec_read(u8 addr, u8 *val) 400int ec_read(u8 addr, u8 * val)
415{ 401{
416 int err; 402 int err;
417 u8 temp_data; 403 u8 temp_data;
@@ -459,16 +445,6 @@ int ec_transaction(u8 command,
459 445
460EXPORT_SYMBOL(ec_transaction); 446EXPORT_SYMBOL(ec_transaction);
461 447
462/* Get the handle to the EC device */
463acpi_handle ec_get_handle(void)
464{
465 if (!first_ec)
466 return NULL;
467 return first_ec->handle;
468}
469
470EXPORT_SYMBOL(ec_get_handle);
471
472void acpi_ec_block_transactions(void) 448void acpi_ec_block_transactions(void)
473{ 449{
474 struct acpi_ec *ec = first_ec; 450 struct acpi_ec *ec = first_ec;
@@ -476,10 +452,10 @@ void acpi_ec_block_transactions(void)
476 if (!ec) 452 if (!ec)
477 return; 453 return;
478 454
479 mutex_lock(&ec->mutex); 455 mutex_lock(&ec->lock);
480 /* Prevent transactions from being carried out */ 456 /* Prevent transactions from being carried out */
481 set_bit(EC_FLAGS_BLOCKED, &ec->flags); 457 set_bit(EC_FLAGS_BLOCKED, &ec->flags);
482 mutex_unlock(&ec->mutex); 458 mutex_unlock(&ec->lock);
483} 459}
484 460
485void acpi_ec_unblock_transactions(void) 461void acpi_ec_unblock_transactions(void)
@@ -489,10 +465,10 @@ void acpi_ec_unblock_transactions(void)
489 if (!ec) 465 if (!ec)
490 return; 466 return;
491 467
492 mutex_lock(&ec->mutex); 468 mutex_lock(&ec->lock);
493 /* Allow transactions to be carried out again */ 469 /* Allow transactions to be carried out again */
494 clear_bit(EC_FLAGS_BLOCKED, &ec->flags); 470 clear_bit(EC_FLAGS_BLOCKED, &ec->flags);
495 mutex_unlock(&ec->mutex); 471 mutex_unlock(&ec->lock);
496} 472}
497 473
498void acpi_ec_unblock_transactions_early(void) 474void acpi_ec_unblock_transactions_early(void)
@@ -544,9 +520,9 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
544 handler->handle = handle; 520 handler->handle = handle;
545 handler->func = func; 521 handler->func = func;
546 handler->data = data; 522 handler->data = data;
547 mutex_lock(&ec->mutex); 523 mutex_lock(&ec->lock);
548 list_add(&handler->node, &ec->list); 524 list_add(&handler->node, &ec->list);
549 mutex_unlock(&ec->mutex); 525 mutex_unlock(&ec->lock);
550 return 0; 526 return 0;
551} 527}
552 528
@@ -555,14 +531,14 @@ EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
555void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) 531void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
556{ 532{
557 struct acpi_ec_query_handler *handler, *tmp; 533 struct acpi_ec_query_handler *handler, *tmp;
558 mutex_lock(&ec->mutex); 534 mutex_lock(&ec->lock);
559 list_for_each_entry_safe(handler, tmp, &ec->list, node) { 535 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
560 if (query_bit == handler->query_bit) { 536 if (query_bit == handler->query_bit) {
561 list_del(&handler->node); 537 list_del(&handler->node);
562 kfree(handler); 538 kfree(handler);
563 } 539 }
564 } 540 }
565 mutex_unlock(&ec->mutex); 541 mutex_unlock(&ec->lock);
566} 542}
567 543
568EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler); 544EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
@@ -609,9 +585,9 @@ static void acpi_ec_gpe_query(void *ec_cxt)
609 struct acpi_ec *ec = ec_cxt; 585 struct acpi_ec *ec = ec_cxt;
610 if (!ec) 586 if (!ec)
611 return; 587 return;
612 mutex_lock(&ec->mutex); 588 mutex_lock(&ec->lock);
613 acpi_ec_sync_query(ec); 589 acpi_ec_sync_query(ec);
614 mutex_unlock(&ec->mutex); 590 mutex_unlock(&ec->lock);
615} 591}
616 592
617static int ec_check_sci(struct acpi_ec *ec, u8 state) 593static int ec_check_sci(struct acpi_ec *ec, u8 state)
@@ -630,11 +606,10 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device,
630 u32 gpe_number, void *data) 606 u32 gpe_number, void *data)
631{ 607{
632 struct acpi_ec *ec = data; 608 struct acpi_ec *ec = data;
633 u8 status = acpi_ec_read_status(ec);
634 609
635 pr_debug(PREFIX "~~~> interrupt, status:0x%02x\n", status); 610 pr_debug(PREFIX "~~~> interrupt\n");
636 611
637 advance_transaction(ec, status); 612 advance_transaction(ec, acpi_ec_read_status(ec));
638 if (ec_transaction_done(ec) && 613 if (ec_transaction_done(ec) &&
639 (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) { 614 (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) {
640 wake_up(&ec->wait); 615 wake_up(&ec->wait);
@@ -700,10 +675,10 @@ static struct acpi_ec *make_acpi_ec(void)
700 if (!ec) 675 if (!ec)
701 return NULL; 676 return NULL;
702 ec->flags = 1 << EC_FLAGS_QUERY_PENDING; 677 ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
703 mutex_init(&ec->mutex); 678 mutex_init(&ec->lock);
704 init_waitqueue_head(&ec->wait); 679 init_waitqueue_head(&ec->wait);
705 INIT_LIST_HEAD(&ec->list); 680 INIT_LIST_HEAD(&ec->list);
706 spin_lock_init(&ec->lock); 681 spin_lock_init(&ec->curr_lock);
707 return ec; 682 return ec;
708} 683}
709 684
@@ -837,10 +812,10 @@ static int acpi_ec_add(struct acpi_device *device)
837 first_ec = ec; 812 first_ec = ec;
838 device->driver_data = ec; 813 device->driver_data = ec;
839 814
840 ret = !!request_region(ec->data_addr, 1, "EC data"); 815 WARN(!request_region(ec->data_addr, 1, "EC data"),
841 WARN(!ret, "Could not request EC data io port 0x%lx", ec->data_addr); 816 "Could not request EC data io port 0x%lx", ec->data_addr);
842 ret = !!request_region(ec->command_addr, 1, "EC cmd"); 817 WARN(!request_region(ec->command_addr, 1, "EC cmd"),
843 WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); 818 "Could not request EC cmd io port 0x%lx", ec->command_addr);
844 819
845 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", 820 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
846 ec->gpe, ec->command_addr, ec->data_addr); 821 ec->gpe, ec->command_addr, ec->data_addr);
@@ -862,12 +837,12 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
862 837
863 ec = acpi_driver_data(device); 838 ec = acpi_driver_data(device);
864 ec_remove_handlers(ec); 839 ec_remove_handlers(ec);
865 mutex_lock(&ec->mutex); 840 mutex_lock(&ec->lock);
866 list_for_each_entry_safe(handler, tmp, &ec->list, node) { 841 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
867 list_del(&handler->node); 842 list_del(&handler->node);
868 kfree(handler); 843 kfree(handler);
869 } 844 }
870 mutex_unlock(&ec->mutex); 845 mutex_unlock(&ec->lock);
871 release_region(ec->data_addr, 1); 846 release_region(ec->data_addr, 1);
872 release_region(ec->command_addr, 1); 847 release_region(ec->command_addr, 1);
873 device->driver_data = NULL; 848 device->driver_data = NULL;
@@ -939,17 +914,6 @@ static int ec_flag_msi(const struct dmi_system_id *id)
939 return 0; 914 return 0;
940} 915}
941 916
942/*
943 * Clevo M720 notebook actually works ok with IRQ mode, if we lifted
944 * the GPE storm threshold back to 20
945 */
946static int ec_enlarge_storm_threshold(const struct dmi_system_id *id)
947{
948 pr_debug("Setting the EC GPE storm threshold to 20\n");
949 ec_storm_threshold = 20;
950 return 0;
951}
952
953static struct dmi_system_id __initdata ec_dmi_table[] = { 917static struct dmi_system_id __initdata ec_dmi_table[] = {
954 { 918 {
955 ec_skip_dsdt_scan, "Compal JFL92", { 919 ec_skip_dsdt_scan, "Compal JFL92", {
@@ -981,13 +945,10 @@ static struct dmi_system_id __initdata ec_dmi_table[] = {
981 { 945 {
982 ec_validate_ecdt, "ASUS hardware", { 946 ec_validate_ecdt, "ASUS hardware", {
983 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc.") }, NULL}, 947 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc.") }, NULL},
984 {
985 ec_enlarge_storm_threshold, "CLEVO hardware", {
986 DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
987 DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL},
988 {}, 948 {},
989}; 949};
990 950
951
991int __init acpi_ec_ecdt_probe(void) 952int __init acpi_ec_ecdt_probe(void)
992{ 953{
993 acpi_status status; 954 acpi_status status;
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index 7586544fddb..22f918bacd3 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -11,7 +11,6 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/acpi.h> 12#include <linux/acpi.h>
13#include <linux/debugfs.h> 13#include <linux/debugfs.h>
14#include <linux/module.h>
15#include "internal.h" 14#include "internal.h"
16 15
17MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>"); 16MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
@@ -27,6 +26,12 @@ MODULE_PARM_DESC(write_support, "Dangerous, reboot and removal of battery may "
27 26
28static struct dentry *acpi_ec_debugfs_dir; 27static struct dentry *acpi_ec_debugfs_dir;
29 28
29static int acpi_ec_open_io(struct inode *i, struct file *f)
30{
31 f->private_data = i->i_private;
32 return 0;
33}
34
30static ssize_t acpi_ec_read_io(struct file *f, char __user *buf, 35static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31 size_t count, loff_t *off) 36 size_t count, loff_t *off)
32{ 37{
@@ -89,7 +94,7 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
89 94
90static const struct file_operations acpi_ec_io_ops = { 95static const struct file_operations acpi_ec_io_ops = {
91 .owner = THIS_MODULE, 96 .owner = THIS_MODULE,
92 .open = simple_open, 97 .open = acpi_ec_open_io,
93 .read = acpi_ec_read_io, 98 .read = acpi_ec_read_io,
94 .write = acpi_ec_write_io, 99 .write = acpi_ec_write_io,
95 .llseek = default_llseek, 100 .llseek = default_llseek,
@@ -99,7 +104,7 @@ int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
99{ 104{
100 struct dentry *dev_dir; 105 struct dentry *dev_dir;
101 char name[64]; 106 char name[64];
102 umode_t mode = 0400; 107 mode_t mode = 0400;
103 108
104 if (ec_device_count == 0) { 109 if (ec_device_count == 0) {
105 acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL); 110 acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL);
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 1442737cede..85d90899380 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/spinlock.h> 9#include <linux/spinlock.h>
10#include <linux/export.h>
11#include <linux/proc_fs.h> 10#include <linux/proc_fs.h>
12#include <linux/init.h> 11#include <linux/init.h>
13#include <linux/poll.h> 12#include <linux/poll.h>
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 3bd6a54702d..0f0356ca1a9 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -46,6 +46,8 @@ MODULE_LICENSE("GPL");
46 46
47static int acpi_fan_add(struct acpi_device *device); 47static int acpi_fan_add(struct acpi_device *device);
48static int acpi_fan_remove(struct acpi_device *device, int type); 48static int acpi_fan_remove(struct acpi_device *device, int type);
49static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state);
50static int acpi_fan_resume(struct acpi_device *device);
49 51
50static const struct acpi_device_id fan_device_ids[] = { 52static const struct acpi_device_id fan_device_ids[] = {
51 {"PNP0C0B", 0}, 53 {"PNP0C0B", 0},
@@ -53,12 +55,6 @@ static const struct acpi_device_id fan_device_ids[] = {
53}; 55};
54MODULE_DEVICE_TABLE(acpi, fan_device_ids); 56MODULE_DEVICE_TABLE(acpi, fan_device_ids);
55 57
56#ifdef CONFIG_PM_SLEEP
57static int acpi_fan_suspend(struct device *dev);
58static int acpi_fan_resume(struct device *dev);
59#endif
60static SIMPLE_DEV_PM_OPS(acpi_fan_pm, acpi_fan_suspend, acpi_fan_resume);
61
62static struct acpi_driver acpi_fan_driver = { 58static struct acpi_driver acpi_fan_driver = {
63 .name = "fan", 59 .name = "fan",
64 .class = ACPI_FAN_CLASS, 60 .class = ACPI_FAN_CLASS,
@@ -66,8 +62,9 @@ static struct acpi_driver acpi_fan_driver = {
66 .ops = { 62 .ops = {
67 .add = acpi_fan_add, 63 .add = acpi_fan_add,
68 .remove = acpi_fan_remove, 64 .remove = acpi_fan_remove,
65 .suspend = acpi_fan_suspend,
66 .resume = acpi_fan_resume,
69 }, 67 },
70 .drv.pm = &acpi_fan_pm,
71}; 68};
72 69
73/* thermal cooling device callbacks */ 70/* thermal cooling device callbacks */
@@ -186,30 +183,48 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
186 return 0; 183 return 0;
187} 184}
188 185
189#ifdef CONFIG_PM_SLEEP 186static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state)
190static int acpi_fan_suspend(struct device *dev)
191{ 187{
192 if (!dev) 188 if (!device)
193 return -EINVAL; 189 return -EINVAL;
194 190
195 acpi_bus_set_power(to_acpi_device(dev)->handle, ACPI_STATE_D0); 191 acpi_bus_set_power(device->handle, ACPI_STATE_D0);
196 192
197 return AE_OK; 193 return AE_OK;
198} 194}
199 195
200static int acpi_fan_resume(struct device *dev) 196static int acpi_fan_resume(struct acpi_device *device)
201{ 197{
202 int result; 198 int result;
203 199
204 if (!dev) 200 if (!device)
205 return -EINVAL; 201 return -EINVAL;
206 202
207 result = acpi_bus_update_power(to_acpi_device(dev)->handle, NULL); 203 result = acpi_bus_update_power(device->handle, NULL);
208 if (result) 204 if (result)
209 printk(KERN_ERR PREFIX "Error updating fan power state\n"); 205 printk(KERN_ERR PREFIX "Error updating fan power state\n");
210 206
211 return result; 207 return result;
212} 208}
213#endif
214 209
215module_acpi_driver(acpi_fan_driver); 210static int __init acpi_fan_init(void)
211{
212 int result = 0;
213
214 result = acpi_bus_register_driver(&acpi_fan_driver);
215 if (result < 0)
216 return -ENODEV;
217
218 return 0;
219}
220
221static void __exit acpi_fan_exit(void)
222{
223
224 acpi_bus_unregister_driver(&acpi_fan_driver);
225
226 return;
227}
228
229module_init(acpi_fan_init);
230module_exit(acpi_fan_exit);
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 95af6f674a6..7c47ed55e52 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * This file is released under the GPLv2. 7 * This file is released under the GPLv2.
8 */ 8 */
9#include <linux/export.h>
10#include <linux/init.h> 9#include <linux/init.h>
11#include <linux/list.h> 10#include <linux/list.h>
12#include <linux/device.h> 11#include <linux/device.h>
@@ -18,20 +17,13 @@
18 17
19#define ACPI_GLUE_DEBUG 0 18#define ACPI_GLUE_DEBUG 0
20#if ACPI_GLUE_DEBUG 19#if ACPI_GLUE_DEBUG
21#define DBG(fmt, ...) \ 20#define DBG(x...) printk(PREFIX x)
22 printk(KERN_DEBUG PREFIX fmt, ##__VA_ARGS__)
23#else 21#else
24#define DBG(fmt, ...) \ 22#define DBG(x...) do { } while(0)
25do { \
26 if (0) \
27 printk(KERN_DEBUG PREFIX fmt, ##__VA_ARGS__); \
28} while (0)
29#endif 23#endif
30static LIST_HEAD(bus_type_list); 24static LIST_HEAD(bus_type_list);
31static DECLARE_RWSEM(bus_type_sem); 25static DECLARE_RWSEM(bus_type_sem);
32 26
33#define PHYSICAL_NODE_STRING "physical_node"
34
35int register_acpi_bus_type(struct acpi_bus_type *type) 27int register_acpi_bus_type(struct acpi_bus_type *type)
36{ 28{
37 if (acpi_disabled) 29 if (acpi_disabled)
@@ -46,7 +38,6 @@ int register_acpi_bus_type(struct acpi_bus_type *type)
46 } 38 }
47 return -ENODEV; 39 return -ENODEV;
48} 40}
49EXPORT_SYMBOL_GPL(register_acpi_bus_type);
50 41
51int unregister_acpi_bus_type(struct acpi_bus_type *type) 42int unregister_acpi_bus_type(struct acpi_bus_type *type)
52{ 43{
@@ -62,7 +53,6 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type)
62 } 53 }
63 return -ENODEV; 54 return -ENODEV;
64} 55}
65EXPORT_SYMBOL_GPL(unregister_acpi_bus_type);
66 56
67static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) 57static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
68{ 58{
@@ -131,138 +121,84 @@ acpi_handle acpi_get_child(acpi_handle parent, u64 address)
131 121
132EXPORT_SYMBOL(acpi_get_child); 122EXPORT_SYMBOL(acpi_get_child);
133 123
124/* Link ACPI devices with physical devices */
125static void acpi_glue_data_handler(acpi_handle handle,
126 void *context)
127{
128 /* we provide an empty handler */
129}
130
131/* Note: a success call will increase reference count by one */
132struct device *acpi_get_physical_device(acpi_handle handle)
133{
134 acpi_status status;
135 struct device *dev;
136
137 status = acpi_get_data(handle, acpi_glue_data_handler, (void **)&dev);
138 if (ACPI_SUCCESS(status))
139 return get_device(dev);
140 return NULL;
141}
142
143EXPORT_SYMBOL(acpi_get_physical_device);
144
134static int acpi_bind_one(struct device *dev, acpi_handle handle) 145static int acpi_bind_one(struct device *dev, acpi_handle handle)
135{ 146{
136 struct acpi_device *acpi_dev; 147 struct acpi_device *acpi_dev;
137 acpi_status status; 148 acpi_status status;
138 struct acpi_device_physical_node *physical_node, *pn;
139 char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2];
140 int retval = -EINVAL;
141
142 if (ACPI_HANDLE(dev)) {
143 if (handle) {
144 dev_warn(dev, "ACPI handle is already set\n");
145 return -EINVAL;
146 } else {
147 handle = ACPI_HANDLE(dev);
148 }
149 }
150 if (!handle)
151 return -EINVAL;
152 149
150 if (dev->archdata.acpi_handle) {
151 dev_warn(dev, "Drivers changed 'acpi_handle'\n");
152 return -EINVAL;
153 }
153 get_device(dev); 154 get_device(dev);
154 status = acpi_bus_get_device(handle, &acpi_dev); 155 status = acpi_attach_data(handle, acpi_glue_data_handler, dev);
155 if (ACPI_FAILURE(status)) 156 if (ACPI_FAILURE(status)) {
156 goto err; 157 put_device(dev);
157 158 return -EINVAL;
158 physical_node = kzalloc(sizeof(*physical_node), GFP_KERNEL);
159 if (!physical_node) {
160 retval = -ENOMEM;
161 goto err;
162 } 159 }
160 dev->archdata.acpi_handle = handle;
163 161
164 mutex_lock(&acpi_dev->physical_node_lock); 162 status = acpi_bus_get_device(handle, &acpi_dev);
165 163 if (!ACPI_FAILURE(status)) {
166 /* Sanity check. */ 164 int ret;
167 list_for_each_entry(pn, &acpi_dev->physical_node_list, node) 165
168 if (pn->dev == dev) { 166 ret = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj,
169 dev_warn(dev, "Already associated with ACPI node\n"); 167 "firmware_node");
170 goto err_free; 168 ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
171 } 169 "physical_node");
172 170 if (acpi_dev->wakeup.flags.valid)
173 /* allocate physical node id according to physical_node_id_bitmap */ 171 device_set_wakeup_capable(dev, true);
174 physical_node->node_id =
175 find_first_zero_bit(acpi_dev->physical_node_id_bitmap,
176 ACPI_MAX_PHYSICAL_NODE);
177 if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) {
178 retval = -ENOSPC;
179 goto err_free;
180 } 172 }
181 173
182 set_bit(physical_node->node_id, acpi_dev->physical_node_id_bitmap);
183 physical_node->dev = dev;
184 list_add_tail(&physical_node->node, &acpi_dev->physical_node_list);
185 acpi_dev->physical_node_count++;
186
187 mutex_unlock(&acpi_dev->physical_node_lock);
188
189 if (!ACPI_HANDLE(dev))
190 ACPI_HANDLE_SET(dev, acpi_dev->handle);
191
192 if (!physical_node->node_id)
193 strcpy(physical_node_name, PHYSICAL_NODE_STRING);
194 else
195 sprintf(physical_node_name,
196 "physical_node%d", physical_node->node_id);
197 retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
198 physical_node_name);
199 retval = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj,
200 "firmware_node");
201
202 if (acpi_dev->wakeup.flags.valid)
203 device_set_wakeup_capable(dev, true);
204
205 return 0; 174 return 0;
206
207 err:
208 ACPI_HANDLE_SET(dev, NULL);
209 put_device(dev);
210 return retval;
211
212 err_free:
213 mutex_unlock(&acpi_dev->physical_node_lock);
214 kfree(physical_node);
215 goto err;
216} 175}
217 176
218static int acpi_unbind_one(struct device *dev) 177static int acpi_unbind_one(struct device *dev)
219{ 178{
220 struct acpi_device_physical_node *entry; 179 if (!dev->archdata.acpi_handle)
221 struct acpi_device *acpi_dev;
222 acpi_status status;
223 struct list_head *node, *next;
224
225 if (!ACPI_HANDLE(dev))
226 return 0; 180 return 0;
181 if (dev == acpi_get_physical_device(dev->archdata.acpi_handle)) {
182 struct acpi_device *acpi_dev;
227 183
228 status = acpi_bus_get_device(ACPI_HANDLE(dev), &acpi_dev); 184 /* acpi_get_physical_device increase refcnt by one */
229 if (ACPI_FAILURE(status)) 185 put_device(dev);
230 goto err;
231
232 mutex_lock(&acpi_dev->physical_node_lock);
233 list_for_each_safe(node, next, &acpi_dev->physical_node_list) {
234 char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2];
235
236 entry = list_entry(node, struct acpi_device_physical_node,
237 node);
238 if (entry->dev != dev)
239 continue;
240
241 list_del(node);
242 clear_bit(entry->node_id, acpi_dev->physical_node_id_bitmap);
243
244 acpi_dev->physical_node_count--;
245 186
246 if (!entry->node_id) 187 if (!acpi_bus_get_device(dev->archdata.acpi_handle,
247 strcpy(physical_node_name, PHYSICAL_NODE_STRING); 188 &acpi_dev)) {
248 else 189 sysfs_remove_link(&dev->kobj, "firmware_node");
249 sprintf(physical_node_name, 190 sysfs_remove_link(&acpi_dev->dev.kobj, "physical_node");
250 "physical_node%d", entry->node_id); 191 }
251 192
252 sysfs_remove_link(&acpi_dev->dev.kobj, physical_node_name); 193 acpi_detach_data(dev->archdata.acpi_handle,
253 sysfs_remove_link(&dev->kobj, "firmware_node"); 194 acpi_glue_data_handler);
254 ACPI_HANDLE_SET(dev, NULL); 195 dev->archdata.acpi_handle = NULL;
255 /* acpi_bind_one increase refcnt by one */ 196 /* acpi_bind_one increase refcnt by one */
256 put_device(dev); 197 put_device(dev);
257 kfree(entry); 198 } else {
199 dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
258 } 200 }
259 mutex_unlock(&acpi_dev->physical_node_lock);
260
261 return 0; 201 return 0;
262
263err:
264 dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
265 return -EINVAL;
266} 202}
267 203
268static int acpi_platform_notify(struct device *dev) 204static int acpi_platform_notify(struct device *dev)
@@ -271,10 +207,6 @@ static int acpi_platform_notify(struct device *dev)
271 acpi_handle handle; 207 acpi_handle handle;
272 int ret = -EINVAL; 208 int ret = -EINVAL;
273 209
274 ret = acpi_bind_one(dev, NULL);
275 if (!ret)
276 goto out;
277
278 if (!dev->bus || !dev->parent) { 210 if (!dev->bus || !dev->parent) {
279 /* bridge devices genernally haven't bus or parent */ 211 /* bridge devices genernally haven't bus or parent */
280 ret = acpi_find_bridge_device(dev, &handle); 212 ret = acpi_find_bridge_device(dev, &handle);
@@ -288,16 +220,16 @@ static int acpi_platform_notify(struct device *dev)
288 } 220 }
289 if ((ret = type->find_device(dev, &handle)) != 0) 221 if ((ret = type->find_device(dev, &handle)) != 0)
290 DBG("Can't get handler for %s\n", dev_name(dev)); 222 DBG("Can't get handler for %s\n", dev_name(dev));
291 end: 223 end:
292 if (!ret) 224 if (!ret)
293 acpi_bind_one(dev, handle); 225 acpi_bind_one(dev, handle);
294 226
295 out:
296#if ACPI_GLUE_DEBUG 227#if ACPI_GLUE_DEBUG
297 if (!ret) { 228 if (!ret) {
298 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 229 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
299 230
300 acpi_get_name(dev->acpi_handle, ACPI_FULL_PATHNAME, &buffer); 231 acpi_get_name(dev->archdata.acpi_handle,
232 ACPI_FULL_PATHNAME, &buffer);
301 DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer); 233 DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer);
302 kfree(buffer.pointer); 234 kfree(buffer.pointer);
303 } else 235 } else
diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c
index a0cc796932f..d0c1967f759 100644
--- a/drivers/acpi/hed.c
+++ b/drivers/acpi/hed.c
@@ -61,7 +61,7 @@ static void acpi_hed_notify(struct acpi_device *device, u32 event)
61 blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL); 61 blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL);
62} 62}
63 63
64static int acpi_hed_add(struct acpi_device *device) 64static int __devinit acpi_hed_add(struct acpi_device *device)
65{ 65{
66 /* Only one hardware error device */ 66 /* Only one hardware error device */
67 if (hed_handle) 67 if (hed_handle)
@@ -70,7 +70,7 @@ static int acpi_hed_add(struct acpi_device *device)
70 return 0; 70 return 0;
71} 71}
72 72
73static int acpi_hed_remove(struct acpi_device *device, int type) 73static int __devexit acpi_hed_remove(struct acpi_device *device, int type)
74{ 74{
75 hed_handle = NULL; 75 hed_handle = NULL;
76 return 0; 76 return 0;
@@ -86,7 +86,25 @@ static struct acpi_driver acpi_hed_driver = {
86 .notify = acpi_hed_notify, 86 .notify = acpi_hed_notify,
87 }, 87 },
88}; 88};
89module_acpi_driver(acpi_hed_driver); 89
90static int __init acpi_hed_init(void)
91{
92 if (acpi_disabled)
93 return -ENODEV;
94
95 if (acpi_bus_register_driver(&acpi_hed_driver) < 0)
96 return -ENODEV;
97
98 return 0;
99}
100
101static void __exit acpi_hed_exit(void)
102{
103 acpi_bus_unregister_driver(&acpi_hed_driver);
104}
105
106module_init(acpi_hed_init);
107module_exit(acpi_hed_exit);
90 108
91ACPI_MODULE_NAME("hed"); 109ACPI_MODULE_NAME("hed");
92MODULE_AUTHOR("Huang Ying"); 110MODULE_AUTHOR("Huang Ying");
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 3c407cdc1ec..ca75b9ce048 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -58,11 +58,11 @@ struct acpi_ec {
58 unsigned long data_addr; 58 unsigned long data_addr;
59 unsigned long global_lock; 59 unsigned long global_lock;
60 unsigned long flags; 60 unsigned long flags;
61 struct mutex mutex; 61 struct mutex lock;
62 wait_queue_head_t wait; 62 wait_queue_head_t wait;
63 struct list_head list; 63 struct list_head list;
64 struct transaction *curr; 64 struct transaction *curr;
65 spinlock_t lock; 65 spinlock_t curr_lock;
66}; 66};
67 67
68extern struct acpi_ec *first_ec; 68extern struct acpi_ec *first_ec;
@@ -93,11 +93,4 @@ static inline int suspend_nvs_save(void) { return 0; }
93static inline void suspend_nvs_restore(void) {} 93static inline void suspend_nvs_restore(void) {}
94#endif 94#endif
95 95
96/*--------------------------------------------------------------------------
97 Platform bus support
98 -------------------------------------------------------------------------- */
99struct platform_device;
100
101struct platform_device *acpi_create_platform_device(struct acpi_device *adev);
102
103#endif /* _ACPI_INTERNAL_H_ */ 96#endif /* _ACPI_INTERNAL_H_ */
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index cb31298ca68..3b5c3189fd9 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -45,8 +45,6 @@ static int pxm_to_node_map[MAX_PXM_DOMAINS]
45static int node_to_pxm_map[MAX_NUMNODES] 45static int node_to_pxm_map[MAX_NUMNODES]
46 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; 46 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
47 47
48unsigned char acpi_srat_revision __initdata;
49
50int pxm_to_node(int pxm) 48int pxm_to_node(int pxm)
51{ 49{
52 if (pxm < 0) 50 if (pxm < 0)
@@ -237,8 +235,6 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header,
237 return 0; 235 return 0;
238} 236}
239 237
240static int __initdata parsed_numa_memblks;
241
242static int __init 238static int __init
243acpi_parse_memory_affinity(struct acpi_subtable_header * header, 239acpi_parse_memory_affinity(struct acpi_subtable_header * header,
244 const unsigned long end) 240 const unsigned long end)
@@ -252,20 +248,16 @@ acpi_parse_memory_affinity(struct acpi_subtable_header * header,
252 acpi_table_print_srat_entry(header); 248 acpi_table_print_srat_entry(header);
253 249
254 /* let architecture-dependent part to do it */ 250 /* let architecture-dependent part to do it */
255 if (!acpi_numa_memory_affinity_init(memory_affinity)) 251 acpi_numa_memory_affinity_init(memory_affinity);
256 parsed_numa_memblks++; 252
257 return 0; 253 return 0;
258} 254}
259 255
260static int __init acpi_parse_srat(struct acpi_table_header *table) 256static int __init acpi_parse_srat(struct acpi_table_header *table)
261{ 257{
262 struct acpi_table_srat *srat;
263 if (!table) 258 if (!table)
264 return -EINVAL; 259 return -EINVAL;
265 260
266 srat = (struct acpi_table_srat *)table;
267 acpi_srat_revision = srat->header.revision;
268
269 /* Real work done in acpi_table_parse_srat below. */ 261 /* Real work done in acpi_table_parse_srat below. */
270 262
271 return 0; 263 return 0;
@@ -306,10 +298,8 @@ int __init acpi_numa_init(void)
306 298
307 acpi_numa_arch_fixup(); 299 acpi_numa_arch_fixup();
308 300
309 if (cnt < 0) 301 if (cnt <= 0)
310 return cnt; 302 return cnt ?: -ENOENT;
311 else if (!parsed_numa_memblks)
312 return -ENOENT;
313 return 0; 303 return 0;
314} 304}
315 305
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c
index 266bc58ce0c..096787b43c9 100644
--- a/drivers/acpi/nvs.c
+++ b/drivers/acpi/nvs.c
@@ -15,56 +15,6 @@
15#include <linux/acpi_io.h> 15#include <linux/acpi_io.h>
16#include <acpi/acpiosxf.h> 16#include <acpi/acpiosxf.h>
17 17
18/* ACPI NVS regions, APEI may use it */
19
20struct nvs_region {
21 __u64 phys_start;
22 __u64 size;
23 struct list_head node;
24};
25
26static LIST_HEAD(nvs_region_list);
27
28#ifdef CONFIG_ACPI_SLEEP
29static int suspend_nvs_register(unsigned long start, unsigned long size);
30#else
31static inline int suspend_nvs_register(unsigned long a, unsigned long b)
32{
33 return 0;
34}
35#endif
36
37int acpi_nvs_register(__u64 start, __u64 size)
38{
39 struct nvs_region *region;
40
41 region = kmalloc(sizeof(*region), GFP_KERNEL);
42 if (!region)
43 return -ENOMEM;
44 region->phys_start = start;
45 region->size = size;
46 list_add_tail(&region->node, &nvs_region_list);
47
48 return suspend_nvs_register(start, size);
49}
50
51int acpi_nvs_for_each_region(int (*func)(__u64 start, __u64 size, void *data),
52 void *data)
53{
54 int rc;
55 struct nvs_region *region;
56
57 list_for_each_entry(region, &nvs_region_list, node) {
58 rc = func(region->phys_start, region->size, data);
59 if (rc)
60 return rc;
61 }
62
63 return 0;
64}
65
66
67#ifdef CONFIG_ACPI_SLEEP
68/* 18/*
69 * Platforms, like ACPI, may want us to save some memory used by them during 19 * Platforms, like ACPI, may want us to save some memory used by them during
70 * suspend and to restore the contents of this memory during the subsequent 20 * suspend and to restore the contents of this memory during the subsequent
@@ -91,12 +41,12 @@ static LIST_HEAD(nvs_list);
91 * things so that the data from page-aligned addresses in this region will 41 * things so that the data from page-aligned addresses in this region will
92 * be copied into separate RAM pages. 42 * be copied into separate RAM pages.
93 */ 43 */
94static int suspend_nvs_register(unsigned long start, unsigned long size) 44int suspend_nvs_register(unsigned long start, unsigned long size)
95{ 45{
96 struct nvs_page *entry, *next; 46 struct nvs_page *entry, *next;
97 47
98 pr_info("PM: Registering ACPI NVS region [mem %#010lx-%#010lx] (%ld bytes)\n", 48 pr_info("PM: Registering ACPI NVS region at %lx (%ld bytes)\n",
99 start, start + size - 1, size); 49 start, size);
100 50
101 while (size > 0) { 51 while (size > 0) {
102 unsigned int nr_bytes; 52 unsigned int nr_bytes;
@@ -209,4 +159,3 @@ void suspend_nvs_restore(void)
209 if (entry->data) 159 if (entry->data)
210 memcpy(entry->kaddr, entry->data, entry->size); 160 memcpy(entry->kaddr, entry->data, entry->size);
211} 161}
212#endif
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 3ff26786154..fa32f584229 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -31,7 +31,6 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/highmem.h>
35#include <linux/pci.h> 34#include <linux/pci.h>
36#include <linux/interrupt.h> 35#include <linux/interrupt.h>
37#include <linux/kmod.h> 36#include <linux/kmod.h>
@@ -77,15 +76,24 @@ EXPORT_SYMBOL(acpi_in_debugger);
77extern char line_buf[80]; 76extern char line_buf[80];
78#endif /*ENABLE_DEBUGGER */ 77#endif /*ENABLE_DEBUGGER */
79 78
80static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
81 u32 pm1b_ctrl);
82
83static acpi_osd_handler acpi_irq_handler; 79static acpi_osd_handler acpi_irq_handler;
84static void *acpi_irq_context; 80static void *acpi_irq_context;
85static struct workqueue_struct *kacpid_wq; 81static struct workqueue_struct *kacpid_wq;
86static struct workqueue_struct *kacpi_notify_wq; 82static struct workqueue_struct *kacpi_notify_wq;
87struct workqueue_struct *kacpi_hotplug_wq; 83static struct workqueue_struct *kacpi_hotplug_wq;
88EXPORT_SYMBOL(kacpi_hotplug_wq); 84
85struct acpi_res_list {
86 resource_size_t start;
87 resource_size_t end;
88 acpi_adr_space_type resource_type; /* IO port, System memory, ...*/
89 char name[5]; /* only can have a length of 4 chars, make use of this
90 one instead of res->name, no need to kalloc then */
91 struct list_head resource_list;
92 int count;
93};
94
95static LIST_HEAD(resource_list_head);
96static DEFINE_SPINLOCK(acpi_res_lock);
89 97
90/* 98/*
91 * This list of permanent mappings is for memory that may be accessed from 99 * This list of permanent mappings is for memory that may be accessed from
@@ -157,21 +165,17 @@ static u32 acpi_osi_handler(acpi_string interface, u32 supported)
157 return supported; 165 return supported;
158} 166}
159 167
160static void __init acpi_request_region (struct acpi_generic_address *gas, 168static void __init acpi_request_region (struct acpi_generic_address *addr,
161 unsigned int length, char *desc) 169 unsigned int length, char *desc)
162{ 170{
163 u64 addr; 171 if (!addr->address || !length)
164
165 /* Handle possible alignment issues */
166 memcpy(&addr, &gas->address, sizeof(addr));
167 if (!addr || !length)
168 return; 172 return;
169 173
170 /* Resources are never freed */ 174 /* Resources are never freed */
171 if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) 175 if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
172 request_region(addr, length, desc); 176 request_region(addr->address, length, desc);
173 else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) 177 else if (addr->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
174 request_mem_region(addr, length, desc); 178 request_mem_region(addr->address, length, desc);
175} 179}
176 180
177static int __init acpi_reserve_resources(void) 181static int __init acpi_reserve_resources(void)
@@ -325,37 +329,6 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
325 return NULL; 329 return NULL;
326} 330}
327 331
328#ifndef CONFIG_IA64
329#define should_use_kmap(pfn) page_is_ram(pfn)
330#else
331/* ioremap will take care of cache attributes */
332#define should_use_kmap(pfn) 0
333#endif
334
335static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
336{
337 unsigned long pfn;
338
339 pfn = pg_off >> PAGE_SHIFT;
340 if (should_use_kmap(pfn)) {
341 if (pg_sz > PAGE_SIZE)
342 return NULL;
343 return (void __iomem __force *)kmap(pfn_to_page(pfn));
344 } else
345 return acpi_os_ioremap(pg_off, pg_sz);
346}
347
348static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
349{
350 unsigned long pfn;
351
352 pfn = pg_off >> PAGE_SHIFT;
353 if (should_use_kmap(pfn))
354 kunmap(pfn_to_page(pfn));
355 else
356 iounmap(vaddr);
357}
358
359void __iomem *__init_refok 332void __iomem *__init_refok
360acpi_os_map_memory(acpi_physical_address phys, acpi_size size) 333acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
361{ 334{
@@ -388,7 +361,7 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
388 361
389 pg_off = round_down(phys, PAGE_SIZE); 362 pg_off = round_down(phys, PAGE_SIZE);
390 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off; 363 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
391 virt = acpi_map(pg_off, pg_sz); 364 virt = acpi_os_ioremap(pg_off, pg_sz);
392 if (!virt) { 365 if (!virt) {
393 mutex_unlock(&acpi_ioremap_lock); 366 mutex_unlock(&acpi_ioremap_lock);
394 kfree(map); 367 kfree(map);
@@ -419,7 +392,7 @@ static void acpi_os_map_cleanup(struct acpi_ioremap *map)
419{ 392{
420 if (!map->refcount) { 393 if (!map->refcount) {
421 synchronize_rcu(); 394 synchronize_rcu();
422 acpi_unmap(map->phys, map->virt); 395 iounmap(map->virt);
423 kfree(map); 396 kfree(map);
424 } 397 }
425} 398}
@@ -453,42 +426,35 @@ void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
453 __acpi_unmap_table(virt, size); 426 __acpi_unmap_table(virt, size);
454} 427}
455 428
456int acpi_os_map_generic_address(struct acpi_generic_address *gas) 429static int acpi_os_map_generic_address(struct acpi_generic_address *addr)
457{ 430{
458 u64 addr;
459 void __iomem *virt; 431 void __iomem *virt;
460 432
461 if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) 433 if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
462 return 0; 434 return 0;
463 435
464 /* Handle possible alignment issues */ 436 if (!addr->address || !addr->bit_width)
465 memcpy(&addr, &gas->address, sizeof(addr));
466 if (!addr || !gas->bit_width)
467 return -EINVAL; 437 return -EINVAL;
468 438
469 virt = acpi_os_map_memory(addr, gas->bit_width / 8); 439 virt = acpi_os_map_memory(addr->address, addr->bit_width / 8);
470 if (!virt) 440 if (!virt)
471 return -EIO; 441 return -EIO;
472 442
473 return 0; 443 return 0;
474} 444}
475EXPORT_SYMBOL(acpi_os_map_generic_address);
476 445
477void acpi_os_unmap_generic_address(struct acpi_generic_address *gas) 446static void acpi_os_unmap_generic_address(struct acpi_generic_address *addr)
478{ 447{
479 u64 addr;
480 struct acpi_ioremap *map; 448 struct acpi_ioremap *map;
481 449
482 if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) 450 if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
483 return; 451 return;
484 452
485 /* Handle possible alignment issues */ 453 if (!addr->address || !addr->bit_width)
486 memcpy(&addr, &gas->address, sizeof(addr));
487 if (!addr || !gas->bit_width)
488 return; 454 return;
489 455
490 mutex_lock(&acpi_ioremap_lock); 456 mutex_lock(&acpi_ioremap_lock);
491 map = acpi_map_lookup(addr, gas->bit_width / 8); 457 map = acpi_map_lookup(addr->address, addr->bit_width / 8);
492 if (!map) { 458 if (!map) {
493 mutex_unlock(&acpi_ioremap_lock); 459 mutex_unlock(&acpi_ioremap_lock);
494 return; 460 return;
@@ -498,7 +464,6 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
498 464
499 acpi_os_map_cleanup(map); 465 acpi_os_map_cleanup(map);
500} 466}
501EXPORT_SYMBOL(acpi_os_unmap_generic_address);
502 467
503#ifdef ACPI_FUTURE_USAGE 468#ifdef ACPI_FUTURE_USAGE
504acpi_status 469acpi_status
@@ -534,137 +499,6 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
534 return AE_OK; 499 return AE_OK;
535} 500}
536 501
537#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
538#include <linux/earlycpio.h>
539#include <linux/memblock.h>
540
541static u64 acpi_tables_addr;
542static int all_tables_size;
543
544/* Copied from acpica/tbutils.c:acpi_tb_checksum() */
545u8 __init acpi_table_checksum(u8 *buffer, u32 length)
546{
547 u8 sum = 0;
548 u8 *end = buffer + length;
549
550 while (buffer < end)
551 sum = (u8) (sum + *(buffer++));
552 return sum;
553}
554
555/* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */
556static const char * const table_sigs[] = {
557 ACPI_SIG_BERT, ACPI_SIG_CPEP, ACPI_SIG_ECDT, ACPI_SIG_EINJ,
558 ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT, ACPI_SIG_MSCT,
559 ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT, ACPI_SIG_ASF,
560 ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR, ACPI_SIG_HPET,
561 ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG, ACPI_SIG_MCHI,
562 ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI, ACPI_SIG_TCPA,
563 ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT, ACPI_SIG_WDDT,
564 ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT,
565 ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL };
566
567/* Non-fatal errors: Affected tables/files are ignored */
568#define INVALID_TABLE(x, path, name) \
569 { pr_err("ACPI OVERRIDE: " x " [%s%s]\n", path, name); continue; }
570
571#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
572
573/* Must not increase 10 or needs code modification below */
574#define ACPI_OVERRIDE_TABLES 10
575
576void __init acpi_initrd_override(void *data, size_t size)
577{
578 int sig, no, table_nr = 0, total_offset = 0;
579 long offset = 0;
580 struct acpi_table_header *table;
581 char cpio_path[32] = "kernel/firmware/acpi/";
582 struct cpio_data file;
583 struct cpio_data early_initrd_files[ACPI_OVERRIDE_TABLES];
584 char *p;
585
586 if (data == NULL || size == 0)
587 return;
588
589 for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) {
590 file = find_cpio_data(cpio_path, data, size, &offset);
591 if (!file.data)
592 break;
593
594 data += offset;
595 size -= offset;
596
597 if (file.size < sizeof(struct acpi_table_header))
598 INVALID_TABLE("Table smaller than ACPI header",
599 cpio_path, file.name);
600
601 table = file.data;
602
603 for (sig = 0; table_sigs[sig]; sig++)
604 if (!memcmp(table->signature, table_sigs[sig], 4))
605 break;
606
607 if (!table_sigs[sig])
608 INVALID_TABLE("Unknown signature",
609 cpio_path, file.name);
610 if (file.size != table->length)
611 INVALID_TABLE("File length does not match table length",
612 cpio_path, file.name);
613 if (acpi_table_checksum(file.data, table->length))
614 INVALID_TABLE("Bad table checksum",
615 cpio_path, file.name);
616
617 pr_info("%4.4s ACPI table found in initrd [%s%s][0x%x]\n",
618 table->signature, cpio_path, file.name, table->length);
619
620 all_tables_size += table->length;
621 early_initrd_files[table_nr].data = file.data;
622 early_initrd_files[table_nr].size = file.size;
623 table_nr++;
624 }
625 if (table_nr == 0)
626 return;
627
628 acpi_tables_addr =
629 memblock_find_in_range(0, max_low_pfn_mapped << PAGE_SHIFT,
630 all_tables_size, PAGE_SIZE);
631 if (!acpi_tables_addr) {
632 WARN_ON(1);
633 return;
634 }
635 /*
636 * Only calling e820_add_reserve does not work and the
637 * tables are invalid (memory got used) later.
638 * memblock_reserve works as expected and the tables won't get modified.
639 * But it's not enough on X86 because ioremap will
640 * complain later (used by acpi_os_map_memory) that the pages
641 * that should get mapped are not marked "reserved".
642 * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area)
643 * works fine.
644 */
645 memblock_reserve(acpi_tables_addr, acpi_tables_addr + all_tables_size);
646 arch_reserve_mem_area(acpi_tables_addr, all_tables_size);
647
648 p = early_ioremap(acpi_tables_addr, all_tables_size);
649
650 for (no = 0; no < table_nr; no++) {
651 memcpy(p + total_offset, early_initrd_files[no].data,
652 early_initrd_files[no].size);
653 total_offset += early_initrd_files[no].size;
654 }
655 early_iounmap(p, all_tables_size);
656}
657#endif /* CONFIG_ACPI_INITRD_TABLE_OVERRIDE */
658
659static void acpi_table_taint(struct acpi_table_header *table)
660{
661 pr_warn(PREFIX
662 "Override [%4.4s-%8.8s], this is unsafe: tainting kernel\n",
663 table->signature, table->oem_table_id);
664 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
665}
666
667
668acpi_status 502acpi_status
669acpi_os_table_override(struct acpi_table_header * existing_table, 503acpi_os_table_override(struct acpi_table_header * existing_table,
670 struct acpi_table_header ** new_table) 504 struct acpi_table_header ** new_table)
@@ -678,72 +512,14 @@ acpi_os_table_override(struct acpi_table_header * existing_table,
678 if (strncmp(existing_table->signature, "DSDT", 4) == 0) 512 if (strncmp(existing_table->signature, "DSDT", 4) == 0)
679 *new_table = (struct acpi_table_header *)AmlCode; 513 *new_table = (struct acpi_table_header *)AmlCode;
680#endif 514#endif
681 if (*new_table != NULL) 515 if (*new_table != NULL) {
682 acpi_table_taint(existing_table); 516 printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], "
683 return AE_OK; 517 "this is unsafe: tainting kernel\n",
684} 518 existing_table->signature,
685 519 existing_table->oem_table_id);
686acpi_status 520 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
687acpi_os_physical_table_override(struct acpi_table_header *existing_table, 521 }
688 acpi_physical_address *address,
689 u32 *table_length)
690{
691#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
692 *table_length = 0;
693 *address = 0;
694 return AE_OK;
695#else
696 int table_offset = 0;
697 struct acpi_table_header *table;
698
699 *table_length = 0;
700 *address = 0;
701
702 if (!acpi_tables_addr)
703 return AE_OK;
704
705 do {
706 if (table_offset + ACPI_HEADER_SIZE > all_tables_size) {
707 WARN_ON(1);
708 return AE_OK;
709 }
710
711 table = acpi_os_map_memory(acpi_tables_addr + table_offset,
712 ACPI_HEADER_SIZE);
713
714 if (table_offset + table->length > all_tables_size) {
715 acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
716 WARN_ON(1);
717 return AE_OK;
718 }
719
720 table_offset += table->length;
721
722 if (memcmp(existing_table->signature, table->signature, 4)) {
723 acpi_os_unmap_memory(table,
724 ACPI_HEADER_SIZE);
725 continue;
726 }
727
728 /* Only override tables with matching oem id */
729 if (memcmp(table->oem_table_id, existing_table->oem_table_id,
730 ACPI_OEM_TABLE_ID_SIZE)) {
731 acpi_os_unmap_memory(table,
732 ACPI_HEADER_SIZE);
733 continue;
734 }
735
736 table_offset -= table->length;
737 *table_length = table->length;
738 acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
739 *address = acpi_tables_addr + table_offset;
740 break;
741 } while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
742
743 if (*address != 0)
744 acpi_table_taint(existing_table);
745 return AE_OK; 522 return AE_OK;
746#endif
747} 523}
748 524
749static irqreturn_t acpi_irq(int irq, void *dev_id) 525static irqreturn_t acpi_irq(int irq, void *dev_id)
@@ -891,28 +667,13 @@ acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
891 667
892EXPORT_SYMBOL(acpi_os_write_port); 668EXPORT_SYMBOL(acpi_os_write_port);
893 669
894#ifdef readq
895static inline u64 read64(const volatile void __iomem *addr)
896{
897 return readq(addr);
898}
899#else
900static inline u64 read64(const volatile void __iomem *addr)
901{
902 u64 l, h;
903 l = readl(addr);
904 h = readl(addr+4);
905 return l | (h << 32);
906}
907#endif
908
909acpi_status 670acpi_status
910acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width) 671acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
911{ 672{
912 void __iomem *virt_addr; 673 void __iomem *virt_addr;
913 unsigned int size = width / 8; 674 unsigned int size = width / 8;
914 bool unmap = false; 675 bool unmap = false;
915 u64 dummy; 676 u32 dummy;
916 677
917 rcu_read_lock(); 678 rcu_read_lock();
918 virt_addr = acpi_map_vaddr_lookup(phys_addr, size); 679 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
@@ -937,9 +698,6 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width)
937 case 32: 698 case 32:
938 *(u32 *) value = readl(virt_addr); 699 *(u32 *) value = readl(virt_addr);
939 break; 700 break;
940 case 64:
941 *(u64 *) value = read64(virt_addr);
942 break;
943 default: 701 default:
944 BUG(); 702 BUG();
945 } 703 }
@@ -952,21 +710,8 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width)
952 return AE_OK; 710 return AE_OK;
953} 711}
954 712
955#ifdef writeq
956static inline void write64(u64 val, volatile void __iomem *addr)
957{
958 writeq(val, addr);
959}
960#else
961static inline void write64(u64 val, volatile void __iomem *addr)
962{
963 writel(val, addr);
964 writel(val>>32, addr+4);
965}
966#endif
967
968acpi_status 713acpi_status
969acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width) 714acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
970{ 715{
971 void __iomem *virt_addr; 716 void __iomem *virt_addr;
972 unsigned int size = width / 8; 717 unsigned int size = width / 8;
@@ -992,9 +737,6 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width)
992 case 32: 737 case 32:
993 writel(value, virt_addr); 738 writel(value, virt_addr);
994 break; 739 break;
995 case 64:
996 write64(value, virt_addr);
997 break;
998 default: 740 default:
999 BUG(); 741 BUG();
1000 } 742 }
@@ -1071,7 +813,7 @@ static void acpi_os_execute_deferred(struct work_struct *work)
1071 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); 813 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
1072 814
1073 if (dpc->wait) 815 if (dpc->wait)
1074 acpi_os_wait_events_complete(); 816 acpi_os_wait_events_complete(NULL);
1075 817
1076 dpc->function(dpc->context); 818 dpc->function(dpc->context);
1077 kfree(dpc); 819 kfree(dpc);
@@ -1112,7 +854,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
1112 * having a static work_struct. 854 * having a static work_struct.
1113 */ 855 */
1114 856
1115 dpc = kzalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); 857 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
1116 if (!dpc) 858 if (!dpc)
1117 return AE_NO_MEMORY; 859 return AE_NO_MEMORY;
1118 860
@@ -1124,22 +866,17 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
1124 * because the hotplug code may call driver .remove() functions, 866 * because the hotplug code may call driver .remove() functions,
1125 * which invoke flush_scheduled_work/acpi_os_wait_events_complete 867 * which invoke flush_scheduled_work/acpi_os_wait_events_complete
1126 * to flush these workqueues. 868 * to flush these workqueues.
1127 *
1128 * To prevent lockdep from complaining unnecessarily, make sure that
1129 * there is a different static lockdep key for each workqueue by using
1130 * INIT_WORK() for each of them separately.
1131 */ 869 */
1132 if (hp) { 870 queue = hp ? kacpi_hotplug_wq :
1133 queue = kacpi_hotplug_wq; 871 (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq);
1134 dpc->wait = 1; 872 dpc->wait = hp ? 1 : 0;
873
874 if (queue == kacpi_hotplug_wq)
1135 INIT_WORK(&dpc->work, acpi_os_execute_deferred); 875 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
1136 } else if (type == OSL_NOTIFY_HANDLER) { 876 else if (queue == kacpi_notify_wq)
1137 queue = kacpi_notify_wq;
1138 INIT_WORK(&dpc->work, acpi_os_execute_deferred); 877 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
1139 } else { 878 else
1140 queue = kacpid_wq;
1141 INIT_WORK(&dpc->work, acpi_os_execute_deferred); 879 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
1142 }
1143 880
1144 /* 881 /*
1145 * On some machines, a software-initiated SMI causes corruption unless 882 * On some machines, a software-initiated SMI causes corruption unless
@@ -1171,9 +908,8 @@ acpi_status acpi_os_hotplug_execute(acpi_osd_exec_callback function,
1171{ 908{
1172 return __acpi_os_execute(0, function, context, 1); 909 return __acpi_os_execute(0, function, context, 1);
1173} 910}
1174EXPORT_SYMBOL(acpi_os_hotplug_execute);
1175 911
1176void acpi_os_wait_events_complete(void) 912void acpi_os_wait_events_complete(void *context)
1177{ 913{
1178 flush_workqueue(kacpid_wq); 914 flush_workqueue(kacpid_wq);
1179 flush_workqueue(kacpi_notify_wq); 915 flush_workqueue(kacpi_notify_wq);
@@ -1541,28 +1277,44 @@ __setup("acpi_enforce_resources=", acpi_enforce_resources_setup);
1541 * drivers */ 1277 * drivers */
1542int acpi_check_resource_conflict(const struct resource *res) 1278int acpi_check_resource_conflict(const struct resource *res)
1543{ 1279{
1544 acpi_adr_space_type space_id; 1280 struct acpi_res_list *res_list_elem;
1545 acpi_size length; 1281 int ioport = 0, clash = 0;
1546 u8 warn = 0;
1547 int clash = 0;
1548 1282
1549 if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) 1283 if (acpi_enforce_resources == ENFORCE_RESOURCES_NO)
1550 return 0; 1284 return 0;
1551 if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM)) 1285 if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM))
1552 return 0; 1286 return 0;
1553 1287
1554 if (res->flags & IORESOURCE_IO) 1288 ioport = res->flags & IORESOURCE_IO;
1555 space_id = ACPI_ADR_SPACE_SYSTEM_IO;
1556 else
1557 space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY;
1558 1289
1559 length = res->end - res->start + 1; 1290 spin_lock(&acpi_res_lock);
1560 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) 1291 list_for_each_entry(res_list_elem, &resource_list_head,
1561 warn = 1; 1292 resource_list) {
1562 clash = acpi_check_address_range(space_id, res->start, length, warn); 1293 if (ioport && (res_list_elem->resource_type
1294 != ACPI_ADR_SPACE_SYSTEM_IO))
1295 continue;
1296 if (!ioport && (res_list_elem->resource_type
1297 != ACPI_ADR_SPACE_SYSTEM_MEMORY))
1298 continue;
1299
1300 if (res->end < res_list_elem->start
1301 || res_list_elem->end < res->start)
1302 continue;
1303 clash = 1;
1304 break;
1305 }
1306 spin_unlock(&acpi_res_lock);
1563 1307
1564 if (clash) { 1308 if (clash) {
1565 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { 1309 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) {
1310 printk(KERN_WARNING "ACPI: resource %s %pR"
1311 " conflicts with ACPI region %s "
1312 "[%s 0x%zx-0x%zx]\n",
1313 res->name, res, res_list_elem->name,
1314 (res_list_elem->resource_type ==
1315 ACPI_ADR_SPACE_SYSTEM_IO) ? "io" : "mem",
1316 (size_t) res_list_elem->start,
1317 (size_t) res_list_elem->end);
1566 if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX) 1318 if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX)
1567 printk(KERN_NOTICE "ACPI: This conflict may" 1319 printk(KERN_NOTICE "ACPI: This conflict may"
1568 " cause random problems and system" 1320 " cause random problems and system"
@@ -1714,6 +1466,155 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
1714 kmem_cache_free(cache, object); 1466 kmem_cache_free(cache, object);
1715 return (AE_OK); 1467 return (AE_OK);
1716} 1468}
1469
1470static inline int acpi_res_list_add(struct acpi_res_list *res)
1471{
1472 struct acpi_res_list *res_list_elem;
1473
1474 list_for_each_entry(res_list_elem, &resource_list_head,
1475 resource_list) {
1476
1477 if (res->resource_type == res_list_elem->resource_type &&
1478 res->start == res_list_elem->start &&
1479 res->end == res_list_elem->end) {
1480
1481 /*
1482 * The Region(addr,len) already exist in the list,
1483 * just increase the count
1484 */
1485
1486 res_list_elem->count++;
1487 return 0;
1488 }
1489 }
1490
1491 res->count = 1;
1492 list_add(&res->resource_list, &resource_list_head);
1493 return 1;
1494}
1495
1496static inline void acpi_res_list_del(struct acpi_res_list *res)
1497{
1498 struct acpi_res_list *res_list_elem;
1499
1500 list_for_each_entry(res_list_elem, &resource_list_head,
1501 resource_list) {
1502
1503 if (res->resource_type == res_list_elem->resource_type &&
1504 res->start == res_list_elem->start &&
1505 res->end == res_list_elem->end) {
1506
1507 /*
1508 * If the res count is decreased to 0,
1509 * remove and free it
1510 */
1511
1512 if (--res_list_elem->count == 0) {
1513 list_del(&res_list_elem->resource_list);
1514 kfree(res_list_elem);
1515 }
1516 return;
1517 }
1518 }
1519}
1520
1521acpi_status
1522acpi_os_invalidate_address(
1523 u8 space_id,
1524 acpi_physical_address address,
1525 acpi_size length)
1526{
1527 struct acpi_res_list res;
1528
1529 switch (space_id) {
1530 case ACPI_ADR_SPACE_SYSTEM_IO:
1531 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
1532 /* Only interference checks against SystemIO and SystemMemory
1533 are needed */
1534 res.start = address;
1535 res.end = address + length - 1;
1536 res.resource_type = space_id;
1537 spin_lock(&acpi_res_lock);
1538 acpi_res_list_del(&res);
1539 spin_unlock(&acpi_res_lock);
1540 break;
1541 case ACPI_ADR_SPACE_PCI_CONFIG:
1542 case ACPI_ADR_SPACE_EC:
1543 case ACPI_ADR_SPACE_SMBUS:
1544 case ACPI_ADR_SPACE_CMOS:
1545 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
1546 case ACPI_ADR_SPACE_DATA_TABLE:
1547 case ACPI_ADR_SPACE_FIXED_HARDWARE:
1548 break;
1549 }
1550 return AE_OK;
1551}
1552
1553/******************************************************************************
1554 *
1555 * FUNCTION: acpi_os_validate_address
1556 *
1557 * PARAMETERS: space_id - ACPI space ID
1558 * address - Physical address
1559 * length - Address length
1560 *
1561 * RETURN: AE_OK if address/length is valid for the space_id. Otherwise,
1562 * should return AE_AML_ILLEGAL_ADDRESS.
1563 *
1564 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1565 * the addresses accessed by AML operation regions.
1566 *
1567 *****************************************************************************/
1568
1569acpi_status
1570acpi_os_validate_address (
1571 u8 space_id,
1572 acpi_physical_address address,
1573 acpi_size length,
1574 char *name)
1575{
1576 struct acpi_res_list *res;
1577 int added;
1578 if (acpi_enforce_resources == ENFORCE_RESOURCES_NO)
1579 return AE_OK;
1580
1581 switch (space_id) {
1582 case ACPI_ADR_SPACE_SYSTEM_IO:
1583 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
1584 /* Only interference checks against SystemIO and SystemMemory
1585 are needed */
1586 res = kzalloc(sizeof(struct acpi_res_list), GFP_KERNEL);
1587 if (!res)
1588 return AE_OK;
1589 /* ACPI names are fixed to 4 bytes, still better use strlcpy */
1590 strlcpy(res->name, name, 5);
1591 res->start = address;
1592 res->end = address + length - 1;
1593 res->resource_type = space_id;
1594 spin_lock(&acpi_res_lock);
1595 added = acpi_res_list_add(res);
1596 spin_unlock(&acpi_res_lock);
1597 pr_debug("%s %s resource: start: 0x%llx, end: 0x%llx, "
1598 "name: %s\n", added ? "Added" : "Already exist",
1599 (space_id == ACPI_ADR_SPACE_SYSTEM_IO)
1600 ? "SystemIO" : "System Memory",
1601 (unsigned long long)res->start,
1602 (unsigned long long)res->end,
1603 res->name);
1604 if (!added)
1605 kfree(res);
1606 break;
1607 case ACPI_ADR_SPACE_PCI_CONFIG:
1608 case ACPI_ADR_SPACE_EC:
1609 case ACPI_ADR_SPACE_SMBUS:
1610 case ACPI_ADR_SPACE_CMOS:
1611 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
1612 case ACPI_ADR_SPACE_DATA_TABLE:
1613 case ACPI_ADR_SPACE_FIXED_HARDWARE:
1614 break;
1615 }
1616 return AE_OK;
1617}
1717#endif 1618#endif
1718 1619
1719acpi_status __init acpi_os_initialize(void) 1620acpi_status __init acpi_os_initialize(void)
@@ -1757,24 +1658,3 @@ acpi_status acpi_os_terminate(void)
1757 1658
1758 return AE_OK; 1659 return AE_OK;
1759} 1660}
1760
1761acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
1762 u32 pm1b_control)
1763{
1764 int rc = 0;
1765 if (__acpi_os_prepare_sleep)
1766 rc = __acpi_os_prepare_sleep(sleep_state,
1767 pm1a_control, pm1b_control);
1768 if (rc < 0)
1769 return AE_ERROR;
1770 else if (rc > 0)
1771 return AE_CTRL_SKIP;
1772
1773 return AE_OK;
1774}
1775
1776void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
1777 u32 pm1a_ctrl, u32 pm1b_ctrl))
1778{
1779 __acpi_os_prepare_sleep = func;
1780}
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index a1dee29beed..2ef04098cc1 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -45,12 +45,11 @@ static int acpi_pci_unbind(struct acpi_device *device)
45 45
46 device_set_run_wake(&dev->dev, false); 46 device_set_run_wake(&dev->dev, false);
47 pci_acpi_remove_pm_notifier(device); 47 pci_acpi_remove_pm_notifier(device);
48 acpi_power_resource_unregister_device(&dev->dev, device->handle);
49 48
50 if (!dev->subordinate) 49 if (!dev->subordinate)
51 goto out; 50 goto out;
52 51
53 acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number); 52 acpi_pci_irq_del_prt(dev->subordinate);
54 53
55 device->ops.bind = NULL; 54 device->ops.bind = NULL;
56 device->ops.unbind = NULL; 55 device->ops.unbind = NULL;
@@ -64,7 +63,7 @@ static int acpi_pci_bind(struct acpi_device *device)
64{ 63{
65 acpi_status status; 64 acpi_status status;
66 acpi_handle handle; 65 acpi_handle handle;
67 unsigned char bus; 66 struct pci_bus *bus;
68 struct pci_dev *dev; 67 struct pci_dev *dev;
69 68
70 dev = acpi_get_pci_dev(device->handle); 69 dev = acpi_get_pci_dev(device->handle);
@@ -72,7 +71,6 @@ static int acpi_pci_bind(struct acpi_device *device)
72 return 0; 71 return 0;
73 72
74 pci_acpi_add_pm_notifier(device, dev); 73 pci_acpi_add_pm_notifier(device, dev);
75 acpi_power_resource_register_device(&dev->dev, device->handle);
76 if (device->wakeup.flags.run_wake) 74 if (device->wakeup.flags.run_wake)
77 device_set_run_wake(&dev->dev, true); 75 device_set_run_wake(&dev->dev, true);
78 76
@@ -102,11 +100,11 @@ static int acpi_pci_bind(struct acpi_device *device)
102 goto out; 100 goto out;
103 101
104 if (dev->subordinate) 102 if (dev->subordinate)
105 bus = dev->subordinate->number; 103 bus = dev->subordinate;
106 else 104 else
107 bus = dev->bus->number; 105 bus = dev->bus;
108 106
109 acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus); 107 acpi_pci_irq_add_prt(device->handle, bus);
110 108
111out: 109out:
112 pci_dev_put(dev); 110 pci_dev_put(dev);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 68a921d0324..7f9eba9a0b0 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -184,7 +184,7 @@ static void do_prt_fixups(struct acpi_prt_entry *entry,
184 } 184 }
185} 185}
186 186
187static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus, 187static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus,
188 struct acpi_pci_routing_table *prt) 188 struct acpi_pci_routing_table *prt)
189{ 189{
190 struct acpi_prt_entry *entry; 190 struct acpi_prt_entry *entry;
@@ -198,8 +198,8 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
198 * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert 198 * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert
199 * it here. 199 * it here.
200 */ 200 */
201 entry->id.segment = segment; 201 entry->id.segment = pci_domain_nr(bus);
202 entry->id.bus = bus; 202 entry->id.bus = bus->number;
203 entry->id.device = (prt->address >> 16) & 0xFFFF; 203 entry->id.device = (prt->address >> 16) & 0xFFFF;
204 entry->pin = prt->pin + 1; 204 entry->pin = prt->pin + 1;
205 205
@@ -244,7 +244,7 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
244 return 0; 244 return 0;
245} 245}
246 246
247int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) 247int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus)
248{ 248{
249 acpi_status status; 249 acpi_status status;
250 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 250 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -273,7 +273,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
273 273
274 entry = buffer.pointer; 274 entry = buffer.pointer;
275 while (entry && (entry->length > 0)) { 275 while (entry && (entry->length > 0)) {
276 acpi_pci_irq_add_entry(handle, segment, bus, entry); 276 acpi_pci_irq_add_entry(handle, bus, entry);
277 entry = (struct acpi_pci_routing_table *) 277 entry = (struct acpi_pci_routing_table *)
278 ((unsigned long)entry + entry->length); 278 ((unsigned long)entry + entry->length);
279 } 279 }
@@ -282,16 +282,17 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
282 return 0; 282 return 0;
283} 283}
284 284
285void acpi_pci_irq_del_prt(int segment, int bus) 285void acpi_pci_irq_del_prt(struct pci_bus *bus)
286{ 286{
287 struct acpi_prt_entry *entry, *tmp; 287 struct acpi_prt_entry *entry, *tmp;
288 288
289 printk(KERN_DEBUG 289 printk(KERN_DEBUG
290 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", 290 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
291 segment, bus); 291 pci_domain_nr(bus), bus->number);
292 spin_lock(&acpi_prt_lock); 292 spin_lock(&acpi_prt_lock);
293 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) { 293 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
294 if (segment == entry->id.segment && bus == entry->id.bus) { 294 if (pci_domain_nr(bus) == entry->id.segment
295 && bus->number == entry->id.bus) {
295 list_del(&entry->list); 296 list_del(&entry->list);
296 kfree(entry); 297 kfree(entry);
297 } 298 }
@@ -458,19 +459,19 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
458 */ 459 */
459 if (gsi < 0) { 460 if (gsi < 0) {
460 u32 dev_gsi; 461 u32 dev_gsi;
462 dev_warn(&dev->dev, "PCI INT %c: no GSI", pin_name(pin));
461 /* Interrupt Line values above 0xF are forbidden */ 463 /* Interrupt Line values above 0xF are forbidden */
462 if (dev->irq > 0 && (dev->irq <= 0xF) && 464 if (dev->irq > 0 && (dev->irq <= 0xF) &&
463 (acpi_isa_irq_to_gsi(dev->irq, &dev_gsi) == 0)) { 465 (acpi_isa_irq_to_gsi(dev->irq, &dev_gsi) == 0)) {
464 dev_warn(&dev->dev, "PCI INT %c: no GSI - using ISA IRQ %d\n", 466 printk(" - using ISA IRQ %d\n", dev->irq);
465 pin_name(pin), dev->irq);
466 acpi_register_gsi(&dev->dev, dev_gsi, 467 acpi_register_gsi(&dev->dev, dev_gsi,
467 ACPI_LEVEL_SENSITIVE, 468 ACPI_LEVEL_SENSITIVE,
468 ACPI_ACTIVE_LOW); 469 ACPI_ACTIVE_LOW);
470 return 0;
469 } else { 471 } else {
470 dev_warn(&dev->dev, "PCI INT %c: no GSI\n", 472 printk("\n");
471 pin_name(pin)); 473 return 0;
472 } 474 }
473 return 0;
474 } 475 }
475 476
476 rc = acpi_register_gsi(&dev->dev, gsi, triggering, polarity); 477 rc = acpi_register_gsi(&dev->dev, gsi, triggering, polarity);
@@ -486,14 +487,19 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
486 else 487 else
487 link_desc[0] = '\0'; 488 link_desc[0] = '\0';
488 489
489 dev_dbg(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n", 490 dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n",
490 pin_name(pin), link_desc, gsi, 491 pin_name(pin), link_desc, gsi,
491 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 492 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
492 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 493 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
493 494
494 return 0; 495 return 0;
495} 496}
496 497
498/* FIXME: implement x86/x86_64 version */
499void __attribute__ ((weak)) acpi_unregister_gsi(u32 i)
500{
501}
502
497void acpi_pci_irq_disable(struct pci_dev *dev) 503void acpi_pci_irq_disable(struct pci_dev *dev)
498{ 504{
499 struct acpi_prt_entry *entry; 505 struct acpi_prt_entry *entry;
@@ -518,6 +524,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
518 * (e.g. PCI_UNDEFINED_IRQ). 524 * (e.g. PCI_UNDEFINED_IRQ).
519 */ 525 */
520 526
521 dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin)); 527 dev_info(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
522 acpi_unregister_gsi(gsi); 528 acpi_unregister_gsi(gsi);
523} 529}
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index a12808259df..4a29763b8eb 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -720,21 +720,21 @@ static int acpi_pci_link_add(struct acpi_device *device)
720 acpi_device_bid(device)); 720 acpi_device_bid(device));
721 for (i = 0; i < link->irq.possible_count; i++) { 721 for (i = 0; i < link->irq.possible_count; i++) {
722 if (link->irq.active == link->irq.possible[i]) { 722 if (link->irq.active == link->irq.possible[i]) {
723 printk(KERN_CONT " *%d", link->irq.possible[i]); 723 printk(" *%d", link->irq.possible[i]);
724 found = 1; 724 found = 1;
725 } else 725 } else
726 printk(KERN_CONT " %d", link->irq.possible[i]); 726 printk(" %d", link->irq.possible[i]);
727 } 727 }
728 728
729 printk(KERN_CONT ")"); 729 printk(")");
730 730
731 if (!found) 731 if (!found)
732 printk(KERN_CONT " *%d", link->irq.active); 732 printk(" *%d", link->irq.active);
733 733
734 if (!link->device->status.enabled) 734 if (!link->device->status.enabled)
735 printk(KERN_CONT ", disabled."); 735 printk(", disabled.");
736 736
737 printk(KERN_CONT "\n"); 737 printk("\n");
738 738
739 list_add_tail(&link->list, &acpi_link_list); 739 list_add_tail(&link->list, &acpi_link_list);
740 740
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 7928d4dc705..2672c798272 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -27,7 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/mutex.h> 30#include <linux/spinlock.h>
31#include <linux/pm.h> 31#include <linux/pm.h>
32#include <linux/pm_runtime.h> 32#include <linux/pm_runtime.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
@@ -71,11 +71,9 @@ static struct acpi_driver acpi_pci_root_driver = {
71 }, 71 },
72}; 72};
73 73
74/* Lock to protect both acpi_pci_roots and acpi_pci_drivers lists */
75static DEFINE_MUTEX(acpi_pci_root_lock);
76static LIST_HEAD(acpi_pci_roots); 74static LIST_HEAD(acpi_pci_roots);
77static LIST_HEAD(acpi_pci_drivers);
78 75
76static struct acpi_pci_driver *sub_driver;
79static DEFINE_MUTEX(osc_lock); 77static DEFINE_MUTEX(osc_lock);
80 78
81int acpi_pci_register_driver(struct acpi_pci_driver *driver) 79int acpi_pci_register_driver(struct acpi_pci_driver *driver)
@@ -83,46 +81,55 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver)
83 int n = 0; 81 int n = 0;
84 struct acpi_pci_root *root; 82 struct acpi_pci_root *root;
85 83
86 mutex_lock(&acpi_pci_root_lock); 84 struct acpi_pci_driver **pptr = &sub_driver;
87 list_add_tail(&driver->node, &acpi_pci_drivers); 85 while (*pptr)
88 if (driver->add) 86 pptr = &(*pptr)->next;
89 list_for_each_entry(root, &acpi_pci_roots, node) { 87 *pptr = driver;
90 driver->add(root); 88
91 n++; 89 if (!driver->add)
92 } 90 return 0;
93 mutex_unlock(&acpi_pci_root_lock); 91
92 list_for_each_entry(root, &acpi_pci_roots, node) {
93 driver->add(root->device->handle);
94 n++;
95 }
94 96
95 return n; 97 return n;
96} 98}
99
97EXPORT_SYMBOL(acpi_pci_register_driver); 100EXPORT_SYMBOL(acpi_pci_register_driver);
98 101
99void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) 102void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
100{ 103{
101 struct acpi_pci_root *root; 104 struct acpi_pci_root *root;
102 105
103 mutex_lock(&acpi_pci_root_lock); 106 struct acpi_pci_driver **pptr = &sub_driver;
104 list_del(&driver->node); 107 while (*pptr) {
105 if (driver->remove) 108 if (*pptr == driver)
106 list_for_each_entry(root, &acpi_pci_roots, node) 109 break;
107 driver->remove(root); 110 pptr = &(*pptr)->next;
108 mutex_unlock(&acpi_pci_root_lock); 111 }
112 BUG_ON(!*pptr);
113 *pptr = (*pptr)->next;
114
115 if (!driver->remove)
116 return;
117
118 list_for_each_entry(root, &acpi_pci_roots, node)
119 driver->remove(root->device->handle);
109} 120}
121
110EXPORT_SYMBOL(acpi_pci_unregister_driver); 122EXPORT_SYMBOL(acpi_pci_unregister_driver);
111 123
112acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) 124acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
113{ 125{
114 struct acpi_pci_root *root; 126 struct acpi_pci_root *root;
115 acpi_handle handle = NULL;
116 127
117 mutex_lock(&acpi_pci_root_lock);
118 list_for_each_entry(root, &acpi_pci_roots, node) 128 list_for_each_entry(root, &acpi_pci_roots, node)
119 if ((root->segment == (u16) seg) && 129 if ((root->segment == (u16) seg) &&
120 (root->secondary.start == (u16) bus)) { 130 (root->secondary.start == (u16) bus))
121 handle = root->device->handle; 131 return root->device->handle;
122 break; 132 return NULL;
123 }
124 mutex_unlock(&acpi_pci_root_lock);
125 return handle;
126} 133}
127 134
128EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle); 135EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle);
@@ -270,15 +277,12 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
270struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) 277struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
271{ 278{
272 struct acpi_pci_root *root; 279 struct acpi_pci_root *root;
273 struct acpi_device *device;
274
275 if (acpi_bus_get_device(handle, &device) ||
276 acpi_match_device_ids(device, root_device_ids))
277 return NULL;
278 280
279 root = acpi_driver_data(device); 281 list_for_each_entry(root, &acpi_pci_roots, node) {
280 282 if (root->device->handle == handle)
281 return root; 283 return root;
284 }
285 return NULL;
282} 286}
283EXPORT_SYMBOL_GPL(acpi_pci_find_root); 287EXPORT_SYMBOL_GPL(acpi_pci_find_root);
284 288
@@ -445,7 +449,7 @@ out:
445} 449}
446EXPORT_SYMBOL(acpi_pci_osc_control_set); 450EXPORT_SYMBOL(acpi_pci_osc_control_set);
447 451
448static int acpi_pci_root_add(struct acpi_device *device) 452static int __devinit acpi_pci_root_add(struct acpi_device *device)
449{ 453{
450 unsigned long long segment, bus; 454 unsigned long long segment, bus;
451 acpi_status status; 455 acpi_status status;
@@ -454,7 +458,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
454 acpi_handle handle; 458 acpi_handle handle;
455 struct acpi_device *child; 459 struct acpi_device *child;
456 u32 flags, base_flags; 460 u32 flags, base_flags;
457 bool is_osc_granted = false;
458 461
459 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 462 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
460 if (!root) 463 if (!root)
@@ -502,47 +505,75 @@ static int acpi_pci_root_add(struct acpi_device *device)
502 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); 505 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
503 device->driver_data = root; 506 device->driver_data = root;
504 507
508 /*
509 * All supported architectures that use ACPI have support for
510 * PCI domains, so we indicate this in _OSC support capabilities.
511 */
512 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
513 acpi_pci_osc_support(root, flags);
514
515 /*
516 * TBD: Need PCI interface for enumeration/configuration of roots.
517 */
518
519 /* TBD: Locking */
520 list_add_tail(&root->node, &acpi_pci_roots);
521
505 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", 522 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n",
506 acpi_device_name(device), acpi_device_bid(device), 523 acpi_device_name(device), acpi_device_bid(device),
507 root->segment, &root->secondary); 524 root->segment, &root->secondary);
508 525
509 /* 526 /*
527 * Scan the Root Bridge
528 * --------------------
529 * Must do this prior to any attempt to bind the root device, as the
530 * PCI namespace does not get created until this call is made (and
531 * thus the root bridge's pci_dev does not exist).
532 */
533 root->bus = pci_acpi_scan_root(root);
534 if (!root->bus) {
535 printk(KERN_ERR PREFIX
536 "Bus %04x:%02x not present in PCI namespace\n",
537 root->segment, (unsigned int)root->secondary.start);
538 result = -ENODEV;
539 goto end;
540 }
541
542 /*
543 * Attach ACPI-PCI Context
544 * -----------------------
545 * Thus binding the ACPI and PCI devices.
546 */
547 result = acpi_pci_bind_root(device);
548 if (result)
549 goto end;
550
551 /*
510 * PCI Routing Table 552 * PCI Routing Table
511 * ----------------- 553 * -----------------
512 * Evaluate and parse _PRT, if exists. 554 * Evaluate and parse _PRT, if exists.
513 */ 555 */
514 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); 556 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
515 if (ACPI_SUCCESS(status)) 557 if (ACPI_SUCCESS(status))
516 result = acpi_pci_irq_add_prt(device->handle, root->segment, 558 result = acpi_pci_irq_add_prt(device->handle, root->bus);
517 root->secondary.start);
518
519 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
520 559
521 /* 560 /*
522 * All supported architectures that use ACPI have support for 561 * Scan and bind all _ADR-Based Devices
523 * PCI domains, so we indicate this in _OSC support capabilities.
524 */ 562 */
525 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT; 563 list_for_each_entry(child, &device->children, node)
526 acpi_pci_osc_support(root, flags); 564 acpi_pci_bridge_scan(child);
527 565
528 /* Indicate support for various _OSC capabilities. */ 566 /* Indicate support for various _OSC capabilities. */
529 if (pci_ext_cfg_avail()) 567 if (pci_ext_cfg_avail(root->bus->self))
530 flags |= OSC_EXT_PCI_CONFIG_SUPPORT; 568 flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
531 if (pcie_aspm_support_enabled()) { 569 if (pcie_aspm_support_enabled())
532 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT | 570 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT |
533 OSC_CLOCK_PWR_CAPABILITY_SUPPORT; 571 OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
534 }
535 if (pci_msi_enabled()) 572 if (pci_msi_enabled())
536 flags |= OSC_MSI_SUPPORT; 573 flags |= OSC_MSI_SUPPORT;
537 if (flags != base_flags) { 574 if (flags != base_flags)
538 status = acpi_pci_osc_support(root, flags); 575 acpi_pci_osc_support(root, flags);
539 if (ACPI_FAILURE(status)) { 576
540 dev_info(&device->dev, "ACPI _OSC support "
541 "notification failed, disabling PCIe ASPM\n");
542 pcie_no_aspm();
543 flags = base_flags;
544 }
545 }
546 if (!pcie_ports_disabled 577 if (!pcie_ports_disabled
547 && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) { 578 && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
548 flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL 579 flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -551,81 +582,33 @@ static int acpi_pci_root_add(struct acpi_device *device)
551 582
552 if (pci_aer_available()) { 583 if (pci_aer_available()) {
553 if (aer_acpi_firmware_first()) 584 if (aer_acpi_firmware_first())
554 dev_dbg(&device->dev, 585 dev_dbg(root->bus->bridge,
555 "PCIe errors handled by BIOS.\n"); 586 "PCIe errors handled by BIOS.\n");
556 else 587 else
557 flags |= OSC_PCI_EXPRESS_AER_CONTROL; 588 flags |= OSC_PCI_EXPRESS_AER_CONTROL;
558 } 589 }
559 590
560 dev_info(&device->dev, 591 dev_info(root->bus->bridge,
561 "Requesting ACPI _OSC control (0x%02x)\n", flags); 592 "Requesting ACPI _OSC control (0x%02x)\n", flags);
562 593
563 status = acpi_pci_osc_control_set(device->handle, &flags, 594 status = acpi_pci_osc_control_set(device->handle, &flags,
564 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); 595 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
565 if (ACPI_SUCCESS(status)) { 596 if (ACPI_SUCCESS(status)) {
566 is_osc_granted = true; 597 dev_info(root->bus->bridge,
567 dev_info(&device->dev,
568 "ACPI _OSC control (0x%02x) granted\n", flags); 598 "ACPI _OSC control (0x%02x) granted\n", flags);
569 } else { 599 } else {
570 is_osc_granted = false; 600 dev_info(root->bus->bridge,
571 dev_info(&device->dev,
572 "ACPI _OSC request failed (%s), " 601 "ACPI _OSC request failed (%s), "
573 "returned control mask: 0x%02x\n", 602 "returned control mask: 0x%02x\n",
574 acpi_format_exception(status), flags); 603 acpi_format_exception(status), flags);
604 pr_info("ACPI _OSC control for PCIe not granted, "
605 "disabling ASPM\n");
606 pcie_no_aspm();
575 } 607 }
576 } else { 608 } else {
577 dev_info(&device->dev, 609 dev_info(root->bus->bridge,
578 "Unable to request _OSC control " 610 "Unable to request _OSC control "
579 "(_OSC support mask: 0x%02x)\n", flags); 611 "(_OSC support mask: 0x%02x)\n", flags);
580 }
581
582 /*
583 * TBD: Need PCI interface for enumeration/configuration of roots.
584 */
585
586 mutex_lock(&acpi_pci_root_lock);
587 list_add_tail(&root->node, &acpi_pci_roots);
588 mutex_unlock(&acpi_pci_root_lock);
589
590 /*
591 * Scan the Root Bridge
592 * --------------------
593 * Must do this prior to any attempt to bind the root device, as the
594 * PCI namespace does not get created until this call is made (and
595 * thus the root bridge's pci_dev does not exist).
596 */
597 root->bus = pci_acpi_scan_root(root);
598 if (!root->bus) {
599 printk(KERN_ERR PREFIX
600 "Bus %04x:%02x not present in PCI namespace\n",
601 root->segment, (unsigned int)root->secondary.start);
602 result = -ENODEV;
603 goto out_del_root;
604 }
605
606 /*
607 * Attach ACPI-PCI Context
608 * -----------------------
609 * Thus binding the ACPI and PCI devices.
610 */
611 result = acpi_pci_bind_root(device);
612 if (result)
613 goto out_del_root;
614
615 /*
616 * Scan and bind all _ADR-Based Devices
617 */
618 list_for_each_entry(child, &device->children, node)
619 acpi_pci_bridge_scan(child);
620
621 /* ASPM setting */
622 if (is_osc_granted) {
623 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
624 pcie_clear_aspm(root->bus);
625 } else {
626 pr_info("ACPI _OSC control for PCIe not granted, "
627 "disabling ASPM\n");
628 pcie_no_aspm();
629 } 612 }
630 613
631 pci_acpi_add_bus_pm_notifier(device, root->bus); 614 pci_acpi_add_bus_pm_notifier(device, root->bus);
@@ -634,13 +617,9 @@ static int acpi_pci_root_add(struct acpi_device *device)
634 617
635 return 0; 618 return 0;
636 619
637out_del_root:
638 mutex_lock(&acpi_pci_root_lock);
639 list_del(&root->node);
640 mutex_unlock(&acpi_pci_root_lock);
641
642 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
643end: 620end:
621 if (!list_empty(&root->node))
622 list_del(&root->node);
644 kfree(root); 623 kfree(root);
645 return result; 624 return result;
646} 625}
@@ -648,53 +627,18 @@ end:
648static int acpi_pci_root_start(struct acpi_device *device) 627static int acpi_pci_root_start(struct acpi_device *device)
649{ 628{
650 struct acpi_pci_root *root = acpi_driver_data(device); 629 struct acpi_pci_root *root = acpi_driver_data(device);
651 struct acpi_pci_driver *driver;
652
653 if (system_state != SYSTEM_BOOTING)
654 pci_assign_unassigned_bus_resources(root->bus);
655
656 mutex_lock(&acpi_pci_root_lock);
657 list_for_each_entry(driver, &acpi_pci_drivers, node)
658 if (driver->add)
659 driver->add(root);
660 mutex_unlock(&acpi_pci_root_lock);
661
662 /* need to after hot-added ioapic is registered */
663 if (system_state != SYSTEM_BOOTING)
664 pci_enable_bridges(root->bus);
665 630
666 pci_bus_add_devices(root->bus); 631 pci_bus_add_devices(root->bus);
667
668 return 0; 632 return 0;
669} 633}
670 634
671static int acpi_pci_root_remove(struct acpi_device *device, int type) 635static int acpi_pci_root_remove(struct acpi_device *device, int type)
672{ 636{
673 acpi_status status;
674 acpi_handle handle;
675 struct acpi_pci_root *root = acpi_driver_data(device); 637 struct acpi_pci_root *root = acpi_driver_data(device);
676 struct acpi_pci_driver *driver;
677
678 pci_stop_root_bus(root->bus);
679
680 mutex_lock(&acpi_pci_root_lock);
681 list_for_each_entry_reverse(driver, &acpi_pci_drivers, node)
682 if (driver->remove)
683 driver->remove(root);
684 mutex_unlock(&acpi_pci_root_lock);
685 638
686 device_set_run_wake(root->bus->bridge, false); 639 device_set_run_wake(root->bus->bridge, false);
687 pci_acpi_remove_bus_pm_notifier(device); 640 pci_acpi_remove_bus_pm_notifier(device);
688 641
689 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
690 if (ACPI_SUCCESS(status))
691 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
692
693 pci_remove_root_bus(root->bus);
694
695 mutex_lock(&acpi_pci_root_lock);
696 list_del(&root->node);
697 mutex_unlock(&acpi_pci_root_lock);
698 kfree(root); 642 kfree(root);
699 return 0; 643 return 0;
700} 644}
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index d22585f21ae..07f7fea8a4e 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -34,7 +34,7 @@
34#include <acpi/acpi_drivers.h> 34#include <acpi/acpi_drivers.h>
35#include <linux/dmi.h> 35#include <linux/dmi.h>
36 36
37static bool debug; 37static int debug;
38static int check_sta_before_sun; 38static int check_sta_before_sun;
39 39
40#define DRIVER_VERSION "0.1" 40#define DRIVER_VERSION "0.1"
@@ -67,8 +67,8 @@ struct acpi_pci_slot {
67 struct list_head list; /* node in the list of slots */ 67 struct list_head list; /* node in the list of slots */
68}; 68};
69 69
70static int acpi_pci_slot_add(struct acpi_pci_root *root); 70static int acpi_pci_slot_add(acpi_handle handle);
71static void acpi_pci_slot_remove(struct acpi_pci_root *root); 71static void acpi_pci_slot_remove(acpi_handle handle);
72 72
73static LIST_HEAD(slot_list); 73static LIST_HEAD(slot_list);
74static DEFINE_MUTEX(slot_list_lock); 74static DEFINE_MUTEX(slot_list_lock);
@@ -233,20 +233,45 @@ out:
233 233
234/* 234/*
235 * walk_root_bridge - generic root bridge walker 235 * walk_root_bridge - generic root bridge walker
236 * @root: poiner of an acpi_pci_root 236 * @handle: points to an acpi_pci_root
237 * @user_function: user callback for slot objects 237 * @user_function: user callback for slot objects
238 * 238 *
239 * Call user_function for all objects underneath this root bridge. 239 * Call user_function for all objects underneath this root bridge.
240 * Walk p2p bridges underneath us and call user_function on those too. 240 * Walk p2p bridges underneath us and call user_function on those too.
241 */ 241 */
242static int 242static int
243walk_root_bridge(struct acpi_pci_root *root, acpi_walk_callback user_function) 243walk_root_bridge(acpi_handle handle, acpi_walk_callback user_function)
244{ 244{
245 int seg, bus;
246 unsigned long long tmp;
245 acpi_status status; 247 acpi_status status;
246 acpi_handle handle = root->device->handle; 248 acpi_handle dummy_handle;
247 struct pci_bus *pci_bus = root->bus; 249 struct pci_bus *pci_bus;
248 struct callback_args context; 250 struct callback_args context;
249 251
252 /* If the bridge doesn't have _STA, we assume it is always there */
253 status = acpi_get_handle(handle, "_STA", &dummy_handle);
254 if (ACPI_SUCCESS(status)) {
255 status = acpi_evaluate_integer(handle, "_STA", NULL, &tmp);
256 if (ACPI_FAILURE(status)) {
257 info("%s: _STA evaluation failure\n", __func__);
258 return 0;
259 }
260 if ((tmp & ACPI_STA_DEVICE_FUNCTIONING) == 0)
261 /* don't register this object */
262 return 0;
263 }
264
265 status = acpi_evaluate_integer(handle, "_SEG", NULL, &tmp);
266 seg = ACPI_SUCCESS(status) ? tmp : 0;
267
268 status = acpi_evaluate_integer(handle, "_BBN", NULL, &tmp);
269 bus = ACPI_SUCCESS(status) ? tmp : 0;
270
271 pci_bus = pci_find_bus(seg, bus);
272 if (!pci_bus)
273 return 0;
274
250 context.pci_bus = pci_bus; 275 context.pci_bus = pci_bus;
251 context.user_function = user_function; 276 context.user_function = user_function;
252 context.root_handle = handle; 277 context.root_handle = handle;
@@ -270,11 +295,11 @@ walk_root_bridge(struct acpi_pci_root *root, acpi_walk_callback user_function)
270 * @handle: points to an acpi_pci_root 295 * @handle: points to an acpi_pci_root
271 */ 296 */
272static int 297static int
273acpi_pci_slot_add(struct acpi_pci_root *root) 298acpi_pci_slot_add(acpi_handle handle)
274{ 299{
275 acpi_status status; 300 acpi_status status;
276 301
277 status = walk_root_bridge(root, register_slot); 302 status = walk_root_bridge(handle, register_slot);
278 if (ACPI_FAILURE(status)) 303 if (ACPI_FAILURE(status))
279 err("%s: register_slot failure - %d\n", __func__, status); 304 err("%s: register_slot failure - %d\n", __func__, status);
280 305
@@ -286,11 +311,10 @@ acpi_pci_slot_add(struct acpi_pci_root *root)
286 * @handle: points to an acpi_pci_root 311 * @handle: points to an acpi_pci_root
287 */ 312 */
288static void 313static void
289acpi_pci_slot_remove(struct acpi_pci_root *root) 314acpi_pci_slot_remove(acpi_handle handle)
290{ 315{
291 struct acpi_pci_slot *slot, *tmp; 316 struct acpi_pci_slot *slot, *tmp;
292 struct pci_bus *pbus; 317 struct pci_bus *pbus;
293 acpi_handle handle = root->device->handle;
294 318
295 mutex_lock(&slot_list_lock); 319 mutex_lock(&slot_list_lock);
296 list_for_each_entry_safe(slot, tmp, &slot_list, list) { 320 list_for_each_entry_safe(slot, tmp, &slot_list, list) {
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 6e7b9d52381..9ac2a9fa90f 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -40,11 +40,9 @@
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/slab.h>
43#include <linux/pm_runtime.h>
44#include <acpi/acpi_bus.h> 43#include <acpi/acpi_bus.h>
45#include <acpi/acpi_drivers.h> 44#include <acpi/acpi_drivers.h>
46#include "sleep.h" 45#include "sleep.h"
47#include "internal.h"
48 46
49#define PREFIX "ACPI: " 47#define PREFIX "ACPI: "
50 48
@@ -60,6 +58,7 @@ ACPI_MODULE_NAME("power");
60 58
61static int acpi_power_add(struct acpi_device *device); 59static int acpi_power_add(struct acpi_device *device);
62static int acpi_power_remove(struct acpi_device *device, int type); 60static int acpi_power_remove(struct acpi_device *device, int type);
61static int acpi_power_resume(struct acpi_device *device);
63 62
64static const struct acpi_device_id power_device_ids[] = { 63static const struct acpi_device_id power_device_ids[] = {
65 {ACPI_POWER_HID, 0}, 64 {ACPI_POWER_HID, 0},
@@ -67,11 +66,6 @@ static const struct acpi_device_id power_device_ids[] = {
67}; 66};
68MODULE_DEVICE_TABLE(acpi, power_device_ids); 67MODULE_DEVICE_TABLE(acpi, power_device_ids);
69 68
70#ifdef CONFIG_PM_SLEEP
71static int acpi_power_resume(struct device *dev);
72#endif
73static SIMPLE_DEV_PM_OPS(acpi_power_pm, NULL, acpi_power_resume);
74
75static struct acpi_driver acpi_power_driver = { 69static struct acpi_driver acpi_power_driver = {
76 .name = "power", 70 .name = "power",
77 .class = ACPI_POWER_CLASS, 71 .class = ACPI_POWER_CLASS,
@@ -79,22 +73,8 @@ static struct acpi_driver acpi_power_driver = {
79 .ops = { 73 .ops = {
80 .add = acpi_power_add, 74 .add = acpi_power_add,
81 .remove = acpi_power_remove, 75 .remove = acpi_power_remove,
76 .resume = acpi_power_resume,
82 }, 77 },
83 .drv.pm = &acpi_power_pm,
84};
85
86/*
87 * A power managed device
88 * A device may rely on multiple power resources.
89 * */
90struct acpi_power_managed_device {
91 struct device *dev; /* The physical device */
92 acpi_handle *handle;
93};
94
95struct acpi_power_resource_device {
96 struct acpi_power_managed_device *device;
97 struct acpi_power_resource_device *next;
98}; 78};
99 79
100struct acpi_power_resource { 80struct acpi_power_resource {
@@ -104,10 +84,6 @@ struct acpi_power_resource {
104 u32 order; 84 u32 order;
105 unsigned int ref_count; 85 unsigned int ref_count;
106 struct mutex resource_lock; 86 struct mutex resource_lock;
107
108 /* List of devices relying on this power resource */
109 struct acpi_power_resource_device *devices;
110 struct mutex devices_lock;
111}; 87};
112 88
113static struct list_head acpi_power_resource_list; 89static struct list_head acpi_power_resource_list;
@@ -207,23 +183,6 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
207 return 0; 183 return 0;
208} 184}
209 185
210/* Resume the device when all power resources in _PR0 are on */
211static void acpi_power_on_device(struct acpi_power_managed_device *device)
212{
213 struct acpi_device *acpi_dev;
214 acpi_handle handle = device->handle;
215 int state;
216
217 if (acpi_bus_get_device(handle, &acpi_dev))
218 return;
219
220 if(acpi_power_get_inferred_state(acpi_dev, &state))
221 return;
222
223 if (state == ACPI_STATE_D0 && pm_runtime_suspended(device->dev))
224 pm_request_resume(device->dev);
225}
226
227static int __acpi_power_on(struct acpi_power_resource *resource) 186static int __acpi_power_on(struct acpi_power_resource *resource)
228{ 187{
229 acpi_status status = AE_OK; 188 acpi_status status = AE_OK;
@@ -244,9 +203,7 @@ static int __acpi_power_on(struct acpi_power_resource *resource)
244static int acpi_power_on(acpi_handle handle) 203static int acpi_power_on(acpi_handle handle)
245{ 204{
246 int result = 0; 205 int result = 0;
247 bool resume_device = false;
248 struct acpi_power_resource *resource = NULL; 206 struct acpi_power_resource *resource = NULL;
249 struct acpi_power_resource_device *device_list;
250 207
251 result = acpi_power_get_context(handle, &resource); 208 result = acpi_power_get_context(handle, &resource);
252 if (result) 209 if (result)
@@ -262,25 +219,10 @@ static int acpi_power_on(acpi_handle handle)
262 result = __acpi_power_on(resource); 219 result = __acpi_power_on(resource);
263 if (result) 220 if (result)
264 resource->ref_count--; 221 resource->ref_count--;
265 else
266 resume_device = true;
267 } 222 }
268 223
269 mutex_unlock(&resource->resource_lock); 224 mutex_unlock(&resource->resource_lock);
270 225
271 if (!resume_device)
272 return result;
273
274 mutex_lock(&resource->devices_lock);
275
276 device_list = resource->devices;
277 while (device_list) {
278 acpi_power_on_device(device_list->device);
279 device_list = device_list->next;
280 }
281
282 mutex_unlock(&resource->devices_lock);
283
284 return result; 226 return result;
285} 227}
286 228
@@ -357,120 +299,6 @@ static int acpi_power_on_list(struct acpi_handle_list *list)
357 return result; 299 return result;
358} 300}
359 301
360static void __acpi_power_resource_unregister_device(struct device *dev,
361 acpi_handle res_handle)
362{
363 struct acpi_power_resource *resource = NULL;
364 struct acpi_power_resource_device *prev, *curr;
365
366 if (acpi_power_get_context(res_handle, &resource))
367 return;
368
369 mutex_lock(&resource->devices_lock);
370 prev = NULL;
371 curr = resource->devices;
372 while (curr) {
373 if (curr->device->dev == dev) {
374 if (!prev)
375 resource->devices = curr->next;
376 else
377 prev->next = curr->next;
378
379 kfree(curr);
380 break;
381 }
382
383 prev = curr;
384 curr = curr->next;
385 }
386 mutex_unlock(&resource->devices_lock);
387}
388
389/* Unlink dev from all power resources in _PR0 */
390void acpi_power_resource_unregister_device(struct device *dev, acpi_handle handle)
391{
392 struct acpi_device *acpi_dev;
393 struct acpi_handle_list *list;
394 int i;
395
396 if (!dev || !handle)
397 return;
398
399 if (acpi_bus_get_device(handle, &acpi_dev))
400 return;
401
402 list = &acpi_dev->power.states[ACPI_STATE_D0].resources;
403
404 for (i = 0; i < list->count; i++)
405 __acpi_power_resource_unregister_device(dev,
406 list->handles[i]);
407}
408EXPORT_SYMBOL_GPL(acpi_power_resource_unregister_device);
409
410static int __acpi_power_resource_register_device(
411 struct acpi_power_managed_device *powered_device, acpi_handle handle)
412{
413 struct acpi_power_resource *resource = NULL;
414 struct acpi_power_resource_device *power_resource_device;
415 int result;
416
417 result = acpi_power_get_context(handle, &resource);
418 if (result)
419 return result;
420
421 power_resource_device = kzalloc(
422 sizeof(*power_resource_device), GFP_KERNEL);
423 if (!power_resource_device)
424 return -ENOMEM;
425
426 power_resource_device->device = powered_device;
427
428 mutex_lock(&resource->devices_lock);
429 power_resource_device->next = resource->devices;
430 resource->devices = power_resource_device;
431 mutex_unlock(&resource->devices_lock);
432
433 return 0;
434}
435
436/* Link dev to all power resources in _PR0 */
437int acpi_power_resource_register_device(struct device *dev, acpi_handle handle)
438{
439 struct acpi_device *acpi_dev;
440 struct acpi_handle_list *list;
441 struct acpi_power_managed_device *powered_device;
442 int i, ret;
443
444 if (!dev || !handle)
445 return -ENODEV;
446
447 ret = acpi_bus_get_device(handle, &acpi_dev);
448 if (ret || !acpi_dev->power.flags.power_resources)
449 return -ENODEV;
450
451 powered_device = kzalloc(sizeof(*powered_device), GFP_KERNEL);
452 if (!powered_device)
453 return -ENOMEM;
454
455 powered_device->dev = dev;
456 powered_device->handle = handle;
457
458 list = &acpi_dev->power.states[ACPI_STATE_D0].resources;
459
460 for (i = 0; i < list->count; i++) {
461 ret = __acpi_power_resource_register_device(powered_device,
462 list->handles[i]);
463
464 if (ret) {
465 acpi_power_resource_unregister_device(dev, handle);
466 break;
467 }
468 }
469
470 return ret;
471}
472EXPORT_SYMBOL_GPL(acpi_power_resource_register_device);
473
474/** 302/**
475 * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in 303 * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in
476 * ACPI 3.0) _PSW (Power State Wake) 304 * ACPI 3.0) _PSW (Power State Wake)
@@ -641,7 +469,7 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
641 * We know a device's inferred power state when all the resources 469 * We know a device's inferred power state when all the resources
642 * required for a given D-state are 'on'. 470 * required for a given D-state are 'on'.
643 */ 471 */
644 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) { 472 for (i = ACPI_STATE_D0; i < ACPI_STATE_D3; i++) {
645 list = &device->power.states[i].resources; 473 list = &device->power.states[i].resources;
646 if (list->count < 1) 474 if (list->count < 1)
647 continue; 475 continue;
@@ -670,16 +498,16 @@ int acpi_power_on_resources(struct acpi_device *device, int state)
670 498
671int acpi_power_transition(struct acpi_device *device, int state) 499int acpi_power_transition(struct acpi_device *device, int state)
672{ 500{
673 int result = 0; 501 int result;
674 502
675 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD)) 503 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
676 return -EINVAL; 504 return -EINVAL;
677 505
678 if (device->power.state == state) 506 if (device->power.state == state)
679 return 0; 507 return 0;
680 508
681 if ((device->power.state < ACPI_STATE_D0) 509 if ((device->power.state < ACPI_STATE_D0)
682 || (device->power.state > ACPI_STATE_D3_COLD)) 510 || (device->power.state > ACPI_STATE_D3))
683 return -ENODEV; 511 return -ENODEV;
684 512
685 /* TBD: Resources must be ordered. */ 513 /* TBD: Resources must be ordered. */
@@ -689,11 +517,8 @@ int acpi_power_transition(struct acpi_device *device, int state)
689 * (e.g. so the device doesn't lose power while transitioning). Then, 517 * (e.g. so the device doesn't lose power while transitioning). Then,
690 * we dereference all power resources used in the current list. 518 * we dereference all power resources used in the current list.
691 */ 519 */
692 if (state < ACPI_STATE_D3_COLD) 520 result = acpi_power_on_list(&device->power.states[state].resources);
693 result = acpi_power_on_list( 521 if (!result)
694 &device->power.states[state].resources);
695
696 if (!result && device->power.state < ACPI_STATE_D3_COLD)
697 acpi_power_off_list( 522 acpi_power_off_list(
698 &device->power.states[device->power.state].resources); 523 &device->power.states[device->power.state].resources);
699 524
@@ -725,7 +550,6 @@ static int acpi_power_add(struct acpi_device *device)
725 550
726 resource->device = device; 551 resource->device = device;
727 mutex_init(&resource->resource_lock); 552 mutex_init(&resource->resource_lock);
728 mutex_init(&resource->devices_lock);
729 strcpy(resource->name, device->pnp.bus_id); 553 strcpy(resource->name, device->pnp.bus_id);
730 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); 554 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
731 strcpy(acpi_device_class(device), ACPI_POWER_CLASS); 555 strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
@@ -782,17 +606,14 @@ static int acpi_power_remove(struct acpi_device *device, int type)
782 return 0; 606 return 0;
783} 607}
784 608
785#ifdef CONFIG_PM_SLEEP 609static int acpi_power_resume(struct acpi_device *device)
786static int acpi_power_resume(struct device *dev)
787{ 610{
788 int result = 0, state; 611 int result = 0, state;
789 struct acpi_device *device;
790 struct acpi_power_resource *resource; 612 struct acpi_power_resource *resource;
791 613
792 if (!dev) 614 if (!device)
793 return -EINVAL; 615 return -EINVAL;
794 616
795 device = to_acpi_device(dev);
796 resource = acpi_driver_data(device); 617 resource = acpi_driver_data(device);
797 if (!resource) 618 if (!resource)
798 return -EINVAL; 619 return -EINVAL;
@@ -811,7 +632,6 @@ static int acpi_power_resume(struct device *dev)
811 632
812 return result; 633 return result;
813} 634}
814#endif
815 635
816int __init acpi_power_init(void) 636int __init acpi_power_init(void)
817{ 637{
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index ef98796b382..f5f986991b5 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -1,6 +1,5 @@
1#include <linux/proc_fs.h> 1#include <linux/proc_fs.h>
2#include <linux/seq_file.h> 2#include <linux/seq_file.h>
3#include <linux/export.h>
4#include <linux/suspend.h> 3#include <linux/suspend.h>
5#include <linux/bcd.h> 4#include <linux/bcd.h>
6#include <asm/uaccess.h> 5#include <asm/uaccess.h>
@@ -302,41 +301,26 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
302 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 301 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
303 struct acpi_device *dev = 302 struct acpi_device *dev =
304 container_of(node, struct acpi_device, wakeup_list); 303 container_of(node, struct acpi_device, wakeup_list);
305 struct acpi_device_physical_node *entry; 304 struct device *ldev;
306 305
307 if (!dev->wakeup.flags.valid) 306 if (!dev->wakeup.flags.valid)
308 continue; 307 continue;
309 308
310 seq_printf(seq, "%s\t S%d\t", 309 ldev = acpi_get_physical_device(dev->handle);
310 seq_printf(seq, "%s\t S%d\t%c%-8s ",
311 dev->pnp.bus_id, 311 dev->pnp.bus_id,
312 (u32) dev->wakeup.sleep_state); 312 (u32) dev->wakeup.sleep_state,
313 313 dev->wakeup.flags.run_wake ? '*' : ' ',
314 if (!dev->physical_node_count) 314 (device_may_wakeup(&dev->dev)
315 seq_printf(seq, "%c%-8s\n", 315 || (ldev && device_may_wakeup(ldev))) ?
316 dev->wakeup.flags.run_wake ? 316 "enabled" : "disabled");
317 '*' : ' ', "disabled"); 317 if (ldev)
318 else { 318 seq_printf(seq, "%s:%s",
319 struct device *ldev; 319 ldev->bus ? ldev->bus->name : "no-bus",
320 list_for_each_entry(entry, &dev->physical_node_list, 320 dev_name(ldev));
321 node) { 321 seq_printf(seq, "\n");
322 ldev = get_device(entry->dev); 322 put_device(ldev);
323 if (!ldev) 323
324 continue;
325
326 if (&entry->node !=
327 dev->physical_node_list.next)
328 seq_printf(seq, "\t\t");
329
330 seq_printf(seq, "%c%-8s %s:%s\n",
331 dev->wakeup.flags.run_wake ? '*' : ' ',
332 (device_may_wakeup(&dev->dev) ||
333 (ldev && device_may_wakeup(ldev))) ?
334 "enabled" : "disabled",
335 ldev->bus ? ldev->bus->name :
336 "no-bus", dev_name(ldev));
337 put_device(ldev);
338 }
339 }
340 } 324 }
341 mutex_unlock(&acpi_device_lock); 325 mutex_unlock(&acpi_device_lock);
342 return 0; 326 return 0;
@@ -344,14 +328,12 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
344 328
345static void physical_device_enable_wakeup(struct acpi_device *adev) 329static void physical_device_enable_wakeup(struct acpi_device *adev)
346{ 330{
347 struct acpi_device_physical_node *entry; 331 struct device *dev = acpi_get_physical_device(adev->handle);
348 332
349 list_for_each_entry(entry, 333 if (dev && device_can_wakeup(dev)) {
350 &adev->physical_node_list, node) 334 bool enable = !device_may_wakeup(dev);
351 if (entry->dev && device_can_wakeup(entry->dev)) { 335 device_set_wakeup_enable(dev, enable);
352 bool enable = !device_may_wakeup(entry->dev); 336 }
353 device_set_wakeup_enable(entry->dev, enable);
354 }
355} 337}
356 338
357static ssize_t 339static ssize_t
@@ -362,13 +344,16 @@ acpi_system_write_wakeup_device(struct file *file,
362 struct list_head *node, *next; 344 struct list_head *node, *next;
363 char strbuf[5]; 345 char strbuf[5];
364 char str[5] = ""; 346 char str[5] = "";
347 unsigned int len = count;
365 348
366 if (count > 4) 349 if (len > 4)
367 count = 4; 350 len = 4;
351 if (len < 0)
352 return -EFAULT;
368 353
369 if (copy_from_user(strbuf, buffer, count)) 354 if (copy_from_user(strbuf, buffer, len))
370 return -EFAULT; 355 return -EFAULT;
371 strbuf[count] = '\0'; 356 strbuf[len] = '\0';
372 sscanf(strbuf, "%s", str); 357 sscanf(strbuf, "%s", str);
373 358
374 mutex_lock(&acpi_device_lock); 359 mutex_lock(&acpi_device_lock);
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index eff722278ff..02d2a4c9084 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -7,7 +7,6 @@
7 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 7 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
8 * - Added _PDC for platforms with Intel CPUs 8 * - Added _PDC for platforms with Intel CPUs
9 */ 9 */
10#include <linux/export.h>
11#include <linux/dmi.h> 10#include <linux/dmi.h>
12#include <linux/slab.h> 11#include <linux/slab.h>
13 12
@@ -173,32 +172,8 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
173 apic_id = map_mat_entry(handle, type, acpi_id); 172 apic_id = map_mat_entry(handle, type, acpi_id);
174 if (apic_id == -1) 173 if (apic_id == -1)
175 apic_id = map_madt_entry(type, acpi_id); 174 apic_id = map_madt_entry(type, acpi_id);
176 if (apic_id == -1) { 175 if (apic_id == -1)
177 /* 176 return apic_id;
178 * On UP processor, there is no _MAT or MADT table.
179 * So above apic_id is always set to -1.
180 *
181 * BIOS may define multiple CPU handles even for UP processor.
182 * For example,
183 *
184 * Scope (_PR)
185 * {
186 * Processor (CPU0, 0x00, 0x00000410, 0x06) {}
187 * Processor (CPU1, 0x01, 0x00000410, 0x06) {}
188 * Processor (CPU2, 0x02, 0x00000410, 0x06) {}
189 * Processor (CPU3, 0x03, 0x00000410, 0x06) {}
190 * }
191 *
192 * Ignores apic_id and always returns 0 for the processor
193 * handle with acpi id 0 if nr_cpu_ids is 1.
194 * This should be the case if SMP tables are not found.
195 * Return -1 for other CPU's handle.
196 */
197 if (nr_cpu_ids <= 1 && acpi_id == 0)
198 return acpi_id;
199 else
200 return apic_id;
201 }
202 177
203#ifdef CONFIG_SMP 178#ifdef CONFIG_SMP
204 for_each_possible_cpu(i) { 179 for_each_possible_cpu(i) {
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index e83311bf1eb..a4e0f1ba604 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -44,9 +44,9 @@
44#include <linux/moduleparam.h> 44#include <linux/moduleparam.h>
45#include <linux/cpuidle.h> 45#include <linux/cpuidle.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/acpi.h>
48 47
49#include <asm/io.h> 48#include <asm/io.h>
49#include <asm/system.h>
50#include <asm/cpu.h> 50#include <asm/cpu.h>
51#include <asm/delay.h> 51#include <asm/delay.h>
52#include <asm/uaccess.h> 52#include <asm/uaccess.h>
@@ -68,7 +68,6 @@
68#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 68#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
69#define ACPI_PROCESSOR_NOTIFY_POWER 0x81 69#define ACPI_PROCESSOR_NOTIFY_POWER 0x81
70#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 70#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
71#define ACPI_PROCESSOR_DEVICE_HID "ACPI0007"
72 71
73#define ACPI_PROCESSOR_LIMIT_USER 0 72#define ACPI_PROCESSOR_LIMIT_USER 0
74#define ACPI_PROCESSOR_LIMIT_THERMAL 1 73#define ACPI_PROCESSOR_LIMIT_THERMAL 1
@@ -83,20 +82,17 @@ MODULE_LICENSE("GPL");
83static int acpi_processor_add(struct acpi_device *device); 82static int acpi_processor_add(struct acpi_device *device);
84static int acpi_processor_remove(struct acpi_device *device, int type); 83static int acpi_processor_remove(struct acpi_device *device, int type);
85static void acpi_processor_notify(struct acpi_device *device, u32 event); 84static void acpi_processor_notify(struct acpi_device *device, u32 event);
86static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr); 85static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
87static int acpi_processor_handle_eject(struct acpi_processor *pr); 86static int acpi_processor_handle_eject(struct acpi_processor *pr);
88static int acpi_processor_start(struct acpi_processor *pr); 87
89 88
90static const struct acpi_device_id processor_device_ids[] = { 89static const struct acpi_device_id processor_device_ids[] = {
91 {ACPI_PROCESSOR_OBJECT_HID, 0}, 90 {ACPI_PROCESSOR_OBJECT_HID, 0},
92 {ACPI_PROCESSOR_DEVICE_HID, 0}, 91 {"ACPI0007", 0},
93 {"", 0}, 92 {"", 0},
94}; 93};
95MODULE_DEVICE_TABLE(acpi, processor_device_ids); 94MODULE_DEVICE_TABLE(acpi, processor_device_ids);
96 95
97static SIMPLE_DEV_PM_OPS(acpi_processor_pm,
98 acpi_processor_suspend, acpi_processor_resume);
99
100static struct acpi_driver acpi_processor_driver = { 96static struct acpi_driver acpi_processor_driver = {
101 .name = "processor", 97 .name = "processor",
102 .class = ACPI_PROCESSOR_CLASS, 98 .class = ACPI_PROCESSOR_CLASS,
@@ -104,9 +100,10 @@ static struct acpi_driver acpi_processor_driver = {
104 .ops = { 100 .ops = {
105 .add = acpi_processor_add, 101 .add = acpi_processor_add,
106 .remove = acpi_processor_remove, 102 .remove = acpi_processor_remove,
103 .suspend = acpi_processor_suspend,
104 .resume = acpi_processor_resume,
107 .notify = acpi_processor_notify, 105 .notify = acpi_processor_notify,
108 }, 106 },
109 .drv.pm = &acpi_processor_pm,
110}; 107};
111 108
112#define INSTALL_NOTIFY_HANDLER 1 109#define INSTALL_NOTIFY_HANDLER 1
@@ -283,9 +280,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
283 /* Declared with "Processor" statement; match ProcessorID */ 280 /* Declared with "Processor" statement; match ProcessorID */
284 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); 281 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
285 if (ACPI_FAILURE(status)) { 282 if (ACPI_FAILURE(status)) {
286 dev_err(&device->dev, 283 printk(KERN_ERR PREFIX "Evaluating processor object\n");
287 "Failed to evaluate processor object (0x%x)\n",
288 status);
289 return -ENODEV; 284 return -ENODEV;
290 } 285 }
291 286
@@ -304,9 +299,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
304 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, 299 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
305 NULL, &value); 300 NULL, &value);
306 if (ACPI_FAILURE(status)) { 301 if (ACPI_FAILURE(status)) {
307 dev_err(&device->dev, 302 printk(KERN_ERR PREFIX
308 "Failed to evaluate processor _UID (0x%x)\n", 303 "Evaluating processor _UID [%#x]\n", status);
309 status);
310 return -ENODEV; 304 return -ENODEV;
311 } 305 }
312 device_declaration = 1; 306 device_declaration = 1;
@@ -330,8 +324,10 @@ static int acpi_processor_get_info(struct acpi_device *device)
330 * they are physically not present. 324 * they are physically not present.
331 */ 325 */
332 if (pr->id == -1) { 326 if (pr->id == -1) {
333 if (ACPI_FAILURE(acpi_processor_hotadd_init(pr))) 327 if (ACPI_FAILURE
328 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
334 return -ENODEV; 329 return -ENODEV;
330 }
335 } 331 }
336 /* 332 /*
337 * On some boxes several processors use the same processor bus id. 333 * On some boxes several processors use the same processor bus id.
@@ -349,7 +345,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
349 if (!object.processor.pblk_address) 345 if (!object.processor.pblk_address)
350 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); 346 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
351 else if (object.processor.pblk_length != 6) 347 else if (object.processor.pblk_length != 6)
352 dev_err(&device->dev, "Invalid PBLK length [%d]\n", 348 printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n",
353 object.processor.pblk_length); 349 object.processor.pblk_length);
354 else { 350 else {
355 pr->throttling.address = object.processor.pblk_address; 351 pr->throttling.address = object.processor.pblk_address;
@@ -413,7 +409,6 @@ static void acpi_processor_notify(struct acpi_device *device, u32 event)
413 acpi_bus_generate_proc_event(device, event, 0); 409 acpi_bus_generate_proc_event(device, event, 0);
414 acpi_bus_generate_netlink_event(device->pnp.device_class, 410 acpi_bus_generate_netlink_event(device->pnp.device_class,
415 dev_name(&device->dev), event, 0); 411 dev_name(&device->dev), event, 0);
416 break;
417 default: 412 default:
418 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 413 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
419 "Unsupported event [0x%x]\n", event)); 414 "Unsupported event [0x%x]\n", event));
@@ -430,22 +425,10 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
430 struct acpi_processor *pr = per_cpu(processors, cpu); 425 struct acpi_processor *pr = per_cpu(processors, cpu);
431 426
432 if (action == CPU_ONLINE && pr) { 427 if (action == CPU_ONLINE && pr) {
433 /* CPU got physically hotplugged and onlined the first time: 428 acpi_processor_ppc_has_changed(pr, 0);
434 * Initialize missing things 429 acpi_processor_cst_has_changed(pr);
435 */ 430 acpi_processor_reevaluate_tstate(pr, action);
436 if (pr->flags.need_hotplug_init) { 431 acpi_processor_tstate_has_changed(pr);
437 pr_info("Will online and init hotplugged CPU: %d\n",
438 pr->id);
439 WARN(acpi_processor_start(pr), "Failed to start CPU:"
440 " %d\n", pr->id);
441 pr->flags.need_hotplug_init = 0;
442 /* Normal CPU soft online event */
443 } else {
444 acpi_processor_ppc_has_changed(pr, 0);
445 acpi_processor_hotplug(pr);
446 acpi_processor_reevaluate_tstate(pr, action);
447 acpi_processor_tstate_has_changed(pr);
448 }
449 } 432 }
450 if (action == CPU_DEAD && pr) { 433 if (action == CPU_DEAD && pr) {
451 /* invalidate the flag.throttling after one CPU is offline */ 434 /* invalidate the flag.throttling after one CPU is offline */
@@ -459,87 +442,19 @@ static struct notifier_block acpi_cpu_notifier =
459 .notifier_call = acpi_cpu_soft_notify, 442 .notifier_call = acpi_cpu_soft_notify,
460}; 443};
461 444
462/*
463 * acpi_processor_start() is called by the cpu_hotplug_notifier func:
464 * acpi_cpu_soft_notify(). Getting it __cpuinit{data} is difficult, the
465 * root cause seem to be that acpi_processor_uninstall_hotplug_notify()
466 * is in the module_exit (__exit) func. Allowing acpi_processor_start()
467 * to not be in __cpuinit section, but being called from __cpuinit funcs
468 * via __ref looks like the right thing to do here.
469 */
470static __ref int acpi_processor_start(struct acpi_processor *pr)
471{
472 struct acpi_device *device = per_cpu(processor_device_array, pr->id);
473 int result = 0;
474
475#ifdef CONFIG_CPU_FREQ
476 acpi_processor_ppc_has_changed(pr, 0);
477 acpi_processor_load_module(pr);
478#endif
479 acpi_processor_get_throttling_info(pr);
480 acpi_processor_get_limit_info(pr);
481
482 if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
483 acpi_processor_power_init(pr);
484
485 pr->cdev = thermal_cooling_device_register("Processor", device,
486 &processor_cooling_ops);
487 if (IS_ERR(pr->cdev)) {
488 result = PTR_ERR(pr->cdev);
489 goto err_power_exit;
490 }
491
492 dev_dbg(&device->dev, "registered as cooling_device%d\n",
493 pr->cdev->id);
494
495 result = sysfs_create_link(&device->dev.kobj,
496 &pr->cdev->device.kobj,
497 "thermal_cooling");
498 if (result) {
499 dev_err(&device->dev,
500 "Failed to create sysfs link 'thermal_cooling'\n");
501 goto err_thermal_unregister;
502 }
503 result = sysfs_create_link(&pr->cdev->device.kobj,
504 &device->dev.kobj,
505 "device");
506 if (result) {
507 dev_err(&pr->cdev->device,
508 "Failed to create sysfs link 'device'\n");
509 goto err_remove_sysfs_thermal;
510 }
511
512 return 0;
513
514err_remove_sysfs_thermal:
515 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
516err_thermal_unregister:
517 thermal_cooling_device_unregister(pr->cdev);
518err_power_exit:
519 acpi_processor_power_exit(pr);
520
521 return result;
522}
523
524/*
525 * Do not put anything in here which needs the core to be online.
526 * For example MSR access or setting up things which check for cpuinfo_x86
527 * (cpu_data(cpu)) values, like CPU feature flags, family, model, etc.
528 * Such things have to be put in and set up above in acpi_processor_start()
529 */
530static int __cpuinit acpi_processor_add(struct acpi_device *device) 445static int __cpuinit acpi_processor_add(struct acpi_device *device)
531{ 446{
532 struct acpi_processor *pr = NULL; 447 struct acpi_processor *pr = NULL;
533 int result = 0; 448 int result = 0;
534 struct device *dev; 449 struct sys_device *sysdev;
535 450
536 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); 451 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
537 if (!pr) 452 if (!pr)
538 return -ENOMEM; 453 return -ENOMEM;
539 454
540 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { 455 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
541 result = -ENOMEM; 456 kfree(pr);
542 goto err_free_pr; 457 return -ENOMEM;
543 } 458 }
544 459
545 pr->handle = device->handle; 460 pr->handle = device->handle;
@@ -567,9 +482,8 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
567 */ 482 */
568 if (per_cpu(processor_device_array, pr->id) != NULL && 483 if (per_cpu(processor_device_array, pr->id) != NULL &&
569 per_cpu(processor_device_array, pr->id) != device) { 484 per_cpu(processor_device_array, pr->id) != device) {
570 dev_warn(&device->dev, 485 printk(KERN_WARNING "BIOS reported wrong ACPI id "
571 "BIOS reported wrong ACPI id %d for the processor\n", 486 "for the processor\n");
572 pr->id);
573 result = -ENODEV; 487 result = -ENODEV;
574 goto err_free_cpumask; 488 goto err_free_cpumask;
575 } 489 }
@@ -577,36 +491,58 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
577 491
578 per_cpu(processors, pr->id) = pr; 492 per_cpu(processors, pr->id) = pr;
579 493
580 dev = get_cpu_device(pr->id); 494 sysdev = get_cpu_sysdev(pr->id);
581 if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) { 495 if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) {
582 result = -EFAULT; 496 result = -EFAULT;
583 goto err_clear_processor; 497 goto err_free_cpumask;
584 } 498 }
585 499
586 /* 500#ifdef CONFIG_CPU_FREQ
587 * Do not start hotplugged CPUs now, but when they 501 acpi_processor_ppc_has_changed(pr, 0);
588 * are onlined the first time 502#endif
589 */ 503 acpi_processor_get_throttling_info(pr);
590 if (pr->flags.need_hotplug_init) 504 acpi_processor_get_limit_info(pr);
591 return 0; 505
506
507 if (cpuidle_get_driver() == &acpi_idle_driver)
508 acpi_processor_power_init(pr, device);
509
510 pr->cdev = thermal_cooling_device_register("Processor", device,
511 &processor_cooling_ops);
512 if (IS_ERR(pr->cdev)) {
513 result = PTR_ERR(pr->cdev);
514 goto err_power_exit;
515 }
592 516
593 result = acpi_processor_start(pr); 517 dev_dbg(&device->dev, "registered as cooling_device%d\n",
594 if (result) 518 pr->cdev->id);
519
520 result = sysfs_create_link(&device->dev.kobj,
521 &pr->cdev->device.kobj,
522 "thermal_cooling");
523 if (result) {
524 printk(KERN_ERR PREFIX "Create sysfs link\n");
525 goto err_thermal_unregister;
526 }
527 result = sysfs_create_link(&pr->cdev->device.kobj,
528 &device->dev.kobj,
529 "device");
530 if (result) {
531 printk(KERN_ERR PREFIX "Create sysfs link\n");
595 goto err_remove_sysfs; 532 goto err_remove_sysfs;
533 }
596 534
597 return 0; 535 return 0;
598 536
599err_remove_sysfs: 537err_remove_sysfs:
600 sysfs_remove_link(&device->dev.kobj, "sysdev"); 538 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
601err_clear_processor: 539err_thermal_unregister:
602 /* 540 thermal_cooling_device_unregister(pr->cdev);
603 * processor_device_array is not cleared to allow checks for buggy BIOS 541err_power_exit:
604 */ 542 acpi_processor_power_exit(pr, device);
605 per_cpu(processors, pr->id) = NULL;
606err_free_cpumask: 543err_free_cpumask:
607 free_cpumask_var(pr->throttling.shared_cpu_map); 544 free_cpumask_var(pr->throttling.shared_cpu_map);
608err_free_pr: 545
609 kfree(pr);
610 return result; 546 return result;
611} 547}
612 548
@@ -628,7 +564,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
628 return -EINVAL; 564 return -EINVAL;
629 } 565 }
630 566
631 acpi_processor_power_exit(pr); 567 acpi_processor_power_exit(pr, device);
632 568
633 sysfs_remove_link(&device->dev.kobj, "sysdev"); 569 sysfs_remove_link(&device->dev.kobj, "sysdev");
634 570
@@ -702,11 +638,11 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
702static void acpi_processor_hotplug_notify(acpi_handle handle, 638static void acpi_processor_hotplug_notify(acpi_handle handle,
703 u32 event, void *data) 639 u32 event, void *data)
704{ 640{
641 struct acpi_processor *pr;
705 struct acpi_device *device = NULL; 642 struct acpi_device *device = NULL;
706 struct acpi_eject_event *ej_event = NULL;
707 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
708 int result; 643 int result;
709 644
645
710 switch (event) { 646 switch (event) {
711 case ACPI_NOTIFY_BUS_CHECK: 647 case ACPI_NOTIFY_BUS_CHECK:
712 case ACPI_NOTIFY_DEVICE_CHECK: 648 case ACPI_NOTIFY_DEVICE_CHECK:
@@ -718,100 +654,53 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
718 if (!is_processor_present(handle)) 654 if (!is_processor_present(handle))
719 break; 655 break;
720 656
721 if (!acpi_bus_get_device(handle, &device)) 657 if (acpi_bus_get_device(handle, &device)) {
722 break; 658 result = acpi_processor_device_add(handle, &device);
723 659 if (result)
724 result = acpi_processor_device_add(handle, &device); 660 printk(KERN_ERR PREFIX
725 if (result) { 661 "Unable to add the device\n");
726 acpi_handle_err(handle, "Unable to add the device\n");
727 break; 662 break;
728 } 663 }
729
730 ost_code = ACPI_OST_SC_SUCCESS;
731 break; 664 break;
732
733 case ACPI_NOTIFY_EJECT_REQUEST: 665 case ACPI_NOTIFY_EJECT_REQUEST:
734 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 666 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
735 "received ACPI_NOTIFY_EJECT_REQUEST\n")); 667 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
736 668
737 if (acpi_bus_get_device(handle, &device)) { 669 if (acpi_bus_get_device(handle, &device)) {
738 acpi_handle_err(handle, 670 printk(KERN_ERR PREFIX
739 "Device don't exist, dropping EJECT\n"); 671 "Device don't exist, dropping EJECT\n");
740 break;
741 }
742 if (!acpi_driver_data(device)) {
743 acpi_handle_err(handle,
744 "Driver data is NULL, dropping EJECT\n");
745 break; 672 break;
746 } 673 }
747 674 pr = acpi_driver_data(device);
748 ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); 675 if (!pr) {
749 if (!ej_event) { 676 printk(KERN_ERR PREFIX
750 acpi_handle_err(handle, "No memory, dropping EJECT\n"); 677 "Driver data is NULL, dropping EJECT\n");
751 break; 678 return;
752 } 679 }
753 680 break;
754 ej_event->handle = handle;
755 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
756 acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
757 (void *)ej_event);
758
759 /* eject is performed asynchronously */
760 return;
761
762 default: 681 default:
763 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 682 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
764 "Unsupported event [0x%x]\n", event)); 683 "Unsupported event [0x%x]\n", event));
765 684 break;
766 /* non-hotplug event; possibly handled by other handler */
767 return;
768 } 685 }
769 686
770 /* Inform firmware that the hotplug operation has completed */
771 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL);
772 return; 687 return;
773} 688}
774 689
775static acpi_status is_processor_device(acpi_handle handle)
776{
777 struct acpi_device_info *info;
778 char *hid;
779 acpi_status status;
780
781 status = acpi_get_object_info(handle, &info);
782 if (ACPI_FAILURE(status))
783 return status;
784
785 if (info->type == ACPI_TYPE_PROCESSOR) {
786 kfree(info);
787 return AE_OK; /* found a processor object */
788 }
789
790 if (!(info->valid & ACPI_VALID_HID)) {
791 kfree(info);
792 return AE_ERROR;
793 }
794
795 hid = info->hardware_id.string;
796 if ((hid == NULL) || strcmp(hid, ACPI_PROCESSOR_DEVICE_HID)) {
797 kfree(info);
798 return AE_ERROR;
799 }
800
801 kfree(info);
802 return AE_OK; /* found a processor device object */
803}
804
805static acpi_status 690static acpi_status
806processor_walk_namespace_cb(acpi_handle handle, 691processor_walk_namespace_cb(acpi_handle handle,
807 u32 lvl, void *context, void **rv) 692 u32 lvl, void *context, void **rv)
808{ 693{
809 acpi_status status; 694 acpi_status status;
810 int *action = context; 695 int *action = context;
696 acpi_object_type type = 0;
811 697
812 status = is_processor_device(handle); 698 status = acpi_get_type(handle, &type);
813 if (ACPI_FAILURE(status)) 699 if (ACPI_FAILURE(status))
814 return AE_OK; /* not a processor; continue to walk */ 700 return (AE_OK);
701
702 if (type != ACPI_TYPE_PROCESSOR)
703 return (AE_OK);
815 704
816 switch (*action) { 705 switch (*action) {
817 case INSTALL_NOTIFY_HANDLER: 706 case INSTALL_NOTIFY_HANDLER:
@@ -829,37 +718,24 @@ processor_walk_namespace_cb(acpi_handle handle,
829 break; 718 break;
830 } 719 }
831 720
832 /* found a processor; skip walking underneath */ 721 return (AE_OK);
833 return AE_CTRL_DEPTH;
834} 722}
835 723
836static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr) 724static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
837{ 725{
838 acpi_handle handle = pr->handle;
839 726
840 if (!is_processor_present(handle)) { 727 if (!is_processor_present(handle)) {
841 return AE_ERROR; 728 return AE_ERROR;
842 } 729 }
843 730
844 if (acpi_map_lsapic(handle, &pr->id)) 731 if (acpi_map_lsapic(handle, p_cpu))
845 return AE_ERROR; 732 return AE_ERROR;
846 733
847 if (arch_register_cpu(pr->id)) { 734 if (arch_register_cpu(*p_cpu)) {
848 acpi_unmap_lsapic(pr->id); 735 acpi_unmap_lsapic(*p_cpu);
849 return AE_ERROR; 736 return AE_ERROR;
850 } 737 }
851 738
852 /* CPU got hot-plugged, but cpu_data is not initialized yet
853 * Set flag to delay cpu_idle/throttling initialization
854 * in:
855 * acpi_processor_add()
856 * acpi_processor_get_info()
857 * and do it when the CPU gets online the first time
858 * TBD: Cleanup above functions and try to do this more elegant.
859 */
860 pr_info("CPU %d got hotplugged\n", pr->id);
861 pr->flags.need_hotplug_init = 1;
862
863 return AE_OK; 739 return AE_OK;
864} 740}
865 741
@@ -868,26 +744,12 @@ static int acpi_processor_handle_eject(struct acpi_processor *pr)
868 if (cpu_online(pr->id)) 744 if (cpu_online(pr->id))
869 cpu_down(pr->id); 745 cpu_down(pr->id);
870 746
871 get_online_cpus();
872 /*
873 * The cpu might become online again at this point. So we check whether
874 * the cpu has been onlined or not. If the cpu became online, it means
875 * that someone wants to use the cpu. So acpi_processor_handle_eject()
876 * returns -EAGAIN.
877 */
878 if (unlikely(cpu_online(pr->id))) {
879 put_online_cpus();
880 pr_warn("Failed to remove CPU %d, because other task "
881 "brought the CPU back online\n", pr->id);
882 return -EAGAIN;
883 }
884 arch_unregister_cpu(pr->id); 747 arch_unregister_cpu(pr->id);
885 acpi_unmap_lsapic(pr->id); 748 acpi_unmap_lsapic(pr->id);
886 put_online_cpus();
887 return (0); 749 return (0);
888} 750}
889#else 751#else
890static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr) 752static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
891{ 753{
892 return AE_ERROR; 754 return AE_ERROR;
893} 755}
@@ -902,7 +764,7 @@ void acpi_processor_install_hotplug_notify(void)
902{ 764{
903#ifdef CONFIG_ACPI_HOTPLUG_CPU 765#ifdef CONFIG_ACPI_HOTPLUG_CPU
904 int action = INSTALL_NOTIFY_HANDLER; 766 int action = INSTALL_NOTIFY_HANDLER;
905 acpi_walk_namespace(ACPI_TYPE_ANY, 767 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
906 ACPI_ROOT_OBJECT, 768 ACPI_ROOT_OBJECT,
907 ACPI_UINT32_MAX, 769 ACPI_UINT32_MAX,
908 processor_walk_namespace_cb, NULL, &action, NULL); 770 processor_walk_namespace_cb, NULL, &action, NULL);
@@ -915,7 +777,7 @@ void acpi_processor_uninstall_hotplug_notify(void)
915{ 777{
916#ifdef CONFIG_ACPI_HOTPLUG_CPU 778#ifdef CONFIG_ACPI_HOTPLUG_CPU
917 int action = UNINSTALL_NOTIFY_HANDLER; 779 int action = UNINSTALL_NOTIFY_HANDLER;
918 acpi_walk_namespace(ACPI_TYPE_ANY, 780 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
919 ACPI_ROOT_OBJECT, 781 ACPI_ROOT_OBJECT,
920 ACPI_UINT32_MAX, 782 ACPI_UINT32_MAX,
921 processor_walk_namespace_cb, NULL, &action, NULL); 783 processor_walk_namespace_cb, NULL, &action, NULL);
@@ -936,9 +798,19 @@ static int __init acpi_processor_init(void)
936 if (acpi_disabled) 798 if (acpi_disabled)
937 return 0; 799 return 0;
938 800
801 memset(&errata, 0, sizeof(errata));
802
803 if (!cpuidle_register_driver(&acpi_idle_driver)) {
804 printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
805 acpi_idle_driver.name);
806 } else {
807 printk(KERN_DEBUG "ACPI: acpi_idle yielding to %s\n",
808 cpuidle_get_driver()->name);
809 }
810
939 result = acpi_bus_register_driver(&acpi_processor_driver); 811 result = acpi_bus_register_driver(&acpi_processor_driver);
940 if (result < 0) 812 if (result < 0)
941 return result; 813 goto out_cpuidle;
942 814
943 acpi_processor_install_hotplug_notify(); 815 acpi_processor_install_hotplug_notify();
944 816
@@ -949,6 +821,11 @@ static int __init acpi_processor_init(void)
949 acpi_processor_throttling_init(); 821 acpi_processor_throttling_init();
950 822
951 return 0; 823 return 0;
824
825out_cpuidle:
826 cpuidle_unregister_driver(&acpi_idle_driver);
827
828 return result;
952} 829}
953 830
954static void __exit acpi_processor_exit(void) 831static void __exit acpi_processor_exit(void)
@@ -964,6 +841,8 @@ static void __exit acpi_processor_exit(void)
964 841
965 acpi_bus_unregister_driver(&acpi_processor_driver); 842 acpi_bus_unregister_driver(&acpi_processor_driver);
966 843
844 cpuidle_unregister_driver(&acpi_idle_driver);
845
967 return; 846 return;
968} 847}
969 848
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index f1a5da44591..431ab11c8c1 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -37,7 +37,7 @@
37#include <linux/dmi.h> 37#include <linux/dmi.h>
38#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
39#include <linux/sched.h> /* need_resched() */ 39#include <linux/sched.h> /* need_resched() */
40#include <linux/pm_qos.h> 40#include <linux/pm_qos_params.h>
41#include <linux/clockchips.h> 41#include <linux/clockchips.h>
42#include <linux/cpuidle.h> 42#include <linux/cpuidle.h>
43#include <linux/irqflags.h> 43#include <linux/irqflags.h>
@@ -79,8 +79,6 @@ module_param(bm_check_disable, uint, 0000);
79static unsigned int latency_factor __read_mostly = 2; 79static unsigned int latency_factor __read_mostly = 2;
80module_param(latency_factor, uint, 0644); 80module_param(latency_factor, uint, 0644);
81 81
82static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device);
83
84static int disabled_by_idle_boot_param(void) 82static int disabled_by_idle_boot_param(void)
85{ 83{
86 return boot_option_idle_override == IDLE_POLL || 84 return boot_option_idle_override == IDLE_POLL ||
@@ -223,6 +221,10 @@ static void lapic_timer_state_broadcast(struct acpi_processor *pr,
223 221
224#endif 222#endif
225 223
224/*
225 * Suspend / resume control
226 */
227static int acpi_idle_suspend;
226static u32 saved_bm_rld; 228static u32 saved_bm_rld;
227 229
228static void acpi_idle_bm_rld_save(void) 230static void acpi_idle_bm_rld_save(void)
@@ -239,15 +241,23 @@ static void acpi_idle_bm_rld_restore(void)
239 acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld); 241 acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld);
240} 242}
241 243
242int acpi_processor_suspend(struct device *dev) 244int acpi_processor_suspend(struct acpi_device * device, pm_message_t state)
243{ 245{
246 if (acpi_idle_suspend == 1)
247 return 0;
248
244 acpi_idle_bm_rld_save(); 249 acpi_idle_bm_rld_save();
250 acpi_idle_suspend = 1;
245 return 0; 251 return 0;
246} 252}
247 253
248int acpi_processor_resume(struct device *dev) 254int acpi_processor_resume(struct acpi_device * device)
249{ 255{
256 if (acpi_idle_suspend == 0)
257 return 0;
258
250 acpi_idle_bm_rld_restore(); 259 acpi_idle_bm_rld_restore();
260 acpi_idle_suspend = 0;
251 return 0; 261 return 0;
252} 262}
253 263
@@ -303,16 +313,16 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
303 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5; 313 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5;
304 314
305 /* determine latencies from FADT */ 315 /* determine latencies from FADT */
306 pr->power.states[ACPI_STATE_C2].latency = acpi_gbl_FADT.c2_latency; 316 pr->power.states[ACPI_STATE_C2].latency = acpi_gbl_FADT.C2latency;
307 pr->power.states[ACPI_STATE_C3].latency = acpi_gbl_FADT.c3_latency; 317 pr->power.states[ACPI_STATE_C3].latency = acpi_gbl_FADT.C3latency;
308 318
309 /* 319 /*
310 * FADT specified C2 latency must be less than or equal to 320 * FADT specified C2 latency must be less than or equal to
311 * 100 microseconds. 321 * 100 microseconds.
312 */ 322 */
313 if (acpi_gbl_FADT.c2_latency > ACPI_PROCESSOR_MAX_C2_LATENCY) { 323 if (acpi_gbl_FADT.C2latency > ACPI_PROCESSOR_MAX_C2_LATENCY) {
314 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 324 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
315 "C2 latency too large [%d]\n", acpi_gbl_FADT.c2_latency)); 325 "C2 latency too large [%d]\n", acpi_gbl_FADT.C2latency));
316 /* invalidate C2 */ 326 /* invalidate C2 */
317 pr->power.states[ACPI_STATE_C2].address = 0; 327 pr->power.states[ACPI_STATE_C2].address = 0;
318 } 328 }
@@ -321,9 +331,9 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
321 * FADT supplied C3 latency must be less than or equal to 331 * FADT supplied C3 latency must be less than or equal to
322 * 1000 microseconds. 332 * 1000 microseconds.
323 */ 333 */
324 if (acpi_gbl_FADT.c3_latency > ACPI_PROCESSOR_MAX_C3_LATENCY) { 334 if (acpi_gbl_FADT.C3latency > ACPI_PROCESSOR_MAX_C3_LATENCY) {
325 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 335 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
326 "C3 latency too large [%d]\n", acpi_gbl_FADT.c3_latency)); 336 "C3 latency too large [%d]\n", acpi_gbl_FADT.C3latency));
327 /* invalidate C3 */ 337 /* invalidate C3 */
328 pr->power.states[ACPI_STATE_C3].address = 0; 338 pr->power.states[ACPI_STATE_C3].address = 0;
329 } 339 }
@@ -485,6 +495,8 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
485 if (obj->type != ACPI_TYPE_INTEGER) 495 if (obj->type != ACPI_TYPE_INTEGER)
486 continue; 496 continue;
487 497
498 cx.power = obj->integer.value;
499
488 current_count++; 500 current_count++;
489 memcpy(&(pr->power.states[current_count]), &cx, sizeof(cx)); 501 memcpy(&(pr->power.states[current_count]), &cx, sizeof(cx));
490 502
@@ -583,6 +595,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
583 */ 595 */
584 cx->valid = 1; 596 cx->valid = 1;
585 597
598 cx->latency_ticks = cx->latency;
586 /* 599 /*
587 * On older chipsets, BM_RLD needs to be set 600 * On older chipsets, BM_RLD needs to be set
588 * in order for Bus Master activity to wake the 601 * in order for Bus Master activity to wake the
@@ -615,6 +628,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
615 if (!cx->address) 628 if (!cx->address)
616 break; 629 break;
617 cx->valid = 1; 630 cx->valid = 1;
631 cx->latency_ticks = cx->latency; /* Normalize latency */
618 break; 632 break;
619 633
620 case ACPI_STATE_C3: 634 case ACPI_STATE_C3:
@@ -727,77 +741,68 @@ static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx)
727/** 741/**
728 * acpi_idle_enter_c1 - enters an ACPI C1 state-type 742 * acpi_idle_enter_c1 - enters an ACPI C1 state-type
729 * @dev: the target CPU 743 * @dev: the target CPU
730 * @drv: cpuidle driver containing cpuidle state info 744 * @state: the state data
731 * @index: index of target state
732 * 745 *
733 * This is equivalent to the HALT instruction. 746 * This is equivalent to the HALT instruction.
734 */ 747 */
735static int acpi_idle_enter_c1(struct cpuidle_device *dev, 748static int acpi_idle_enter_c1(struct cpuidle_device *dev,
736 struct cpuidle_driver *drv, int index) 749 struct cpuidle_state *state)
737{ 750{
751 ktime_t kt1, kt2;
752 s64 idle_time;
738 struct acpi_processor *pr; 753 struct acpi_processor *pr;
739 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 754 struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
740 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);
741 755
742 pr = __this_cpu_read(processors); 756 pr = __this_cpu_read(processors);
743 757
744 if (unlikely(!pr)) 758 if (unlikely(!pr))
745 return -EINVAL; 759 return 0;
760
761 local_irq_disable();
762
763 /* Do not access any ACPI IO ports in suspend path */
764 if (acpi_idle_suspend) {
765 local_irq_enable();
766 cpu_relax();
767 return 0;
768 }
746 769
747 lapic_timer_state_broadcast(pr, cx, 1); 770 lapic_timer_state_broadcast(pr, cx, 1);
771 kt1 = ktime_get_real();
748 acpi_idle_do_entry(cx); 772 acpi_idle_do_entry(cx);
773 kt2 = ktime_get_real();
774 idle_time = ktime_to_us(ktime_sub(kt2, kt1));
749 775
776 local_irq_enable();
777 cx->usage++;
750 lapic_timer_state_broadcast(pr, cx, 0); 778 lapic_timer_state_broadcast(pr, cx, 0);
751 779
752 return index; 780 return idle_time;
753}
754
755
756/**
757 * acpi_idle_play_dead - enters an ACPI state for long-term idle (i.e. off-lining)
758 * @dev: the target CPU
759 * @index: the index of suggested state
760 */
761static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
762{
763 struct cpuidle_state_usage *state_usage = &dev->states_usage[index];
764 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);
765
766 ACPI_FLUSH_CPU_CACHE();
767
768 while (1) {
769
770 if (cx->entry_method == ACPI_CSTATE_HALT)
771 safe_halt();
772 else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) {
773 inb(cx->address);
774 /* See comment in acpi_idle_do_entry() */
775 inl(acpi_gbl_FADT.xpm_timer_block.address);
776 } else
777 return -ENODEV;
778 }
779
780 /* Never reached */
781 return 0;
782} 781}
783 782
784/** 783/**
785 * acpi_idle_enter_simple - enters an ACPI state without BM handling 784 * acpi_idle_enter_simple - enters an ACPI state without BM handling
786 * @dev: the target CPU 785 * @dev: the target CPU
787 * @drv: cpuidle driver with cpuidle state information 786 * @state: the state data
788 * @index: the index of suggested state
789 */ 787 */
790static int acpi_idle_enter_simple(struct cpuidle_device *dev, 788static int acpi_idle_enter_simple(struct cpuidle_device *dev,
791 struct cpuidle_driver *drv, int index) 789 struct cpuidle_state *state)
792{ 790{
793 struct acpi_processor *pr; 791 struct acpi_processor *pr;
794 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 792 struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
795 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); 793 ktime_t kt1, kt2;
794 s64 idle_time_ns;
795 s64 idle_time;
796 796
797 pr = __this_cpu_read(processors); 797 pr = __this_cpu_read(processors);
798 798
799 if (unlikely(!pr)) 799 if (unlikely(!pr))
800 return -EINVAL; 800 return 0;
801
802 if (acpi_idle_suspend)
803 return(acpi_idle_enter_c1(dev, state));
804
805 local_irq_disable();
801 806
802 if (cx->entry_method != ACPI_CSTATE_FFH) { 807 if (cx->entry_method != ACPI_CSTATE_FFH) {
803 current_thread_info()->status &= ~TS_POLLING; 808 current_thread_info()->status &= ~TS_POLLING;
@@ -809,7 +814,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
809 814
810 if (unlikely(need_resched())) { 815 if (unlikely(need_resched())) {
811 current_thread_info()->status |= TS_POLLING; 816 current_thread_info()->status |= TS_POLLING;
812 return -EINVAL; 817 local_irq_enable();
818 return 0;
813 } 819 }
814 } 820 }
815 821
@@ -822,52 +828,71 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
822 if (cx->type == ACPI_STATE_C3) 828 if (cx->type == ACPI_STATE_C3)
823 ACPI_FLUSH_CPU_CACHE(); 829 ACPI_FLUSH_CPU_CACHE();
824 830
831 kt1 = ktime_get_real();
825 /* Tell the scheduler that we are going deep-idle: */ 832 /* Tell the scheduler that we are going deep-idle: */
826 sched_clock_idle_sleep_event(); 833 sched_clock_idle_sleep_event();
827 acpi_idle_do_entry(cx); 834 acpi_idle_do_entry(cx);
835 kt2 = ktime_get_real();
836 idle_time_ns = ktime_to_ns(ktime_sub(kt2, kt1));
837 idle_time = idle_time_ns;
838 do_div(idle_time, NSEC_PER_USEC);
828 839
829 sched_clock_idle_wakeup_event(0); 840 /* Tell the scheduler how much we idled: */
841 sched_clock_idle_wakeup_event(idle_time_ns);
830 842
843 local_irq_enable();
831 if (cx->entry_method != ACPI_CSTATE_FFH) 844 if (cx->entry_method != ACPI_CSTATE_FFH)
832 current_thread_info()->status |= TS_POLLING; 845 current_thread_info()->status |= TS_POLLING;
833 846
847 cx->usage++;
848
834 lapic_timer_state_broadcast(pr, cx, 0); 849 lapic_timer_state_broadcast(pr, cx, 0);
835 return index; 850 cx->time += idle_time;
851 return idle_time;
836} 852}
837 853
838static int c3_cpu_count; 854static int c3_cpu_count;
839static DEFINE_RAW_SPINLOCK(c3_lock); 855static DEFINE_SPINLOCK(c3_lock);
840 856
841/** 857/**
842 * acpi_idle_enter_bm - enters C3 with proper BM handling 858 * acpi_idle_enter_bm - enters C3 with proper BM handling
843 * @dev: the target CPU 859 * @dev: the target CPU
844 * @drv: cpuidle driver containing state data 860 * @state: the state data
845 * @index: the index of suggested state
846 * 861 *
847 * If BM is detected, the deepest non-C3 idle state is entered instead. 862 * If BM is detected, the deepest non-C3 idle state is entered instead.
848 */ 863 */
849static int acpi_idle_enter_bm(struct cpuidle_device *dev, 864static int acpi_idle_enter_bm(struct cpuidle_device *dev,
850 struct cpuidle_driver *drv, int index) 865 struct cpuidle_state *state)
851{ 866{
852 struct acpi_processor *pr; 867 struct acpi_processor *pr;
853 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 868 struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
854 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); 869 ktime_t kt1, kt2;
870 s64 idle_time_ns;
871 s64 idle_time;
872
855 873
856 pr = __this_cpu_read(processors); 874 pr = __this_cpu_read(processors);
857 875
858 if (unlikely(!pr)) 876 if (unlikely(!pr))
859 return -EINVAL; 877 return 0;
878
879 if (acpi_idle_suspend)
880 return(acpi_idle_enter_c1(dev, state));
860 881
861 if (!cx->bm_sts_skip && acpi_idle_bm_check()) { 882 if (!cx->bm_sts_skip && acpi_idle_bm_check()) {
862 if (drv->safe_state_index >= 0) { 883 if (dev->safe_state) {
863 return drv->states[drv->safe_state_index].enter(dev, 884 dev->last_state = dev->safe_state;
864 drv, drv->safe_state_index); 885 return dev->safe_state->enter(dev, dev->safe_state);
865 } else { 886 } else {
887 local_irq_disable();
866 acpi_safe_halt(); 888 acpi_safe_halt();
867 return -EBUSY; 889 local_irq_enable();
890 return 0;
868 } 891 }
869 } 892 }
870 893
894 local_irq_disable();
895
871 if (cx->entry_method != ACPI_CSTATE_FFH) { 896 if (cx->entry_method != ACPI_CSTATE_FFH) {
872 current_thread_info()->status &= ~TS_POLLING; 897 current_thread_info()->status &= ~TS_POLLING;
873 /* 898 /*
@@ -878,7 +903,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
878 903
879 if (unlikely(need_resched())) { 904 if (unlikely(need_resched())) {
880 current_thread_info()->status |= TS_POLLING; 905 current_thread_info()->status |= TS_POLLING;
881 return -EINVAL; 906 local_irq_enable();
907 return 0;
882 } 908 }
883 } 909 }
884 910
@@ -892,6 +918,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
892 */ 918 */
893 lapic_timer_state_broadcast(pr, cx, 1); 919 lapic_timer_state_broadcast(pr, cx, 1);
894 920
921 kt1 = ktime_get_real();
895 /* 922 /*
896 * disable bus master 923 * disable bus master
897 * bm_check implies we need ARB_DIS 924 * bm_check implies we need ARB_DIS
@@ -903,12 +930,12 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
903 * without doing anything. 930 * without doing anything.
904 */ 931 */
905 if (pr->flags.bm_check && pr->flags.bm_control) { 932 if (pr->flags.bm_check && pr->flags.bm_control) {
906 raw_spin_lock(&c3_lock); 933 spin_lock(&c3_lock);
907 c3_cpu_count++; 934 c3_cpu_count++;
908 /* Disable bus master arbitration when all CPUs are in C3 */ 935 /* Disable bus master arbitration when all CPUs are in C3 */
909 if (c3_cpu_count == num_online_cpus()) 936 if (c3_cpu_count == num_online_cpus())
910 acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 1); 937 acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 1);
911 raw_spin_unlock(&c3_lock); 938 spin_unlock(&c3_lock);
912 } else if (!pr->flags.bm_check) { 939 } else if (!pr->flags.bm_check) {
913 ACPI_FLUSH_CPU_CACHE(); 940 ACPI_FLUSH_CPU_CACHE();
914 } 941 }
@@ -917,39 +944,45 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
917 944
918 /* Re-enable bus master arbitration */ 945 /* Re-enable bus master arbitration */
919 if (pr->flags.bm_check && pr->flags.bm_control) { 946 if (pr->flags.bm_check && pr->flags.bm_control) {
920 raw_spin_lock(&c3_lock); 947 spin_lock(&c3_lock);
921 acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 0); 948 acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 0);
922 c3_cpu_count--; 949 c3_cpu_count--;
923 raw_spin_unlock(&c3_lock); 950 spin_unlock(&c3_lock);
924 } 951 }
952 kt2 = ktime_get_real();
953 idle_time_ns = ktime_to_ns(ktime_sub(kt2, kt1));
954 idle_time = idle_time_ns;
955 do_div(idle_time, NSEC_PER_USEC);
925 956
926 sched_clock_idle_wakeup_event(0); 957 /* Tell the scheduler how much we idled: */
958 sched_clock_idle_wakeup_event(idle_time_ns);
927 959
960 local_irq_enable();
928 if (cx->entry_method != ACPI_CSTATE_FFH) 961 if (cx->entry_method != ACPI_CSTATE_FFH)
929 current_thread_info()->status |= TS_POLLING; 962 current_thread_info()->status |= TS_POLLING;
930 963
964 cx->usage++;
965
931 lapic_timer_state_broadcast(pr, cx, 0); 966 lapic_timer_state_broadcast(pr, cx, 0);
932 return index; 967 cx->time += idle_time;
968 return idle_time;
933} 969}
934 970
935struct cpuidle_driver acpi_idle_driver = { 971struct cpuidle_driver acpi_idle_driver = {
936 .name = "acpi_idle", 972 .name = "acpi_idle",
937 .owner = THIS_MODULE, 973 .owner = THIS_MODULE,
938 .en_core_tk_irqen = 1,
939}; 974};
940 975
941/** 976/**
942 * acpi_processor_setup_cpuidle_cx - prepares and configures CPUIDLE 977 * acpi_processor_setup_cpuidle - prepares and configures CPUIDLE
943 * device i.e. per-cpu data
944 *
945 * @pr: the ACPI processor 978 * @pr: the ACPI processor
946 */ 979 */
947static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr) 980static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
948{ 981{
949 int i, count = CPUIDLE_DRIVER_STATE_START; 982 int i, count = CPUIDLE_DRIVER_STATE_START;
950 struct acpi_processor_cx *cx; 983 struct acpi_processor_cx *cx;
951 struct cpuidle_state_usage *state_usage; 984 struct cpuidle_state *state;
952 struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id); 985 struct cpuidle_device *dev = &pr->power.dev;
953 986
954 if (!pr->flags.power_setup_done) 987 if (!pr->flags.power_setup_done)
955 return -EINVAL; 988 return -EINVAL;
@@ -959,62 +992,9 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
959 } 992 }
960 993
961 dev->cpu = pr->id; 994 dev->cpu = pr->id;
962
963 if (max_cstate == 0)
964 max_cstate = 1;
965
966 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
967 cx = &pr->power.states[i];
968 state_usage = &dev->states_usage[count];
969
970 if (!cx->valid)
971 continue;
972
973#ifdef CONFIG_HOTPLUG_CPU
974 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
975 !pr->flags.has_cst &&
976 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
977 continue;
978#endif
979
980 cpuidle_set_statedata(state_usage, cx);
981
982 count++;
983 if (count == CPUIDLE_STATE_MAX)
984 break;
985 }
986
987 dev->state_count = count;
988
989 if (!count)
990 return -EINVAL;
991
992 return 0;
993}
994
995/**
996 * acpi_processor_setup_cpuidle states- prepares and configures cpuidle
997 * global state data i.e. idle routines
998 *
999 * @pr: the ACPI processor
1000 */
1001static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
1002{
1003 int i, count = CPUIDLE_DRIVER_STATE_START;
1004 struct acpi_processor_cx *cx;
1005 struct cpuidle_state *state;
1006 struct cpuidle_driver *drv = &acpi_idle_driver;
1007
1008 if (!pr->flags.power_setup_done)
1009 return -EINVAL;
1010
1011 if (pr->flags.power == 0)
1012 return -EINVAL;
1013
1014 drv->safe_state_index = -1;
1015 for (i = 0; i < CPUIDLE_STATE_MAX; i++) { 995 for (i = 0; i < CPUIDLE_STATE_MAX; i++) {
1016 drv->states[i].name[0] = '\0'; 996 dev->states[i].name[0] = '\0';
1017 drv->states[i].desc[0] = '\0'; 997 dev->states[i].desc[0] = '\0';
1018 } 998 }
1019 999
1020 if (max_cstate == 0) 1000 if (max_cstate == 0)
@@ -1022,6 +1002,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
1022 1002
1023 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { 1003 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
1024 cx = &pr->power.states[i]; 1004 cx = &pr->power.states[i];
1005 state = &dev->states[count];
1025 1006
1026 if (!cx->valid) 1007 if (!cx->valid)
1027 continue; 1008 continue;
@@ -1032,8 +1013,8 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
1032 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) 1013 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
1033 continue; 1014 continue;
1034#endif 1015#endif
1016 cpuidle_set_statedata(state, cx);
1035 1017
1036 state = &drv->states[count];
1037 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); 1018 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i);
1038 strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); 1019 strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
1039 state->exit_latency = cx->latency; 1020 state->exit_latency = cx->latency;
@@ -1046,15 +1027,13 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
1046 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1027 state->flags |= CPUIDLE_FLAG_TIME_VALID;
1047 1028
1048 state->enter = acpi_idle_enter_c1; 1029 state->enter = acpi_idle_enter_c1;
1049 state->enter_dead = acpi_idle_play_dead; 1030 dev->safe_state = state;
1050 drv->safe_state_index = count;
1051 break; 1031 break;
1052 1032
1053 case ACPI_STATE_C2: 1033 case ACPI_STATE_C2:
1054 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1034 state->flags |= CPUIDLE_FLAG_TIME_VALID;
1055 state->enter = acpi_idle_enter_simple; 1035 state->enter = acpi_idle_enter_simple;
1056 state->enter_dead = acpi_idle_play_dead; 1036 dev->safe_state = state;
1057 drv->safe_state_index = count;
1058 break; 1037 break;
1059 1038
1060 case ACPI_STATE_C3: 1039 case ACPI_STATE_C3:
@@ -1070,7 +1049,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
1070 break; 1049 break;
1071 } 1050 }
1072 1051
1073 drv->state_count = count; 1052 dev->state_count = count;
1074 1053
1075 if (!count) 1054 if (!count)
1076 return -EINVAL; 1055 return -EINVAL;
@@ -1078,10 +1057,9 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
1078 return 0; 1057 return 0;
1079} 1058}
1080 1059
1081int acpi_processor_hotplug(struct acpi_processor *pr) 1060int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1082{ 1061{
1083 int ret = 0; 1062 int ret = 0;
1084 struct cpuidle_device *dev;
1085 1063
1086 if (disabled_by_idle_boot_param()) 1064 if (disabled_by_idle_boot_param())
1087 return 0; 1065 return 0;
@@ -1096,87 +1074,22 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
1096 if (!pr->flags.power_setup_done) 1074 if (!pr->flags.power_setup_done)
1097 return -ENODEV; 1075 return -ENODEV;
1098 1076
1099 dev = per_cpu(acpi_cpuidle_device, pr->id);
1100 cpuidle_pause_and_lock(); 1077 cpuidle_pause_and_lock();
1101 cpuidle_disable_device(dev); 1078 cpuidle_disable_device(&pr->power.dev);
1102 acpi_processor_get_power_info(pr); 1079 acpi_processor_get_power_info(pr);
1103 if (pr->flags.power) { 1080 if (pr->flags.power) {
1104 acpi_processor_setup_cpuidle_cx(pr); 1081 acpi_processor_setup_cpuidle(pr);
1105 ret = cpuidle_enable_device(dev); 1082 ret = cpuidle_enable_device(&pr->power.dev);
1106 } 1083 }
1107 cpuidle_resume_and_unlock(); 1084 cpuidle_resume_and_unlock();
1108 1085
1109 return ret; 1086 return ret;
1110} 1087}
1111 1088
1112int acpi_processor_cst_has_changed(struct acpi_processor *pr) 1089int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1113{ 1090 struct acpi_device *device)
1114 int cpu;
1115 struct acpi_processor *_pr;
1116 struct cpuidle_device *dev;
1117
1118 if (disabled_by_idle_boot_param())
1119 return 0;
1120
1121 if (!pr)
1122 return -EINVAL;
1123
1124 if (nocst)
1125 return -ENODEV;
1126
1127 if (!pr->flags.power_setup_done)
1128 return -ENODEV;
1129
1130 /*
1131 * FIXME: Design the ACPI notification to make it once per
1132 * system instead of once per-cpu. This condition is a hack
1133 * to make the code that updates C-States be called once.
1134 */
1135
1136 if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) {
1137
1138 cpuidle_pause_and_lock();
1139 /* Protect against cpu-hotplug */
1140 get_online_cpus();
1141
1142 /* Disable all cpuidle devices */
1143 for_each_online_cpu(cpu) {
1144 _pr = per_cpu(processors, cpu);
1145 if (!_pr || !_pr->flags.power_setup_done)
1146 continue;
1147 dev = per_cpu(acpi_cpuidle_device, cpu);
1148 cpuidle_disable_device(dev);
1149 }
1150
1151 /* Populate Updated C-state information */
1152 acpi_processor_setup_cpuidle_states(pr);
1153
1154 /* Enable all cpuidle devices */
1155 for_each_online_cpu(cpu) {
1156 _pr = per_cpu(processors, cpu);
1157 if (!_pr || !_pr->flags.power_setup_done)
1158 continue;
1159 acpi_processor_get_power_info(_pr);
1160 if (_pr->flags.power) {
1161 acpi_processor_setup_cpuidle_cx(_pr);
1162 dev = per_cpu(acpi_cpuidle_device, cpu);
1163 cpuidle_enable_device(dev);
1164 }
1165 }
1166 put_online_cpus();
1167 cpuidle_resume_and_unlock();
1168 }
1169
1170 return 0;
1171}
1172
1173static int acpi_processor_registered;
1174
1175int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
1176{ 1091{
1177 acpi_status status = 0; 1092 acpi_status status = 0;
1178 int retval;
1179 struct cpuidle_device *dev;
1180 static int first_run; 1093 static int first_run;
1181 1094
1182 if (disabled_by_idle_boot_param()) 1095 if (disabled_by_idle_boot_param())
@@ -1213,51 +1126,21 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
1213 * platforms that only support C1. 1126 * platforms that only support C1.
1214 */ 1127 */
1215 if (pr->flags.power) { 1128 if (pr->flags.power) {
1216 /* Register acpi_idle_driver if not already registered */ 1129 acpi_processor_setup_cpuidle(pr);
1217 if (!acpi_processor_registered) { 1130 if (cpuidle_register_device(&pr->power.dev))
1218 acpi_processor_setup_cpuidle_states(pr); 1131 return -EIO;
1219 retval = cpuidle_register_driver(&acpi_idle_driver);
1220 if (retval)
1221 return retval;
1222 printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
1223 acpi_idle_driver.name);
1224 }
1225
1226 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1227 if (!dev)
1228 return -ENOMEM;
1229 per_cpu(acpi_cpuidle_device, pr->id) = dev;
1230
1231 acpi_processor_setup_cpuidle_cx(pr);
1232
1233 /* Register per-cpu cpuidle_device. Cpuidle driver
1234 * must already be registered before registering device
1235 */
1236 retval = cpuidle_register_device(dev);
1237 if (retval) {
1238 if (acpi_processor_registered == 0)
1239 cpuidle_unregister_driver(&acpi_idle_driver);
1240 return retval;
1241 }
1242 acpi_processor_registered++;
1243 } 1132 }
1244 return 0; 1133 return 0;
1245} 1134}
1246 1135
1247int acpi_processor_power_exit(struct acpi_processor *pr) 1136int acpi_processor_power_exit(struct acpi_processor *pr,
1137 struct acpi_device *device)
1248{ 1138{
1249 struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
1250
1251 if (disabled_by_idle_boot_param()) 1139 if (disabled_by_idle_boot_param())
1252 return 0; 1140 return 0;
1253 1141
1254 if (pr->flags.power) { 1142 cpuidle_unregister_device(&pr->power.dev);
1255 cpuidle_unregister_device(dev);
1256 acpi_processor_registered--;
1257 if (acpi_processor_registered == 0)
1258 cpuidle_unregister_driver(&acpi_idle_driver);
1259 }
1260
1261 pr->flags.power_setup_done = 0; 1143 pr->flags.power_setup_done = 0;
1144
1262 return 0; 1145 return 0;
1263} 1146}
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 836bfe06904..85b32376dad 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -240,28 +240,6 @@ void acpi_processor_ppc_exit(void)
240 acpi_processor_ppc_status &= ~PPC_REGISTERED; 240 acpi_processor_ppc_status &= ~PPC_REGISTERED;
241} 241}
242 242
243/*
244 * Do a quick check if the systems looks like it should use ACPI
245 * cpufreq. We look at a _PCT method being available, but don't
246 * do a whole lot of sanity checks.
247 */
248void acpi_processor_load_module(struct acpi_processor *pr)
249{
250 static int requested;
251 acpi_status status = 0;
252 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
253
254 if (!arch_has_acpi_pdc() || requested)
255 return;
256 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
257 if (!ACPI_FAILURE(status)) {
258 printk(KERN_INFO PREFIX "Requesting acpi_cpufreq\n");
259 request_module_nowait("acpi_cpufreq");
260 requested = 1;
261 }
262 kfree(buffer.pointer);
263}
264
265static int acpi_processor_get_performance_control(struct acpi_processor *pr) 243static int acpi_processor_get_performance_control(struct acpi_processor *pr)
266{ 244{
267 int result = 0; 245 int result = 0;
@@ -324,34 +302,6 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
324 return result; 302 return result;
325} 303}
326 304
327#ifdef CONFIG_X86
328/*
329 * Some AMDs have 50MHz frequency multiples, but only provide 100MHz rounding
330 * in their ACPI data. Calculate the real values and fix up the _PSS data.
331 */
332static void amd_fixup_frequency(struct acpi_processor_px *px, int i)
333{
334 u32 hi, lo, fid, did;
335 int index = px->control & 0x00000007;
336
337 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
338 return;
339
340 if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
341 || boot_cpu_data.x86 == 0x11) {
342 rdmsr(MSR_AMD_PSTATE_DEF_BASE + index, lo, hi);
343 fid = lo & 0x3f;
344 did = (lo >> 6) & 7;
345 if (boot_cpu_data.x86 == 0x10)
346 px->core_frequency = (100 * (fid + 0x10)) >> did;
347 else
348 px->core_frequency = (100 * (fid + 8)) >> did;
349 }
350}
351#else
352static void amd_fixup_frequency(struct acpi_processor_px *px, int i) {};
353#endif
354
355static int acpi_processor_get_performance_states(struct acpi_processor *pr) 305static int acpi_processor_get_performance_states(struct acpi_processor *pr)
356{ 306{
357 int result = 0; 307 int result = 0;
@@ -361,7 +311,6 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
361 struct acpi_buffer state = { 0, NULL }; 311 struct acpi_buffer state = { 0, NULL };
362 union acpi_object *pss = NULL; 312 union acpi_object *pss = NULL;
363 int i; 313 int i;
364 int last_invalid = -1;
365 314
366 315
367 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); 316 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
@@ -407,8 +356,6 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
407 goto end; 356 goto end;
408 } 357 }
409 358
410 amd_fixup_frequency(px, i);
411
412 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 359 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
413 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n", 360 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
414 i, 361 i,
@@ -425,33 +372,14 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
425 ((u32)(px->core_frequency * 1000) != 372 ((u32)(px->core_frequency * 1000) !=
426 (px->core_frequency * 1000))) { 373 (px->core_frequency * 1000))) {
427 printk(KERN_ERR FW_BUG PREFIX 374 printk(KERN_ERR FW_BUG PREFIX
428 "Invalid BIOS _PSS frequency found for processor %d: 0x%llx MHz\n", 375 "Invalid BIOS _PSS frequency: 0x%llx MHz\n",
429 pr->id, px->core_frequency); 376 px->core_frequency);
430 if (last_invalid == -1) 377 result = -EFAULT;
431 last_invalid = i; 378 kfree(pr->performance->states);
432 } else { 379 goto end;
433 if (last_invalid != -1) {
434 /*
435 * Copy this valid entry over last_invalid entry
436 */
437 memcpy(&(pr->performance->states[last_invalid]),
438 px, sizeof(struct acpi_processor_px));
439 ++last_invalid;
440 }
441 } 380 }
442 } 381 }
443 382
444 if (last_invalid == 0) {
445 printk(KERN_ERR FW_BUG PREFIX
446 "No valid BIOS _PSS frequency found for processor %d\n", pr->id);
447 result = -EFAULT;
448 kfree(pr->performance->states);
449 pr->performance->states = NULL;
450 }
451
452 if (last_invalid > 0)
453 pr->performance->state_count = last_invalid;
454
455 end: 383 end:
456 kfree(buffer.pointer); 384 kfree(buffer.pointer);
457 385
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 641b5450a0d..870550d6a4b 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.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/sysdev.h>
33 34
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35 36
@@ -57,27 +58,6 @@ ACPI_MODULE_NAME("processor_thermal");
57static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg); 58static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg);
58static unsigned int acpi_thermal_cpufreq_is_init = 0; 59static unsigned int acpi_thermal_cpufreq_is_init = 0;
59 60
60#define reduction_pctg(cpu) \
61 per_cpu(cpufreq_thermal_reduction_pctg, phys_package_first_cpu(cpu))
62
63/*
64 * Emulate "per package data" using per cpu data (which should really be
65 * provided elsewhere)
66 *
67 * Note we can lose a CPU on cpu hotunplug, in this case we forget the state
68 * temporarily. Fortunately that's not a big issue here (I hope)
69 */
70static int phys_package_first_cpu(int cpu)
71{
72 int i;
73 int id = topology_physical_package_id(cpu);
74
75 for_each_online_cpu(i)
76 if (topology_physical_package_id(i) == id)
77 return i;
78 return 0;
79}
80
81static int cpu_has_cpufreq(unsigned int cpu) 61static int cpu_has_cpufreq(unsigned int cpu)
82{ 62{
83 struct cpufreq_policy policy; 63 struct cpufreq_policy policy;
@@ -97,7 +77,7 @@ static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
97 77
98 max_freq = ( 78 max_freq = (
99 policy->cpuinfo.max_freq * 79 policy->cpuinfo.max_freq *
100 (100 - reduction_pctg(policy->cpu) * 20) 80 (100 - per_cpu(cpufreq_thermal_reduction_pctg, policy->cpu) * 20)
101 ) / 100; 81 ) / 100;
102 82
103 cpufreq_verify_within_limits(policy, 0, max_freq); 83 cpufreq_verify_within_limits(policy, 0, max_freq);
@@ -123,28 +103,16 @@ static int cpufreq_get_cur_state(unsigned int cpu)
123 if (!cpu_has_cpufreq(cpu)) 103 if (!cpu_has_cpufreq(cpu))
124 return 0; 104 return 0;
125 105
126 return reduction_pctg(cpu); 106 return per_cpu(cpufreq_thermal_reduction_pctg, cpu);
127} 107}
128 108
129static int cpufreq_set_cur_state(unsigned int cpu, int state) 109static int cpufreq_set_cur_state(unsigned int cpu, int state)
130{ 110{
131 int i;
132
133 if (!cpu_has_cpufreq(cpu)) 111 if (!cpu_has_cpufreq(cpu))
134 return 0; 112 return 0;
135 113
136 reduction_pctg(cpu) = state; 114 per_cpu(cpufreq_thermal_reduction_pctg, cpu) = state;
137 115 cpufreq_update_policy(cpu);
138 /*
139 * Update all the CPUs in the same package because they all
140 * contribute to the temperature and often share the same
141 * frequency.
142 */
143 for_each_online_cpu(i) {
144 if (topology_physical_package_id(i) ==
145 topology_physical_package_id(cpu))
146 cpufreq_update_policy(i);
147 }
148 return 0; 116 return 0;
149} 117}
150 118
@@ -152,6 +120,10 @@ void acpi_thermal_cpufreq_init(void)
152{ 120{
153 int i; 121 int i;
154 122
123 for (i = 0; i < nr_cpu_ids; i++)
124 if (cpu_present(i))
125 per_cpu(cpufreq_thermal_reduction_pctg, i) = 0;
126
155 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block, 127 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block,
156 CPUFREQ_POLICY_NOTIFIER); 128 CPUFREQ_POLICY_NOTIFIER);
157 if (!i) 129 if (!i)
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1d02b7b5ade..605a2954ef1 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -769,7 +769,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
769 u64 *value) 769 u64 *value)
770{ 770{
771 u32 bit_width, bit_offset; 771 u32 bit_width, bit_offset;
772 u32 ptc_value; 772 u64 ptc_value;
773 u64 ptc_mask; 773 u64 ptc_mask;
774 struct acpi_processor_throttling *throttling; 774 struct acpi_processor_throttling *throttling;
775 int ret = -1; 775 int ret = -1;
@@ -777,11 +777,12 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
777 throttling = &pr->throttling; 777 throttling = &pr->throttling;
778 switch (throttling->status_register.space_id) { 778 switch (throttling->status_register.space_id) {
779 case ACPI_ADR_SPACE_SYSTEM_IO: 779 case ACPI_ADR_SPACE_SYSTEM_IO:
780 ptc_value = 0;
780 bit_width = throttling->status_register.bit_width; 781 bit_width = throttling->status_register.bit_width;
781 bit_offset = throttling->status_register.bit_offset; 782 bit_offset = throttling->status_register.bit_offset;
782 783
783 acpi_os_read_port((acpi_io_address) throttling->status_register. 784 acpi_os_read_port((acpi_io_address) throttling->status_register.
784 address, &ptc_value, 785 address, (u32 *) &ptc_value,
785 (u32) (bit_width + bit_offset)); 786 (u32) (bit_width + bit_offset));
786 ptc_mask = (1 << bit_width) - 1; 787 ptc_mask = (1 << bit_width) - 1;
787 *value = (u64) ((ptc_value >> bit_offset) & ptc_mask); 788 *value = (u64) ((ptc_value >> bit_offset) & ptc_mask);
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
deleted file mode 100644
index a3868f6c222..00000000000
--- a/drivers/acpi/resource.c
+++ /dev/null
@@ -1,526 +0,0 @@
1/*
2 * drivers/acpi/resource.c - ACPI device resources interpretation.
3 *
4 * Copyright (C) 2012, Intel Corp.
5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */
24
25#include <linux/acpi.h>
26#include <linux/device.h>
27#include <linux/export.h>
28#include <linux/ioport.h>
29#include <linux/slab.h>
30
31#ifdef CONFIG_X86
32#define valid_IRQ(i) (((i) != 0) && ((i) != 2))
33#else
34#define valid_IRQ(i) (true)
35#endif
36
37static unsigned long acpi_dev_memresource_flags(u64 len, u8 write_protect,
38 bool window)
39{
40 unsigned long flags = IORESOURCE_MEM;
41
42 if (len == 0)
43 flags |= IORESOURCE_DISABLED;
44
45 if (write_protect == ACPI_READ_WRITE_MEMORY)
46 flags |= IORESOURCE_MEM_WRITEABLE;
47
48 if (window)
49 flags |= IORESOURCE_WINDOW;
50
51 return flags;
52}
53
54static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len,
55 u8 write_protect)
56{
57 res->start = start;
58 res->end = start + len - 1;
59 res->flags = acpi_dev_memresource_flags(len, write_protect, false);
60}
61
62/**
63 * acpi_dev_resource_memory - Extract ACPI memory resource information.
64 * @ares: Input ACPI resource object.
65 * @res: Output generic resource object.
66 *
67 * Check if the given ACPI resource object represents a memory resource and
68 * if that's the case, use the information in it to populate the generic
69 * resource object pointed to by @res.
70 */
71bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)
72{
73 struct acpi_resource_memory24 *memory24;
74 struct acpi_resource_memory32 *memory32;
75 struct acpi_resource_fixed_memory32 *fixed_memory32;
76
77 switch (ares->type) {
78 case ACPI_RESOURCE_TYPE_MEMORY24:
79 memory24 = &ares->data.memory24;
80 acpi_dev_get_memresource(res, memory24->minimum,
81 memory24->address_length,
82 memory24->write_protect);
83 break;
84 case ACPI_RESOURCE_TYPE_MEMORY32:
85 memory32 = &ares->data.memory32;
86 acpi_dev_get_memresource(res, memory32->minimum,
87 memory32->address_length,
88 memory32->write_protect);
89 break;
90 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
91 fixed_memory32 = &ares->data.fixed_memory32;
92 acpi_dev_get_memresource(res, fixed_memory32->address,
93 fixed_memory32->address_length,
94 fixed_memory32->write_protect);
95 break;
96 default:
97 return false;
98 }
99 return true;
100}
101EXPORT_SYMBOL_GPL(acpi_dev_resource_memory);
102
103static unsigned int acpi_dev_ioresource_flags(u64 start, u64 end, u8 io_decode,
104 bool window)
105{
106 int flags = IORESOURCE_IO;
107
108 if (io_decode == ACPI_DECODE_16)
109 flags |= IORESOURCE_IO_16BIT_ADDR;
110
111 if (start > end || end >= 0x10003)
112 flags |= IORESOURCE_DISABLED;
113
114 if (window)
115 flags |= IORESOURCE_WINDOW;
116
117 return flags;
118}
119
120static void acpi_dev_get_ioresource(struct resource *res, u64 start, u64 len,
121 u8 io_decode)
122{
123 u64 end = start + len - 1;
124
125 res->start = start;
126 res->end = end;
127 res->flags = acpi_dev_ioresource_flags(start, end, io_decode, false);
128}
129
130/**
131 * acpi_dev_resource_io - Extract ACPI I/O resource information.
132 * @ares: Input ACPI resource object.
133 * @res: Output generic resource object.
134 *
135 * Check if the given ACPI resource object represents an I/O resource and
136 * if that's the case, use the information in it to populate the generic
137 * resource object pointed to by @res.
138 */
139bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)
140{
141 struct acpi_resource_io *io;
142 struct acpi_resource_fixed_io *fixed_io;
143
144 switch (ares->type) {
145 case ACPI_RESOURCE_TYPE_IO:
146 io = &ares->data.io;
147 acpi_dev_get_ioresource(res, io->minimum,
148 io->address_length,
149 io->io_decode);
150 break;
151 case ACPI_RESOURCE_TYPE_FIXED_IO:
152 fixed_io = &ares->data.fixed_io;
153 acpi_dev_get_ioresource(res, fixed_io->address,
154 fixed_io->address_length,
155 ACPI_DECODE_10);
156 break;
157 default:
158 return false;
159 }
160 return true;
161}
162EXPORT_SYMBOL_GPL(acpi_dev_resource_io);
163
164/**
165 * acpi_dev_resource_address_space - Extract ACPI address space information.
166 * @ares: Input ACPI resource object.
167 * @res: Output generic resource object.
168 *
169 * Check if the given ACPI resource object represents an address space resource
170 * and if that's the case, use the information in it to populate the generic
171 * resource object pointed to by @res.
172 */
173bool acpi_dev_resource_address_space(struct acpi_resource *ares,
174 struct resource *res)
175{
176 acpi_status status;
177 struct acpi_resource_address64 addr;
178 bool window;
179 u64 len;
180 u8 io_decode;
181
182 switch (ares->type) {
183 case ACPI_RESOURCE_TYPE_ADDRESS16:
184 case ACPI_RESOURCE_TYPE_ADDRESS32:
185 case ACPI_RESOURCE_TYPE_ADDRESS64:
186 break;
187 default:
188 return false;
189 }
190
191 status = acpi_resource_to_address64(ares, &addr);
192 if (ACPI_FAILURE(status))
193 return true;
194
195 res->start = addr.minimum;
196 res->end = addr.maximum;
197 window = addr.producer_consumer == ACPI_PRODUCER;
198
199 switch(addr.resource_type) {
200 case ACPI_MEMORY_RANGE:
201 len = addr.maximum - addr.minimum + 1;
202 res->flags = acpi_dev_memresource_flags(len,
203 addr.info.mem.write_protect,
204 window);
205 break;
206 case ACPI_IO_RANGE:
207 io_decode = addr.granularity == 0xfff ?
208 ACPI_DECODE_10 : ACPI_DECODE_16;
209 res->flags = acpi_dev_ioresource_flags(addr.minimum,
210 addr.maximum,
211 io_decode, window);
212 break;
213 case ACPI_BUS_NUMBER_RANGE:
214 res->flags = IORESOURCE_BUS;
215 break;
216 default:
217 res->flags = 0;
218 }
219
220 return true;
221}
222EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space);
223
224/**
225 * acpi_dev_resource_ext_address_space - Extract ACPI address space information.
226 * @ares: Input ACPI resource object.
227 * @res: Output generic resource object.
228 *
229 * Check if the given ACPI resource object represents an extended address space
230 * resource and if that's the case, use the information in it to populate the
231 * generic resource object pointed to by @res.
232 */
233bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
234 struct resource *res)
235{
236 struct acpi_resource_extended_address64 *ext_addr;
237 bool window;
238 u64 len;
239 u8 io_decode;
240
241 if (ares->type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64)
242 return false;
243
244 ext_addr = &ares->data.ext_address64;
245
246 res->start = ext_addr->minimum;
247 res->end = ext_addr->maximum;
248 window = ext_addr->producer_consumer == ACPI_PRODUCER;
249
250 switch(ext_addr->resource_type) {
251 case ACPI_MEMORY_RANGE:
252 len = ext_addr->maximum - ext_addr->minimum + 1;
253 res->flags = acpi_dev_memresource_flags(len,
254 ext_addr->info.mem.write_protect,
255 window);
256 break;
257 case ACPI_IO_RANGE:
258 io_decode = ext_addr->granularity == 0xfff ?
259 ACPI_DECODE_10 : ACPI_DECODE_16;
260 res->flags = acpi_dev_ioresource_flags(ext_addr->minimum,
261 ext_addr->maximum,
262 io_decode, window);
263 break;
264 case ACPI_BUS_NUMBER_RANGE:
265 res->flags = IORESOURCE_BUS;
266 break;
267 default:
268 res->flags = 0;
269 }
270
271 return true;
272}
273EXPORT_SYMBOL_GPL(acpi_dev_resource_ext_address_space);
274
275/**
276 * acpi_dev_irq_flags - Determine IRQ resource flags.
277 * @triggering: Triggering type as provided by ACPI.
278 * @polarity: Interrupt polarity as provided by ACPI.
279 * @shareable: Whether or not the interrupt is shareable.
280 */
281unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable)
282{
283 unsigned long flags;
284
285 if (triggering == ACPI_LEVEL_SENSITIVE)
286 flags = polarity == ACPI_ACTIVE_LOW ?
287 IORESOURCE_IRQ_LOWLEVEL : IORESOURCE_IRQ_HIGHLEVEL;
288 else
289 flags = polarity == ACPI_ACTIVE_LOW ?
290 IORESOURCE_IRQ_LOWEDGE : IORESOURCE_IRQ_HIGHEDGE;
291
292 if (shareable == ACPI_SHARED)
293 flags |= IORESOURCE_IRQ_SHAREABLE;
294
295 return flags | IORESOURCE_IRQ;
296}
297EXPORT_SYMBOL_GPL(acpi_dev_irq_flags);
298
299static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi)
300{
301 res->start = gsi;
302 res->end = gsi;
303 res->flags = IORESOURCE_IRQ | IORESOURCE_DISABLED;
304}
305
306static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
307 u8 triggering, u8 polarity, u8 shareable)
308{
309 int irq, p, t;
310
311 if (!valid_IRQ(gsi)) {
312 acpi_dev_irqresource_disabled(res, gsi);
313 return;
314 }
315
316 /*
317 * In IO-APIC mode, use overrided attribute. Two reasons:
318 * 1. BIOS bug in DSDT
319 * 2. BIOS uses IO-APIC mode Interrupt Source Override
320 */
321 if (!acpi_get_override_irq(gsi, &t, &p)) {
322 u8 trig = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
323 u8 pol = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
324
325 if (triggering != trig || polarity != pol) {
326 pr_warning("ACPI: IRQ %d override to %s, %s\n", gsi,
327 t ? "edge" : "level", p ? "low" : "high");
328 triggering = trig;
329 polarity = pol;
330 }
331 }
332
333 res->flags = acpi_dev_irq_flags(triggering, polarity, shareable);
334 irq = acpi_register_gsi(NULL, gsi, triggering, polarity);
335 if (irq >= 0) {
336 res->start = irq;
337 res->end = irq;
338 } else {
339 acpi_dev_irqresource_disabled(res, gsi);
340 }
341}
342
343/**
344 * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information.
345 * @ares: Input ACPI resource object.
346 * @index: Index into the array of GSIs represented by the resource.
347 * @res: Output generic resource object.
348 *
349 * Check if the given ACPI resource object represents an interrupt resource
350 * and @index does not exceed the resource's interrupt count (true is returned
351 * in that case regardless of the results of the other checks)). If that's the
352 * case, register the GSI corresponding to @index from the array of interrupts
353 * represented by the resource and populate the generic resource object pointed
354 * to by @res accordingly. If the registration of the GSI is not successful,
355 * IORESOURCE_DISABLED will be set it that object's flags.
356 */
357bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
358 struct resource *res)
359{
360 struct acpi_resource_irq *irq;
361 struct acpi_resource_extended_irq *ext_irq;
362
363 switch (ares->type) {
364 case ACPI_RESOURCE_TYPE_IRQ:
365 /*
366 * Per spec, only one interrupt per descriptor is allowed in
367 * _CRS, but some firmware violates this, so parse them all.
368 */
369 irq = &ares->data.irq;
370 if (index >= irq->interrupt_count) {
371 acpi_dev_irqresource_disabled(res, 0);
372 return false;
373 }
374 acpi_dev_get_irqresource(res, irq->interrupts[index],
375 irq->triggering, irq->polarity,
376 irq->sharable);
377 break;
378 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
379 ext_irq = &ares->data.extended_irq;
380 if (index >= ext_irq->interrupt_count) {
381 acpi_dev_irqresource_disabled(res, 0);
382 return false;
383 }
384 acpi_dev_get_irqresource(res, ext_irq->interrupts[index],
385 ext_irq->triggering, ext_irq->polarity,
386 ext_irq->sharable);
387 break;
388 default:
389 return false;
390 }
391
392 return true;
393}
394EXPORT_SYMBOL_GPL(acpi_dev_resource_interrupt);
395
396/**
397 * acpi_dev_free_resource_list - Free resource from %acpi_dev_get_resources().
398 * @list: The head of the resource list to free.
399 */
400void acpi_dev_free_resource_list(struct list_head *list)
401{
402 struct resource_list_entry *rentry, *re;
403
404 list_for_each_entry_safe(rentry, re, list, node) {
405 list_del(&rentry->node);
406 kfree(rentry);
407 }
408}
409EXPORT_SYMBOL_GPL(acpi_dev_free_resource_list);
410
411struct res_proc_context {
412 struct list_head *list;
413 int (*preproc)(struct acpi_resource *, void *);
414 void *preproc_data;
415 int count;
416 int error;
417};
418
419static acpi_status acpi_dev_new_resource_entry(struct resource *r,
420 struct res_proc_context *c)
421{
422 struct resource_list_entry *rentry;
423
424 rentry = kmalloc(sizeof(*rentry), GFP_KERNEL);
425 if (!rentry) {
426 c->error = -ENOMEM;
427 return AE_NO_MEMORY;
428 }
429 rentry->res = *r;
430 list_add_tail(&rentry->node, c->list);
431 c->count++;
432 return AE_OK;
433}
434
435static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,
436 void *context)
437{
438 struct res_proc_context *c = context;
439 struct resource r;
440 int i;
441
442 if (c->preproc) {
443 int ret;
444
445 ret = c->preproc(ares, c->preproc_data);
446 if (ret < 0) {
447 c->error = ret;
448 return AE_CTRL_TERMINATE;
449 } else if (ret > 0) {
450 return AE_OK;
451 }
452 }
453
454 memset(&r, 0, sizeof(r));
455
456 if (acpi_dev_resource_memory(ares, &r)
457 || acpi_dev_resource_io(ares, &r)
458 || acpi_dev_resource_address_space(ares, &r)
459 || acpi_dev_resource_ext_address_space(ares, &r))
460 return acpi_dev_new_resource_entry(&r, c);
461
462 for (i = 0; acpi_dev_resource_interrupt(ares, i, &r); i++) {
463 acpi_status status;
464
465 status = acpi_dev_new_resource_entry(&r, c);
466 if (ACPI_FAILURE(status))
467 return status;
468 }
469
470 return AE_OK;
471}
472
473/**
474 * acpi_dev_get_resources - Get current resources of a device.
475 * @adev: ACPI device node to get the resources for.
476 * @list: Head of the resultant list of resources (must be empty).
477 * @preproc: The caller's preprocessing routine.
478 * @preproc_data: Pointer passed to the caller's preprocessing routine.
479 *
480 * Evaluate the _CRS method for the given device node and process its output by
481 * (1) executing the @preproc() rountine provided by the caller, passing the
482 * resource pointer and @preproc_data to it as arguments, for each ACPI resource
483 * returned and (2) converting all of the returned ACPI resources into struct
484 * resource objects if possible. If the return value of @preproc() in step (1)
485 * is different from 0, step (2) is not applied to the given ACPI resource and
486 * if that value is negative, the whole processing is aborted and that value is
487 * returned as the final error code.
488 *
489 * The resultant struct resource objects are put on the list pointed to by
490 * @list, that must be empty initially, as members of struct resource_list_entry
491 * objects. Callers of this routine should use %acpi_dev_free_resource_list() to
492 * free that list.
493 *
494 * The number of resources in the output list is returned on success, an error
495 * code reflecting the error condition is returned otherwise.
496 */
497int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
498 int (*preproc)(struct acpi_resource *, void *),
499 void *preproc_data)
500{
501 struct res_proc_context c;
502 acpi_handle not_used;
503 acpi_status status;
504
505 if (!adev || !adev->handle || !list_empty(list))
506 return -EINVAL;
507
508 status = acpi_get_handle(adev->handle, METHOD_NAME__CRS, &not_used);
509 if (ACPI_FAILURE(status))
510 return 0;
511
512 c.list = list;
513 c.preproc = preproc;
514 c.preproc_data = preproc_data;
515 c.count = 0;
516 c.error = 0;
517 status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS,
518 acpi_dev_process_resource, &c);
519 if (ACPI_FAILURE(status)) {
520 acpi_dev_free_resource_list(list);
521 return c.error ? c.error : -EIO;
522 }
523
524 return c.count;
525}
526EXPORT_SYMBOL_GPL(acpi_dev_get_resources);
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index ff0740e0a9c..6e36d0c0057 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -988,19 +988,15 @@ static void acpi_sbs_rmdirs(void)
988#endif 988#endif
989} 989}
990 990
991#ifdef CONFIG_PM_SLEEP 991static int acpi_sbs_resume(struct acpi_device *device)
992static int acpi_sbs_resume(struct device *dev)
993{ 992{
994 struct acpi_sbs *sbs; 993 struct acpi_sbs *sbs;
995 if (!dev) 994 if (!device)
996 return -EINVAL; 995 return -EINVAL;
997 sbs = to_acpi_device(dev)->driver_data; 996 sbs = device->driver_data;
998 acpi_sbs_callback(sbs); 997 acpi_sbs_callback(sbs);
999 return 0; 998 return 0;
1000} 999}
1001#endif
1002
1003static SIMPLE_DEV_PM_OPS(acpi_sbs_pm, NULL, acpi_sbs_resume);
1004 1000
1005static struct acpi_driver acpi_sbs_driver = { 1001static struct acpi_driver acpi_sbs_driver = {
1006 .name = "sbs", 1002 .name = "sbs",
@@ -1009,8 +1005,8 @@ static struct acpi_driver acpi_sbs_driver = {
1009 .ops = { 1005 .ops = {
1010 .add = acpi_sbs_add, 1006 .add = acpi_sbs_add,
1011 .remove = acpi_sbs_remove, 1007 .remove = acpi_sbs_remove,
1008 .resume = acpi_sbs_resume,
1012 }, 1009 },
1013 .drv.pm = &acpi_sbs_pm,
1014}; 1010};
1015 1011
1016static int __init acpi_sbs_init(void) 1012static int __init acpi_sbs_init(void)
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index cf6129a8af7..f8be23b6c12 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -13,7 +13,6 @@
13#include <linux/wait.h> 13#include <linux/wait.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/module.h>
17#include <linux/interrupt.h> 16#include <linux/interrupt.h>
18#include "sbshc.h" 17#include "sbshc.h"
19 18
@@ -310,7 +309,23 @@ static int acpi_smbus_hc_remove(struct acpi_device *device, int type)
310 return 0; 309 return 0;
311} 310}
312 311
313module_acpi_driver(acpi_smb_hc_driver); 312static int __init acpi_smb_hc_init(void)
313{
314 int result;
315
316 result = acpi_bus_register_driver(&acpi_smb_hc_driver);
317 if (result < 0)
318 return -ENODEV;
319 return 0;
320}
321
322static void __exit acpi_smb_hc_exit(void)
323{
324 acpi_bus_unregister_driver(&acpi_smb_hc_driver);
325}
326
327module_init(acpi_smb_hc_init);
328module_exit(acpi_smb_hc_exit);
314 329
315MODULE_LICENSE("GPL"); 330MODULE_LICENSE("GPL");
316MODULE_AUTHOR("Alexey Starikovskiy"); 331MODULE_AUTHOR("Alexey Starikovskiy");
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c88be6c37c3..449c556274c 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -10,7 +10,6 @@
10#include <linux/signal.h> 10#include <linux/signal.h>
11#include <linux/kthread.h> 11#include <linux/kthread.h>
12#include <linux/dmi.h> 12#include <linux/dmi.h>
13#include <linux/nls.h>
14 13
15#include <acpi/acpi_drivers.h> 14#include <acpi/acpi_drivers.h>
16 15
@@ -29,27 +28,6 @@ extern struct acpi_device *acpi_root;
29 28
30static const char *dummy_hid = "device"; 29static const char *dummy_hid = "device";
31 30
32/*
33 * The following ACPI IDs are known to be suitable for representing as
34 * platform devices.
35 */
36static const struct acpi_device_id acpi_platform_device_ids[] = {
37
38 { "PNP0D40" },
39
40 /* Haswell LPSS devices */
41 { "INT33C0", 0 },
42 { "INT33C1", 0 },
43 { "INT33C2", 0 },
44 { "INT33C3", 0 },
45 { "INT33C4", 0 },
46 { "INT33C5", 0 },
47 { "INT33C6", 0 },
48 { "INT33C7", 0 },
49
50 { }
51};
52
53static LIST_HEAD(acpi_device_list); 31static LIST_HEAD(acpi_device_list);
54static LIST_HEAD(acpi_bus_id_list); 32static LIST_HEAD(acpi_bus_id_list);
55DEFINE_MUTEX(acpi_device_lock); 33DEFINE_MUTEX(acpi_device_lock);
@@ -105,30 +83,19 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha
105} 83}
106static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); 84static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
107 85
108/** 86static void acpi_bus_hot_remove_device(void *context)
109 * acpi_bus_hot_remove_device: hot-remove a device and its children
110 * @context: struct acpi_eject_event pointer (freed in this func)
111 *
112 * Hot-remove a device and its children. This function frees up the
113 * memory space passed by arg context, so that the caller may call
114 * this function asynchronously through acpi_os_hotplug_execute().
115 */
116void acpi_bus_hot_remove_device(void *context)
117{ 87{
118 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context;
119 struct acpi_device *device; 88 struct acpi_device *device;
120 acpi_handle handle = ej_event->handle; 89 acpi_handle handle = context;
121 acpi_handle temp;
122 struct acpi_object_list arg_list; 90 struct acpi_object_list arg_list;
123 union acpi_object arg; 91 union acpi_object arg;
124 acpi_status status = AE_OK; 92 acpi_status status = AE_OK;
125 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
126 93
127 if (acpi_bus_get_device(handle, &device)) 94 if (acpi_bus_get_device(handle, &device))
128 goto err_out; 95 return;
129 96
130 if (!device) 97 if (!device)
131 goto err_out; 98 return;
132 99
133 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 100 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
134 "Hot-removing device %s...\n", dev_name(&device->dev))); 101 "Hot-removing device %s...\n", dev_name(&device->dev)));
@@ -136,19 +103,16 @@ void acpi_bus_hot_remove_device(void *context)
136 if (acpi_bus_trim(device, 1)) { 103 if (acpi_bus_trim(device, 1)) {
137 printk(KERN_ERR PREFIX 104 printk(KERN_ERR PREFIX
138 "Removing device failed\n"); 105 "Removing device failed\n");
139 goto err_out; 106 return;
140 } 107 }
141 108
142 /* device has been freed */
143 device = NULL;
144
145 /* power off device */ 109 /* power off device */
146 status = acpi_evaluate_object(handle, "_PS3", NULL, NULL); 110 status = acpi_evaluate_object(handle, "_PS3", NULL, NULL);
147 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) 111 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
148 printk(KERN_WARNING PREFIX 112 printk(KERN_WARNING PREFIX
149 "Power-off device failed\n"); 113 "Power-off device failed\n");
150 114
151 if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", &temp))) { 115 if (device->flags.lockable) {
152 arg_list.count = 1; 116 arg_list.count = 1;
153 arg_list.pointer = &arg; 117 arg_list.pointer = &arg;
154 arg.type = ACPI_TYPE_INTEGER; 118 arg.type = ACPI_TYPE_INTEGER;
@@ -165,24 +129,12 @@ void acpi_bus_hot_remove_device(void *context)
165 * TBD: _EJD support. 129 * TBD: _EJD support.
166 */ 130 */
167 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); 131 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
168 if (ACPI_FAILURE(status)) { 132 if (ACPI_FAILURE(status))
169 if (status != AE_NOT_FOUND) 133 printk(KERN_WARNING PREFIX
170 printk(KERN_WARNING PREFIX 134 "Eject device failed\n");
171 "Eject device failed\n");
172 goto err_out;
173 }
174
175 kfree(context);
176 return;
177 135
178err_out:
179 /* Inform firmware the hot-remove operation has completed w/ error */
180 (void) acpi_evaluate_hotplug_ost(handle,
181 ej_event->event, ost_code, NULL);
182 kfree(context);
183 return; 136 return;
184} 137}
185EXPORT_SYMBOL(acpi_bus_hot_remove_device);
186 138
187static ssize_t 139static ssize_t
188acpi_eject_store(struct device *d, struct device_attribute *attr, 140acpi_eject_store(struct device *d, struct device_attribute *attr,
@@ -192,7 +144,6 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
192 acpi_status status; 144 acpi_status status;
193 acpi_object_type type = 0; 145 acpi_object_type type = 0;
194 struct acpi_device *acpi_device = to_acpi_device(d); 146 struct acpi_device *acpi_device = to_acpi_device(d);
195 struct acpi_eject_event *ej_event;
196 147
197 if ((!count) || (buf[0] != '1')) { 148 if ((!count) || (buf[0] != '1')) {
198 return -EINVAL; 149 return -EINVAL;
@@ -209,25 +160,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
209 goto err; 160 goto err;
210 } 161 }
211 162
212 ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); 163 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, acpi_device->handle);
213 if (!ej_event) {
214 ret = -ENOMEM;
215 goto err;
216 }
217
218 ej_event->handle = acpi_device->handle;
219 if (acpi_device->flags.eject_pending) {
220 /* event originated from ACPI eject notification */
221 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
222 acpi_device->flags.eject_pending = 0;
223 } else {
224 /* event originated from user */
225 ej_event->event = ACPI_OST_EC_OSPM_EJECT;
226 (void) acpi_evaluate_hotplug_ost(ej_event->handle,
227 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
228 }
229
230 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, (void *)ej_event);
231err: 164err:
232 return ret; 165 return ret;
233} 166}
@@ -242,25 +175,6 @@ acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *bu
242} 175}
243static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL); 176static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
244 177
245static ssize_t acpi_device_uid_show(struct device *dev,
246 struct device_attribute *attr, char *buf)
247{
248 struct acpi_device *acpi_dev = to_acpi_device(dev);
249
250 return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
251}
252static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
253
254static ssize_t acpi_device_adr_show(struct device *dev,
255 struct device_attribute *attr, char *buf)
256{
257 struct acpi_device *acpi_dev = to_acpi_device(dev);
258
259 return sprintf(buf, "0x%08x\n",
260 (unsigned int)(acpi_dev->pnp.bus_address));
261}
262static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL);
263
264static ssize_t 178static ssize_t
265acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) { 179acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) {
266 struct acpi_device *acpi_dev = to_acpi_device(dev); 180 struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -278,47 +192,10 @@ end:
278} 192}
279static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL); 193static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
280 194
281/* sysfs file that shows description text from the ACPI _STR method */
282static ssize_t description_show(struct device *dev,
283 struct device_attribute *attr,
284 char *buf) {
285 struct acpi_device *acpi_dev = to_acpi_device(dev);
286 int result;
287
288 if (acpi_dev->pnp.str_obj == NULL)
289 return 0;
290
291 /*
292 * The _STR object contains a Unicode identifier for a device.
293 * We need to convert to utf-8 so it can be displayed.
294 */
295 result = utf16s_to_utf8s(
296 (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
297 acpi_dev->pnp.str_obj->buffer.length,
298 UTF16_LITTLE_ENDIAN, buf,
299 PAGE_SIZE);
300
301 buf[result++] = '\n';
302
303 return result;
304}
305static DEVICE_ATTR(description, 0444, description_show, NULL);
306
307static ssize_t
308acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
309 char *buf) {
310 struct acpi_device *acpi_dev = to_acpi_device(dev);
311
312 return sprintf(buf, "%lu\n", acpi_dev->pnp.sun);
313}
314static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
315
316static int acpi_device_setup_files(struct acpi_device *dev) 195static int acpi_device_setup_files(struct acpi_device *dev)
317{ 196{
318 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
319 acpi_status status; 197 acpi_status status;
320 acpi_handle temp; 198 acpi_handle temp;
321 unsigned long long sun;
322 int result = 0; 199 int result = 0;
323 200
324 /* 201 /*
@@ -340,36 +217,6 @@ static int acpi_device_setup_files(struct acpi_device *dev)
340 goto end; 217 goto end;
341 } 218 }
342 219
343 /*
344 * If device has _STR, 'description' file is created
345 */
346 status = acpi_get_handle(dev->handle, "_STR", &temp);
347 if (ACPI_SUCCESS(status)) {
348 status = acpi_evaluate_object(dev->handle, "_STR",
349 NULL, &buffer);
350 if (ACPI_FAILURE(status))
351 buffer.pointer = NULL;
352 dev->pnp.str_obj = buffer.pointer;
353 result = device_create_file(&dev->dev, &dev_attr_description);
354 if (result)
355 goto end;
356 }
357
358 if (dev->flags.bus_address)
359 result = device_create_file(&dev->dev, &dev_attr_adr);
360 if (dev->pnp.unique_id)
361 result = device_create_file(&dev->dev, &dev_attr_uid);
362
363 status = acpi_evaluate_integer(dev->handle, "_SUN", NULL, &sun);
364 if (ACPI_SUCCESS(status)) {
365 dev->pnp.sun = (unsigned long)sun;
366 result = device_create_file(&dev->dev, &dev_attr_sun);
367 if (result)
368 goto end;
369 } else {
370 dev->pnp.sun = (unsigned long)-1;
371 }
372
373 /* 220 /*
374 * If device has _EJ0, 'eject' file is created that is used to trigger 221 * If device has _EJ0, 'eject' file is created that is used to trigger
375 * hot-removal function from userland. 222 * hot-removal function from userland.
@@ -387,28 +234,13 @@ static void acpi_device_remove_files(struct acpi_device *dev)
387 acpi_handle temp; 234 acpi_handle temp;
388 235
389 /* 236 /*
390 * If device has _STR, remove 'description' file 237 * If device has _EJ0, 'eject' file is created that is used to trigger
391 */ 238 * hot-removal function from userland.
392 status = acpi_get_handle(dev->handle, "_STR", &temp);
393 if (ACPI_SUCCESS(status)) {
394 kfree(dev->pnp.str_obj);
395 device_remove_file(&dev->dev, &dev_attr_description);
396 }
397 /*
398 * If device has _EJ0, remove 'eject' file.
399 */ 239 */
400 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 240 status = acpi_get_handle(dev->handle, "_EJ0", &temp);
401 if (ACPI_SUCCESS(status)) 241 if (ACPI_SUCCESS(status))
402 device_remove_file(&dev->dev, &dev_attr_eject); 242 device_remove_file(&dev->dev, &dev_attr_eject);
403 243
404 status = acpi_get_handle(dev->handle, "_SUN", &temp);
405 if (ACPI_SUCCESS(status))
406 device_remove_file(&dev->dev, &dev_attr_sun);
407
408 if (dev->pnp.unique_id)
409 device_remove_file(&dev->dev, &dev_attr_uid);
410 if (dev->flags.bus_address)
411 device_remove_file(&dev->dev, &dev_attr_adr);
412 device_remove_file(&dev->dev, &dev_attr_modalias); 244 device_remove_file(&dev->dev, &dev_attr_modalias);
413 device_remove_file(&dev->dev, &dev_attr_hid); 245 device_remove_file(&dev->dev, &dev_attr_hid);
414 if (dev->handle) 246 if (dev->handle)
@@ -418,8 +250,8 @@ static void acpi_device_remove_files(struct acpi_device *dev)
418 ACPI Bus operations 250 ACPI Bus operations
419 -------------------------------------------------------------------------- */ 251 -------------------------------------------------------------------------- */
420 252
421static const struct acpi_device_id *__acpi_match_device( 253int acpi_match_device_ids(struct acpi_device *device,
422 struct acpi_device *device, const struct acpi_device_id *ids) 254 const struct acpi_device_id *ids)
423{ 255{
424 const struct acpi_device_id *id; 256 const struct acpi_device_id *id;
425 struct acpi_hardware_id *hwid; 257 struct acpi_hardware_id *hwid;
@@ -429,44 +261,14 @@ static const struct acpi_device_id *__acpi_match_device(
429 * driver for it. 261 * driver for it.
430 */ 262 */
431 if (!device->status.present) 263 if (!device->status.present)
432 return NULL; 264 return -ENODEV;
433 265
434 for (id = ids; id->id[0]; id++) 266 for (id = ids; id->id[0]; id++)
435 list_for_each_entry(hwid, &device->pnp.ids, list) 267 list_for_each_entry(hwid, &device->pnp.ids, list)
436 if (!strcmp((char *) id->id, hwid->id)) 268 if (!strcmp((char *) id->id, hwid->id))
437 return id; 269 return 0;
438 270
439 return NULL; 271 return -ENOENT;
440}
441
442/**
443 * acpi_match_device - Match a struct device against a given list of ACPI IDs
444 * @ids: Array of struct acpi_device_id object to match against.
445 * @dev: The device structure to match.
446 *
447 * Check if @dev has a valid ACPI handle and if there is a struct acpi_device
448 * object for that handle and use that object to match against a given list of
449 * device IDs.
450 *
451 * Return a pointer to the first matching ID on success or %NULL on failure.
452 */
453const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
454 const struct device *dev)
455{
456 struct acpi_device *adev;
457
458 if (!ids || !ACPI_HANDLE(dev)
459 || ACPI_FAILURE(acpi_bus_get_device(ACPI_HANDLE(dev), &adev)))
460 return NULL;
461
462 return __acpi_match_device(adev, ids);
463}
464EXPORT_SYMBOL_GPL(acpi_match_device);
465
466int acpi_match_device_ids(struct acpi_device *device,
467 const struct acpi_device_id *ids)
468{
469 return __acpi_match_device(device, ids) ? 0 : -ENOENT;
470} 272}
471EXPORT_SYMBOL(acpi_match_device_ids); 273EXPORT_SYMBOL(acpi_match_device_ids);
472 274
@@ -485,10 +287,29 @@ static void acpi_device_release(struct device *dev)
485 struct acpi_device *acpi_dev = to_acpi_device(dev); 287 struct acpi_device *acpi_dev = to_acpi_device(dev);
486 288
487 acpi_free_ids(acpi_dev); 289 acpi_free_ids(acpi_dev);
488 kfree(acpi_dev->pnp.unique_id);
489 kfree(acpi_dev); 290 kfree(acpi_dev);
490} 291}
491 292
293static int acpi_device_suspend(struct device *dev, pm_message_t state)
294{
295 struct acpi_device *acpi_dev = to_acpi_device(dev);
296 struct acpi_driver *acpi_drv = acpi_dev->driver;
297
298 if (acpi_drv && acpi_drv->ops.suspend)
299 return acpi_drv->ops.suspend(acpi_dev, state);
300 return 0;
301}
302
303static int acpi_device_resume(struct device *dev)
304{
305 struct acpi_device *acpi_dev = to_acpi_device(dev);
306 struct acpi_driver *acpi_drv = acpi_dev->driver;
307
308 if (acpi_drv && acpi_drv->ops.resume)
309 return acpi_drv->ops.resume(acpi_dev);
310 return 0;
311}
312
492static int acpi_bus_match(struct device *dev, struct device_driver *drv) 313static int acpi_bus_match(struct device *dev, struct device_driver *drv)
493{ 314{
494 struct acpi_device *acpi_dev = to_acpi_device(dev); 315 struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -620,6 +441,8 @@ static int acpi_device_remove(struct device * dev)
620 441
621struct bus_type acpi_bus_type = { 442struct bus_type acpi_bus_type = {
622 .name = "acpi", 443 .name = "acpi",
444 .suspend = acpi_device_suspend,
445 .resume = acpi_device_resume,
623 .match = acpi_bus_match, 446 .match = acpi_bus_match,
624 .probe = acpi_device_probe, 447 .probe = acpi_device_probe,
625 .remove = acpi_device_remove, 448 .remove = acpi_device_remove,
@@ -640,8 +463,6 @@ static int acpi_device_register(struct acpi_device *device)
640 INIT_LIST_HEAD(&device->children); 463 INIT_LIST_HEAD(&device->children);
641 INIT_LIST_HEAD(&device->node); 464 INIT_LIST_HEAD(&device->node);
642 INIT_LIST_HEAD(&device->wakeup_list); 465 INIT_LIST_HEAD(&device->wakeup_list);
643 INIT_LIST_HEAD(&device->physical_node_list);
644 mutex_init(&device->physical_node_lock);
645 466
646 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); 467 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
647 if (!new_bus_id) { 468 if (!new_bus_id) {
@@ -968,8 +789,8 @@ acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
968static void acpi_bus_set_run_wake_flags(struct acpi_device *device) 789static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
969{ 790{
970 struct acpi_device_id button_device_ids[] = { 791 struct acpi_device_id button_device_ids[] = {
971 {"PNP0C0C", 0},
972 {"PNP0C0D", 0}, 792 {"PNP0C0D", 0},
793 {"PNP0C0C", 0},
973 {"PNP0C0E", 0}, 794 {"PNP0C0E", 0},
974 {"", 0}, 795 {"", 0},
975 }; 796 };
@@ -981,11 +802,6 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
981 /* Power button, Lid switch always enable wakeup */ 802 /* Power button, Lid switch always enable wakeup */
982 if (!acpi_match_device_ids(device, button_device_ids)) { 803 if (!acpi_match_device_ids(device, button_device_ids)) {
983 device->wakeup.flags.run_wake = 1; 804 device->wakeup.flags.run_wake = 1;
984 if (!acpi_match_device_ids(device, &button_device_ids[1])) {
985 /* Do not use Lid/sleep button for S5 wakeup */
986 if (device->wakeup.sleep_state == ACPI_STATE_S5)
987 device->wakeup.sleep_state = ACPI_STATE_S4;
988 }
989 device_set_wakeup_capable(&device->dev, true); 805 device_set_wakeup_capable(&device->dev, true);
990 return; 806 return;
991 } 807 }
@@ -1053,7 +869,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
1053 /* 869 /*
1054 * Enumerate supported power management states 870 * Enumerate supported power management states
1055 */ 871 */
1056 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) { 872 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) {
1057 struct acpi_device_power_state *ps = &device->power.states[i]; 873 struct acpi_device_power_state *ps = &device->power.states[i];
1058 char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' }; 874 char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' };
1059 875
@@ -1064,6 +880,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
1064 int j; 880 int j;
1065 881
1066 device->power.flags.power_resources = 1; 882 device->power.flags.power_resources = 1;
883 ps->flags.valid = 1;
1067 for (j = 0; j < ps->resources.count; j++) 884 for (j = 0; j < ps->resources.count; j++)
1068 acpi_bus_add_power_resource(ps->resources.handles[j]); 885 acpi_bus_add_power_resource(ps->resources.handles[j]);
1069 } 886 }
@@ -1071,19 +888,15 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
1071 /* Evaluate "_PSx" to see if we can do explicit sets */ 888 /* Evaluate "_PSx" to see if we can do explicit sets */
1072 object_name[2] = 'S'; 889 object_name[2] = 'S';
1073 status = acpi_get_handle(device->handle, object_name, &handle); 890 status = acpi_get_handle(device->handle, object_name, &handle);
1074 if (ACPI_SUCCESS(status)) 891 if (ACPI_SUCCESS(status)) {
1075 ps->flags.explicit_set = 1; 892 ps->flags.explicit_set = 1;
1076
1077 /*
1078 * State is valid if there are means to put the device into it.
1079 * D3hot is only valid if _PR3 present.
1080 */
1081 if (ps->resources.count ||
1082 (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) {
1083 ps->flags.valid = 1; 893 ps->flags.valid = 1;
1084 ps->flags.os_accessible = 1;
1085 } 894 }
1086 895
896 /* State is valid if we have some power control */
897 if (ps->resources.count || ps->flags.explicit_set)
898 ps->flags.valid = 1;
899
1087 ps->power = -1; /* Unknown - driver assigned */ 900 ps->power = -1; /* Unknown - driver assigned */
1088 ps->latency = -1; /* Unknown - driver assigned */ 901 ps->latency = -1; /* Unknown - driver assigned */
1089 } 902 }
@@ -1094,15 +907,6 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
1094 device->power.states[ACPI_STATE_D3].flags.valid = 1; 907 device->power.states[ACPI_STATE_D3].flags.valid = 1;
1095 device->power.states[ACPI_STATE_D3].power = 0; 908 device->power.states[ACPI_STATE_D3].power = 0;
1096 909
1097 /* Set D3cold's explicit_set flag if _PS3 exists. */
1098 if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set)
1099 device->power.states[ACPI_STATE_D3_COLD].flags.explicit_set = 1;
1100
1101 /* Presence of _PS3 or _PRx means we can put the device into D3 cold */
1102 if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set ||
1103 device->power.flags.power_resources)
1104 device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1;
1105
1106 acpi_bus_init_power(device); 910 acpi_bus_init_power(device);
1107 911
1108 return 0; 912 return 0;
@@ -1134,6 +938,11 @@ static int acpi_bus_get_flags(struct acpi_device *device)
1134 device->flags.ejectable = 1; 938 device->flags.ejectable = 1;
1135 } 939 }
1136 940
941 /* Presence of _LCK indicates 'lockable' */
942 status = acpi_get_handle(device->handle, "_LCK", &temp);
943 if (ACPI_SUCCESS(status))
944 device->flags.lockable = 1;
945
1137 /* Power resources cannot be power manageable. */ 946 /* Power resources cannot be power manageable. */
1138 if (device->device_type == ACPI_BUS_TYPE_POWER) 947 if (device->device_type == ACPI_BUS_TYPE_POWER)
1139 return 0; 948 return 0;
@@ -1253,12 +1062,13 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id)
1253 if (!id) 1062 if (!id)
1254 return; 1063 return;
1255 1064
1256 id->id = kstrdup(dev_id, GFP_KERNEL); 1065 id->id = kmalloc(strlen(dev_id) + 1, GFP_KERNEL);
1257 if (!id->id) { 1066 if (!id->id) {
1258 kfree(id); 1067 kfree(id);
1259 return; 1068 return;
1260 } 1069 }
1261 1070
1071 strcpy(id->id, dev_id);
1262 list_add_tail(&id->list, &device->pnp.ids); 1072 list_add_tail(&id->list, &device->pnp.ids);
1263} 1073}
1264 1074
@@ -1301,7 +1111,7 @@ static void acpi_device_set_id(struct acpi_device *device)
1301{ 1111{
1302 acpi_status status; 1112 acpi_status status;
1303 struct acpi_device_info *info; 1113 struct acpi_device_info *info;
1304 struct acpi_pnp_device_id_list *cid_list; 1114 struct acpica_device_id_list *cid_list;
1305 int i; 1115 int i;
1306 1116
1307 switch (device->device_type) { 1117 switch (device->device_type) {
@@ -1328,9 +1138,6 @@ static void acpi_device_set_id(struct acpi_device *device)
1328 device->pnp.bus_address = info->address; 1138 device->pnp.bus_address = info->address;
1329 device->flags.bus_address = 1; 1139 device->flags.bus_address = 1;
1330 } 1140 }
1331 if (info->valid & ACPI_VALID_UID)
1332 device->pnp.unique_id = kstrdup(info->unique_id.string,
1333 GFP_KERNEL);
1334 1141
1335 kfree(info); 1142 kfree(info);
1336 1143
@@ -1346,7 +1153,7 @@ static void acpi_device_set_id(struct acpi_device *device)
1346 acpi_add_id(device, ACPI_DOCK_HID); 1153 acpi_add_id(device, ACPI_DOCK_HID);
1347 else if (!acpi_ibm_smbus_match(device)) 1154 else if (!acpi_ibm_smbus_match(device))
1348 acpi_add_id(device, ACPI_SMBUS_IBM_HID); 1155 acpi_add_id(device, ACPI_SMBUS_IBM_HID);
1349 else if (list_empty(&device->pnp.ids) && 1156 else if (!acpi_device_hid(device) &&
1350 ACPI_IS_ROOT_DEVICE(device->parent)) { 1157 ACPI_IS_ROOT_DEVICE(device->parent)) {
1351 acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ 1158 acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
1352 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); 1159 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
@@ -1602,13 +1409,8 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
1602 */ 1409 */
1603 device = NULL; 1410 device = NULL;
1604 acpi_bus_get_device(handle, &device); 1411 acpi_bus_get_device(handle, &device);
1605 if (ops->acpi_op_add && !device) { 1412 if (ops->acpi_op_add && !device)
1606 acpi_add_single_object(&device, handle, type, sta, ops); 1413 acpi_add_single_object(&device, handle, type, sta, ops);
1607 /* Is the device a known good platform device? */
1608 if (device
1609 && !acpi_match_device_ids(device, acpi_platform_device_ids))
1610 acpi_create_platform_device(device);
1611 }
1612 1414
1613 if (!device) 1415 if (!device)
1614 return AE_CTRL_DEPTH; 1416 return AE_CTRL_DEPTH;
@@ -1761,7 +1563,6 @@ static int acpi_bus_scan_fixed(void)
1761 ACPI_BUS_TYPE_POWER_BUTTON, 1563 ACPI_BUS_TYPE_POWER_BUTTON,
1762 ACPI_STA_DEFAULT, 1564 ACPI_STA_DEFAULT,
1763 &ops); 1565 &ops);
1764 device_init_wakeup(&device->dev, true);
1765 } 1566 }
1766 1567
1767 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1568 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 2fcc67d34b1..3ed80b2ca90 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -17,7 +17,6 @@
17#include <linux/suspend.h> 17#include <linux/suspend.h>
18#include <linux/reboot.h> 18#include <linux/reboot.h>
19#include <linux/acpi.h> 19#include <linux/acpi.h>
20#include <linux/module.h>
21 20
22#include <asm/io.h> 21#include <asm/io.h>
23 22
@@ -64,9 +63,11 @@ static int acpi_sleep_prepare(u32 acpi_state)
64#ifdef CONFIG_ACPI_SLEEP 63#ifdef CONFIG_ACPI_SLEEP
65 /* do we have a wakeup address for S2 and S3? */ 64 /* do we have a wakeup address for S2 and S3? */
66 if (acpi_state == ACPI_STATE_S3) { 65 if (acpi_state == ACPI_STATE_S3) {
67 if (!acpi_wakeup_address) 66 if (!acpi_wakeup_address) {
68 return -EFAULT; 67 return -EFAULT;
69 acpi_set_firmware_waking_vector(acpi_wakeup_address); 68 }
69 acpi_set_firmware_waking_vector(
70 (acpi_physical_address)acpi_wakeup_address);
70 71
71 } 72 }
72 ACPI_FLUSH_CPU_CACHE(); 73 ACPI_FLUSH_CPU_CACHE();
@@ -81,13 +82,6 @@ static int acpi_sleep_prepare(u32 acpi_state)
81#ifdef CONFIG_ACPI_SLEEP 82#ifdef CONFIG_ACPI_SLEEP
82static u32 acpi_target_sleep_state = ACPI_STATE_S0; 83static u32 acpi_target_sleep_state = ACPI_STATE_S0;
83 84
84u32 acpi_target_system_state(void)
85{
86 return acpi_target_sleep_state;
87}
88
89static bool pwr_btn_event_pending;
90
91/* 85/*
92 * The ACPI specification wants us to save NVS memory regions during hibernation 86 * The ACPI specification wants us to save NVS memory regions during hibernation
93 * and to restore them during the subsequent resume. Windows does that also for 87 * and to restore them during the subsequent resume. Windows does that also for
@@ -103,21 +97,6 @@ void __init acpi_nvs_nosave(void)
103} 97}
104 98
105/* 99/*
106 * The ACPI specification wants us to save NVS memory regions during hibernation
107 * but says nothing about saving NVS during S3. Not all versions of Windows
108 * save NVS on S3 suspend either, and it is clear that not all systems need
109 * NVS to be saved at S3 time. To improve suspend/resume time, allow the
110 * user to disable saving NVS on S3 if their system does not require it, but
111 * continue to save/restore NVS for S4 as specified.
112 */
113static bool nvs_nosave_s3;
114
115void __init acpi_nvs_nosave_s3(void)
116{
117 nvs_nosave_s3 = true;
118}
119
120/*
121 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the 100 * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
122 * user to request that behavior by using the 'acpi_old_suspend_ordering' 101 * user to request that behavior by using the 'acpi_old_suspend_ordering'
123 * kernel command line option that causes the following variable to be set. 102 * kernel command line option that causes the following variable to be set.
@@ -129,187 +108,13 @@ void __init acpi_old_suspend_ordering(void)
129 old_suspend_ordering = true; 108 old_suspend_ordering = true;
130} 109}
131 110
132static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
133{
134 acpi_old_suspend_ordering();
135 return 0;
136}
137
138static int __init init_nvs_nosave(const struct dmi_system_id *d)
139{
140 acpi_nvs_nosave();
141 return 0;
142}
143
144static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
145 {
146 .callback = init_old_suspend_ordering,
147 .ident = "Abit KN9 (nForce4 variant)",
148 .matches = {
149 DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"),
150 DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"),
151 },
152 },
153 {
154 .callback = init_old_suspend_ordering,
155 .ident = "HP xw4600 Workstation",
156 .matches = {
157 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
158 DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"),
159 },
160 },
161 {
162 .callback = init_old_suspend_ordering,
163 .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)",
164 .matches = {
165 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."),
166 DMI_MATCH(DMI_BOARD_NAME, "M2N8L"),
167 },
168 },
169 {
170 .callback = init_old_suspend_ordering,
171 .ident = "Panasonic CF51-2L",
172 .matches = {
173 DMI_MATCH(DMI_BOARD_VENDOR,
174 "Matsushita Electric Industrial Co.,Ltd."),
175 DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"),
176 },
177 },
178 {
179 .callback = init_nvs_nosave,
180 .ident = "Sony Vaio VGN-FW21E",
181 .matches = {
182 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
183 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW21E"),
184 },
185 },
186 {
187 .callback = init_nvs_nosave,
188 .ident = "Sony Vaio VPCEB17FX",
189 .matches = {
190 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
191 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB17FX"),
192 },
193 },
194 {
195 .callback = init_nvs_nosave,
196 .ident = "Sony Vaio VGN-SR11M",
197 .matches = {
198 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
199 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR11M"),
200 },
201 },
202 {
203 .callback = init_nvs_nosave,
204 .ident = "Everex StepNote Series",
205 .matches = {
206 DMI_MATCH(DMI_SYS_VENDOR, "Everex Systems, Inc."),
207 DMI_MATCH(DMI_PRODUCT_NAME, "Everex StepNote Series"),
208 },
209 },
210 {
211 .callback = init_nvs_nosave,
212 .ident = "Sony Vaio VPCEB1Z1E",
213 .matches = {
214 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
215 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"),
216 },
217 },
218 {
219 .callback = init_nvs_nosave,
220 .ident = "Sony Vaio VGN-NW130D",
221 .matches = {
222 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
223 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"),
224 },
225 },
226 {
227 .callback = init_nvs_nosave,
228 .ident = "Sony Vaio VPCCW29FX",
229 .matches = {
230 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
231 DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"),
232 },
233 },
234 {
235 .callback = init_nvs_nosave,
236 .ident = "Averatec AV1020-ED2",
237 .matches = {
238 DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"),
239 DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"),
240 },
241 },
242 {
243 .callback = init_old_suspend_ordering,
244 .ident = "Asus A8N-SLI DELUXE",
245 .matches = {
246 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
247 DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"),
248 },
249 },
250 {
251 .callback = init_old_suspend_ordering,
252 .ident = "Asus A8N-SLI Premium",
253 .matches = {
254 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
255 DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"),
256 },
257 },
258 {
259 .callback = init_nvs_nosave,
260 .ident = "Sony Vaio VGN-SR26GN_P",
261 .matches = {
262 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
263 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR26GN_P"),
264 },
265 },
266 {
267 .callback = init_nvs_nosave,
268 .ident = "Sony Vaio VPCEB1S1E",
269 .matches = {
270 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
271 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1S1E"),
272 },
273 },
274 {
275 .callback = init_nvs_nosave,
276 .ident = "Sony Vaio VGN-FW520F",
277 .matches = {
278 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
279 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW520F"),
280 },
281 },
282 {
283 .callback = init_nvs_nosave,
284 .ident = "Asus K54C",
285 .matches = {
286 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
287 DMI_MATCH(DMI_PRODUCT_NAME, "K54C"),
288 },
289 },
290 {
291 .callback = init_nvs_nosave,
292 .ident = "Asus K54HR",
293 .matches = {
294 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
295 DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"),
296 },
297 },
298 {},
299};
300
301static void acpi_sleep_dmi_check(void)
302{
303 dmi_check_system(acpisleep_dmi_table);
304}
305
306/** 111/**
307 * acpi_pm_freeze - Disable the GPEs and suspend EC transactions. 112 * acpi_pm_freeze - Disable the GPEs and suspend EC transactions.
308 */ 113 */
309static int acpi_pm_freeze(void) 114static int acpi_pm_freeze(void)
310{ 115{
311 acpi_disable_all_gpes(); 116 acpi_disable_all_gpes();
312 acpi_os_wait_events_complete(); 117 acpi_os_wait_events_complete(NULL);
313 acpi_ec_block_transactions(); 118 acpi_ec_block_transactions();
314 return 0; 119 return 0;
315} 120}
@@ -351,14 +156,6 @@ static int acpi_pm_prepare(void)
351 return error; 156 return error;
352} 157}
353 158
354static int find_powerf_dev(struct device *dev, void *data)
355{
356 struct acpi_device *device = to_acpi_device(dev);
357 const char *hid = acpi_device_hid(device);
358
359 return !strcmp(hid, ACPI_BUTTON_HID_POWERF);
360}
361
362/** 159/**
363 * acpi_pm_finish - Instruct the platform to leave a sleep state. 160 * acpi_pm_finish - Instruct the platform to leave a sleep state.
364 * 161 *
@@ -367,7 +164,6 @@ static int find_powerf_dev(struct device *dev, void *data)
367 */ 164 */
368static void acpi_pm_finish(void) 165static void acpi_pm_finish(void)
369{ 166{
370 struct device *pwr_btn_dev;
371 u32 acpi_state = acpi_target_sleep_state; 167 u32 acpi_state = acpi_target_sleep_state;
372 168
373 acpi_ec_unblock_transactions(); 169 acpi_ec_unblock_transactions();
@@ -385,23 +181,6 @@ static void acpi_pm_finish(void)
385 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 181 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
386 182
387 acpi_target_sleep_state = ACPI_STATE_S0; 183 acpi_target_sleep_state = ACPI_STATE_S0;
388
389 /* If we were woken with the fixed power button, provide a small
390 * hint to userspace in the form of a wakeup event on the fixed power
391 * button device (if it can be found).
392 *
393 * We delay the event generation til now, as the PM layer requires
394 * timekeeping to be running before we generate events. */
395 if (!pwr_btn_event_pending)
396 return;
397
398 pwr_btn_event_pending = false;
399 pwr_btn_dev = bus_find_device(&acpi_bus_type, NULL, NULL,
400 find_powerf_dev);
401 if (pwr_btn_dev) {
402 pm_wakeup_event(pwr_btn_dev, 0);
403 put_device(pwr_btn_dev);
404 }
405} 184}
406 185
407/** 186/**
@@ -418,7 +197,6 @@ static void acpi_pm_end(void)
418} 197}
419#else /* !CONFIG_ACPI_SLEEP */ 198#else /* !CONFIG_ACPI_SLEEP */
420#define acpi_target_sleep_state ACPI_STATE_S0 199#define acpi_target_sleep_state ACPI_STATE_S0
421static inline void acpi_sleep_dmi_check(void) {}
422#endif /* CONFIG_ACPI_SLEEP */ 200#endif /* CONFIG_ACPI_SLEEP */
423 201
424#ifdef CONFIG_SUSPEND 202#ifdef CONFIG_SUSPEND
@@ -438,7 +216,7 @@ static int acpi_suspend_begin(suspend_state_t pm_state)
438 u32 acpi_state = acpi_suspend_states[pm_state]; 216 u32 acpi_state = acpi_suspend_states[pm_state];
439 int error = 0; 217 int error = 0;
440 218
441 error = (nvs_nosave || nvs_nosave_s3) ? 0 : suspend_nvs_alloc(); 219 error = nvs_nosave ? 0 : suspend_nvs_alloc();
442 if (error) 220 if (error)
443 return error; 221 return error;
444 222
@@ -486,29 +264,15 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
486 /* This violates the spec but is required for bug compatibility. */ 264 /* This violates the spec but is required for bug compatibility. */
487 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); 265 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
488 266
489 /* Reprogram control registers */ 267 /* Reprogram control registers and execute _BFS */
490 acpi_leave_sleep_state_prep(acpi_state); 268 acpi_leave_sleep_state_prep(acpi_state);
491 269
492 /* ACPI 3.0 specs (P62) says that it's the responsibility 270 /* ACPI 3.0 specs (P62) says that it's the responsibility
493 * of the OSPM to clear the status bit [ implying that the 271 * of the OSPM to clear the status bit [ implying that the
494 * POWER_BUTTON event should not reach userspace ] 272 * POWER_BUTTON event should not reach userspace ]
495 *
496 * However, we do generate a small hint for userspace in the form of
497 * a wakeup event. We flag this condition for now and generate the
498 * event later, as we're currently too early in resume to be able to
499 * generate wakeup events.
500 */ 273 */
501 if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) { 274 if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3))
502 acpi_event_status pwr_btn_status; 275 acpi_clear_event(ACPI_EVENT_POWER_BUTTON);
503
504 acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status);
505
506 if (pwr_btn_status & ACPI_EVENT_FLAG_SET) {
507 acpi_clear_event(ACPI_EVENT_POWER_BUTTON);
508 /* Flag for later */
509 pwr_btn_event_pending = true;
510 }
511 }
512 276
513 /* 277 /*
514 * Disable and clear GPE status before interrupt is enabled. Some GPEs 278 * Disable and clear GPE status before interrupt is enabled. Some GPEs
@@ -577,6 +341,111 @@ static const struct platform_suspend_ops acpi_suspend_ops_old = {
577 .end = acpi_pm_end, 341 .end = acpi_pm_end,
578 .recover = acpi_pm_finish, 342 .recover = acpi_pm_finish,
579}; 343};
344
345static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
346{
347 old_suspend_ordering = true;
348 return 0;
349}
350
351static int __init init_nvs_nosave(const struct dmi_system_id *d)
352{
353 acpi_nvs_nosave();
354 return 0;
355}
356
357static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
358 {
359 .callback = init_old_suspend_ordering,
360 .ident = "Abit KN9 (nForce4 variant)",
361 .matches = {
362 DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"),
363 DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"),
364 },
365 },
366 {
367 .callback = init_old_suspend_ordering,
368 .ident = "HP xw4600 Workstation",
369 .matches = {
370 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
371 DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"),
372 },
373 },
374 {
375 .callback = init_old_suspend_ordering,
376 .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)",
377 .matches = {
378 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."),
379 DMI_MATCH(DMI_BOARD_NAME, "M2N8L"),
380 },
381 },
382 {
383 .callback = init_old_suspend_ordering,
384 .ident = "Panasonic CF51-2L",
385 .matches = {
386 DMI_MATCH(DMI_BOARD_VENDOR,
387 "Matsushita Electric Industrial Co.,Ltd."),
388 DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"),
389 },
390 },
391 {
392 .callback = init_nvs_nosave,
393 .ident = "Sony Vaio VGN-SR11M",
394 .matches = {
395 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
396 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR11M"),
397 },
398 },
399 {
400 .callback = init_nvs_nosave,
401 .ident = "Everex StepNote Series",
402 .matches = {
403 DMI_MATCH(DMI_SYS_VENDOR, "Everex Systems, Inc."),
404 DMI_MATCH(DMI_PRODUCT_NAME, "Everex StepNote Series"),
405 },
406 },
407 {
408 .callback = init_nvs_nosave,
409 .ident = "Sony Vaio VPCEB1Z1E",
410 .matches = {
411 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
412 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"),
413 },
414 },
415 {
416 .callback = init_nvs_nosave,
417 .ident = "Sony Vaio VGN-NW130D",
418 .matches = {
419 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
420 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"),
421 },
422 },
423 {
424 .callback = init_nvs_nosave,
425 .ident = "Averatec AV1020-ED2",
426 .matches = {
427 DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"),
428 DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"),
429 },
430 },
431 {
432 .callback = init_old_suspend_ordering,
433 .ident = "Asus A8N-SLI DELUXE",
434 .matches = {
435 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
436 DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"),
437 },
438 },
439 {
440 .callback = init_old_suspend_ordering,
441 .ident = "Asus A8N-SLI Premium",
442 .matches = {
443 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
444 DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"),
445 },
446 },
447 {},
448};
580#endif /* CONFIG_SUSPEND */ 449#endif /* CONFIG_SUSPEND */
581 450
582#ifdef CONFIG_HIBERNATION 451#ifdef CONFIG_HIBERNATION
@@ -610,7 +479,7 @@ static int acpi_hibernation_enter(void)
610 479
611 /* This shouldn't return. If it returns, we have a problem */ 480 /* This shouldn't return. If it returns, we have a problem */
612 status = acpi_enter_sleep_state(ACPI_STATE_S4); 481 status = acpi_enter_sleep_state(ACPI_STATE_S4);
613 /* Reprogram control registers */ 482 /* Reprogram control registers and execute _BFS */
614 acpi_leave_sleep_state_prep(ACPI_STATE_S4); 483 acpi_leave_sleep_state_prep(ACPI_STATE_S4);
615 484
616 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 485 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
@@ -623,7 +492,7 @@ static void acpi_hibernation_leave(void)
623 * enable it here. 492 * enable it here.
624 */ 493 */
625 acpi_enable(); 494 acpi_enable();
626 /* Reprogram control registers */ 495 /* Reprogram control registers and execute _BFS */
627 acpi_leave_sleep_state_prep(ACPI_STATE_S4); 496 acpi_leave_sleep_state_prep(ACPI_STATE_S4);
628 /* Check the hardware signature */ 497 /* Check the hardware signature */
629 if (facs && s4_hardware_signature != facs->hardware_signature) { 498 if (facs && s4_hardware_signature != facs->hardware_signature) {
@@ -715,6 +584,127 @@ int acpi_suspend(u32 acpi_state)
715 return -EINVAL; 584 return -EINVAL;
716} 585}
717 586
587#ifdef CONFIG_PM
588/**
589 * acpi_pm_device_sleep_state - return preferred power state of ACPI device
590 * in the system sleep state given by %acpi_target_sleep_state
591 * @dev: device to examine; its driver model wakeup flags control
592 * whether it should be able to wake up the system
593 * @d_min_p: used to store the upper limit of allowed states range
594 * Return value: preferred power state of the device on success, -ENODEV on
595 * failure (ie. if there's no 'struct acpi_device' for @dev)
596 *
597 * Find the lowest power (highest number) ACPI device power state that
598 * device @dev can be in while the system is in the sleep state represented
599 * by %acpi_target_sleep_state. If @wake is nonzero, the device should be
600 * able to wake up the system from this sleep state. If @d_min_p is set,
601 * the highest power (lowest number) device power state of @dev allowed
602 * in this system sleep state is stored at the location pointed to by it.
603 *
604 * The caller must ensure that @dev is valid before using this function.
605 * The caller is also responsible for figuring out if the device is
606 * supposed to be able to wake up the system and passing this information
607 * via @wake.
608 */
609
610int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p)
611{
612 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
613 struct acpi_device *adev;
614 char acpi_method[] = "_SxD";
615 unsigned long long d_min, d_max;
616
617 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
618 printk(KERN_DEBUG "ACPI handle has no context!\n");
619 return -ENODEV;
620 }
621
622 acpi_method[2] = '0' + acpi_target_sleep_state;
623 /*
624 * If the sleep state is S0, we will return D3, but if the device has
625 * _S0W, we will use the value from _S0W
626 */
627 d_min = ACPI_STATE_D0;
628 d_max = ACPI_STATE_D3;
629
630 /*
631 * If present, _SxD methods return the minimum D-state (highest power
632 * state) we can use for the corresponding S-states. Otherwise, the
633 * minimum D-state is D0 (ACPI 3.x).
634 *
635 * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
636 * provided -- that's our fault recovery, we ignore retval.
637 */
638 if (acpi_target_sleep_state > ACPI_STATE_S0)
639 acpi_evaluate_integer(handle, acpi_method, NULL, &d_min);
640
641 /*
642 * If _PRW says we can wake up the system from the target sleep state,
643 * the D-state returned by _SxD is sufficient for that (we assume a
644 * wakeup-aware driver if wake is set). Still, if _SxW exists
645 * (ACPI 3.x), it should return the maximum (lowest power) D-state that
646 * can wake the system. _S0W may be valid, too.
647 */
648 if (acpi_target_sleep_state == ACPI_STATE_S0 ||
649 (device_may_wakeup(dev) &&
650 adev->wakeup.sleep_state <= acpi_target_sleep_state)) {
651 acpi_status status;
652
653 acpi_method[3] = 'W';
654 status = acpi_evaluate_integer(handle, acpi_method, NULL,
655 &d_max);
656 if (ACPI_FAILURE(status)) {
657 if (acpi_target_sleep_state != ACPI_STATE_S0 ||
658 status != AE_NOT_FOUND)
659 d_max = d_min;
660 } else if (d_max < d_min) {
661 /* Warn the user of the broken DSDT */
662 printk(KERN_WARNING "ACPI: Wrong value from %s\n",
663 acpi_method);
664 /* Sanitize it */
665 d_min = d_max;
666 }
667 }
668
669 if (d_min_p)
670 *d_min_p = d_min;
671 return d_max;
672}
673#endif /* CONFIG_PM */
674
675#ifdef CONFIG_PM_SLEEP
676/**
677 * acpi_pm_device_sleep_wake - enable or disable the system wake-up
678 * capability of given device
679 * @dev: device to handle
680 * @enable: 'true' - enable, 'false' - disable the wake-up capability
681 */
682int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
683{
684 acpi_handle handle;
685 struct acpi_device *adev;
686 int error;
687
688 if (!device_can_wakeup(dev))
689 return -EINVAL;
690
691 handle = DEVICE_ACPI_HANDLE(dev);
692 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
693 dev_dbg(dev, "ACPI handle has no context in %s!\n", __func__);
694 return -ENODEV;
695 }
696
697 error = enable ?
698 acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) :
699 acpi_disable_wakeup_device_power(adev);
700 if (!error)
701 dev_info(dev, "wake-up capability %s by ACPI\n",
702 enable ? "enabled" : "disabled");
703
704 return error;
705}
706#endif /* CONFIG_PM_SLEEP */
707
718static void acpi_power_off_prepare(void) 708static void acpi_power_off_prepare(void)
719{ 709{
720 /* Prepare to power off the system */ 710 /* Prepare to power off the system */
@@ -730,19 +720,45 @@ static void acpi_power_off(void)
730 acpi_enter_sleep_state(ACPI_STATE_S5); 720 acpi_enter_sleep_state(ACPI_STATE_S5);
731} 721}
732 722
723/*
724 * ACPI 2.0 created the optional _GTS and _BFS,
725 * but industry adoption has been neither rapid nor broad.
726 *
727 * Linux gets into trouble when it executes poorly validated
728 * paths through the BIOS, so disable _GTS and _BFS by default,
729 * but do speak up and offer the option to enable them.
730 */
731static void __init acpi_gts_bfs_check(void)
732{
733 acpi_handle dummy;
734
735 if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_NAME__GTS, &dummy)))
736 {
737 printk(KERN_NOTICE PREFIX "BIOS offers _GTS\n");
738 printk(KERN_NOTICE PREFIX "If \"acpi.gts=1\" improves suspend, "
739 "please notify linux-acpi@vger.kernel.org\n");
740 }
741 if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_NAME__BFS, &dummy)))
742 {
743 printk(KERN_NOTICE PREFIX "BIOS offers _BFS\n");
744 printk(KERN_NOTICE PREFIX "If \"acpi.bfs=1\" improves resume, "
745 "please notify linux-acpi@vger.kernel.org\n");
746 }
747}
748
733int __init acpi_sleep_init(void) 749int __init acpi_sleep_init(void)
734{ 750{
735 acpi_status status; 751 acpi_status status;
736 u8 type_a, type_b; 752 u8 type_a, type_b;
737#ifdef CONFIG_SUSPEND 753#ifdef CONFIG_SUSPEND
738 int i = 0; 754 int i = 0;
755
756 dmi_check_system(acpisleep_dmi_table);
739#endif 757#endif
740 758
741 if (acpi_disabled) 759 if (acpi_disabled)
742 return 0; 760 return 0;
743 761
744 acpi_sleep_dmi_check();
745
746 sleep_states[ACPI_STATE_S0] = 1; 762 sleep_states[ACPI_STATE_S0] = 1;
747 printk(KERN_INFO PREFIX "(supports S0"); 763 printk(KERN_INFO PREFIX "(supports S0");
748 764
@@ -751,7 +767,7 @@ int __init acpi_sleep_init(void)
751 status = acpi_get_sleep_type_data(i, &type_a, &type_b); 767 status = acpi_get_sleep_type_data(i, &type_a, &type_b);
752 if (ACPI_SUCCESS(status)) { 768 if (ACPI_SUCCESS(status)) {
753 sleep_states[i] = 1; 769 sleep_states[i] = 1;
754 printk(KERN_CONT " S%d", i); 770 printk(" S%d", i);
755 } 771 }
756 } 772 }
757 773
@@ -765,7 +781,7 @@ int __init acpi_sleep_init(void)
765 hibernation_set_ops(old_suspend_ordering ? 781 hibernation_set_ops(old_suspend_ordering ?
766 &acpi_hibernation_ops_old : &acpi_hibernation_ops); 782 &acpi_hibernation_ops_old : &acpi_hibernation_ops);
767 sleep_states[ACPI_STATE_S4] = 1; 783 sleep_states[ACPI_STATE_S4] = 1;
768 printk(KERN_CONT " S4"); 784 printk(" S4");
769 if (!nosigcheck) { 785 if (!nosigcheck) {
770 acpi_get_table(ACPI_SIG_FACS, 1, 786 acpi_get_table(ACPI_SIG_FACS, 1,
771 (struct acpi_table_header **)&facs); 787 (struct acpi_table_header **)&facs);
@@ -778,15 +794,16 @@ int __init acpi_sleep_init(void)
778 status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); 794 status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
779 if (ACPI_SUCCESS(status)) { 795 if (ACPI_SUCCESS(status)) {
780 sleep_states[ACPI_STATE_S5] = 1; 796 sleep_states[ACPI_STATE_S5] = 1;
781 printk(KERN_CONT " S5"); 797 printk(" S5");
782 pm_power_off_prepare = acpi_power_off_prepare; 798 pm_power_off_prepare = acpi_power_off_prepare;
783 pm_power_off = acpi_power_off; 799 pm_power_off = acpi_power_off;
784 } 800 }
785 printk(KERN_CONT ")\n"); 801 printk(")\n");
786 /* 802 /*
787 * Register the tts_notifier to reboot notifier list so that the _TTS 803 * Register the tts_notifier to reboot notifier list so that the _TTS
788 * object can also be evaluated when the system enters S5. 804 * object can also be evaluated when the system enters S5.
789 */ 805 */
790 register_reboot_notifier(&tts_notifier); 806 register_reboot_notifier(&tts_notifier);
807 acpi_gts_bfs_check();
791 return 0; 808 return 0;
792} 809}
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index ea61ca9129c..c538d0ef10f 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -173,7 +173,7 @@ static int param_set_trace_state(const char *val, struct kernel_param *kp)
173{ 173{
174 int result = 0; 174 int result = 0;
175 175
176 if (!strncmp(val, "enable", sizeof("enable") - 1)) { 176 if (!strncmp(val, "enable", strlen("enable") - 1)) {
177 result = acpi_debug_trace(trace_method_name, trace_debug_level, 177 result = acpi_debug_trace(trace_method_name, trace_debug_level,
178 trace_debug_layer, 0); 178 trace_debug_layer, 0);
179 if (result) 179 if (result)
@@ -181,7 +181,7 @@ static int param_set_trace_state(const char *val, struct kernel_param *kp)
181 goto exit; 181 goto exit;
182 } 182 }
183 183
184 if (!strncmp(val, "disable", sizeof("disable") - 1)) { 184 if (!strncmp(val, "disable", strlen("disable") - 1)) {
185 int name = 0; 185 int name = 0;
186 result = acpi_debug_trace((char *)&name, trace_debug_level, 186 result = acpi_debug_trace((char *)&name, trace_debug_level,
187 trace_debug_layer, 0); 187 trace_debug_layer, 0);
@@ -476,7 +476,7 @@ static void fixed_event_count(u32 event_number)
476 return; 476 return;
477} 477}
478 478
479static void acpi_global_event_handler(u32 event_type, acpi_handle device, 479static void acpi_gbl_event_handler(u32 event_type, acpi_handle device,
480 u32 event_number, void *context) 480 u32 event_number, void *context)
481{ 481{
482 if (event_type == ACPI_EVENT_TYPE_GPE) 482 if (event_type == ACPI_EVENT_TYPE_GPE)
@@ -638,7 +638,7 @@ void acpi_irq_stats_init(void)
638 if (all_counters == NULL) 638 if (all_counters == NULL)
639 goto fail; 639 goto fail;
640 640
641 status = acpi_install_global_event_handler(acpi_global_event_handler, NULL); 641 status = acpi_install_global_event_handler(acpi_gbl_event_handler, NULL);
642 if (ACPI_FAILURE(status)) 642 if (ACPI_FAILURE(status))
643 goto fail; 643 goto fail;
644 644
@@ -706,23 +706,11 @@ static void __exit interrupt_stats_exit(void)
706 return; 706 return;
707} 707}
708 708
709static ssize_t
710acpi_show_profile(struct device *dev, struct device_attribute *attr,
711 char *buf)
712{
713 return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile);
714}
715
716static const struct device_attribute pm_profile_attr =
717 __ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL);
718
719int __init acpi_sysfs_init(void) 709int __init acpi_sysfs_init(void)
720{ 710{
721 int result; 711 int result;
722 712
723 result = acpi_tables_sysfs_init(); 713 result = acpi_tables_sysfs_init();
724 if (result) 714
725 return result;
726 result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr);
727 return result; 715 return result;
728} 716}
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 506fbd4b573..48fbc647b17 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -98,6 +98,7 @@ MODULE_PARM_DESC(psv, "Disable or override all passive trip points.");
98 98
99static int acpi_thermal_add(struct acpi_device *device); 99static int acpi_thermal_add(struct acpi_device *device);
100static int acpi_thermal_remove(struct acpi_device *device, int type); 100static int acpi_thermal_remove(struct acpi_device *device, int type);
101static int acpi_thermal_resume(struct acpi_device *device);
101static void acpi_thermal_notify(struct acpi_device *device, u32 event); 102static void acpi_thermal_notify(struct acpi_device *device, u32 event);
102 103
103static const struct acpi_device_id thermal_device_ids[] = { 104static const struct acpi_device_id thermal_device_ids[] = {
@@ -106,11 +107,6 @@ static const struct acpi_device_id thermal_device_ids[] = {
106}; 107};
107MODULE_DEVICE_TABLE(acpi, thermal_device_ids); 108MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
108 109
109#ifdef CONFIG_PM_SLEEP
110static int acpi_thermal_resume(struct device *dev);
111#endif
112static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, NULL, acpi_thermal_resume);
113
114static struct acpi_driver acpi_thermal_driver = { 110static struct acpi_driver acpi_thermal_driver = {
115 .name = "thermal", 111 .name = "thermal",
116 .class = ACPI_THERMAL_CLASS, 112 .class = ACPI_THERMAL_CLASS,
@@ -118,9 +114,9 @@ static struct acpi_driver acpi_thermal_driver = {
118 .ops = { 114 .ops = {
119 .add = acpi_thermal_add, 115 .add = acpi_thermal_add,
120 .remove = acpi_thermal_remove, 116 .remove = acpi_thermal_remove,
117 .resume = acpi_thermal_resume,
121 .notify = acpi_thermal_notify, 118 .notify = acpi_thermal_notify,
122 }, 119 },
123 .drv.pm = &acpi_thermal_pm,
124}; 120};
125 121
126struct acpi_thermal_state { 122struct acpi_thermal_state {
@@ -554,6 +550,8 @@ static int thermal_get_temp(struct thermal_zone_device *thermal,
554 return 0; 550 return 0;
555} 551}
556 552
553static const char enabled[] = "kernel";
554static const char disabled[] = "user";
557static int thermal_get_mode(struct thermal_zone_device *thermal, 555static int thermal_get_mode(struct thermal_zone_device *thermal,
558 enum thermal_device_mode *mode) 556 enum thermal_device_mode *mode)
559{ 557{
@@ -590,8 +588,8 @@ static int thermal_set_mode(struct thermal_zone_device *thermal,
590 if (enable != tz->tz_enabled) { 588 if (enable != tz->tz_enabled) {
591 tz->tz_enabled = enable; 589 tz->tz_enabled = enable;
592 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 590 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
593 "%s kernel ACPI thermal control\n", 591 "%s ACPI thermal control\n",
594 tz->tz_enabled ? "Enable" : "Disable")); 592 tz->tz_enabled ? enabled : disabled));
595 acpi_thermal_check(tz); 593 acpi_thermal_check(tz);
596 } 594 }
597 return 0; 595 return 0;
@@ -708,40 +706,6 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
708 return -EINVAL; 706 return -EINVAL;
709} 707}
710 708
711static int thermal_get_trend(struct thermal_zone_device *thermal,
712 int trip, enum thermal_trend *trend)
713{
714 struct acpi_thermal *tz = thermal->devdata;
715 enum thermal_trip_type type;
716 int i;
717
718 if (thermal_get_trip_type(thermal, trip, &type))
719 return -EINVAL;
720
721 if (type == THERMAL_TRIP_ACTIVE) {
722 /* aggressive active cooling */
723 *trend = THERMAL_TREND_RAISING;
724 return 0;
725 }
726
727 /*
728 * tz->temperature has already been updated by generic thermal layer,
729 * before this callback being invoked
730 */
731 i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature))
732 + (tz->trips.passive.tc2
733 * (tz->temperature - tz->trips.passive.temperature));
734
735 if (i > 0)
736 *trend = THERMAL_TREND_RAISING;
737 else if (i < 0)
738 *trend = THERMAL_TREND_DROPPING;
739 else
740 *trend = THERMAL_TREND_STABLE;
741 return 0;
742}
743
744
745static int thermal_notify(struct thermal_zone_device *thermal, int trip, 709static int thermal_notify(struct thermal_zone_device *thermal, int trip,
746 enum thermal_trip_type trip_type) 710 enum thermal_trip_type trip_type)
747{ 711{
@@ -765,9 +729,11 @@ static int thermal_notify(struct thermal_zone_device *thermal, int trip,
765 return 0; 729 return 0;
766} 730}
767 731
732typedef int (*cb)(struct thermal_zone_device *, int,
733 struct thermal_cooling_device *);
768static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, 734static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
769 struct thermal_cooling_device *cdev, 735 struct thermal_cooling_device *cdev,
770 bool bind) 736 cb action)
771{ 737{
772 struct acpi_device *device = cdev->devdata; 738 struct acpi_device *device = cdev->devdata;
773 struct acpi_thermal *tz = thermal->devdata; 739 struct acpi_thermal *tz = thermal->devdata;
@@ -791,19 +757,11 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
791 i++) { 757 i++) {
792 handle = tz->trips.passive.devices.handles[i]; 758 handle = tz->trips.passive.devices.handles[i];
793 status = acpi_bus_get_device(handle, &dev); 759 status = acpi_bus_get_device(handle, &dev);
794 if (ACPI_FAILURE(status) || dev != device) 760 if (ACPI_SUCCESS(status) && (dev == device)) {
795 continue; 761 result = action(thermal, trip, cdev);
796 if (bind) 762 if (result)
797 result = 763 goto failed;
798 thermal_zone_bind_cooling_device 764 }
799 (thermal, trip, cdev,
800 THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
801 else
802 result =
803 thermal_zone_unbind_cooling_device
804 (thermal, trip, cdev);
805 if (result)
806 goto failed;
807 } 765 }
808 } 766 }
809 767
@@ -816,17 +774,11 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
816 j++) { 774 j++) {
817 handle = tz->trips.active[i].devices.handles[j]; 775 handle = tz->trips.active[i].devices.handles[j];
818 status = acpi_bus_get_device(handle, &dev); 776 status = acpi_bus_get_device(handle, &dev);
819 if (ACPI_FAILURE(status) || dev != device) 777 if (ACPI_SUCCESS(status) && (dev == device)) {
820 continue; 778 result = action(thermal, trip, cdev);
821 if (bind) 779 if (result)
822 result = thermal_zone_bind_cooling_device 780 goto failed;
823 (thermal, trip, cdev, 781 }
824 THERMAL_NO_LIMIT, THERMAL_NO_LIMIT);
825 else
826 result = thermal_zone_unbind_cooling_device
827 (thermal, trip, cdev);
828 if (result)
829 goto failed;
830 } 782 }
831 } 783 }
832 784
@@ -834,14 +786,7 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
834 handle = tz->devices.handles[i]; 786 handle = tz->devices.handles[i];
835 status = acpi_bus_get_device(handle, &dev); 787 status = acpi_bus_get_device(handle, &dev);
836 if (ACPI_SUCCESS(status) && (dev == device)) { 788 if (ACPI_SUCCESS(status) && (dev == device)) {
837 if (bind) 789 result = action(thermal, -1, cdev);
838 result = thermal_zone_bind_cooling_device
839 (thermal, -1, cdev,
840 THERMAL_NO_LIMIT,
841 THERMAL_NO_LIMIT);
842 else
843 result = thermal_zone_unbind_cooling_device
844 (thermal, -1, cdev);
845 if (result) 790 if (result)
846 goto failed; 791 goto failed;
847 } 792 }
@@ -855,14 +800,16 @@ static int
855acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal, 800acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal,
856 struct thermal_cooling_device *cdev) 801 struct thermal_cooling_device *cdev)
857{ 802{
858 return acpi_thermal_cooling_device_cb(thermal, cdev, true); 803 return acpi_thermal_cooling_device_cb(thermal, cdev,
804 thermal_zone_bind_cooling_device);
859} 805}
860 806
861static int 807static int
862acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, 808acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
863 struct thermal_cooling_device *cdev) 809 struct thermal_cooling_device *cdev)
864{ 810{
865 return acpi_thermal_cooling_device_cb(thermal, cdev, false); 811 return acpi_thermal_cooling_device_cb(thermal, cdev,
812 thermal_zone_unbind_cooling_device);
866} 813}
867 814
868static const struct thermal_zone_device_ops acpi_thermal_zone_ops = { 815static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
@@ -874,7 +821,6 @@ static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
874 .get_trip_type = thermal_get_trip_type, 821 .get_trip_type = thermal_get_trip_type,
875 .get_trip_temp = thermal_get_trip_temp, 822 .get_trip_temp = thermal_get_trip_temp,
876 .get_crit_temp = thermal_get_crit_temp, 823 .get_crit_temp = thermal_get_crit_temp,
877 .get_trend = thermal_get_trend,
878 .notify = thermal_notify, 824 .notify = thermal_notify,
879}; 825};
880 826
@@ -899,15 +845,18 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
899 845
900 if (tz->trips.passive.flags.valid) 846 if (tz->trips.passive.flags.valid)
901 tz->thermal_zone = 847 tz->thermal_zone =
902 thermal_zone_device_register("acpitz", trips, 0, tz, 848 thermal_zone_device_register("acpitz", trips, tz,
903 &acpi_thermal_zone_ops, NULL, 849 &acpi_thermal_zone_ops,
850 tz->trips.passive.tc1,
851 tz->trips.passive.tc2,
904 tz->trips.passive.tsp*100, 852 tz->trips.passive.tsp*100,
905 tz->polling_frequency*100); 853 tz->polling_frequency*100);
906 else 854 else
907 tz->thermal_zone = 855 tz->thermal_zone =
908 thermal_zone_device_register("acpitz", trips, 0, tz, 856 thermal_zone_device_register("acpitz", trips, tz,
909 &acpi_thermal_zone_ops, NULL, 857 &acpi_thermal_zone_ops,
910 0, tz->polling_frequency*100); 858 0, 0, 0,
859 tz->polling_frequency*100);
911 if (IS_ERR(tz->thermal_zone)) 860 if (IS_ERR(tz->thermal_zone))
912 return -ENODEV; 861 return -ENODEV;
913 862
@@ -984,38 +933,6 @@ static void acpi_thermal_notify(struct acpi_device *device, u32 event)
984 } 933 }
985} 934}
986 935
987/*
988 * On some platforms, the AML code has dependency about
989 * the evaluating order of _TMP and _CRT/_HOT/_PSV/_ACx.
990 * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after
991 * /_CRT/_HOT/_PSV/_ACx, or else system will be power off.
992 * 2. On HP Compaq 6715b/6715s, the return value of _PSV is 0
993 * if _TMP has never been evaluated.
994 *
995 * As this dependency is totally transparent to OS, evaluate
996 * all of them once, in the order of _CRT/_HOT/_PSV/_ACx,
997 * _TMP, before they are actually used.
998 */
999static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz)
1000{
1001 acpi_handle handle = tz->device->handle;
1002 unsigned long long value;
1003 int i;
1004
1005 acpi_evaluate_integer(handle, "_CRT", NULL, &value);
1006 acpi_evaluate_integer(handle, "_HOT", NULL, &value);
1007 acpi_evaluate_integer(handle, "_PSV", NULL, &value);
1008 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
1009 char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
1010 acpi_status status;
1011
1012 status = acpi_evaluate_integer(handle, name, NULL, &value);
1013 if (status == AE_NOT_FOUND)
1014 break;
1015 }
1016 acpi_evaluate_integer(handle, "_TMP", NULL, &value);
1017}
1018
1019static int acpi_thermal_get_info(struct acpi_thermal *tz) 936static int acpi_thermal_get_info(struct acpi_thermal *tz)
1020{ 937{
1021 int result = 0; 938 int result = 0;
@@ -1024,15 +941,13 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
1024 if (!tz) 941 if (!tz)
1025 return -EINVAL; 942 return -EINVAL;
1026 943
1027 acpi_thermal_aml_dependency_fix(tz); 944 /* Get temperature [_TMP] (required) */
1028 945 result = acpi_thermal_get_temperature(tz);
1029 /* Get trip points [_CRT, _PSV, etc.] (required) */
1030 result = acpi_thermal_get_trip_points(tz);
1031 if (result) 946 if (result)
1032 return result; 947 return result;
1033 948
1034 /* Get temperature [_TMP] (required) */ 949 /* Get trip points [_CRT, _PSV, etc.] (required) */
1035 result = acpi_thermal_get_temperature(tz); 950 result = acpi_thermal_get_trip_points(tz);
1036 if (result) 951 if (result)
1037 return result; 952 return result;
1038 953
@@ -1126,19 +1041,17 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1126 return 0; 1041 return 0;
1127} 1042}
1128 1043
1129#ifdef CONFIG_PM_SLEEP 1044static int acpi_thermal_resume(struct acpi_device *device)
1130static int acpi_thermal_resume(struct device *dev)
1131{ 1045{
1132 struct acpi_thermal *tz; 1046 struct acpi_thermal *tz = NULL;
1133 int i, j, power_state, result; 1047 int i, j, power_state, result;
1134 1048
1135 if (!dev)
1136 return -EINVAL;
1137 1049
1138 tz = acpi_driver_data(to_acpi_device(dev)); 1050 if (!device || !acpi_driver_data(device))
1139 if (!tz)
1140 return -EINVAL; 1051 return -EINVAL;
1141 1052
1053 tz = acpi_driver_data(device);
1054
1142 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { 1055 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
1143 if (!(&tz->trips.active[i])) 1056 if (!(&tz->trips.active[i]))
1144 break; 1057 break;
@@ -1161,7 +1074,6 @@ static int acpi_thermal_resume(struct device *dev)
1161 1074
1162 return AE_OK; 1075 return AE_OK;
1163} 1076}
1164#endif
1165 1077
1166static int thermal_act(const struct dmi_system_id *d) { 1078static int thermal_act(const struct dmi_system_id *d) {
1167 1079
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 74437130431..b002a471c5d 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -28,8 +28,6 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/hardirq.h>
32#include <linux/acpi.h>
33#include <acpi/acpi_bus.h> 31#include <acpi/acpi_bus.h>
34#include <acpi/acpi_drivers.h> 32#include <acpi/acpi_drivers.h>
35 33
@@ -384,114 +382,3 @@ acpi_evaluate_reference(acpi_handle handle,
384} 382}
385 383
386EXPORT_SYMBOL(acpi_evaluate_reference); 384EXPORT_SYMBOL(acpi_evaluate_reference);
387
388acpi_status
389acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
390{
391 acpi_status status;
392 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
393 union acpi_object *output;
394
395 status = acpi_evaluate_object(handle, "_PLD", NULL, &buffer);
396
397 if (ACPI_FAILURE(status))
398 return status;
399
400 output = buffer.pointer;
401
402 if (!output || output->type != ACPI_TYPE_PACKAGE
403 || !output->package.count
404 || output->package.elements[0].type != ACPI_TYPE_BUFFER
405 || output->package.elements[0].buffer.length < ACPI_PLD_REV1_BUFFER_SIZE) {
406 status = AE_TYPE;
407 goto out;
408 }
409
410 status = acpi_decode_pld_buffer(
411 output->package.elements[0].buffer.pointer,
412 output->package.elements[0].buffer.length,
413 pld);
414
415out:
416 kfree(buffer.pointer);
417 return status;
418}
419EXPORT_SYMBOL(acpi_get_physical_device_location);
420
421/**
422 * acpi_evaluate_hotplug_ost: Evaluate _OST for hotplug operations
423 * @handle: ACPI device handle
424 * @source_event: source event code
425 * @status_code: status code
426 * @status_buf: optional detailed information (NULL if none)
427 *
428 * Evaluate _OST for hotplug operations. All ACPI hotplug handlers
429 * must call this function when evaluating _OST for hotplug operations.
430 * When the platform does not support _OST, this function has no effect.
431 */
432acpi_status
433acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
434 u32 status_code, struct acpi_buffer *status_buf)
435{
436#ifdef ACPI_HOTPLUG_OST
437 union acpi_object params[3] = {
438 {.type = ACPI_TYPE_INTEGER,},
439 {.type = ACPI_TYPE_INTEGER,},
440 {.type = ACPI_TYPE_BUFFER,}
441 };
442 struct acpi_object_list arg_list = {3, params};
443 acpi_status status;
444
445 params[0].integer.value = source_event;
446 params[1].integer.value = status_code;
447 if (status_buf != NULL) {
448 params[2].buffer.pointer = status_buf->pointer;
449 params[2].buffer.length = status_buf->length;
450 } else {
451 params[2].buffer.pointer = NULL;
452 params[2].buffer.length = 0;
453 }
454
455 status = acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
456 return status;
457#else
458 return AE_OK;
459#endif
460}
461EXPORT_SYMBOL(acpi_evaluate_hotplug_ost);
462
463/**
464 * acpi_handle_printk: Print message with ACPI prefix and object path
465 *
466 * This function is called through acpi_handle_<level> macros and prints
467 * a message with ACPI prefix and object path. This function acquires
468 * the global namespace mutex to obtain an object path. In interrupt
469 * context, it shows the object path as <n/a>.
470 */
471void
472acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...)
473{
474 struct va_format vaf;
475 va_list args;
476 struct acpi_buffer buffer = {
477 .length = ACPI_ALLOCATE_BUFFER,
478 .pointer = NULL
479 };
480 const char *path;
481
482 va_start(args, fmt);
483 vaf.fmt = fmt;
484 vaf.va = &args;
485
486 if (in_interrupt() ||
487 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer) != AE_OK)
488 path = "<n/a>";
489 else
490 path = buffer.pointer;
491
492 printk("%sACPI: %s: %pV", level, path, &vaf);
493
494 va_end(args);
495 kfree(buffer.pointer);
496}
497EXPORT_SYMBOL(acpi_handle_printk);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index ac9a69cd45f..08a44b532f7 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -69,21 +69,21 @@ MODULE_AUTHOR("Bruno Ducrot");
69MODULE_DESCRIPTION("ACPI Video Driver"); 69MODULE_DESCRIPTION("ACPI Video Driver");
70MODULE_LICENSE("GPL"); 70MODULE_LICENSE("GPL");
71 71
72static bool brightness_switch_enabled = 1; 72static int brightness_switch_enabled = 1;
73module_param(brightness_switch_enabled, bool, 0644); 73module_param(brightness_switch_enabled, bool, 0644);
74 74
75/* 75/*
76 * By default, we don't allow duplicate ACPI video bus devices 76 * By default, we don't allow duplicate ACPI video bus devices
77 * under the same VGA controller 77 * under the same VGA controller
78 */ 78 */
79static bool allow_duplicates; 79static int allow_duplicates;
80module_param(allow_duplicates, bool, 0644); 80module_param(allow_duplicates, bool, 0644);
81 81
82/* 82/*
83 * Some BIOSes claim they use minimum backlight at boot, 83 * Some BIOSes claim they use minimum backlight at boot,
84 * and this may bring dimming screen after boot 84 * and this may bring dimming screen after boot
85 */ 85 */
86static bool use_bios_initial_backlight = 1; 86static int use_bios_initial_backlight = 1;
87module_param(use_bios_initial_backlight, bool, 0644); 87module_param(use_bios_initial_backlight, bool, 0644);
88 88
89static int register_count = 0; 89static int register_count = 0;
@@ -389,12 +389,6 @@ static int __init video_set_bqc_offset(const struct dmi_system_id *d)
389 return 0; 389 return 0;
390} 390}
391 391
392static int video_ignore_initial_backlight(const struct dmi_system_id *d)
393{
394 use_bios_initial_backlight = 0;
395 return 0;
396}
397
398static struct dmi_system_id video_dmi_table[] __initdata = { 392static struct dmi_system_id video_dmi_table[] __initdata = {
399 /* 393 /*
400 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121 394 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
@@ -439,14 +433,6 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
439 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"), 433 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"),
440 }, 434 },
441 }, 435 },
442 {
443 .callback = video_ignore_initial_backlight,
444 .ident = "HP Folio 13-2000",
445 .matches = {
446 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
447 DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"),
448 },
449 },
450 {} 436 {}
451}; 437};
452 438
@@ -562,29 +548,27 @@ acpi_video_device_EDID(struct acpi_video_device *device,
562 * 1. The system BIOS should NOT automatically control the brightness 548 * 1. The system BIOS should NOT automatically control the brightness
563 * level of the LCD when the power changes from AC to DC. 549 * level of the LCD when the power changes from AC to DC.
564 * Return Value: 550 * Return Value:
565 * -EINVAL wrong arg. 551 * -1 wrong arg.
566 */ 552 */
567 553
568static int 554static int
569acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) 555acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
570{ 556{
571 acpi_status status; 557 u64 status = 0;
572 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 558 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
573 struct acpi_object_list args = { 1, &arg0 }; 559 struct acpi_object_list args = { 1, &arg0 };
574 560
575 if (!video->cap._DOS)
576 return 0;
577 561
578 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) 562 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
579 return -EINVAL; 563 status = -1;
564 goto Failed;
565 }
580 arg0.integer.value = (lcd_flag << 2) | bios_flag; 566 arg0.integer.value = (lcd_flag << 2) | bios_flag;
581 video->dos_setting = arg0.integer.value; 567 video->dos_setting = arg0.integer.value;
582 status = acpi_evaluate_object(video->device->handle, "_DOS", 568 acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL);
583 &args, NULL);
584 if (ACPI_FAILURE(status))
585 return -EIO;
586 569
587 return 0; 570 Failed:
571 return status;
588} 572}
589 573
590/* 574/*
@@ -1362,17 +1346,12 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
1362 int status = 0; 1346 int status = 0;
1363 struct acpi_device *dev; 1347 struct acpi_device *dev;
1364 1348
1365 /*
1366 * There are systems where video module known to work fine regardless
1367 * of broken _DOD and ignoring returned value here doesn't cause
1368 * any issues later.
1369 */
1370 acpi_video_device_enumerate(video); 1349 acpi_video_device_enumerate(video);
1371 1350
1372 list_for_each_entry(dev, &device->children, node) { 1351 list_for_each_entry(dev, &device->children, node) {
1373 1352
1374 status = acpi_video_bus_get_one_device(dev, video); 1353 status = acpi_video_bus_get_one_device(dev, video);
1375 if (status) { 1354 if (ACPI_FAILURE(status)) {
1376 printk(KERN_WARNING PREFIX 1355 printk(KERN_WARNING PREFIX
1377 "Can't attach device\n"); 1356 "Can't attach device\n");
1378 continue; 1357 continue;
@@ -1465,7 +1444,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
1465 case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch, 1444 case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch,
1466 * most likely via hotkey. */ 1445 * most likely via hotkey. */
1467 acpi_bus_generate_proc_event(device, event, 0); 1446 acpi_bus_generate_proc_event(device, event, 0);
1468 keycode = KEY_SWITCHVIDEOMODE; 1447 if (!acpi_notifier_call_chain(device, event, 0))
1448 keycode = KEY_SWITCHVIDEOMODE;
1469 break; 1449 break;
1470 1450
1471 case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video 1451 case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video
@@ -1495,9 +1475,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
1495 break; 1475 break;
1496 } 1476 }
1497 1477
1498 if (acpi_notifier_call_chain(device, event, 0)) 1478 if (event != ACPI_VIDEO_NOTIFY_SWITCH)
1499 /* Something vetoed the keypress. */ 1479 acpi_notifier_call_chain(device, event, 0);
1500 keycode = 0;
1501 1480
1502 if (keycode) { 1481 if (keycode) {
1503 input_report_key(input, keycode, 1); 1482 input_report_key(input, keycode, 1);
@@ -1674,20 +1653,15 @@ static int acpi_video_bus_add(struct acpi_device *device)
1674 mutex_init(&video->device_list_lock); 1653 mutex_init(&video->device_list_lock);
1675 INIT_LIST_HEAD(&video->video_device_list); 1654 INIT_LIST_HEAD(&video->video_device_list);
1676 1655
1677 error = acpi_video_bus_get_devices(video, device); 1656 acpi_video_bus_get_devices(video, device);
1678 if (error) 1657 acpi_video_bus_start_devices(video);
1679 goto err_free_video;
1680 1658
1681 video->input = input = input_allocate_device(); 1659 video->input = input = input_allocate_device();
1682 if (!input) { 1660 if (!input) {
1683 error = -ENOMEM; 1661 error = -ENOMEM;
1684 goto err_put_video; 1662 goto err_stop_video;
1685 } 1663 }
1686 1664
1687 error = acpi_video_bus_start_devices(video);
1688 if (error)
1689 goto err_free_input_dev;
1690
1691 snprintf(video->phys, sizeof(video->phys), 1665 snprintf(video->phys, sizeof(video->phys),
1692 "%s/video/input0", acpi_device_hid(video->device)); 1666 "%s/video/input0", acpi_device_hid(video->device));
1693 1667
@@ -1706,6 +1680,10 @@ static int acpi_video_bus_add(struct acpi_device *device)
1706 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); 1680 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit);
1707 set_bit(KEY_DISPLAY_OFF, input->keybit); 1681 set_bit(KEY_DISPLAY_OFF, input->keybit);
1708 1682
1683 error = input_register_device(input);
1684 if (error)
1685 goto err_free_input_dev;
1686
1709 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", 1687 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1710 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), 1688 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
1711 video->flags.multihead ? "yes" : "no", 1689 video->flags.multihead ? "yes" : "no",
@@ -1714,23 +1692,14 @@ static int acpi_video_bus_add(struct acpi_device *device)
1714 1692
1715 video->pm_nb.notifier_call = acpi_video_resume; 1693 video->pm_nb.notifier_call = acpi_video_resume;
1716 video->pm_nb.priority = 0; 1694 video->pm_nb.priority = 0;
1717 error = register_pm_notifier(&video->pm_nb); 1695 register_pm_notifier(&video->pm_nb);
1718 if (error)
1719 goto err_stop_video;
1720
1721 error = input_register_device(input);
1722 if (error)
1723 goto err_unregister_pm_notifier;
1724 1696
1725 return 0; 1697 return 0;
1726 1698
1727 err_unregister_pm_notifier:
1728 unregister_pm_notifier(&video->pm_nb);
1729 err_stop_video:
1730 acpi_video_bus_stop_devices(video);
1731 err_free_input_dev: 1699 err_free_input_dev:
1732 input_free_device(input); 1700 input_free_device(input);
1733 err_put_video: 1701 err_stop_video:
1702 acpi_video_bus_stop_devices(video);
1734 acpi_video_bus_put_devices(video); 1703 acpi_video_bus_put_devices(video);
1735 kfree(video->attached_array); 1704 kfree(video->attached_array);
1736 err_free_video: 1705 err_free_video:
@@ -1762,18 +1731,9 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1762 return 0; 1731 return 0;
1763} 1732}
1764 1733
1765static int __init is_i740(struct pci_dev *dev)
1766{
1767 if (dev->device == 0x00D1)
1768 return 1;
1769 if (dev->device == 0x7000)
1770 return 1;
1771 return 0;
1772}
1773
1774static int __init intel_opregion_present(void) 1734static int __init intel_opregion_present(void)
1775{ 1735{
1776 int opregion = 0; 1736#if defined(CONFIG_DRM_I915) || defined(CONFIG_DRM_I915_MODULE)
1777 struct pci_dev *dev = NULL; 1737 struct pci_dev *dev = NULL;
1778 u32 address; 1738 u32 address;
1779 1739
@@ -1782,15 +1742,13 @@ static int __init intel_opregion_present(void)
1782 continue; 1742 continue;
1783 if (dev->vendor != PCI_VENDOR_ID_INTEL) 1743 if (dev->vendor != PCI_VENDOR_ID_INTEL)
1784 continue; 1744 continue;
1785 /* We don't want to poke around undefined i740 registers */
1786 if (is_i740(dev))
1787 continue;
1788 pci_read_config_dword(dev, 0xfc, &address); 1745 pci_read_config_dword(dev, 0xfc, &address);
1789 if (!address) 1746 if (!address)
1790 continue; 1747 continue;
1791 opregion = 1; 1748 return 1;
1792 } 1749 }
1793 return opregion; 1750#endif
1751 return 0;
1794} 1752}
1795 1753
1796int acpi_video_register(void) 1754int acpi_video_register(void)
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 4ac2593234e..5af3479714f 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -23,7 +23,7 @@
23 * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B) 23 * Depending on whether ACPI graphics extensions (cmp. ACPI spec Appendix B)
24 * are available, video.ko should be used to handle the device. 24 * are available, video.ko should be used to handle the device.
25 * 25 *
26 * Otherwise vendor specific drivers like thinkpad_acpi, asus-laptop, 26 * Otherwise vendor specific drivers like thinkpad_acpi, asus_acpi,
27 * sony_acpi,... can take care about backlight brightness. 27 * sony_acpi,... can take care about backlight brightness.
28 * 28 *
29 * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m) 29 * If CONFIG_ACPI_VIDEO is neither set as "compiled in" (y) nor as a module (m)
@@ -33,7 +33,6 @@
33 * 33 *
34 */ 34 */
35 35
36#include <linux/export.h>
37#include <linux/acpi.h> 36#include <linux/acpi.h>
38#include <linux/dmi.h> 37#include <linux/dmi.h>
39#include <linux/pci.h> 38#include <linux/pci.h>
@@ -132,41 +131,6 @@ find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
132 return AE_OK; 131 return AE_OK;
133} 132}
134 133
135/* Force to use vendor driver when the ACPI device is known to be
136 * buggy */
137static int video_detect_force_vendor(const struct dmi_system_id *d)
138{
139 acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
140 return 0;
141}
142
143static struct dmi_system_id video_detect_dmi_table[] = {
144 /* On Samsung X360, the BIOS will set a flag (VDRV) if generic
145 * ACPI backlight device is used. This flag will definitively break
146 * the backlight interface (even the vendor interface) untill next
147 * reboot. It's why we should prevent video.ko from being used here
148 * and we can't rely on a later call to acpi_video_unregister().
149 */
150 {
151 .callback = video_detect_force_vendor,
152 .ident = "X360",
153 .matches = {
154 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
155 DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
156 DMI_MATCH(DMI_BOARD_NAME, "X360"),
157 },
158 },
159 {
160 .callback = video_detect_force_vendor,
161 .ident = "Asus UL30VT",
162 .matches = {
163 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
164 DMI_MATCH(DMI_PRODUCT_NAME, "UL30VT"),
165 },
166 },
167 { },
168};
169
170/* 134/*
171 * Returns the video capabilities of a specific ACPI graphics device 135 * Returns the video capabilities of a specific ACPI graphics device
172 * 136 *
@@ -199,8 +163,6 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle)
199 * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR; 163 * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
200 *} 164 *}
201 */ 165 */
202
203 dmi_check_system(video_detect_dmi_table);
204 } else { 166 } else {
205 status = acpi_bus_get_device(graphics_handle, &tmp_dev); 167 status = acpi_bus_get_device(graphics_handle, &tmp_dev);
206 if (ACPI_FAILURE(status)) { 168 if (ACPI_FAILURE(status)) {
@@ -219,7 +181,8 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle)
219} 181}
220EXPORT_SYMBOL(acpi_video_get_capabilities); 182EXPORT_SYMBOL(acpi_video_get_capabilities);
221 183
222static void acpi_video_caps_check(void) 184/* Returns true if video.ko can do backlight switching */
185int acpi_video_backlight_support(void)
223{ 186{
224 /* 187 /*
225 * We must check whether the ACPI graphics device is physically plugged 188 * We must check whether the ACPI graphics device is physically plugged
@@ -227,34 +190,6 @@ static void acpi_video_caps_check(void)
227 */ 190 */
228 if (!acpi_video_caps_checked) 191 if (!acpi_video_caps_checked)
229 acpi_video_get_capabilities(NULL); 192 acpi_video_get_capabilities(NULL);
230}
231
232/* Promote the vendor interface instead of the generic video module.
233 * This function allow DMI blacklists to be implemented by externals
234 * platform drivers instead of putting a big blacklist in video_detect.c
235 * After calling this function you will probably want to call
236 * acpi_video_unregister() to make sure the video module is not loaded
237 */
238void acpi_video_dmi_promote_vendor(void)
239{
240 acpi_video_caps_check();
241 acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
242}
243EXPORT_SYMBOL(acpi_video_dmi_promote_vendor);
244
245/* To be called when a driver who previously promoted the vendor
246 * interface */
247void acpi_video_dmi_demote_vendor(void)
248{
249 acpi_video_caps_check();
250 acpi_video_support &= ~ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
251}
252EXPORT_SYMBOL(acpi_video_dmi_demote_vendor);
253
254/* Returns true if video.ko can do backlight switching */
255int acpi_video_backlight_support(void)
256{
257 acpi_video_caps_check();
258 193
259 /* First check for boot param -> highest prio */ 194 /* First check for boot param -> highest prio */
260 if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR) 195 if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR)